Stop lieing about GrBatch color for Rects

BUG=skia:

Review URL: https://codereview.chromium.org/920423003
This commit is contained in:
joshualitt 2015-02-13 12:50:09 -08:00 committed by Commit bot
parent efe513b6fe
commit db0f9516ae
7 changed files with 14 additions and 76 deletions

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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) {