remove legacy virtual for vertices, only support object form
authorMike Reed <reed@google.com>
Fri, 17 Mar 2017 16:09:04 +0000 (12:09 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Fri, 17 Mar 2017 17:03:18 +0000 (17:03 +0000)
BUG=skia:6366

Change-Id: Ic422fa44a788d3488c050c6218dbfba188bb8f3e
Reviewed-on: https://skia-review.googlesource.com/9835
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>

29 files changed:
include/core/SkCanvas.h
include/utils/SkDumpCanvas.h
include/utils/SkLuaCanvas.h
include/utils/SkNWayCanvas.h
include/utils/SkNoDrawCanvas.h
include/utils/SkPaintFilterCanvas.h
src/core/SkCanvas.cpp
src/core/SkColorSpaceXformCanvas.cpp
src/core/SkLiteDL.cpp
src/core/SkLiteDL.h
src/core/SkLiteRecorder.cpp
src/core/SkLiteRecorder.h
src/core/SkOverdrawCanvas.cpp
src/core/SkOverdrawCanvas.h
src/core/SkPictureRecord.cpp
src/core/SkPictureRecord.h
src/core/SkRecorder.cpp
src/core/SkRecorder.h
src/pipe/SkPipeCanvas.cpp
src/pipe/SkPipeCanvas.h
src/utils/SkDeferredCanvas.cpp
src/utils/SkDeferredCanvas.h
src/utils/SkDumpCanvas.cpp
src/utils/SkNWayCanvas.cpp
src/utils/SkPaintFilterCanvas.cpp
tools/debugger/SkDebugCanvas.cpp
tools/debugger/SkDebugCanvas.h
tools/debugger/SkDrawCommand.cpp
tools/debugger/SkDrawCommand.h

index 85531bb74a1a889c8737ba6432bf331b10a9722f..3a2b3fc09aca1b5d13187c808382f120f4419954 100644 (file)
@@ -1442,13 +1442,14 @@ protected:
                            const SkPaint&);
     virtual void onDrawRRect(const SkRRect&, const SkPaint&);
     virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&);
+
+#ifdef SK_SUPPORT_LEGACY_DRAWVERTICES_VIRTUAL
     virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
                                 const SkPoint texs[], const SkColor colors[], SkBlendMode,
-                                const uint16_t indices[], int indexCount, const SkPaint&);
+                                const uint16_t indices[], int indexCount, const SkPaint&) {}
+#endif
+
     virtual void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&);
-    // Subclasses can use this put the vertices object call on the regular draw vertices code path.
-    // This is temporary until we teach recording and other SkCanvas classes about SkVertices.
-    void devolveSkVerticesToRaw(const SkVertices*, SkBlendMode, const SkPaint&);
 
     virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
                              int count, SkBlendMode, const SkRect* cull, const SkPaint*);
index 19e5da567d033e696778721d494e1f7267ed6c68..b8fff7225838e7183e677fb12b9b120a04881b6c 100644 (file)
@@ -112,15 +112,7 @@ protected:
                          const SkPaint*, SrcRectConstraint) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                        const SkPoint vertices[], const SkPoint texs[],
-                        const SkColor colors[], SkBlendMode,
-                        const uint16_t indices[], int indexCount,
-                        const SkPaint&) override;
-    void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
-                              const SkPaint& paint) override {
-        this->devolveSkVerticesToRaw(vertices, mode, paint);
-    }
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
 
     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
index a11d72f26c9add77ed7c071f4f414639d9befa95..49ff377af307ac0178c883879af2d71d9322c017 100644 (file)
@@ -58,15 +58,7 @@ protected:
                          const SkPaint*, SrcRectConstraint) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                        const SkPoint vertices[], const SkPoint texs[],
-                        const SkColor colors[], SkBlendMode,
-                        const uint16_t indices[], int indexCount,
-                        const SkPaint&) override;
-    void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
-                              const SkPaint& paint) override {
-        this->devolveSkVerticesToRaw(vertices, mode, paint);
-    }
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
 
     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
