mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Additionally create "_next" permutations for all of the test binaries on Fuchsia, in order to test both code-paths. Using the #define follow-up CLs can also create a flutter_runner_next binary that does not contain any legacy integration code. BUG: 53847
72 lines
2.2 KiB
C++
72 lines
2.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/clip_rect_layer.h"
|
|
|
|
namespace flutter {
|
|
|
|
ClipRectLayer::ClipRectLayer(const SkRect& clip_rect, Clip clip_behavior)
|
|
: clip_rect_(clip_rect), clip_behavior_(clip_behavior) {
|
|
FML_DCHECK(clip_behavior != Clip::none);
|
|
}
|
|
|
|
void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
TRACE_EVENT0("flutter", "ClipRectLayer::Preroll");
|
|
|
|
SkRect previous_cull_rect = context->cull_rect;
|
|
children_inside_clip_ = context->cull_rect.intersect(clip_rect_);
|
|
if (children_inside_clip_) {
|
|
TRACE_EVENT_INSTANT0("flutter", "children inside clip rect");
|
|
|
|
Layer::AutoPrerollSaveLayerState save =
|
|
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
|
|
context->mutators_stack.PushClipRect(clip_rect_);
|
|
SkRect child_paint_bounds = SkRect::MakeEmpty();
|
|
PrerollChildren(context, matrix, &child_paint_bounds);
|
|
|
|
if (child_paint_bounds.intersect(clip_rect_)) {
|
|
set_paint_bounds(child_paint_bounds);
|
|
}
|
|
context->mutators_stack.Pop();
|
|
}
|
|
context->cull_rect = previous_cull_rect;
|
|
}
|
|
|
|
#if defined(LEGACY_FUCHSIA_EMBEDDER)
|
|
|
|
void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
|
|
TRACE_EVENT0("flutter", "ClipRectLayer::UpdateScene");
|
|
FML_DCHECK(needs_system_composite());
|
|
|
|
// TODO(liyuqian): respect clip_behavior_
|
|
SceneUpdateContext::Clip clip(context, clip_rect_);
|
|
UpdateSceneChildren(context);
|
|
}
|
|
|
|
#endif
|
|
|
|
void ClipRectLayer::Paint(PaintContext& context) const {
|
|
TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
|
|
FML_DCHECK(needs_painting());
|
|
|
|
if (!children_inside_clip_) {
|
|
TRACE_EVENT_INSTANT0("flutter", "children not inside clip rect, skipping");
|
|
return;
|
|
}
|
|
|
|
SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
|
|
context.internal_nodes_canvas->clipRect(clip_rect_,
|
|
clip_behavior_ != Clip::hardEdge);
|
|
|
|
if (UsesSaveLayer()) {
|
|
context.internal_nodes_canvas->saveLayer(clip_rect_, nullptr);
|
|
}
|
|
PaintChildren(context);
|
|
if (UsesSaveLayer()) {
|
|
context.internal_nodes_canvas->restore();
|
|
}
|
|
}
|
|
|
|
} // namespace flutter
|