All batches do their own pipeline compare
BUG=skia:
Review URL: https://codereview.chromium.org/1242033002
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index fed6a7a..7e65fcc 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -938,6 +938,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
AAConvexPathBatch* that = t->cast<AAConvexPathBatch>();
if (this->color() != that->color()) {
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index ca0f4e3..830232b 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -501,6 +501,10 @@
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
AADistanceFieldPathBatch* that = t->cast<AADistanceFieldPathBatch>();
// TODO we could actually probably do a bunch of this work on the CPU, ie map viewMatrix,
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 8a0c9a4..6b1f8a4 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -736,6 +736,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
AAHairlineBatch* that = t->cast<AAHairlineBatch>();
if (this->viewMatrix().hasPerspective() != that->viewMatrix().hasPerspective()) {
diff --git a/src/gpu/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/GrAALinearizingConvexPathRenderer.cpp
index 31d61a4..d899e7d 100644
--- a/src/gpu/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/GrAALinearizingConvexPathRenderer.cpp
@@ -261,6 +261,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch>();
SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index f59b611..93b276a 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -175,6 +175,10 @@
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
AAFillRectBatch* that = t->cast<AAFillRectBatch>();
SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
@@ -617,6 +621,10 @@
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
AAStrokeRectBatch* that = t->cast<AAStrokeRectBatch>();
// TODO batch across miterstroke changes
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 73526ed..868f8bb 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -1873,6 +1873,10 @@
int numGlyphs() const { return fBatch.fNumGlyphs; }
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
BitmapTextBatch* that = t->cast<BitmapTextBatch>();
if (fUseDistanceFields != that->fUseDistanceFields) {
diff --git a/src/gpu/GrBatch.h b/src/gpu/GrBatch.h
index b770112..51c556e 100644
--- a/src/gpu/GrBatch.h
+++ b/src/gpu/GrBatch.h
@@ -57,10 +57,6 @@
return false;
}
- if (!this->pipeline()->isEqual(*that->pipeline())) {
- return false;
- }
-
return this->onCombineIfPossible(that);
}
@@ -97,6 +93,7 @@
SkDEBUGCODE(bool isUsed() const { return fUsed; })
+ const GrPipeline* pipeline() const { return fPipeline; }
void setPipeline(const GrPipeline* pipeline) { fPipeline.reset(SkRef(pipeline)); }
protected:
@@ -113,8 +110,6 @@
return fBounds.joinPossiblyEmptyRect(otherBounds);
}
- const GrPipeline* pipeline() const { return fPipeline; }
-
/** Helper for rendering instances using an instanced index index buffer. This class creates the
space for the vertices and flushes the draws to the batch target.*/
class InstancedHelper {
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index e02e082..77af9e9 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -384,6 +384,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
DefaultPathBatch* that = t->cast<DefaultPathBatch>();
if (this->color() != that->color()) {
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 77a1867..eabdfd2 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -397,6 +397,9 @@
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t) override {
+ //if (!this->pipeline()->isEqual(*t->pipeline())) {
+ // return false;
+ //}
// StrokeRectBatch* that = t->cast<StrokeRectBatch>();
// NonAA stroke rects cannot batch right now
@@ -762,6 +765,10 @@
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
DrawVerticesBatch* that = t->cast<DrawVerticesBatch>();
if (!this->batchablePrimitiveType() || this->primitiveType() != that->primitiveType()) {
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 88b2f3e..d337bbb 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -734,6 +734,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
CircleBatch* that = t->cast<CircleBatch>();
// TODO use vertex color to avoid breaking batches
@@ -953,6 +957,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
EllipseBatch* that = t->cast<EllipseBatch>();
// TODO use vertex color to avoid breaking batches
@@ -1207,6 +1215,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
DIEllipseBatch* that = t->cast<DIEllipseBatch>();
// TODO use vertex color to avoid breaking batches
@@ -1580,6 +1592,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>();
// TODO use vertex color to avoid breaking batches
@@ -1762,6 +1778,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>();
// TODO use vertex color to avoid breaking batches
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 8c40438..c3b8e77 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -153,6 +153,11 @@
////////////////////////////////////////////////////////////////////////////////
bool GrPipeline::isEqual(const GrPipeline& that) const {
+ // If we point to the same pipeline, then we are necessarily equal
+ if (this == &that) {
+ return true;
+ }
+
if (this->getRenderTarget() != that.getRenderTarget() ||
this->fFragmentStages.count() != that.fFragmentStages.count() ||
this->fNumColorStages != that.fNumColorStages ||
diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp
index 222aaef..6933dc1 100644
--- a/src/gpu/GrRectBatch.cpp
+++ b/src/gpu/GrRectBatch.cpp
@@ -173,6 +173,10 @@
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
RectBatch* that = t->cast<RectBatch>();
if (this->hasLocalRect() != that->hasLocalRect()) {
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 18cd3d1..f6fe81b 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -620,6 +620,10 @@
}
bool onCombineIfPossible(GrBatch* t) override {
+ if (!this->pipeline()->isEqual(*t->pipeline())) {
+ return false;
+ }
+
DashBatch* that = t->cast<DashBatch>();
if (this->aaMode() != that->aaMode()) {