aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkShadowTessellator.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-02-06 15:47:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-07 15:03:48 +0000
commitaff27a23ad4b38851429066dbfb43cfa7199e37c (patch)
tree3f3f86564994c42e7b1f91cadfca03ae42d00300 /src/utils/SkShadowTessellator.h
parent1f8be689173bde68802a9ff53d9565b21805b854 (diff)
Use SkVertices for tessellated spot and ambient shadow rendering.
Change-Id: Ia81e7a771d345286533752708e4304c1ae3b97c9 Reviewed-on: https://skia-review.googlesource.com/8042 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stan Iliev <stani@google.com>
Diffstat (limited to 'src/utils/SkShadowTessellator.h')
-rwxr-xr-xsrc/utils/SkShadowTessellator.h77
1 files changed, 20 insertions, 57 deletions
diff --git a/src/utils/SkShadowTessellator.h b/src/utils/SkShadowTessellator.h
index 875bb76f0b..eb49bbee3f 100755
--- a/src/utils/SkShadowTessellator.h
+++ b/src/utils/SkShadowTessellator.h
@@ -8,68 +8,31 @@
#ifndef SkShadowTessellator_DEFINED
#define SkShadowTessellator_DEFINED
-#include "SkTDArray.h"
-#include "SkRefCnt.h"
-#include "SkPoint.h"
-
#include "SkColor.h"
+#include "SkPoint.h"
+#include "SkRefCnt.h"
class SkMatrix;
class SkPath;
+class SkVertices;
-class SkShadowVertices : public SkRefCnt {
-public:
- /**
- * This function generates an ambient shadow mesh for a path by walking the path, outsetting by
- * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively.
- * If transparent is true, then the center of the ambient shadow will be filled in.
- */
- static sk_sp<SkShadowVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm,
- SkScalar radius, SkColor umbraColor,
- SkColor penumbraColor, bool transparent);
-
- /**
- * This function generates a spot shadow mesh for a path by walking the transformed path,
- * further transforming by the scale and translation, and outsetting and insetting by a radius.
- * The center will be clipped against the original path unless transparent is true.
- */
- static sk_sp<SkShadowVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm,
- SkScalar scale, const SkVector& translate,
- SkScalar radius, SkColor umbraColor,
- SkColor penumbraColor, bool transparent);
-
- int vertexCount() const { return fVertexCnt; }
- const SkPoint* positions() const { return fPositions.get(); }
- const SkColor* colors() const { return fColors.get(); }
-
- int indexCount() const { return fIndexCnt; }
- const uint16_t* indices() const { return fIndices.get(); }
-
- size_t size() const {
- return sizeof(*this) + fVertexCnt * (sizeof(SkPoint) + sizeof(SkColor)) +
- fIndexCnt * sizeof(uint16_t);
- }
-
-private:
- template<typename T> using Deleter = SkTDArray<SkPoint>::Deleter;
- template<typename T> using UniqueArray = std::unique_ptr<const T[], Deleter<T>>;
-
- SkShadowVertices(UniqueArray<SkPoint>&& positions, UniqueArray<SkColor>&& colors,
- UniqueArray<uint16_t>&& indices, int vertexCnt, int indexCnt)
- : fVertexCnt(vertexCnt)
- , fIndexCnt(indexCnt)
- , fPositions(std::move(positions))
- , fColors(std::move(colors))
- , fIndices(std::move(indices)) {
- SkASSERT(SkToBool(fPositions) && SkToBool(fColors) && SkToBool(vertexCnt) &&
- SkToBool(fIndices) && SkToBool(indexCnt));
- }
+namespace SkShadowTessellator {
+/**
+ * This function generates an ambient shadow mesh for a path by walking the path, outsetting by
+ * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively.
+ * If transparent is true, then the center of the ambient shadow will be filled in.
+ */
+sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm, SkScalar radius,
+ SkColor umbraColor, SkColor penumbraColor, bool transparent);
- int fVertexCnt;
- int fIndexCnt;
- UniqueArray<SkPoint> fPositions;
- UniqueArray<SkColor> fColors;
- UniqueArray<uint16_t> fIndices;
-};
+/**
+ * This function generates a spot shadow mesh for a path by walking the transformed path,
+ * further transforming by the scale and translation, and outsetting and insetting by a radius.
+ * The center will be clipped against the original path unless transparent is true.
+ */
+sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, SkScalar scale,
+ const SkVector& translate, SkScalar radius, SkColor umbraColor,
+ SkColor penumbraColor, bool transparent);
+}
#endif