index 3ed7d4c41a8389433944b23cdae5ea1496e88f02..3407853fd62a759345a15a2460333aa745265a37 100644 (file)
@@ -70,11 +70,7 @@ protected:
                          const SkPaint*, SrcRectConstraint) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                              const SkPoint vertices[], const SkPoint texs[],
-                              const SkColor colors[], SkBlendMode,
-                              const uint16_t indices[], int indexCount,
-                              const SkPaint&) override;
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
 
     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
index 75c15b201e85c68145b035cc5a03c2ab32e45c10..d21d678f165c55f3107ab36565ec10c644344fe4 100644 (file)
@@ -66,8 +66,6 @@ protected:
                             const SkPaint*) override {}
     void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
                              const SkPaint*) override {}
-    void onDrawVertices(VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
-                        SkBlendMode, const uint16_t[], int, const SkPaint&) override {}
     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
                      int, SkBlendMode, const SkRect*, const SkPaint*) override {}
index 7dc7969e6e58d97e3a6ee9c8b194f66d17431680..31b366373024a2c5258d8c2255d4794e78b8e963 100644 (file)
@@ -74,11 +74,7 @@ protected:
                          const SkPaint*, SrcRectConstraint) override;
     void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                          const SkPaint*) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                              const SkPoint vertices[], const SkPoint texs[],
-                              const SkColor colors[], SkBlendMode,
-                              const uint16_t indices[], int indexCount,
-                              const SkPaint&) override;
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
     void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
                              const SkPoint texCoords[4], SkBlendMode,
                              const SkPaint& paint) override;
index ccdb71b5a0e6575ddde576b7828ef361cf71389d..fbc2a3cc472ea49bbd448fa0ca59ddacc5c8aa95 100644 (file)
@@ -1792,11 +1792,14 @@ void SkCanvas::drawPoints(PointMode mode, size_t count, const SkPoint pts[], con
     this->onDrawPoints(mode, count, pts, paint);
 }
 
-void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[],
+void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, const SkPoint positions[],
                             const SkPoint texs[], const SkColor colors[], SkBlendMode bmode,
                             const uint16_t indices[], int indexCount, const SkPaint& paint) {
-    this->onDrawVertices(vmode, vertexCount, std::move(vertices), texs, colors, bmode, indices,
-                         indexCount, paint);
+    auto vertices = SkVertices::MakeCopy(vmode, vertexCount, positions, texs, colors,
+                                         indexCount, indices);
+    if (vertices) {
+        this->onDrawVerticesObject(vertices.get(), bmode, paint);
+    }
 }
 
 void SkCanvas::drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode,
@@ -2659,23 +2662,6 @@ void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
     this->onDrawTextBlob(blob, x, y, paint);
 }
 
-void SkCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
-                              const SkPoint verts[], const SkPoint texs[],
-                              const SkColor colors[], SkBlendMode bmode,
-                              const uint16_t indices[], int indexCount,
-                              const SkPaint& paint) {
-    TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()");
-    LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr)
-
-    while (iter.next()) {
-        iter.fDevice->drawVertices(vmode, vertexCount, verts, texs,
-                                   colors, bmode, indices, indexCount,
-                                   looper.paint());
-    }
-
-    LOOPER_END
-}
-
 void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
                                     const SkPaint& paint) {
     TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()");
@@ -2689,13 +2675,6 @@ void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmod
     LOOPER_END
 }
 
-void SkCanvas::devolveSkVerticesToRaw(const SkVertices* vertices, SkBlendMode mode,
-                                      const SkPaint& paint) {
-    this->onDrawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
-                         vertices->texCoords(), vertices->colors(), mode,
-                         vertices->indices(), vertices->indexCount(), paint);
-}
-
 void SkCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
                          const SkPoint texCoords[4], SkBlendMode bmode,
                          const SkPaint& paint) {
index 112709dc933acdc911c32949bcca559eb489fbde..e8fc8e40db702a36e0cefc761574845c08011168 100644 (file)
@@ -215,20 +215,21 @@ public:
         SkTLazy<SkPaint> lazy;
         fTarget->drawPoints(mode, count, pts, this->xform(paint, &lazy));
     }
