remove unused VerticesFlags
authorMike Reed <reed@google.com>
Thu, 16 Mar 2017 13:06:34 +0000 (09:06 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 16 Mar 2017 20:08:50 +0000 (20:08 +0000)
Deferring removing the flags parameter from the virtuals until a
later CL (as it collides with another related CL)

BUG=skia:6366

Change-Id: I817fae3df03ecebe5ec3532f691ed06deab890e6
Reviewed-on: https://skia-review.googlesource.com/9739
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>

fuzz/FuzzCanvas.cpp
gm/vertices.cpp
include/core/SkCanvas.h
src/core/SkCanvas.cpp
src/core/SkDevice.cpp
src/gpu/GrRenderTargetContext.cpp
src/gpu/GrRenderTargetContext.h
src/gpu/SkGpuDevice.cpp
src/gpu/ops/GrDrawVerticesOp.cpp
src/gpu/ops/GrDrawVerticesOp.h

index 32ff3ff..33b932b 100644 (file)
@@ -1750,13 +1750,11 @@ static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) {
                                          blendMode, indexCount > 0 ? indices : nullptr, indexCount,
                                          paint);
                 } else {
-                    uint32_t flags;
-                    fuzz->nextRange(&flags, 0, 3);
                     canvas->drawVertices(SkVertices::MakeCopy(vertexMode, vertexCount, vertices,
                                                               useTexs ? texs : nullptr,
                                                               useColors ? colors : nullptr,
                                                               indexCount, indices),
-                                         blendMode, paint, flags);
+                                         blendMode, paint);
                 }
                 break;
             }
