@@ -17,9 +17,8 @@ PhysicalShapeLayer::PhysicalShapeLayer(SkColor color,
1717 float elevation,
1818 const SkPath& path,
1919 Clip clip_behavior)
20- : color_ (color),
20+ : PhysicalShapeLayerBase (color, elevation ),
2121 shadow_color_ (shadow_color),
22- elevation_(elevation),
2322 path_(path),
2423 isRect_(false ),
2524 clip_behavior_(clip_behavior) {
@@ -42,30 +41,33 @@ PhysicalShapeLayer::PhysicalShapeLayer(SkColor color,
4241 // an SkPath.
4342 frameRRect_ = SkRRect::MakeRect (path.getBounds ());
4443 }
44+
45+ set_dimensions (frameRRect_);
4546}
4647
4748void PhysicalShapeLayer::Preroll (PrerollContext* context,
4849 const SkMatrix& matrix) {
4950 TRACE_EVENT0 (" flutter" , " PhysicalShapeLayer::Preroll" );
50- context->total_elevation += elevation_;
51- total_elevation_ = context->total_elevation ;
52- SkRect child_paint_bounds;
53- PrerollChildren (context, matrix, &child_paint_bounds);
54- context->total_elevation -= elevation_;
5551
56- if (elevation_ == 0 ) {
52+ PhysicalShapeLayerBase::Preroll (context, matrix);
53+
54+ if (elevation () == 0 ) {
5755 set_paint_bounds (path_.getBounds ());
5856 } else {
59- #if defined(OS_FUCHSIA)
60- // Let the system compositor draw all shadows for us.
61- set_needs_system_composite (true );
62- #else
57+ if (PhysicalShapeLayerBase::can_system_composite ()) {
58+ set_needs_system_composite (true );
59+ return ;
60+ }
61+ // #if defined(OS_FUCHSIA)
62+ // // Let the system compositor draw all shadows for us.
63+ // set_needs_system_composite(true);
64+ // #else
6365 // We will draw the shadow in Paint(), so add some margin to the paint
6466 // bounds to leave space for the shadow. We fill this whole region and clip
6567 // children to it so we don't need to join the child paint bounds.
66- set_paint_bounds (ComputeShadowBounds (path_.getBounds (), elevation_ ,
68+ set_paint_bounds (ComputeShadowBounds (path_.getBounds (), elevation () ,
6769 context->frame_device_pixel_ratio ));
68- #endif // defined(OS_FUCHSIA)
70+ // #endif // defined(OS_FUCHSIA)
6971 }
7072}
7173
@@ -90,8 +92,8 @@ void PhysicalShapeLayer::UpdateScene(SceneUpdateContext& context) {
9092
9193 TRACE_EVENT_INSTANT0 (" flutter" , " cache miss, creating" );
9294 // If we can't find an existing retained surface, create one.
93- SceneUpdateContext::Frame frame (context, frameRRect_, color_, elevation_ ,
94- total_elevation_, this );
95+ SceneUpdateContext::Frame frame (context, frameRRect_, color (), elevation () ,
96+ this );
9597 for (auto & layer : layers ()) {
9698 if (layer->needs_painting ()) {
9799 frame.AddPaintLayer (layer.get ());
@@ -107,14 +109,14 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
107109 TRACE_EVENT0 (" flutter" , " PhysicalShapeLayer::Paint" );
108110 FML_DCHECK (needs_painting ());
109111
110- if (elevation_ != 0 ) {
111- DrawShadow (context.leaf_nodes_canvas , path_, shadow_color_, elevation_ ,
112- SkColorGetA (color_ ) != 0xff , context.frame_device_pixel_ratio );
112+ if (elevation () != 0 ) {
113+ DrawShadow (context.leaf_nodes_canvas , path_, shadow_color_, elevation () ,
114+ SkColorGetA (color () ) != 0xff , context.frame_device_pixel_ratio );
113115 }
114116
115117 // Call drawPath without clip if possible for better performance.
116118 SkPaint paint;
117- paint.setColor (color_ );
119+ paint.setColor (color () );
118120 paint.setAntiAlias (true );
119121 if (clip_behavior_ != Clip::antiAliasWithSaveLayer) {
120122 context.leaf_nodes_canvas ->drawPath (path_, paint);
0 commit comments