aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-05-08 14:19:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-08 18:42:48 +0000
commite308a122ef996a64a21a6339e3b50b9edfdf654f (patch)
treecdc38ee996e86789f198f93d4a86c240f03d2317 /include/utils
parent6f24180a99bc486cf4cee5da1a45225e7ff263d7 (diff)
Remove height functor for shadows and replace with plane equation params
Change-Id: I948eceb2c58dc50468993dba54c209f18e440e48 Reviewed-on: https://skia-review.googlesource.com/15873 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/SkShadowUtils.h72
1 files changed, 54 insertions, 18 deletions
diff --git a/include/utils/SkShadowUtils.h b/include/utils/SkShadowUtils.h
index 01514a46ff..4a497bb397 100644
--- a/include/utils/SkShadowUtils.h
+++ b/include/utils/SkShadowUtils.h
@@ -43,29 +43,65 @@ public:
uint32_t flags = SkShadowFlags::kNone_ShadowFlag,
SkResourceCache* cache = nullptr);
- /**
- * Draw an offset spot shadow and outlining ambient shadow for the given path using a disc
- * light. Takes a function to vary the z value based on the transformed x and y position.
- * This shadow will not be cached, as the assumption is that this will be used for animation.
- *
- * @param canvas The canvas on which to draw the shadows.
- * @param path The occluder used to generate the shadows.
- * @param heightFunc A function which returns the vertical offset of the occluder from the
- * canvas based on local x and y values (the current matrix is not applied).
- * @param lightPos The 3D position of the light relative to the canvas plane. This is
- * independent of the canvas's current matrix.
- * @param lightRadius The radius of the disc light.
- * @param ambientAlpha The maximum alpha of the ambient shadow.
- * @param spotAlpha The maxium alpha of the spot shadow.
- * @param color The shadow color.
- * @param flags Options controlling opaque occluder optimizations and shadow appearance. See
- * SkShadowFlags.
- */
+ /**
+ * Draw an offset spot shadow and outlining ambient shadow for the given path using a disc
+ * light. Takes a function to vary the z value based on the local x and y position.
+ * This shadow will not be cached, as the assumption is that this will be used for animation.
+ *
+ * Deprecated version with height functor (to be removed when Android is updated).
+ *
+ * @param canvas The canvas on which to draw the shadows.
+ * @param path The occluder used to generate the shadows.
+ * @param heightFunc A function which returns the vertical offset of the occluder from the
+ * canvas based on local x and y values (the current matrix is not applied).
+ * @param lightPos The 3D position of the light relative to the canvas plane. This is
+ * independent of the canvas's current matrix.
+ * @param lightRadius The radius of the disc light.
+ * @param ambientAlpha The maximum alpha of the ambient shadow.
+ * @param spotAlpha The maxium alpha of the spot shadow.
+ * @param color The shadow color.
+ * @param flags Options controlling opaque occluder optimizations and shadow appearance. See
+ * SkShadowFlags.
+ */
static void DrawUncachedShadow(SkCanvas* canvas, const SkPath& path,
std::function<SkScalar(SkScalar, SkScalar)> heightFunc,
const SkPoint3& lightPos, SkScalar lightRadius,
SkScalar ambientAlpha, SkScalar spotAlpha, SkColor color,
+ uint32_t flags = SkShadowFlags::kNone_ShadowFlag) {
+ SkPoint3 zPlane;
+ zPlane.fZ = heightFunc(0, 0);
+ zPlane.fX = heightFunc(1, 0) - zPlane.fZ;
+ zPlane.fY = heightFunc(0, 1) - zPlane.fZ;
+
+ DrawUncachedShadow(canvas, path, zPlane, lightPos, lightRadius, ambientAlpha, spotAlpha,
+ color, flags);
+ }
+
+ /**
+ * Draw an offset spot shadow and outlining ambient shadow for the given path using a disc
+ * light. Uses a plane function to vary the z value based on the local x and y position.
+ * This shadow will not be cached, as the assumption is that this will be used for animation.
+ *
+ * @param canvas The canvas on which to draw the shadows.
+ * @param path The occluder used to generate the shadows.
+ * @param zPlaneParams Values for the plane function which returns the Z offset of the
+ * occluder from the canvas based on local x and y values (the current matrix is not applied).
+ * @param lightPos The 3D position of the light relative to the canvas plane. This is
+ * independent of the canvas's current matrix.
+ * @param lightRadius The radius of the disc light.
+ * @param ambientAlpha The maximum alpha of the ambient shadow.
+ * @param spotAlpha The maxium alpha of the spot shadow.
+ * @param color The shadow color.
+ * @param flags Options controlling opaque occluder optimizations and shadow appearance. See
+ * SkShadowFlags.
+ */
+ static void DrawUncachedShadow(SkCanvas* canvas, const SkPath& path,
+ const SkPoint3& zPlaneParams,
+ const SkPoint3& lightPos, SkScalar lightRadius,
+ SkScalar ambientAlpha, SkScalar spotAlpha, SkColor color,
uint32_t flags = SkShadowFlags::kNone_ShadowFlag);
+
+
};
#endif