index 0d79827..4bf9f87 100644 (file)
@@ -89,7 +89,6 @@ class VerticesGM : public skiagm::GM {
     sk_sp<SkShader>         fShader1;
     sk_sp<SkShader>         fShader2;
     sk_sp<SkColorFilter>    fColorFilter;
-    sk_sp<SkVertices>       fVertices;
     bool                    fUseObject;
     SkScalar                fShaderScale;
 
@@ -104,10 +103,6 @@ protected:
         fShader1 = make_shader1(fShaderScale);
         fShader2 = make_shader2();
         fColorFilter = make_color_filter();
-        if (fUseObject) {
-            fVertices = SkVertices::MakeCopy(SkCanvas::kTriangleFan_VertexMode, kMeshVertexCnt,
-                                             fPts, fTexs, fColors, kMeshIndexCnt, kMeshFan);
-        }
     }
 
     SkString onShortName() override {
@@ -175,16 +170,15 @@ protected:
                             paint.setShader(shader);
                             paint.setColorFilter(cf);
                             paint.setAlpha(alpha);
+
+                            const SkColor* colors = attrs.fHasColors ? fColors : nullptr;
+                            const SkPoint* texs = attrs.fHasTexs ? fTexs : nullptr;
                             if (fUseObject) {
-                                uint32_t flags = 0;
-                                flags |=
-                                        attrs.fHasColors ? 0 : SkCanvas::kIgnoreColors_VerticesFlag;
-                                flags |= attrs.fHasTexs ? 0
-                                                        : SkCanvas::kIgnoreTexCoords_VerticesFlag;
-                                canvas->drawVertices(fVertices, mode, paint, flags);
+                                auto v = SkVertices::MakeCopy(SkCanvas::kTriangleFan_VertexMode,
+                                                              kMeshVertexCnt, fPts, texs, colors,
+                                                              kMeshIndexCnt, kMeshFan);
+                                canvas->drawVertices(v, mode, paint);
                             } else {
-                                const SkColor* colors = attrs.fHasColors ? fColors : nullptr;
-                                const SkPoint* texs = attrs.fHasTexs ? fTexs : nullptr;
                                 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode,
                                                      kMeshVertexCnt, fPts, texs, colors, mode,
                                                      kMeshFan, kMeshIndexCnt, paint);
@@ -240,10 +234,6 @@ static void draw_batching(SkCanvas* canvas, bool useObject) {
 
     }
 
-    sk_sp<SkVertices> vertices;
-    if (useObject) {
-        vertices = builder.detach();
-    }
     canvas->save();
     canvas->translate(10, 10);
     for (bool useShader : {false, true}) {
@@ -253,11 +243,13 @@ static void draw_batching(SkCanvas* canvas, bool useObject) {
                 canvas->concat(m);
                 SkPaint paint;
                 paint.setShader(useShader ? shader : nullptr);
+
+                const SkPoint* t = useTex ? texs : nullptr;
                 if (useObject) {
-                    uint32_t flags = useTex ? 0 : SkCanvas::kIgnoreTexCoords_VerticesFlag;
-                    canvas->drawVertices(vertices, SkBlendMode::kModulate, paint, flags);
+                    auto v = SkVertices::MakeCopy(SkCanvas::kTriangles_VertexMode, kMeshVertexCnt,
+                                                  pts, t, colors, kNumTris * 3, indices);
+                    canvas->drawVertices(v, SkBlendMode::kModulate, paint);
                 } else {
-                    const SkPoint* t = useTex ? texs : nullptr;
                     canvas->drawVertices(SkCanvas::kTriangles_VertexMode, kMeshVertexCnt, pts,
                                          t, colors, indices, kNumTris * 3, paint);
                 }
index 3ce4bae..81841ba 100644 (file)
@@ -1178,12 +1178,7 @@ public:
         this->drawVertices(vmode, vertexCount, vertices, texs, colors, SkBlendMode::kModulate,
                            indices, indexCount, paint);
     }
-    enum VerticesFlags {
-        /** Ignore the vertices' colors and instead use the paint color. */
-        kIgnoreColors_VerticesFlag = 0x1,
-        /** Ignore the vertices' tex coords (and any shader on the paint). */
-        kIgnoreTexCoords_VerticesFlag = 0x2
-    };
+
     /** Draw vertices from an immutable SkVertices object.
 
         @param vertices The mesh to draw.
@@ -1193,8 +1188,7 @@ public:
         @param paint Specifies the shader/texture if present.
         @param flags Allows the caller to ignore colors or texs on vertices.
      */
-    void drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
-                      uint32_t flags = 0);
+    void drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint);
 
     /**
      Draw a cubic coons patch
index 150caa4..23aed12 100644 (file)
@@ -1799,10 +1799,10 @@ void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, const SkPoint ver
                          indexCount, paint);
 }
 
-void SkCanvas::drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
-                            uint32_t flags) {
+void SkCanvas::drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint) {
     RETURN_ON_NULL(vertices);
-    this->onDrawVerticesObject(std::move(vertices), mode, paint, flags);
+    uint32_t deprecatedFlags = 0;
+    this->onDrawVerticesObject(std::move(vertices), mode, paint, deprecatedFlags);
 }
 
 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
@@ -2685,12 +2685,10 @@ void SkCanvas::onDrawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode bmod
 }
 
 void SkCanvas::onDrawVerticesObjectFallback(sk_sp<SkVertices> vertices, SkBlendMode mode,
-                                            const SkPaint& paint, uint32_t flags) {
-    const SkPoint* texs =
-            (flags & SkCanvas::kIgnoreTexCoords_VerticesFlag) ? nullptr : vertices->texCoords();
-    const SkColor* colors = (flags & kIgnoreColors_VerticesFlag) ? nullptr : vertices->colors();
-    this->onDrawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(), texs,
-                         colors, mode, vertices->indices(), vertices->indexCount(), paint);
+                                            const SkPaint& paint, uint32_t deprecatedFlags) {
+    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],
index 7c5c2bf..eb507d4 100644 (file)
@@ -276,14 +276,11 @@ void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
     }
 }
 
-void SkBaseDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
-                                      SkBlendMode mode, const SkPaint& paint, uint32_t flags) {
-    const SkPoint* texs =
-            (flags & SkCanvas::kIgnoreTexCoords_VerticesFlag) ? nullptr : vertices->texCoords();
-    const SkColor* colors =
-            (flags & SkCanvas::kIgnoreColors_VerticesFlag) ? nullptr : vertices->colors();
-    this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(), texs,
-                       colors, mode, vertices->indices(), vertices->indexCount(), paint);
+void SkBaseDevice::drawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode,
+                                      const SkPaint& paint, uint32_t deprecatedFlags) {
+    this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
+                       vertices->texCoords(), vertices->colors(), mode, vertices->indices(),
+                       vertices->indexCount(), paint);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
index 8cc383d..bd73c8b 100644 (file)
@@ -951,8 +951,7 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip,
 void GrRenderTargetContext::drawVertices(const GrClip& clip,
                                          GrPaint&& paint,
                                          const SkMatrix& viewMatrix,
-                                         sk_sp<SkVertices> vertices,
-                                         uint32_t flags) {
+                                         sk_sp<SkVertices> vertices) {
     ASSERT_SINGLE_OWNER
     RETURN_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
@@ -962,7 +961,7 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip,
 
     SkASSERT(vertices);
     std::unique_ptr<GrMeshDrawOp> op =
-            GrDrawVerticesOp::Make(paint.getColor(), std::move(vertices), viewMatrix, flags);
+            GrDrawVerticesOp::Make(paint.getColor(), std::move(vertices), viewMatrix);
     if (!op) {
         return;
     }
index c6793d3..fc2fc0e 100644 (file)
@@ -245,8 +245,7 @@ public:
     void drawVertices(const GrClip&,
                       GrPaint&& paint,
                       const SkMatrix& viewMatrix,
-                      sk_sp<SkVertices> vertices,
-                      uint32_t flags);
+                      sk_sp<SkVertices> vertices);
 
     /**
      * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
index 597d272..6370777 100644 (file)
@@ -1664,16 +1664,16 @@ void SkGpuDevice::drawVertices(SkCanvas::VertexMode vmode,
                                        GrRenderTargetContext::ColorArrayType::kSkColor);
 }
 
-void SkGpuDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
-                                     SkBlendMode mode, const SkPaint& paint, uint32_t flags) {
+void SkGpuDevice::drawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode,
+                                     const SkPaint& paint, uint32_t deprecatedFlags) {
     ASSERT_SINGLE_OWNER
     CHECK_SHOULD_DRAW();
     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVerticesObject", fContext.get());
 
     SkASSERT(vertices);
     GrPaint grPaint;
-    bool hasColors = vertices->hasColors() && !(SkCanvas::kIgnoreColors_VerticesFlag & flags);
-    bool hasTexs = vertices->hasTexCoords() & !(SkCanvas::kIgnoreTexCoords_VerticesFlag & flags);
+    bool hasColors = vertices->hasColors();
+    bool hasTexs = vertices->hasTexCoords();
     if (!hasTexs && !hasColors) {
         // The dreaded wireframe mode. Fallback to drawVertices and go so slooooooow.
         this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
@@ -1685,7 +1685,7 @@ void SkGpuDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
         return;
     }
     fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
-                                       std::move(vertices), flags);
+                                       std::move(vertices));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
index aa13cae..7c59d61 100644 (file)
@@ -32,12 +32,12 @@ std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make(
 }
 
 std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make(GrColor color, sk_sp<SkVertices> vertices,
-                                                     const SkMatrix& viewMatrix, uint32_t flags) {
+                                                     const SkMatrix& viewMatrix) {
     SkASSERT(vertices);
     GrPrimitiveType primType = SkVertexModeToGrPrimitiveType(vertices->mode());
     return std::unique_ptr<GrMeshDrawOp>(new GrDrawVerticesOp(
             std::move(vertices), primType, color, GrRenderTargetContext::ColorArrayType::kSkColor,
-            viewMatrix, flags));
+            viewMatrix));
 }
 
 GrDrawVerticesOp::GrDrawVerticesOp(sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType,
@@ -89,14 +89,14 @@ void GrDrawVerticesOp::applyPipelineOptimizations(const GrPipelineOptimizations&
     GrColor overrideColor;
     if (optimizations.getOverrideColorIfSet(&overrideColor)) {
         fMeshes[0].fColor = overrideColor;
-        fMeshes[0].fFlags |= SkCanvas::kIgnoreColors_VerticesFlag;
+        fMeshes[0].fFlags |= kIgnoreColors_VerticesFlag;
         fFlags &= ~kRequiresPerVertexColors_Flag;
         fColorArrayType = GrRenderTargetContext::ColorArrayType::kPremulGrColor;
     }
     if (optimizations.readsLocalCoords()) {
         fFlags |= kPipelineRequiresLocalCoords_Flag;
     } else {
-        fFlags |= SkCanvas::kIgnoreTexCoords_VerticesFlag;
+        fFlags |= kIgnoreTexCoords_VerticesFlag;
         fFlags &= ~kAnyMeshHasExplicitLocalCoords;
     }
 }
index eddf201..f881d61 100644 (file)
@@ -25,6 +25,11 @@ class GrDrawVerticesOp final : public GrMeshDrawOp {
 public:
     DEFINE_OP_CLASS_ID
 
+    enum {
+        kIgnoreTexCoords_VerticesFlag   = 1 << 0,
+        kIgnoreColors_VerticesFlag      = 1 << 1,
+    };
+
     /**
      * The 'color' param is used if the 'colors' array is null. 'bounds' is the bounds of the
      * 'positions' array (in local space prior to application of 'viewMatrix'). If 'indices' is null
@@ -47,7 +52,7 @@ public:
      * that they should be ignored then the vertex positions are used as local coords.
      */
     static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, sk_sp<SkVertices>,
-                                              const SkMatrix& viewMatrix, uint32_t flags);
+                                              const SkMatrix& viewMatrix);
 
     const char* name() const override { return "DrawVerticesOp"; }
 
@@ -87,11 +92,11 @@ private:
         uint32_t fFlags;
 
         bool hasExplicitLocalCoords() const {
-            return fVertices->hasTexCoords() && !(SkCanvas::kIgnoreTexCoords_VerticesFlag & fFlags);
+            return fVertices->hasTexCoords() && !(kIgnoreTexCoords_VerticesFlag & fFlags);
         }
 
         bool hasPerVertexColors() const {
-            return fVertices->hasColors() && !(SkCanvas::kIgnoreColors_VerticesFlag & fFlags);
+            return fVertices->hasColors() && !(kIgnoreColors_VerticesFlag & fFlags);
         }
     };