-    void onDrawVertices(VertexMode vmode, int count,
-                        const SkPoint* verts, const SkPoint* texs, const SkColor* colors,
-                        SkBlendMode mode,
-                        const uint16_t* indices, int indexCount, const SkPaint& paint) override {
-        SkSTArray<8, SkColor> xformed;
-        if (colors) {
-            xformed.reset(count);
-            this->xform(xformed.begin(), colors, count);
-            colors = xformed.begin();
+    void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
+                              const SkPaint& paint) override {
+        sk_sp<SkVertices> copy;
+        if (vertices->hasColors()) {
+            int count = vertices->vertexCount();
+            SkSTArray<8, SkColor> xformed(count);
+            this->xform(xformed.begin(), vertices->colors(), count);
+            copy = SkVertices::MakeCopy(vertices->mode(), count, vertices->positions(),
+                                        vertices->texCoords(), xformed.begin(),
+                                        vertices->indexCount(), vertices->indices());
+            vertices = copy.get();
         }
 
         SkTLazy<SkPaint> lazy;
-        fTarget->drawVertices(vmode, count, verts, texs, colors, mode, indices, indexCount,
-                              this->xform(paint, &lazy));
+        fTarget->drawVertices(vertices, mode, this->xform(paint, &lazy));
     }
 
     void onDrawText(const void* ptr, size_t len,
index 2da6eb5ef6e19e73e0a65b349634f66e4a061fc8..6751634ea437e22afcd483e644090579b8e9e3c7 100644 (file)
@@ -55,7 +55,7 @@ namespace {
     M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice)          \
     M(DrawText) M(DrawPosText) M(DrawPosTextH)                                  \
     M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob)                        \
-    M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawVerticesObject) M(DrawAtlas)
+    M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas)
 
 #define M(T) T,
     enum class Type : uint8_t { TYPES(M) };
@@ -467,45 +467,7 @@ namespace {
     };
     struct DrawVertices final : Op {
         static const auto kType = Type::DrawVertices;
-        DrawVertices(SkCanvas::VertexMode mode, int count, SkBlendMode bmode, int nindices,
-                     const SkPaint& paint, bool has_texs, bool has_colors, bool has_indices)
-            : mode(mode), count(count), xfermode(bmode), nindices(nindices)
-            , paint(paint), has_texs(has_texs), has_colors(has_colors), has_indices(has_indices) {}
-        SkCanvas::VertexMode mode;
-        int                  count;
-        SkBlendMode          xfermode;
-        int                  nindices;
-        SkPaint              paint;
-        bool                 has_texs;
-        bool                 has_colors;
-        bool                 has_indices;
-        void draw(SkCanvas* c, const SkMatrix&) {
-            SkPoint* vertices = pod<SkPoint>(this, 0);
-            size_t offset = count*sizeof(SkPoint);
-
-            SkPoint* texs = nullptr;
-            if (has_texs) {
-                texs = pod<SkPoint>(this, offset);
-                offset += count*sizeof(SkPoint);
-            }
-
-            SkColor* colors = nullptr;
-            if (has_colors) {
-                colors = pod<SkColor>(this, offset);
-                offset += count*sizeof(SkColor);
-            }
-
-            uint16_t* indices = nullptr;
-            if (has_indices) {
-                indices = pod<uint16_t>(this, offset);
-            }
-            c->drawVertices(mode, count, vertices, texs, colors, xfermode,
-                            indices, nindices, paint);
-        }
-    };
-    struct DrawVerticesObject final : Op {
-        static const auto kType = Type::DrawVerticesObject;
-        DrawVerticesObject(const SkVertices* v, SkBlendMode m, const SkPaint& p)
+        DrawVertices(const SkVertices* v, SkBlendMode m, const SkPaint& p)
             : vertices(sk_ref_sp(const_cast<SkVertices*>(v))), mode(m), paint(p) {}
         sk_sp<SkVertices> vertices;
         SkBlendMode mode;
@@ -712,22 +674,8 @@ void SkLiteDL::drawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint
     void* pod = this->push<DrawPoints>(count*sizeof(SkPoint), mode, count, paint);
     copy_v(pod, points,count);
 }
