aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-10-09 13:47:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-09 13:47:05 -0700
commitd9aa218e8152bb77dfa2efeb8843b61993e0dc56 (patch)
treeca61da5d5fff27e0dfdc6aa530a678f058e1a423 /src
parent9e87fa7c0e52a79ad85bf32eeb71570938e357bd (diff)
Store color and coverage stages in a single array in GrOptDrawState.
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrOptDrawState.cpp37
-rw-r--r--src/gpu/GrOptDrawState.h25
2 files changed, 31 insertions, 31 deletions
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index c8218d7a90..b3d90f7310 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -61,23 +61,20 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
// Copy Color Stages from DS to ODS
if (firstColorStageIdx < drawState.numColorStages()) {
- fColorStages.reset(&drawState.getColorStage(firstColorStageIdx),
- drawState.numColorStages() - firstColorStageIdx);
+ fFragmentStages.reset(&drawState.getColorStage(firstColorStageIdx),
+ drawState.numColorStages() - firstColorStageIdx);
} else {
- fColorStages.reset();
+ fFragmentStages.reset();
}
+ fNumColorStages = fFragmentStages.count();
+
// Copy Coverage Stages from DS to ODS
- if (firstCoverageStageIdx < drawState.numCoverageStages() && separateCoverageFromColor) {
- fCoverageStages.reset(&drawState.getCoverageStage(firstCoverageStageIdx),
- drawState.numCoverageStages() - firstCoverageStageIdx);
- } else {
- fCoverageStages.reset();
- if (firstCoverageStageIdx < drawState.numCoverageStages()) {
- // TODO: Once we have flag to know if we only multiply on stages, only push coverage
- // into color stages if everything is multiply
- fColorStages.push_back_n(drawState.numCoverageStages() - firstCoverageStageIdx,
- &drawState.getCoverageStage(firstCoverageStageIdx));
+ if (firstCoverageStageIdx < drawState.numCoverageStages()) {
+ fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverageStageIdx,
+ &drawState.getCoverageStage(firstCoverageStageIdx));
+ if (!separateCoverageFromColor) {
+ fNumColorStages = fFragmentStages.count();
}
}
};
@@ -326,8 +323,8 @@ bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
}
if (this->getRenderTarget() != that.getRenderTarget() ||
- this->fColorStages.count() != that.fColorStages.count() ||
- this->fCoverageStages.count() != that.fCoverageStages.count() ||
+ this->fFragmentStages.count() != that.fFragmentStages.count() ||
+ this->fNumColorStages != that.fNumColorStages ||
!this->fViewMatrix.cheapEqualTo(that.fViewMatrix) ||
this->fSrcBlend != that.fSrcBlend ||
this->fDstBlend != that.fDstBlend ||
@@ -366,14 +363,8 @@ bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
return false;
}
- for (int i = 0; i < this->numColorStages(); i++) {
- if (!GrProcessorStage::AreCompatible(this->getColorStage(i), that.getColorStage(i),
- explicitLocalCoords)) {
- return false;
- }
- }
- for (int i = 0; i < this->numCoverageStages(); i++) {
- if (!GrProcessorStage::AreCompatible(this->getCoverageStage(i), that.getCoverageStage(i),
+ for (int i = 0; i < this->numFragmentStages(); i++) {
+ if (!GrProcessorStage::AreCompatible(this->getFragmentStage(i), that.getFragmentStage(i),
explicitLocalCoords)) {
return false;
}
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 2721e9dca4..1c439bbff1 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -119,17 +119,24 @@ public:
/// the color / coverage distinction.
////
- int numColorStages() const { return fColorStages.count(); }
- int numCoverageStages() const { return fCoverageStages.count(); }
+ int numColorStages() const { return fNumColorStages; }
+ int numCoverageStages() const { return fFragmentStages.count() - fNumColorStages; }
+ int numFragmentStages() const { return fFragmentStages.count(); }
int numTotalStages() const {
- return this->numColorStages() + this->numCoverageStages() +
- (this->hasGeometryProcessor() ? 1 : 0);
+ return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0);
}
bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
const GrGeometryStage* getGeometryProcessor() const { return fGeometryProcessor.get(); }
- const GrFragmentStage& getColorStage(int idx) const { return fColorStages[idx]; }
- const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageStages[idx]; }
+ const GrFragmentStage& getColorStage(int idx) const {
+ SkASSERT(idx < this->numColorStages());
+ return fFragmentStages[idx];
+ }
+ const GrFragmentStage& getCoverageStage(int idx) const {
+ SkASSERT(idx < this->numCoverageStages());
+ return fFragmentStages[fNumColorStages + idx];
+ }
+ const GrFragmentStage& getFragmentStage(int idx) const { return fFragmentStages[idx]; }
/// @}
@@ -435,8 +442,10 @@ private:
typedef SkSTArray<8, GrFragmentStage> FragmentStageArray;
SkAutoTDelete<GrGeometryStage> fGeometryProcessor;
- FragmentStageArray fColorStages;
- FragmentStageArray fCoverageStages;
+ FragmentStageArray fFragmentStages;
+
+ // This function is equivalent to the offset into fFragmentStages where coverage stages begin.
+ int fNumColorStages;
// This is simply a different representation of info in fVertexAttribs and thus does
// not need to be compared in op==.