Skip to content

Commit

Permalink
Remove Dead Scenic Clipping Code Path. (flutter#10242)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cfontas authored and cbracken committed Jul 30, 2019
1 parent 7436f69 commit f8d122b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 38 deletions.
10 changes: 1 addition & 9 deletions flow/layers/clip_path_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 1 addition & 6 deletions flow/layers/clip_rect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
14 changes: 1 addition & 13 deletions flow/layers/clip_rrect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 0 additions & 7 deletions flow/scene_update_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 2 additions & 3 deletions flow/scene_update_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class SceneUpdateContext {
return entity_node_ptr_;
}

protected:
scenic::ShapeNode& shape_node() { return *shape_node_ptr_; }
std::unique_ptr<scenic::ShapeNode>& shape_node_ptr() {
return shape_node_ptr_;
Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit f8d122b

Please sign in to comment.