-void SkLiteDL::drawVertices(SkCanvas::VertexMode mode, int count, const SkPoint vertices[],
-                            const SkPoint texs[], const SkColor colors[], SkBlendMode xfermode,
-                            const uint16_t indices[], int nindices, const SkPaint& paint) {
-    size_t bytes = count * sizeof(SkPoint);
-    if (texs  )  { bytes += count    * sizeof(SkPoint); }
-    if (colors)  { bytes += count    * sizeof(SkColor); }
-    if (indices) { bytes += nindices * sizeof(uint16_t); }
-    void* pod = this->push<DrawVertices>(bytes, mode, count, xfermode, nindices, paint,
-                                         texs != nullptr, colors != nullptr, indices != nullptr);
-    copy_v(pod, vertices, count,
-                    texs, texs    ? count    : 0,
-                  colors, colors  ? count    : 0,
-                 indices, indices ? nindices : 0);
-}
 void SkLiteDL::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
-    this->push<DrawVerticesObject>(0, vertices, mode, paint);
+    this->push<DrawVertices>(0, vertices, mode, paint);
 }
 void SkLiteDL::drawAtlas(const SkImage* atlas, const SkRSXform xforms[], const SkRect texs[],
                          const SkColor colors[], int count, SkBlendMode xfermode,
index bc5f4e701e0c868760267a0b996fe7182f2493de..f5f7b2198396393819e2ab5707009b7202cb8f86 100644 (file)
@@ -74,8 +74,6 @@ public:
     void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4],
                    SkBlendMode, const SkPaint&);
     void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&);
-    void drawVertices(SkCanvas::VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
-                      SkBlendMode, const uint16_t[], int, const SkPaint&);
     void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&);
     void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
                    SkBlendMode, const SkRect*, const SkPaint*);
index a01ac655e729e39a7b9d384f31f52850f1ebdbce..f899f8822fcfb9a428b6895e60bd0c4d5a2388ac 100644 (file)
@@ -179,14 +179,6 @@ void SkLiteRecorder::onDrawPoints(SkCanvas::PointMode mode,
                                   const SkPaint& paint) {
     fDL->drawPoints(mode, count, pts, paint);
 }
-void SkLiteRecorder::onDrawVertices(SkCanvas::VertexMode mode,
-                                    int count, const SkPoint vertices[],
-                                    const SkPoint texs[], const SkColor colors[],
-                                    SkBlendMode bmode,
-                                    const uint16_t indices[], int indexCount,
-                                    const SkPaint& paint) {
-    fDL->drawVertices(mode, count, vertices, texs, colors, bmode, indices, indexCount, paint);
-}
 void SkLiteRecorder::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
                                           const SkPaint& paint) {
     fDL->drawVertices(vertices, mode, paint);
index 82aeca385a8e8f9f9f338a872345ec9e3550d86b..ea7cc78b2df1aaacc4ba71e1843a01f3f613380e 100644 (file)
@@ -74,8 +74,6 @@ public:
     void onDrawPatch(const SkPoint[12], const SkColor[4],
                      const SkPoint[4], SkBlendMode, const SkPaint&) override;
     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
-    void onDrawVertices(VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
-                        SkBlendMode, const uint16_t[], int, const SkPaint&) override;
     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
                      int, SkBlendMode, const SkRect*, const SkPaint*) override;
index c6b7b9c9cf5d0b53d3caad5c8cf2febf6337fd47..ad37b9a98ffeba5516eaebc8176c2ee0f4a14f6c 100644 (file)
@@ -213,13 +213,9 @@ void SkOverdrawCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint
     fList[0]->onDrawPoints(mode, count, points, this->overdrawPaint(paint));
 }
 
-void SkOverdrawCanvas::onDrawVertices(VertexMode vertexMode, int vertexCount,
-                                      const SkPoint vertices[], const SkPoint texs[],
-                                      const SkColor colors[], SkBlendMode blendMode,
-                                      const uint16_t indices[], int indexCount,
-                                      const SkPaint& paint) {
-    fList[0]->onDrawVertices(vertexMode, vertexCount, vertices, texs, colors, blendMode, indices,
-                            indexCount, this->overdrawPaint(paint));
+void SkOverdrawCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode blendMode,
+                                            const SkPaint& paint) {
+    fList[0]->onDrawVerticesObject(vertices, blendMode, this->overdrawPaint(paint));
 }
 
 void SkOverdrawCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[],
