mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
When we visit a PlatformViewLayer during the paint traversal it replaces the PaintContext's canvas with a new one that is painted ontop of the embedded view. We need to make sure that operations applied by parent layers are also applied to the new canvas. To achieve this we collect all the canvases in a SkNWayCanvas and use this canvas by non leaf nodes. Leaf nodes still paint only to the "current" canvas. This PR moves the overlay canvas creation from the paint phase to the preroll phase, collects them into a SkNWayCanvas and set it in PaintContext. To keep this PR focused, I only used the internal_nodes_canvas in the tranform_layer. Will followup with a PR that changes all internal layers to use the internal_nodes_canvas.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/flow/layers/transform_layer.h"
|
|
|
|
namespace flow {
|
|
|
|
TransformLayer::TransformLayer() = default;
|
|
|
|
TransformLayer::~TransformLayer() = default;
|
|
|
|
void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
SkMatrix child_matrix;
|
|
child_matrix.setConcat(matrix, transform_);
|
|
|
|
SkRect child_paint_bounds = SkRect::MakeEmpty();
|
|
PrerollChildren(context, child_matrix, &child_paint_bounds);
|
|
|
|
transform_.mapRect(&child_paint_bounds);
|
|
set_paint_bounds(child_paint_bounds);
|
|
}
|
|
|
|
#if defined(OS_FUCHSIA)
|
|
|
|
void TransformLayer::UpdateScene(SceneUpdateContext& context) {
|
|
FML_DCHECK(needs_system_composite());
|
|
|
|
SceneUpdateContext::Transform transform(context, transform_);
|
|
UpdateSceneChildren(context);
|
|
}
|
|
|
|
#endif // defined(OS_FUCHSIA)
|
|
|
|
void TransformLayer::Paint(PaintContext& context) const {
|
|
TRACE_EVENT0("flutter", "TransformLayer::Paint");
|
|
FML_DCHECK(needs_painting());
|
|
|
|
SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
|
|
context.internal_nodes_canvas->concat(transform_);
|
|
PaintChildren(context);
|
|
}
|
|
|
|
} // namespace flow
|