44
55#include " flutter/flow/layers/clip_rect_layer.h"
66
7+ #include " flutter/fml/trace_event.h"
8+
9+ #if defined(OS_FUCHSIA)
10+ #include " flutter/flow/scene_update_context.h" // nogncheck
11+ #endif // defined(OS_FUCHSIA)
12+
713namespace flutter {
814
915ClipRectLayer::ClipRectLayer (const SkRect& clip_rect, Clip clip_behavior)
1016 : clip_rect_(clip_rect), clip_behavior_(clip_behavior) {
1117 FML_DCHECK (clip_behavior != Clip::none);
1218}
1319
14- ClipRectLayer::~ClipRectLayer () = default ;
15-
1620void ClipRectLayer::Preroll (PrerollContext* context, const SkMatrix& matrix) {
1721 SkRect previous_cull_rect = context->cull_rect ;
18- if (context-> cull_rect . intersect (clip_rect_)) {
19- context->mutators_stack . PushClipRect (clip_rect_);
20- SkRect child_paint_bounds = SkRect::MakeEmpty ( );
21- PrerollChildren (context, matrix, &child_paint_bounds );
22+ SkRect clip_rect_bounds = clip_rect_;
23+ if ( context->cull_rect . intersect (clip_rect_bounds)) {
24+ context-> mutators_stack . PushClipRect (clip_rect_bounds );
25+ ContainerLayer::Preroll (context, matrix);
2226
23- if (child_paint_bounds.intersect (clip_rect_)) {
24- set_paint_bounds (child_paint_bounds);
27+ if (clip_rect_bounds.intersect (paint_bounds ())) {
28+ set_paint_bounds (clip_rect_bounds);
29+ } else {
30+ set_paint_bounds (SkRect::MakeEmpty ());
2531 }
2632 context->mutators_stack .Pop ();
2733 }
@@ -35,7 +41,7 @@ void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
3541
3642 // TODO(liyuqian): respect clip_behavior_
3743 SceneUpdateContext::Clip clip (context, clip_rect_);
38- UpdateSceneChildren (context);
44+ ContainerLayer::UpdateScene (context);
3945}
4046
4147#endif // defined(OS_FUCHSIA)
@@ -51,7 +57,7 @@ void ClipRectLayer::Paint(PaintContext& context) const {
5157 if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
5258 context.internal_nodes_canvas ->saveLayer (clip_rect_, nullptr );
5359 }
54- PaintChildren (context);
60+ ContainerLayer::Paint (context);
5561 if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
5662 context.internal_nodes_canvas ->restore ();
5763 }
0 commit comments