index dd584ef0bfa6b70159ab3257723b51a88556cdfe..5c247b1630e9a6a8ecfa003aee1634e0fd7cf409 100644 (file)
@@ -38,8 +38,7 @@ public:
     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
     void onDrawRRect(const SkRRect&, const SkPaint&) override;
     void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override;
-    void onDrawVertices(VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
-                        SkBlendMode, const uint16_t[], int, const SkPaint&) override;
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
                      int, SkBlendMode, const SkRect*, const SkPaint*) override;
     void onDrawPath(const SkPath&, const SkPaint&) override;
index a2ada8641955062e8d0dae4ee278f934afbd010a..9bdb6c5cc49e7c75d0baf01575b00f36e8aa8cf0 100644 (file)
@@ -722,17 +722,6 @@ void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matri
     this->validate(initialOffset, size);
 }
 
-void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount,
-                                     const SkPoint pos[], const SkPoint texs[],
-                                     const SkColor cols[], SkBlendMode bmode,
-                                     const uint16_t indices[], int indexCount,
-                                     const SkPaint& paint) {
-    auto vertices = SkVertices::MakeCopy(vmode, vertexCount, pos, texs, cols, indexCount, indices);
-    if (vertices) {
-        this->onDrawVerticesObject(vertices.get(), bmode, paint);
-    }
-}
-
 void SkPictureRecord::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
                                            const SkPaint& paint) {
     // op + paint index + vertices index + mode
index 197684e347c2204213dd5e16d4c3a8581801cc2b..4e0bf460e90a2e017e08df02544e393f4026d8b1 100644 (file)
@@ -203,12 +203,6 @@ protected:
                          const SkPaint*) override;
     void onDrawImageLattice(const SkImage*, const SkCanvas::Lattice& lattice, const SkRect& dst,
                             const SkPaint*) override;
-
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                        const SkPoint vertices[], const SkPoint texs[],
-                        const SkColor colors[], SkBlendMode,
-                        const uint16_t indices[], int indexCount,
-                        const SkPaint&) override;
     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
 
     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
index 9b38bcd2b382f895d5b2ca6fe5df682e8101153f..0f2891a825afd2f6b1d01a0c52cc12af7445a4f8 100644 (file)
@@ -326,15 +326,6 @@ void SkRecorder::onDrawShadowedPicture(const SkPicture* pic, const SkMatrix* mat
 }
 
 
-void SkRecorder::onDrawVertices(VertexMode vmode,
-                                int vertexCount, const SkPoint vertices[],
-                                const SkPoint texs[], const SkColor colors[],
-                                SkBlendMode bmode,
-                                const uint16_t indices[], int indexCount, const SkPaint& paint) {
-    this->onDrawVerticesObject(SkVertices::MakeCopy(vmode, vertexCount, vertices, texs, colors,
-                                                    indexCount, indices).get(), bmode, paint);
-}
-
 void SkRecorder::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
                                       const SkPaint& paint) {
     APPEND(DrawVertices, paint, sk_ref_sp(const_cast<SkVertices*>(vertices)), bmode);
index c13344227e6d01ef59c4b81f49acde6f37247057..3407fc703246f8b40bacb33ab88898601e60bcb8 100644 (file)
@@ -124,11 +124,6 @@ public:
                             const SkPaint*) override;
     void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst,
                              const SkPaint*) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                        const SkPoint vertices[], const SkPoint texs[],
-                        const SkColor colors[], SkBlendMode,
-                        const uint16_t indices[], int indexCount,
-                        const SkPaint&) override;
     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
                      int count, SkBlendMode, const SkRect* cull, const SkPaint*) override;
index e707f0db19dd344f076846c05909f2e058de4efe..b05a643cb81d9dc5b49043983680924a70167285 100644 (file)
@@ -731,47 +731,14 @@ void SkPipeCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
     write_paint(writer, paint, kGeometry_PaintUsage);
 }
 
