Index: src/gpu/GrGeometryProcessor.h |
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h |
index c380f20b0ed7ca1ebbbfeea9b69e6941f8b3b4b0..f0e0b0c0085611425a0329c7c0fed550f9860a22 100644 |
--- a/src/gpu/GrGeometryProcessor.h |
+++ b/src/gpu/GrGeometryProcessor.h |
@@ -23,33 +23,61 @@ |
// atleast bundles |
GrGeometryProcessor(GrColor color, |
const SkMatrix& viewMatrix = SkMatrix::I(), |
- const SkMatrix& localMatrix = SkMatrix::I()) |
+ const SkMatrix& localMatrix = SkMatrix::I(), |
+ bool opaqueVertexColors = false) |
: INHERITED(viewMatrix, localMatrix, false) |
, fColor(color) |
+ , fOpaqueVertexColors(opaqueVertexColors) |
, fWillUseGeoShader(false) |
+ , fHasVertexColor(false) |
, fHasLocalCoords(false) {} |
bool willUseGeoShader() const { return fWillUseGeoShader; } |
- // TODO delete this when paths are in batch |
+ /* |
+ * In an ideal world, two GrGeometryProcessors with the same class id and texture accesses |
+ * would ALWAYS be able to batch together. If two GrGeometryProcesosrs are the same then we |
+ * will only keep one of them. The remaining GrGeometryProcessor then updates its |
+ * GrBatchTracker to incorporate the draw information from the GrGeometryProcessor we discard. |
+ * Any bundles associated with the discarded GrGeometryProcessor will be attached to the |
+ * remaining GrGeometryProcessor. |
+ */ |
bool canMakeEqual(const GrBatchTracker& mine, |
const GrPrimitiveProcessor& that, |
const GrBatchTracker& theirs) const override { |
- SkFAIL("Unsupported\n"); |
- return false; |
+ if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)) { |
+ return false; |
+ } |
+ |
+ // TODO let the GPs decide this |
+ if (!this->viewMatrix().cheapEqualTo(that.viewMatrix())) { |
+ return false; |
+ } |
+ |
+ // TODO remove the hint |
+ const GrGeometryProcessor& other = that.cast<GrGeometryProcessor>(); |
+ if (fHasVertexColor && fOpaqueVertexColors != other.fOpaqueVertexColors) { |
+ return false; |
+ } |
+ |
+ // TODO this equality test should really be broken up, some of this can live on the batch |
+ // tracker test and some of this should be in bundles |
+ if (!this->onIsEqual(other)) { |
+ return false; |
+ } |
+ |
+ return this->onCanMakeEqual(mine, other, theirs); |
} |
// TODO we can remove color from the GrGeometryProcessor base class once we have bundles of |
// primitive data |
GrColor color() const { return fColor; } |
- // TODO Delete when paths are in batch |
- void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
- SkFAIL("Unsupported\n"); |
- } |
- void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
- SkFAIL("Unsupported\n"); |
- } |
+ // TODO this is a total hack until the gp can do deferred geometry |
+ bool hasVertexColor() const { return fHasVertexColor; } |
+ |
+ void getInvariantOutputColor(GrInitInvariantOutput* out) const override; |
+ void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override; |
protected: |
/* |
@@ -100,13 +128,26 @@ |
void setWillUseGeoShader() { fWillUseGeoShader = true; } |
// TODO hack see above |
+ void setHasVertexColor() { fHasVertexColor = true; } |
void setHasLocalCoords() { fHasLocalCoords = true; } |
+ virtual void onGetInvariantOutputColor(GrInitInvariantOutput*) const {} |
+ virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0; |
+ |
private: |
+ virtual bool onCanMakeEqual(const GrBatchTracker& mine, |
+ const GrGeometryProcessor& that, |
+ const GrBatchTracker& theirs) const = 0; |
+ |
+ // TODO delete this when we have more advanced equality testing via bundles and the BT |
+ virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; |
+ |
bool hasExplicitLocalCoords() const override { return fHasLocalCoords; } |
GrColor fColor; |
+ bool fOpaqueVertexColors; |
bool fWillUseGeoShader; |
+ bool fHasVertexColor; |
bool fHasLocalCoords; |
typedef GrPrimitiveProcessor INHERITED; |