aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-02-13 12:50:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-13 12:50:09 -0800
commitdb0f9516ae22a28e16e18bfaa375eca01d29e346 (patch)
tree5ad94618299407b995830499da30229713941cf9 /src
parentefe513b6fea7196dc72c1d49b365c5c28e939012 (diff)
Stop lieing about GrBatch color for Rects
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp5
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.cpp5
-rw-r--r--src/gpu/GrAARectRenderer.cpp36
-rw-r--r--src/gpu/GrBatch.h12
-rw-r--r--src/gpu/GrDrawTarget.cpp5
-rw-r--r--src/gpu/GrOvalRenderer.cpp25
-rw-r--r--src/gpu/GrTestBatch.h2
7 files changed, 14 insertions, 76 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 6b825e7df2..e3e0d5d552 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -711,10 +711,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -865,7 +861,6 @@ private:
bool fCoverageIgnored;
};
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
};
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index cbce6aa4c3..9a374279c7 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -727,10 +727,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -813,7 +809,6 @@ private:
bool fCoverageIgnored;
};
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
const GrIndexBuffer* fLinesIndexBuffer;
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 420c9e7c5a..7e86c0b49d 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -70,24 +70,11 @@ public:
void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
// When this is called on a batch, there is only one geometry bundle
- if (!this->canTweakAlphaForCoverage() && GrColorIsOpaque(fGeoData[0].fColor)) {
- out->setUnknownOpaqueFourComponents();
- } else {
- out->setUnknownFourComponents();
- }
+ out->setKnownFourComponents(fGeoData[0].fColor);
}
void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- if (this->canTweakAlphaForCoverage()) {
- // uniform coverage
- out->setKnownSingleComponent(0xff);
- } else {
- out->setUnknownSingleComponent();
- }
- }
-
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
+ out->setUnknownSingleComponent();
}
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
@@ -103,6 +90,7 @@ public:
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
+ fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) SK_OVERRIDE {
@@ -194,19 +182,12 @@ private:
GrColor color() const { return fBatch.fColor; }
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
- bool canTweakAlphaForCoverage() const { return fBatchOpt.fCanTweakAlphaForCoverage; }
+ bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; }
bool colorIgnored() const { return fBatch.fColorIgnored; }
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE {
AAFillRectBatch* that = t->cast<AAFillRectBatch>();
- if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) {
- return false;
- }
-
- if (this->colorIgnored() != that->colorIgnored()) {
- return false;
- }
SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
// We apply the viewmatrix to the rect points on the cpu. However, if the pipeline uses
@@ -219,6 +200,13 @@ private:
if (this->color() != that->color()) {
fBatch.fColor = GrColor_ILLEGAL;
}
+
+ // In the event of two batches, one who can tweak, one who cannot, we just fall back to
+ // not tweaking
+ if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) {
+ fBatch.fCanTweakAlphaForCoverage = false;
+ }
+
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
return true;
}
@@ -321,9 +309,9 @@ private:
bool fUsesLocalCoords;
bool fColorIgnored;
bool fCoverageIgnored;
+ bool fCanTweakAlphaForCoverage;
};
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
const GrIndexBuffer* fIndexBuffer;
SkSTArray<1, Geometry, true> fGeoData;
diff --git a/src/gpu/GrBatch.h b/src/gpu/GrBatch.h
index 2f1afee1e4..48327c61c2 100644
--- a/src/gpu/GrBatch.h
+++ b/src/gpu/GrBatch.h
@@ -39,10 +39,6 @@ struct GrInitInvariantOutput;
* information will be communicated to the GrBatch prior to geometry generation.
*/
-struct GrBatchOpt {
- bool fCanTweakAlphaForCoverage;
-};
-
class GrBatch : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrBatch)
@@ -54,13 +50,9 @@ public:
virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
/*
- * initBatchOpt is used to communicate possible optimizations to the GrBatch. initBatchTracker
- * is a hook for the some additional overrides from the GrXferProcessor. This is a bit
- * confusing but has to be like this until GrBatch is everywhere.
- *
- * TODO combine to a single init call when GrBatch is everywhere.
+ * initBatchTracker is a hook for the some additional overrides / optimization possibilities
+ * from the GrXferProcessor.
*/
- virtual void initBatchOpt(const GrBatchOpt&) = 0;
virtual void initBatchTracker(const GrPipelineInfo& init) = 0;
bool combineIfPossible(GrBatch* that) {
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e22c45bafc..7ccdce5309 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -545,11 +545,6 @@ void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
return;
}
- // init batch and my other crap
- GrBatchOpt batchOpt;
- batchOpt.fCanTweakAlphaForCoverage = pipelineBuilder->canTweakAlphaForCoverage();
- batch->initBatchOpt(batchOpt);
-
GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batch, devBounds, this);
if (pipelineInfo.mustSkipDraw()) {
return;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 481501f129..d7f88fe137 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -711,10 +711,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -873,7 +869,6 @@ private:
static const int kVertsPerCircle = 4;
static const int kIndicesPerCircle = 6;
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
};
@@ -966,10 +961,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -1133,7 +1124,6 @@ private:
static const int kVertsPerEllipse = 4;
static const int kIndicesPerEllipse = 6;
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
};
@@ -1267,10 +1257,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -1425,7 +1411,6 @@ private:
static const int kVertsPerEllipse = 4;
static const int kIndicesPerEllipse = 6;
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
};
@@ -1655,10 +1640,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -1831,7 +1812,6 @@ private:
bool fCoverageIgnored;
};
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
const GrIndexBuffer* fIndexBuffer;
@@ -1864,10 +1844,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {
- fBatchOpt = batchOpt;
- }
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {
@@ -2050,7 +2026,6 @@ private:
bool fCoverageIgnored;
};
- GrBatchOpt fBatchOpt;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
const GrIndexBuffer* fIndexBuffer;
diff --git a/src/gpu/GrTestBatch.h b/src/gpu/GrTestBatch.h
index ebff721764..677abafaca 100644
--- a/src/gpu/GrTestBatch.h
+++ b/src/gpu/GrTestBatch.h
@@ -35,8 +35,6 @@ public:
out->setUnknownSingleComponent();
}
- void initBatchOpt(const GrBatchOpt& batchOpt) {}
-
void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
// Handle any color overrides
if (init.fColorIgnored) {