-void SkPipeCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
-                                  const SkPoint vertices[], const SkPoint texs[],
-                                  const SkColor colors[], SkBlendMode bmode,
-                                  const uint16_t indices[], int indexCount,
-                                  const SkPaint& paint) {
-    SkASSERT(vertexCount > 0);
-
-    unsigned extra = 0;
-    if (vertexCount <= kVCount_DrawVerticesMask) {
-        extra |= vertexCount;
-    }
-    extra |= (unsigned)vmode << kVMode_DrawVerticesShift;
-    extra |= (unsigned)bmode << kXMode_DrawVerticesShift;
-
-    if (texs) {
-        extra |= kHasTex_DrawVerticesMask;
-    }
-    if (colors) {
-        extra |= kHasColors_DrawVerticesMask;
-    }
-    if (indexCount > 0) {
-        extra |= kHasIndices_DrawVerticesMask;
-    }
+void SkPipeCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+                                        const SkPaint& paint) {
+    unsigned extra = static_cast<unsigned>(bmode);
 
     SkPipeWriter writer(this);
     writer.write32(pack_verb(SkPipeVerb::kDrawVertices, extra));
-    if (vertexCount > kVCount_DrawVerticesMask) {
-        writer.write32(vertexCount);
-    }
-    writer.write(vertices, vertexCount * sizeof(SkPoint));
-    if (texs) {
-        writer.write(texs, vertexCount * sizeof(SkPoint));
-    }
-    if (colors) {
-        writer.write(colors, vertexCount * sizeof(SkColor));
-    }
-    if (indexCount > 0) {
-        writer.write32(indexCount);
-        SkASSERT(SkIsAlign2(indexCount));
-        writer.write(indices, indexCount * sizeof(uint16_t));
-    }
+    // TODO: dedup vertices?
+    writer.writeDataAsByteArray(vertices->encode().get());
     write_paint(writer, paint, kVertices_PaintUsage);
 }
 
index a506da4ece2e28b227cf679ac015ecc7b5a7d6ac..5604ba787a284197b7350f03f088e9140246fe07 100644 (file)
@@ -136,11 +136,7 @@ protected:
                          const SkPaint*) override;
     void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
                             const SkPaint*) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                              const SkPoint vertices[], const SkPoint texs[],
-                              const SkColor colors[], SkBlendMode,
-                              const uint16_t indices[], int indexCount,
-                              const SkPaint&) override;
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
 
     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
index 871cb509cf67fc9472404e269ec8e49e98a56e45..ecd5495e8fefe3a92577c54caff0c9b97c76558d 100644 (file)
@@ -520,14 +520,10 @@ void SkDeferredCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[]
     fCanvas->drawAtlas(image, xform, rects, colors, count, bmode, cull, paint);
 }
 
-void SkDeferredCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
-                                  const SkPoint vertices[], const SkPoint texs[],
-                                  const SkColor colors[], SkBlendMode bmode,
-                                  const uint16_t indices[], int indexCount,
-                                  const SkPaint& paint) {
+void SkDeferredCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+                                            const SkPaint& paint) {
     this->flush_before_saves();
-    fCanvas->drawVertices(vmode, vertexCount, vertices, texs, colors, bmode,
-                           indices, indexCount, paint);
+    fCanvas->drawVertices(vertices, bmode, paint);
 }
 
 void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
index f983a19e237b54b414b1675b1f4035c6c0c0bf4d..b2bae1b94384b5e2e16fa4937f0e748aa0582a0b 100644 (file)
@@ -84,11 +84,7 @@ protected:
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
                          const SkPaint*, SrcRectConstraint) override;
 
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                              const SkPoint vertices[], const SkPoint texs[],
-                              const SkColor colors[], SkBlendMode,
-                              const uint16_t indices[], int indexCount,
-                              const SkPaint&) override;
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
     void onDrawAtlas(const SkImage* image, const SkRSXform xform[],
                      const SkRect rects[], const SkColor colors[],
                      int count, SkBlendMode, const SkRect* cull, const SkPaint* paint) override;
