Index: src/gpu/GrGeometryProcessor.h |
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h |
index 4801069005fdd21ccc4a9103e1f8b9fac4905059..6e2d9457d1e1eea360fd7c1ff3f8a5c08b4d1249 100644 |
--- a/src/gpu/GrGeometryProcessor.h |
+++ b/src/gpu/GrGeometryProcessor.h |
@@ -39,6 +39,23 @@ class GrGLCaps; |
class GrGLGeometryProcessor; |
class GrOptDrawState; |
+struct GrInitInvariantOutput; |
+ |
+/* |
+ * GrGeometryProcessors and GrPathProcessors may effect invariantColor |
+ */ |
+class GrPrimitiveProcessor : public GrProcessor { |
+public: |
+ // TODO GPs and PPs have to provide an initial coverage because the coverage invariant code is |
+ // broken right now |
+ virtual uint8_t coverage() const = 0; |
+ virtual void computeOutputColor(GrInitInvariantOutput* out) const = 0; |
bsalomon
2014/12/10 15:27:00
I'm wondering if this should be "getInvariantColor
|
+ virtual void computeOutputCoverage(GrInitInvariantOutput* out) const = 0; |
+ |
+private: |
+ typedef GrProcessor INHERITED; |
+}; |
+ |
/** |
* A GrGeometryProcessor is used to perform computation in the vertex shader and |
* add support for custom vertex attributes. A GrGemeotryProcessor is typically |
@@ -49,7 +66,7 @@ class GrOptDrawState; |
* added to the vertex attribute array specified on the GrDrawState. |
* GrGeometryProcessor subclasses should be immutable after construction. |
*/ |
-class GrGeometryProcessor : public GrProcessor { |
+class GrGeometryProcessor : public GrPrimitiveProcessor { |
public: |
GrGeometryProcessor(GrColor color, uint8_t coverage = 0xff) |
: fVertexStride(0) |
@@ -111,11 +128,12 @@ public: |
return false; |
} |
- if (!fHasVertexColor && this->getColor() != that.getColor()) { |
+ if (!fHasVertexColor && this->color() != that.color()) { |
return false; |
} |
- if (!fHasVertexCoverage && this->getCoverage() != that.getCoverage()) { |
+ // TODO this is fragile, most gps set their coverage to 0xff so this is okay |
bsalomon
2014/12/10 15:27:00
what's the plan here?
|
+ if (!fHasVertexCoverage && this->coverage() != that.coverage()) { |
return false; |
} |
return this->onIsEqual(that); |
@@ -130,8 +148,8 @@ public: |
virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {} |
- GrColor getColor() const { return fColor; } |
- uint8_t getCoverage() const { return fCoverage; } |
+ GrColor color() const { return fColor; } |
+ uint8_t coverage() const { return fCoverage; } |
// TODO this is a total hack until the gp can own whether or not it uses uniform |
// color / coverage |
@@ -139,7 +157,8 @@ public: |
bool hasVertexCoverage() const { return fHasVertexCoverage; } |
bool hasLocalCoords() const { return fHasLocalCoords; } |
- void computeInvariantColor(GrInvariantOutput* inout) const; |
+ virtual void computeOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE; |
+ virtual void computeOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE; |
protected: |
/** |
@@ -160,12 +179,17 @@ protected: |
void setHasVertexCoverage() { fHasVertexCoverage = true; } |
void setHasLocalCoords() { fHasLocalCoords = true; } |
+ virtual void onComputeOutputColor(GrInitInvariantOutput*) const {} |
+ virtual void onComputeOutputCoverage(GrInitInvariantOutput*) const = 0; |
+ |
private: |
virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; |
SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; |
size_t fVertexStride; |
GrColor fColor; |
+ // TODO HACK |
+public: |
uint8_t fCoverage; |
bool fWillUseGeoShader; |
bool fHasVertexColor; |
@@ -174,4 +198,25 @@ private: |
typedef GrProcessor INHERITED; |
}; |
+ |
+/* |
+ * The path equivalent of the GP. Can only upload uniform color. |
bsalomon
2014/12/10 15:27:00
Maybe a comment that we plan to extend responsibil
|
+ */ |
+class GrPathProcessor : public GrPrimitiveProcessor { |
+public: |
+ static GrPathProcessor* Create(GrColor color) { |
+ return SkNEW_ARGS(GrPathProcessor, (color)); |
+ } |
+ |
+ virtual const char* name() SK_OVERRIDE const { return "PathProcessor"; } |
+ virtual uint8_t coverage() SK_OVERRIDE const { return 0xff; } |
bsalomon
2014/12/10 15:27:00
no need for virtual keyword on overrides.
|
+ virtual void computeOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE; |
+ virtual void computeOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE; |
+ |
+private: |
+ GrPathProcessor(GrColor color) : fColor(color) {} |
+ GrColor fColor; |
+ |
+ typedef GrProcessor INHERITED; |
+}; |
#endif |