Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flow/layers/physical_shape_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ void PhysicalShapeLayer::Preroll(PrerollContext* context,
set_needs_system_composite(true);
#else
// Add some margin to the paint bounds to leave space for the shadow.
// The margin is hardcoded to an arbitrary maximum for now because Skia
// The margin is set to a multiple of elevation_ for now because Skia
// doesn't provide a way to calculate it. We fill this whole region
// and clip children to it so we don't need to join the child paint bounds.
SkRect bounds(path_.getBounds());
bounds.outset(20.0, 20.0);
bounds.outset(elevation_ * 1.5, elevation_ * 1.5);

@liyuqian liyuqian Mar 5, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following outset might be more accurate according to the physical model used by Flutter and Skia:

ex = (kLightRadius * device_pixel_ratio_ + bounds.width() * 0.5) / kLightHeight;
ey = (kLightRadius * device_pixel_ratio_ + bounds.height() * 0.5) / kLightHeight;
bounds.outset(elevation_ * ex, elevation_ * ey);

See
img_20190305_143908
for the illustration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, be careful about device_pixel_ratio_. It seems that all elevation_, kLightRadius, kLightHeight should be multiplied with device_pixel_ratio_. The ratio of elevation_ and kLightHeight cancels out, but you'll still need kLightRadius * device_pixel_ratio_.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it and tried to incorporate your diagram as a comment. Does that look right?

set_paint_bounds(bounds);
#endif // defined(OS_FUCHSIA)
}
Expand Down