index dc420136f5f8fae546b050aa2c2c105b8806566f..030f4deed3b4fa247005f6ae52c0f27d3d645a32 100644 (file)
@@ -465,14 +465,10 @@ void SkDumpCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matri
                picture->cullRect().fRight, picture->cullRect().fBottom);
 }
 
-void SkDumpCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
-                                  const SkPoint vertices[], const SkPoint texs[],
-                                  const SkColor colors[], SkBlendMode,
-                                  const uint16_t indices[], int indexCount,
-                                  const SkPaint& paint) {
-    this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)",
-               toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX),
-               SkScalarToFloat(vertices[0].fY));
+void SkDumpCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode,
+                                        const SkPaint& paint) {
+    this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] ...)",
+               toString(vertices->mode()), vertices->vertexCount());
 }
 
 void SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
index 4f51d85f4fd16316091f88bf3498bad3f821d80f..4f6ad46d8505466da35da42fc2ae6dd310968105 100644 (file)
@@ -282,15 +282,11 @@ void SkNWayCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matri
     }
 }
 
-void SkNWayCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
-                                  const SkPoint vertices[], const SkPoint texs[],
-                                  const SkColor colors[], SkBlendMode bmode,
-                                  const uint16_t indices[], int indexCount,
-                                  const SkPaint& paint) {
+void SkNWayCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+                                        const SkPaint& paint) {
     Iter iter(fList);
     while (iter.next()) {
-        iter->drawVertices(vmode, vertexCount, vertices, texs, colors, bmode,
-                           indices, indexCount, paint);
+        iter->drawVertices(vertices, bmode, paint);
     }
 }
 
index c6b28d0c5df2dd985a2cbedf2db7f65ec6abc25b..e504c721190d92307f296a492fcf4b2b1ee67e57 100644 (file)
@@ -147,15 +147,11 @@ void SkPaintFilterCanvas::onDrawImageNine(const SkImage* image, const SkIRect& c
     }
 }
 
-void SkPaintFilterCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
-                                         const SkPoint vertices[], const SkPoint texs[],
-                                         const SkColor colors[], SkBlendMode bmode,
-                                         const uint16_t indices[], int indexCount,
-                                         const SkPaint& paint) {
+void SkPaintFilterCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+                                               const SkPaint& paint) {
     AutoPaintFilter apf(this, kVertices_Type, paint);
     if (apf.shouldDraw()) {
-        this->INHERITED::onDrawVertices(vmode, vertexCount, vertices, texs, colors, bmode, indices,
-                                        indexCount, *apf.paint());
+        this->INHERITED::onDrawVerticesObject(vertices, bmode, *apf.paint());
     }
 }
 
index 522f4edbeba36244fda2c0dde4ed45178ff6ee59..6349810ff951879ceadaec862b8c2a0e31d9e349 100644 (file)
@@ -663,12 +663,10 @@ void SkDebugCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4
     this->addDrawCommand(new SkDrawPatchCommand(cubics, colors, texCoords, bmode, paint));
 }
 
