aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-03-27 14:25:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-27 19:06:59 +0000
commitb436655ad5c40a04b65c1642d0a0e781ce296c96 (patch)
tree4cf0067fb63ab9afbf817e0930c03b858b51588e /include/utils
parentb549cc38c8404c58642ada75c0b24907702cc005 (diff)
Add height function to shadow tessellators.
Prep work for adding perspective support. Bug: skia: Change-Id: Id07d3050afb3f0d001b885e482adb8d03125b619 Reviewed-on: https://skia-review.googlesource.com/10167 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/SkShadowUtils.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/include/utils/SkShadowUtils.h b/include/utils/SkShadowUtils.h
index 3339812c34..01514a46ff 100644
--- a/include/utils/SkShadowUtils.h
+++ b/include/utils/SkShadowUtils.h
@@ -11,6 +11,7 @@
#include "SkColor.h"
#include "SkScalar.h"
#include "../private/SkShadowFlags.h"
+#include <functional>
class SkCanvas;
class SkPath;
@@ -25,7 +26,7 @@ public:
* @param canvas The canvas on which to draw the shadows.
* @param path The occluder used to generate the shadows.
* @param occluderHeight The vertical offset of the occluder from the canvas. This is
- * indepdendent of the canvas's current matrix.
+ * independent of the canvas's current matrix.
* @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.
@@ -41,6 +42,30 @@ public:
SkScalar spotAlpha, SkColor color,
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.
+ */
+ 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);
};
#endif