Index: src/gpu/GrDrawState.h |
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h |
index 249eeebe25aa6229fc9a271896e5dfe26e4f45fb..ce0a583084dffc2f19f21cc03b5257c692a7c466 100644 |
--- a/src/gpu/GrDrawState.h |
+++ b/src/gpu/GrDrawState.h |
@@ -209,50 +209,18 @@ public: |
* coverage is ignored when per-vertex coverage is provided. |
*/ |
void setCoverage(uint8_t coverage) { |
- fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage); |
+ fCoverage = coverage; |
this->invalidateBlendOptFlags(); |
} |
- uint8_t getCoverage() const { return GrColorUnpackR(fCoverage); } |
+ uint8_t getCoverage() const { return fCoverage; } |
- GrColor getCoverageColor() const { return fCoverage; } |
+ GrColor getCoverageColor() const { |
+ return GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage); |
+ } |
/// @} |
- /** |
- * This struct is here so that the GrDrawState can have multiple instances of state information. |
- * The use of this will come in a future revision when we want to keep track of the original |
- * draw state as well as an optimized version of it. |
- */ |
- struct State { |
- State() { |
- this->reset(); |
- } |
- |
- State(const GrEffectStage* colorArray, int colorCount, |
- const GrEffectStage* coverageArray, int coverageCount) |
- : fColorStages(colorArray, colorCount), fCoverageStages(coverageArray, coverageCount) { |
- fSrcBlend = kOne_GrBlendCoeff; |
- fDstBlend = kZero_GrBlendCoeff; |
- } |
- |
- static bool HaveCompatibleState(const State& a, const State& b, bool explicitLocalCoords); |
- |
- void reset() { |
- fSrcBlend = kOne_GrBlendCoeff; |
- fDstBlend = kZero_GrBlendCoeff; |
- fColorStages.reset(); |
- fCoverageStages.reset(); |
- } |
- |
- GrBlendCoeff fSrcBlend; |
- GrBlendCoeff fDstBlend; |
- |
- typedef SkSTArray<4, GrEffectStage> EffectStageArray; |
- EffectStageArray fColorStages; |
- EffectStageArray fCoverageStages; |
- }; |
- |
/////////////////////////////////////////////////////////////////////////// |
/// @name Effect Stages |
/// Each stage hosts a GrEffect. The effect produces an output color or coverage in the fragment |
@@ -275,14 +243,14 @@ public: |
const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int attr1 = -1) { |
SkASSERT(NULL != effect); |
- SkNEW_APPEND_TO_TARRAY(&fState.fColorStages, GrEffectStage, (effect, attr0, attr1)); |
+ SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, attr1)); |
this->invalidateBlendOptFlags(); |
return effect; |
} |
const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, int attr1 = -1) { |
SkASSERT(NULL != effect); |
- SkNEW_APPEND_TO_TARRAY(&fState.fCoverageStages, GrEffectStage, (effect, attr0, attr1)); |
+ SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0, attr1)); |
this->invalidateBlendOptFlags(); |
return effect; |
} |
@@ -334,12 +302,12 @@ public: |
int fCoverageEffectCnt; |
}; |
- int numColorStages() const { return fState.fColorStages.count(); } |
- int numCoverageStages() const { return fState.fCoverageStages.count(); } |
+ int numColorStages() const { return fColorStages.count(); } |
+ int numCoverageStages() const { return fCoverageStages.count(); } |
int numTotalStages() const { return this->numColorStages() + this->numCoverageStages(); } |
- const GrEffectStage& getColorStage(int stageIdx) const { return fState.fColorStages[stageIdx]; } |
- const GrEffectStage& getCoverageStage(int stageIdx) const { return fState.fCoverageStages[stageIdx]; } |
+ const GrEffectStage& getColorStage(int stageIdx) const { return fColorStages[stageIdx]; } |
+ const GrEffectStage& getCoverageStage(int stageIdx) const { return fCoverageStages[stageIdx]; } |
/** |
* Checks whether any of the effects will read the dst pixel color. |
@@ -366,8 +334,8 @@ public: |
* @param dstCoef coefficient applied to the dst color. |
*/ |
void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { |
- fState.fSrcBlend = srcCoeff; |
- fState.fDstBlend = dstCoeff; |
+ fSrcBlend = srcCoeff; |
+ fDstBlend = dstCoeff; |
this->invalidateBlendOptFlags(); |
#ifdef SK_DEBUG |
if (GrBlendCoeffRefsDst(dstCoeff)) { |
@@ -379,13 +347,13 @@ public: |
#endif |
} |
- GrBlendCoeff getSrcBlendCoeff() const { return fState.fSrcBlend; } |
- GrBlendCoeff getDstBlendCoeff() const { return fState.fDstBlend; } |
+ GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } |
+ GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } |
void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff, |
GrBlendCoeff* dstBlendCoeff) const { |
- *srcBlendCoeff = fState.fSrcBlend; |
- *dstBlendCoeff = fState.fDstBlend; |
+ *srcBlendCoeff = fSrcBlend; |
+ *dstBlendCoeff = fDstBlend; |
} |
/** |
@@ -809,15 +777,19 @@ private: |
SkAutoTUnref<GrRenderTarget> fRenderTarget; |
GrColor fColor; |
SkMatrix fViewMatrix; |
+ GrBlendCoeff fSrcBlend; |
+ GrBlendCoeff fDstBlend; |
GrColor fBlendConstant; |
uint32_t fFlagBits; |
const GrVertexAttrib* fVAPtr; |
int fVACount; |
GrStencilSettings fStencilSettings; |
- GrColor fCoverage; |
+ uint8_t fCoverage; |
DrawFace fDrawFace; |
- State fState; |
+ typedef SkSTArray<4, GrEffectStage> EffectStageArray; |
+ EffectStageArray fColorStages; |
+ EffectStageArray fCoverageStages; |
uint32_t fHints; |