-void SkDebugCanvas::onDrawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[],
-                                   const SkPoint texs[], const SkColor colors[],
-                                   SkBlendMode bmode, const uint16_t indices[], int indexCount,
-                                   const SkPaint& paint) {
-    this->addDrawCommand(new SkDrawVerticesCommand(vmode, vertexCount, vertices,
-                         texs, colors, bmode, indices, indexCount, paint));
+void SkDebugCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+                                         const SkPaint& paint) {
+    this->addDrawCommand(new SkDrawVerticesCommand(sk_ref_sp(const_cast<SkVertices*>(vertices)),
+                                                   bmode, paint));
 }
 
 void SkDebugCanvas::willRestore() {
index 2b15bbaf90ced8d4dc6019a6646284921ba2c3be..0f2ae514dd67dadea37903357d3012f23268e73b 100644 (file)
@@ -225,15 +225,7 @@ protected:
     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
     void onDrawRRect(const SkRRect&, const SkPaint&) override;
     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
-    void onDrawVertices(VertexMode vmode, int vertexCount,
-                        const SkPoint vertices[], const SkPoint texs[],
-                        const SkColor colors[], SkBlendMode,
-                        const uint16_t indices[], int indexCount,
-                        const SkPaint&) override;
-    void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
-                              const SkPaint& paint) override {
-        this->devolveSkVerticesToRaw(vertices, mode, paint);
-    }
+    void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
index 09b8ab49ad5a9dfd532b5ce5a0112d17f8ff8923..691a4f801206c31f52805fb04ee9ead48555534c 100644 (file)
@@ -3394,61 +3394,20 @@ SkDrawTextRSXformCommand* SkDrawTextRSXformCommand::fromJSON(Json::Value& comman
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
-                                             const SkPoint vertices[], const SkPoint texs[],
-                                             const SkColor colors[], SkBlendMode bmode,
-                                             const uint16_t indices[], int indexCount,
+SkDrawVerticesCommand::SkDrawVerticesCommand(sk_sp<SkVertices> vertices, SkBlendMode bmode,
                                              const SkPaint& paint)
     : INHERITED(kDrawVertices_OpType)
+    , fVertices(std::move(vertices))
     , fBlendMode(bmode)
+    , fPaint(paint)
 {
-    fVmode = vmode;
-
-    fVertexCount = vertexCount;
-
-    fVertices = new SkPoint[vertexCount];
-    memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
-
-    if (texs) {
-        fTexs = new SkPoint[vertexCount];
-        memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
-    } else {
-        fTexs = nullptr;
-    }
-
-    if (colors) {
-        fColors = new SkColor[vertexCount];
-        memcpy(fColors, colors, vertexCount * sizeof(SkColor));
-    } else {
-        fColors = nullptr;
-    }
-
-    if (indexCount > 0) {
-        fIndices = new uint16_t[indexCount];
-        memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
-    } else {
-        fIndices = nullptr;
-    }
-
-    fIndexCount = indexCount;
-    fPaint = paint;
-
     // TODO(chudy)
     fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
     fInfo.push(SkObjectParser::PaintToString(paint));
 }
 
-SkDrawVerticesCommand::~SkDrawVerticesCommand() {
-    delete [] fVertices;
-    delete [] fTexs;
-    delete [] fColors;
-    delete [] fIndices;
-}
-
 void SkDrawVerticesCommand::execute(SkCanvas* canvas) const {
-    canvas->drawVertices(fVmode, fVertexCount, fVertices,
-                         fTexs, fColors, fBlendMode, fIndices,
-                         fIndexCount, fPaint);
+    canvas->drawVertices(fVertices, fBlendMode, fPaint);
 }
 
 SkRestoreCommand::SkRestoreCommand()
index 964badcf58cdc5496120f09b5bf8d461d4a4a013..e23eed138c7830eb220edb5a0fc356e6cca73e65 100644 (file)
@@ -16,6 +16,7 @@
 #include "SkRSXform.h"
 #include "SkString.h"
 #include "SkTDArray.h"
+#include "SkVertices.h"
 #include "SkJSONCPP.h"
 #include "UrlDataManager.h"
 
@@ -732,24 +733,14 @@ private:
 
 class SkDrawVerticesCommand : public SkDrawCommand {
 public:
-    SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
-                          const SkPoint vertices[], const SkPoint texs[],
-                          const SkColor colors[], SkBlendMode,
-                          const uint16_t indices[], int indexCount,
-                          const SkPaint& paint);
-    virtual ~SkDrawVerticesCommand();
+    SkDrawVerticesCommand(sk_sp<SkVertices>, SkBlendMode, const SkPaint&);
+
     void execute(SkCanvas* canvas) const override;
 
 private:
-    SkCanvas::VertexMode fVmode;
-    int         fVertexCount;
-    SkPoint*    fVertices;
-    SkPoint*    fTexs;
-    SkColor*    fColors;
-    SkBlendMode fBlendMode;
-    uint16_t*   fIndices;
-    int         fIndexCount;
-    SkPaint     fPaint;
+    sk_sp<SkVertices>   fVertices;
+    SkBlendMode         fBlendMode;
+    SkPaint             fPaint;
 
     typedef SkDrawCommand INHERITED;
 };