Index: src/gpu/GrGeometryProcessor.h |
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h |
index ea4e890ee1a424a71adf36a6ebf6af133e9cebbd..96c1cb6bf3643ae9a6a539990861a45a2f78fb97 100644 |
--- a/src/gpu/GrGeometryProcessor.h |
+++ b/src/gpu/GrGeometryProcessor.h |
@@ -22,7 +22,7 @@ public: |
GrGeometryProcessor() |
: INHERITED(false) |
, fWillUseGeoShader(false) |
- , fHasLocalCoords(false) {} |
+ , fLocalCoordsType(kUnused_LocalCoordsType) {} |
bool willUseGeoShader() const override { return fWillUseGeoShader; } |
@@ -45,6 +45,14 @@ public: |
SkFAIL("Unsupported\n"); |
} |
+ bool hasTransformedLocalCoords() const override { |
+ return kHasTransformed_LocalCoordsType == fLocalCoordsType; |
+ } |
+ |
+ bool hasExplicitLocalCoords() const override { |
+ return kHasExplicit_LocalCoordsType == fLocalCoordsType; |
+ } |
+ |
protected: |
/** |
* Subclasses call this from their constructor to register vertex attributes. Attributes |
@@ -64,14 +72,32 @@ protected: |
void setWillUseGeoShader() { fWillUseGeoShader = true; } |
- // TODO hack see above |
- void setHasLocalCoords() { fHasLocalCoords = true; } |
+ /** |
+ * If a GrFragmentProcessor in the GrPipeline needs localCoods, we will provide them in one of |
+ * three ways |
+ * 1) LocalCoordTransform * Position - in Shader |
+ * 2) LocalCoordTransform * ExplicitLocalCoords- in Shader |
+ * 3) A transformation on the CPU uploaded via vertex attribute |
+ * TODO make this GrBatches responsibility |
+ */ |
+ enum LocalCoordsType { |
+ kUnused_LocalCoordsType, |
+ kHasExplicit_LocalCoordsType, |
+ kHasTransformed_LocalCoordsType |
+ }; |
+ |
+ void setHasExplicitLocalCoords() { |
+ SkASSERT(kUnused_LocalCoordsType == fLocalCoordsType); |
+ fLocalCoordsType = kHasExplicit_LocalCoordsType; |
+ } |
+ void setHasTransformedLocalCoords() { |
+ SkASSERT(kUnused_LocalCoordsType == fLocalCoordsType); |
+ fLocalCoordsType = kHasTransformed_LocalCoordsType; |
+ } |
private: |
- bool hasExplicitLocalCoords() const override { return fHasLocalCoords; } |
- |
bool fWillUseGeoShader; |
- bool fHasLocalCoords; |
+ LocalCoordsType fLocalCoordsType; |
typedef GrPrimitiveProcessor INHERITED; |
}; |