24 const SkRect& pathBounds,
bool directional,
27 return zPlaneParams.
fX*
x + zPlaneParams.
fY*
y + zPlaneParams.
fZ;
37 lightPos.
fZ, lightRadius, radius,
41 lightPos.
fZ, lightRadius, radius,
57 pts3D[0].
set(pts[0].fX, pts[0].fY, z);
58 z = heightFunc(pathBounds.
fRight, pathBounds.
fTop);
59 pts3D[1].
set(pts[1].fX, pts[1].fY, z);
61 pts3D[2].
set(pts[2].fX, pts[2].fY, z);
63 pts3D[3].
set(pts[3].fX, pts[3].fY, z);
66 for (
int i = 0; i < 4; ++i) {
73 pts3D[i].
fX -= (lightPos.
fX - pts3D[i].
fX)*zRatio;
74 pts3D[i].
fY -= (lightPos.
fY - pts3D[i].
fY)*zRatio;
81 h0 = (pts3D[1].
cross(pts3D[0])).cross(pts3D[2].cross(pts3D[3]));
83 h1 = (pts3D[0].
cross(pts3D[3])).cross(pts3D[1].cross(pts3D[2]));
85 h2 = (pts3D[0].
cross(pts3D[2])).cross(pts3D[1].cross(pts3D[3]));
101 v = pts3D[1] - pts3D[0];
102 perpDot = v.
fX*
w.fY - v.
fY*
w.fX;
113 toHomogeneous.
setAll(xScale, 0, -xScale*pathBounds.
fLeft - 1,
114 0, yScale, -yScale*pathBounds.
fTop - 1,
116 shadowTransform->
preConcat(toHomogeneous);
126 SkRect ambientBounds = path.getBounds();
154 &spotBlur, &spotScale, &spotOffset);
160 &spotBlur, &spotScale, &spotOffset);
167 ambientBlur = devSpaceAmbientBlur*devToSrcScale;
173 &spotBlur, &spotScale, &spotOffset);
176 if (ctm.
invert(&inverse)) {
182 &spotBlur, &spotScale, &spotOffset);
186 spotBlur *= devToSrcScale;
190 SkRect spotBounds = ambientBounds;
191 ambientBounds.
outset(ambientBlur, ambientBlur);
192 spotBounds.
fLeft *= spotScale;
193 spotBounds.
fTop *= spotScale;
194 spotBounds.
fRight *= spotScale;
195 spotBounds.
fBottom *= spotScale;
196 spotBounds.
offset(spotOffset.
fX, spotOffset.
fY);
197 spotBounds.
outset(spotBlur, spotBlur);
200 *bounds = ambientBounds;
201 bounds->join(spotBounds);
203 bounds->outset(1, 1);
209 if (ctm.
invert(&inverse)) {
#define SkScalarInvert(x)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
#define SK_ScalarNearlyZero
@ kDirectionalLight_ShadowFlag
static constexpr bool SkToBool(const T &x)
void mapVectors(SkVector dst[], const SkVector src[], int count) const
SkMatrix & setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2)
void setScaleTranslate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty)
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
bool invert(SkMatrix *inverse) const
SkScalar getMinScale() const
SkMatrix & preConcat(const SkMatrix &other)
bool hasPerspective() const
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
void mapRectToQuad(SkPoint dst[4], const SkRect &rect) const
const EmbeddedViewParams * params
bool GetSpotShadowTransform(const SkPoint3 &lightPos, SkScalar lightRadius, const SkMatrix &ctm, const SkPoint3 &zPlaneParams, const SkRect &pathBounds, bool directional, SkMatrix *shadowTransform, SkScalar *radius)
void GetLocalBounds(const SkPath &path, const SkDrawShadowRec &rec, const SkMatrix &ctm, SkRect *bounds)
static SkScalar compute_z(SkScalar x, SkScalar y, const SkPoint3 ¶ms)
void GetDirectionalParams(SkScalar occluderZ, SkScalar lightX, SkScalar lightY, SkScalar lightZ, SkScalar lightRadius, SkScalar *blurRadius, SkScalar *scale, SkVector *translate)
SkScalar AmbientBlurRadius(SkScalar height)
void GetSpotParams(SkScalar occluderZ, SkScalar lightX, SkScalar lightY, SkScalar lightZ, SkScalar lightRadius, SkScalar *blurRadius, SkScalar *scale, SkVector *translate)
SkScalar SpotBlurRadius(SkScalar occluderZ, SkScalar lightZ, SkScalar lightRadius)
SkPoint3 cross(const SkPoint3 &vec) const
void set(SkScalar x, SkScalar y, SkScalar z)
static constexpr SkPoint Make(float x, float y)
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
void outset(float dx, float dy)
SkScalar fRight
larger x-axis bounds
constexpr float centerX() const
void offset(float dx, float dy)
constexpr float height() const
constexpr float centerY() const
constexpr float width() const
SkScalar fTop
smaller y-axis bounds