17static constexpr DlScalar kAmbientHeightFactor = 1.0f / 128.0f;
18static constexpr DlScalar kAmbientGeomFactor = 64.0f;
22static constexpr DlScalar kMaxAmbientRadius =
23 300.0f * kAmbientHeightFactor * kAmbientGeomFactor;
26 return std::min(
height * kAmbientHeightFactor * kAmbientGeomFactor,
36static inline float DivideAndClamp(
float numer,
40 float result = std::clamp(numer / denom, min, max);
46inline void GetDirectionalParams(DrawShadowRec
params,
49 DlVector2* translate) {
57 -zRatio *
params.light_position.y);
60DlRect GetLocalBounds(DlRect ambient_bounds,
61 const DlMatrix& matrix,
62 const DrawShadowRec&
params) {
63 if (!matrix.IsInvertible() || ambient_bounds.IsEmpty()) {
72 if (matrix.HasPerspective2D()) {
74 ambient_bounds = ambient_bounds.TransformAndClipBounds(matrix);
77 ambient_blur = AmbientBlurRadius(
params.occluder_z);
80 GetDirectionalParams(
params, &spot_blur, &spot_scale, &spot_offset);
82 auto min_scale = matrix.GetMinScale2D();
85 DlScalar device_to_local_scale = 1.0f / min_scale.value_or(1.0f);
88 DlScalar device_space_ambient_blur = AmbientBlurRadius(
params.occluder_z);
89 ambient_blur = device_space_ambient_blur * device_to_local_scale;
92 GetDirectionalParams(
params, &spot_blur, &spot_scale, &spot_offset);
98 spot_blur *= device_to_local_scale;
102 DlRect spot_bounds = ambient_bounds;
103 ambient_bounds = ambient_bounds.
Expand(ambient_blur);
104 spot_bounds = spot_bounds.
Scale(spot_scale);
105 spot_bounds = spot_bounds.
Shift(spot_offset);
106 spot_bounds = spot_bounds.Expand(spot_blur);
111 result = result.
Expand(1.0f, 1.0f);
114 if (matrix.HasPerspective2D()) {
116 result = result.TransformAndClipBounds(inverse);
129 return GetLocalBounds(
130 path.GetBounds(), ctm,
132 .light_position = DlVector3(0.0f, -1.0f, 1.0f),
133 .light_radius = kShadowLightRadius / kShadowLightHeight,
134 .occluder_z = dpr * elevation,
static DlRect ComputeShadowBounds(const DlPath &path, float elevation, DlScalar dpr, const DlMatrix &ctm)
Compute the local coverage for a |DrawShadow| operation using the given parameters (excluding the col...
const EmbeddedViewParams * params
#define FML_DCHECK(condition)
Vector2 blur_radius
Blur radius in source pixels based on scaled_sigma.
impeller::Scalar DlScalar
impeller::Matrix DlMatrix
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
static constexpr DlScalar kEhCloseEnough
impeller::Vector3 DlVector3
impeller::Vector2 DlVector2
A 4x4 matrix using column-major storage.
constexpr Vector4 TransformDirection(const Vector4 &v) const
constexpr TRect Union(const TRect &o) const
constexpr TRect Scale(Type scale) const
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
constexpr TRect< T > Shift(T dx, T dy) const
Returns a new rectangle translated by the given offset.