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>
diff --git a/src/utils/SkShadowUtils.cpp b/src/utils/SkShadowUtils.cpp
index c4b4e3d..8374aef 100755
--- a/src/utils/SkShadowUtils.cpp
+++ b/src/utils/SkShadowUtils.cpp
@@ -13,6 +13,7 @@
 #include "SkResourceCache.h"
 #include "SkShadowTessellator.h"
 #include "SkTLazy.h"
+#include "SkVertices.h"
 #if SK_SUPPORT_GPU
 #include "GrShape.h"
 #include "effects/GrBlurredEdgeFragmentProcessor.h"
@@ -98,9 +99,9 @@
         return true;
     }
 
-    sk_sp<SkShadowVertices> makeVertices(const SkPath& path, const SkMatrix& ctm) const {
-        return SkShadowVertices::MakeAmbient(path, ctm, fRadius, fUmbraColor, fPenumbraColor,
-                                             fTransparent);
+    sk_sp<SkVertices> makeVertices(const SkPath& path, const SkMatrix& ctm) const {
+        return SkShadowTessellator::MakeAmbient(path, ctm, fRadius, fUmbraColor, fPenumbraColor,
+                                                fTransparent);
     }
 };
 
@@ -148,10 +149,10 @@
         return false;
     }
 
-    sk_sp<SkShadowVertices> makeVertices(const SkPath& path, const SkMatrix& ctm) const {
+    sk_sp<SkVertices> makeVertices(const SkPath& path, const SkMatrix& ctm) const {
         bool transparent = OccluderType::kTransparent == fOccluderType;
-        return SkShadowVertices::MakeSpot(path, ctm, fScale, fOffset, fRadius, fUmbraColor,
-                                          fPenumbraColor, transparent);
+        return SkShadowTessellator::MakeSpot(path, ctm, fScale, fOffset, fRadius, fUmbraColor,
+                                             fPenumbraColor, transparent);
     }
 };
 
@@ -165,23 +166,23 @@
 public:
     size_t size() const { return fAmbientSet.size() + fSpotSet.size(); }
 
-    sk_sp<SkShadowVertices> find(const AmbientVerticesFactory& ambient, const SkMatrix& matrix,
-                                 SkVector* translate) const {
+    sk_sp<SkVertices> find(const AmbientVerticesFactory& ambient, const SkMatrix& matrix,
+                           SkVector* translate) const {
         return fAmbientSet.find(ambient, matrix, translate);
     }
 
-    sk_sp<SkShadowVertices> add(const SkPath& devPath, const AmbientVerticesFactory& ambient,
-                                const SkMatrix& matrix) {
+    sk_sp<SkVertices> add(const SkPath& devPath, const AmbientVerticesFactory& ambient,
+                          const SkMatrix& matrix) {
         return fAmbientSet.add(devPath, ambient, matrix);
     }
 
-    sk_sp<SkShadowVertices> find(const SpotVerticesFactory& spot, const SkMatrix& matrix,
-                                 SkVector* translate) const {
+    sk_sp<SkVertices> find(const SpotVerticesFactory& spot, const SkMatrix& matrix,
+                           SkVector* translate) const {
         return fSpotSet.find(spot, matrix, translate);
     }
 
-    sk_sp<SkShadowVertices> add(const SkPath& devPath, const SpotVerticesFactory& spot,
-                                const SkMatrix& matrix) {
+    sk_sp<SkVertices> add(const SkPath& devPath, const SpotVerticesFactory& spot,
+                          const SkMatrix& matrix) {
         return fSpotSet.add(devPath, spot, matrix);
     }
 
@@ -191,8 +192,8 @@
     public:
         size_t size() const { return fSize; }
 
-        sk_sp<SkShadowVertices> find(const FACTORY& factory, const SkMatrix& matrix,
-                                     SkVector* translate) const {
+        sk_sp<SkVertices> find(const FACTORY& factory, const SkMatrix& matrix,
+                               SkVector* translate) const {
             for (int i = 0; i < MAX_ENTRIES; ++i) {
                 if (fEntries[i].fFactory.isCompatible(factory, translate)) {
                     const SkMatrix& m = fEntries[i].fMatrix;
@@ -214,9 +215,8 @@
             return nullptr;
         }
 
-        sk_sp<SkShadowVertices> add(const SkPath& devPath, const FACTORY& factory,
-                                    const SkMatrix& matrix) {
-            sk_sp<SkShadowVertices> vertices = factory.makeVertices(devPath, matrix);
+        sk_sp<SkVertices> add(const SkPath& path, const FACTORY& factory, const SkMatrix& matrix) {
+            sk_sp<SkVertices> vertices = factory.makeVertices(path, matrix);
             if (!vertices) {
                 return nullptr;
             }
@@ -237,7 +237,7 @@
     private:
         struct Entry {
             FACTORY fFactory;
-            sk_sp<SkShadowVertices> fVertices;
+            sk_sp<SkVertices> fVertices;
             SkMatrix fMatrix;
         };
         Entry fEntries[MAX_ENTRIES];
@@ -277,8 +277,8 @@
     sk_sp<CachedTessellations> refTessellations() const { return fTessellations; }
 
     template <typename FACTORY>
-    sk_sp<SkShadowVertices> find(const FACTORY& factory, const SkMatrix& matrix,
-                                 SkVector* translate) const {
+    sk_sp<SkVertices> find(const FACTORY& factory, const SkMatrix& matrix,
+                           SkVector* translate) const {
         return fTessellations->find(factory, matrix, translate);
     }
 
@@ -300,7 +300,7 @@
     const SkMatrix* const fViewMatrix;
     // If this is valid after Find is called then we found the vertices and they should be drawn
     // with fTranslate applied.
-    sk_sp<SkShadowVertices> fVertices;
+    sk_sp<SkVertices> fVertices;
     SkVector fTranslate = {0, 0};
 
     // If this is valid after Find then the caller should add the vertices to the tessellation set
@@ -385,7 +385,7 @@
         SkResourceCache::Find(*key, FindVisitor<FACTORY>, &context);
     }
 
-    sk_sp<SkShadowVertices> vertices;
+    sk_sp<SkVertices> vertices;
     const SkVector* translate;
     static constexpr SkVector kZeroTranslate = {0, 0};
     bool foundInCache = SkToBool(context.fVertices);
@@ -426,9 +426,7 @@
         canvas->save();
         canvas->translate(translate->fX, translate->fY);
     }
-    canvas->drawVertices(SkCanvas::kTriangles_VertexMode, vertices->vertexCount(),
-                         vertices->positions(), nullptr, vertices->colors(), vertices->indices(),
-                         vertices->indexCount(), paint);
+    canvas->drawVertices(vertices, SkBlendMode::kModulate, paint);
     if (translate->fX || translate->fY) {
         canvas->restore();
     }