Fix flag collision in GrDrawVerticesOp
authorBrian Osman <brianosman@google.com>
Tue, 23 May 2017 19:03:18 +0000 (15:03 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 23 May 2017 20:28:14 +0000 (20:28 +0000)
We were setting a flag meant for Mesh.fFlags on the Op's fFlags. Switch
the Mesh's flags to be a pair of bools, to avoid this in the future.

Bug: skia:
Change-Id: Ib660f3bc9c54874d088a85251f629758c365c8c6
Reviewed-on: https://skia-review.googlesource.com/17766
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>

src/gpu/ops/GrDrawVerticesOp.cpp
src/gpu/ops/GrDrawVerticesOp.h

index 557bb320cf13d55292ebc2c5e0f81edce05fa00f..dafd4dc7c7b6b02f1b5204fce90c29a2d5a04ddf 100644 (file)
@@ -44,7 +44,7 @@ std::unique_ptr<GrLegacyMeshDrawOp> GrDrawVerticesOp::Make(GrColor color,
 GrDrawVerticesOp::GrDrawVerticesOp(sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType,
                                    GrColor color,
                                    GrRenderTargetContext::ColorArrayType colorArrayType,
-                                   const SkMatrix& viewMatrix, uint32_t flags)
+                                   const SkMatrix& viewMatrix)
         : INHERITED(ClassID()), fColorArrayType(colorArrayType) {
     SkASSERT(vertices);
 
@@ -56,7 +56,8 @@ GrDrawVerticesOp::GrDrawVerticesOp(sk_sp<SkVertices> vertices, GrPrimitiveType p
     mesh.fColor = color;
     mesh.fViewMatrix = viewMatrix;
     mesh.fVertices = std::move(vertices);
-    mesh.fFlags = flags;
+    mesh.fIgnoreTexCoords = false;
+    mesh.fIgnoreColors = false;
 
     fFlags = 0;
     if (mesh.hasPerVertexColors()) {
@@ -90,14 +91,14 @@ void GrDrawVerticesOp::applyPipelineOptimizations(const PipelineOptimizations& o
     GrColor overrideColor;
     if (optimizations.getOverrideColorIfSet(&overrideColor)) {
         fMeshes[0].fColor = overrideColor;
-        fMeshes[0].fFlags |= kIgnoreColors_VerticesFlag;
+        fMeshes[0].fIgnoreColors = true;
         fFlags &= ~kRequiresPerVertexColors_Flag;
         fColorArrayType = GrRenderTargetContext::ColorArrayType::kPremulGrColor;
     }
     if (optimizations.readsLocalCoords()) {
         fFlags |= kPipelineRequiresLocalCoords_Flag;
     } else {
-        fFlags |= kIgnoreTexCoords_VerticesFlag;
+        fMeshes[0].fIgnoreTexCoords = true;
         fFlags &= ~kAnyMeshHasExplicitLocalCoords;
     }
 }
index 4bd14afad3b512cccb1569524d059d997350c949..009c5e041545cce0ec7e24770ae1026903397c83 100644 (file)
@@ -25,11 +25,6 @@ class GrDrawVerticesOp final : public GrLegacyMeshDrawOp {
 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
@@ -66,8 +61,7 @@ public:
 
 private:
     GrDrawVerticesOp(sk_sp<SkVertices>, GrPrimitiveType, GrColor,
-                     GrRenderTargetContext::ColorArrayType, const SkMatrix& viewMatrix,
-                     uint32_t flags = 0);
+                     GrRenderTargetContext::ColorArrayType, const SkMatrix& viewMatrix);
 
     void getProcessorAnalysisInputs(GrProcessorAnalysisColor* color,
                                     GrProcessorAnalysisCoverage* coverage) const override;
@@ -89,14 +83,15 @@ private:
         GrColor fColor;  // Used if this->hasPerVertexColors() is false.
         sk_sp<SkVertices> fVertices;
         SkMatrix fViewMatrix;
-        uint32_t fFlags;
+        bool fIgnoreTexCoords;
+        bool fIgnoreColors;
 
         bool hasExplicitLocalCoords() const {
-            return fVertices->hasTexCoords() && !(kIgnoreTexCoords_VerticesFlag & fFlags);
+            return fVertices->hasTexCoords() && !fIgnoreTexCoords;
         }
 
         bool hasPerVertexColors() const {
-            return fVertices->hasColors() && !(kIgnoreColors_VerticesFlag & fFlags);
+            return fVertices->hasColors() && !fIgnoreColors;
         }
     };