From a5a784d0604333260565a7a102959cfdf7f1fc21 Mon Sep 17 00:00:00 2001 From: cfontas Date: Tue, 30 Jul 2019 14:19:32 -0700 Subject: [PATCH] Remove Dead Scenic Clipping Code Path. (flutter/engine#10242) Scenic has now fully transitioned to clipping by adding lists of planes to Nodes; the old approach of adding a ShapeNode "part" is now a no-op, and is safe to remove. --- engine/src/flutter/flow/layers/clip_path_layer.cc | 10 +--------- engine/src/flutter/flow/layers/clip_rect_layer.cc | 7 +------ engine/src/flutter/flow/layers/clip_rrect_layer.cc | 14 +------------- engine/src/flutter/flow/scene_update_context.cc | 7 ------- engine/src/flutter/flow/scene_update_context.h | 5 ++--- 5 files changed, 5 insertions(+), 38 deletions(-) diff --git a/engine/src/flutter/flow/layers/clip_path_layer.cc b/engine/src/flutter/flow/layers/clip_path_layer.cc index c81b3a2190..d08c19b34e 100644 --- a/engine/src/flutter/flow/layers/clip_path_layer.cc +++ b/engine/src/flutter/flow/layers/clip_path_layer.cc @@ -40,16 +40,8 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { void ClipPathLayer::UpdateScene(SceneUpdateContext& context) { FML_DCHECK(needs_system_composite()); - // TODO(SCN-140): Must be able to specify paths as shapes to nodes. - // Treating the shape as a rectangle for now. - auto bounds = clip_path_.getBounds(); - scenic::Rectangle shape(context.session(), // session - bounds.width(), // width - bounds.height() // height - ); - // TODO(liyuqian): respect clip_behavior_ - SceneUpdateContext::Clip clip(context, shape, bounds); + SceneUpdateContext::Clip clip(context, clip_path_.getBounds()); UpdateSceneChildren(context); } diff --git a/engine/src/flutter/flow/layers/clip_rect_layer.cc b/engine/src/flutter/flow/layers/clip_rect_layer.cc index 084b0957c1..de7590624e 100644 --- a/engine/src/flutter/flow/layers/clip_rect_layer.cc +++ b/engine/src/flutter/flow/layers/clip_rect_layer.cc @@ -33,13 +33,8 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { void ClipRectLayer::UpdateScene(SceneUpdateContext& context) { FML_DCHECK(needs_system_composite()); - scenic::Rectangle shape(context.session(), // session - clip_rect_.width(), // width - clip_rect_.height() // height - ); - // TODO(liyuqian): respect clip_behavior_ - SceneUpdateContext::Clip clip(context, shape, clip_rect_); + SceneUpdateContext::Clip clip(context, clip_rect_); UpdateSceneChildren(context); } diff --git a/engine/src/flutter/flow/layers/clip_rrect_layer.cc b/engine/src/flutter/flow/layers/clip_rrect_layer.cc index d810bb70f7..9899a16587 100644 --- a/engine/src/flutter/flow/layers/clip_rrect_layer.cc +++ b/engine/src/flutter/flow/layers/clip_rrect_layer.cc @@ -34,20 +34,8 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) { FML_DCHECK(needs_system_composite()); - // TODO(SCN-137): Need to be able to express the radii as vectors. - scenic::RoundedRectangle shape( - context.session(), // session - clip_rrect_.width(), // width - clip_rrect_.height(), // height - clip_rrect_.radii(SkRRect::kUpperLeft_Corner).x(), // top_left_radius - clip_rrect_.radii(SkRRect::kUpperRight_Corner).x(), // top_right_radius - clip_rrect_.radii(SkRRect::kLowerRight_Corner) - .x(), // bottom_right_radius - clip_rrect_.radii(SkRRect::kLowerLeft_Corner).x() // bottom_left_radius - ); - // TODO(liyuqian): respect clip_behavior_ - SceneUpdateContext::Clip clip(context, shape, clip_rrect_.getBounds()); + SceneUpdateContext::Clip clip(context, clip_rrect_.getBounds()); UpdateSceneChildren(context); } diff --git a/engine/src/flutter/flow/scene_update_context.cc b/engine/src/flutter/flow/scene_update_context.cc index d1fe2a94fa..35709b732b 100644 --- a/engine/src/flutter/flow/scene_update_context.cc +++ b/engine/src/flutter/flow/scene_update_context.cc @@ -328,15 +328,8 @@ void SceneUpdateContext::Frame::AddPaintLayer(Layer* layer) { } SceneUpdateContext::Clip::Clip(SceneUpdateContext& context, - scenic::Shape& shape, const SkRect& shape_bounds) : Entity(context) { - shape_node().SetShape(shape); - shape_node().SetTranslation(shape_bounds.width() * 0.5f + shape_bounds.left(), - shape_bounds.height() * 0.5f + shape_bounds.top(), - 0.f); - entity_node().SetClip(0u, true /* clip to self */); - SetEntityNodeClipPlanes(&entity_node(), shape_bounds); } diff --git a/engine/src/flutter/flow/scene_update_context.h b/engine/src/flutter/flow/scene_update_context.h index ca66004735..ab428b0f3e 100644 --- a/engine/src/flutter/flow/scene_update_context.h +++ b/engine/src/flutter/flow/scene_update_context.h @@ -77,6 +77,7 @@ class SceneUpdateContext { return entity_node_ptr_; } + protected: scenic::ShapeNode& shape_node() { return *shape_node_ptr_; } std::unique_ptr& shape_node_ptr() { return shape_node_ptr_; @@ -132,9 +133,7 @@ class SceneUpdateContext { class Clip : public Entity { public: - Clip(SceneUpdateContext& context, - scenic::Shape& shape, - const SkRect& shape_bounds); + Clip(SceneUpdateContext& context, const SkRect& shape_bounds); ~Clip() = default; };