aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGeometryProcessor.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@google.com>2015-04-28 09:17:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-28 09:17:05 -0700
commit50cb76b2bb0ffa607a1409f77be0ae7d64e31436 (patch)
treeaf55e571828da1a7353457451bafab547079fa1f /src/gpu/GrGeometryProcessor.h
parentef292a0901205b9785a30daae2c036aa34a970ca (diff)
Revert of removing equality / compute invariant loops from GrGeometryProcessors (patchset #2 id:20001 of https://codereview.chromium.org/1111603004/)
Reason for revert: breaks gl programs Original issue's description: > removing equality / compute invariant loops from GrGeometryProcessors > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/ef292a0901205b9785a30daae2c036aa34a970ca TBR=bsalomon@google.com,joshualitt@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1110993002
Diffstat (limited to 'src/gpu/GrGeometryProcessor.h')
-rw-r--r--src/gpu/GrGeometryProcessor.h63
1 files changed, 52 insertions, 11 deletions
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index c380f20b0e..f0e0b0c008 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -23,33 +23,61 @@ public:
// 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 @@ protected:
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;