diff options
author | 2014-08-05 07:35:56 -0700 | |
---|---|---|
committer | 2014-08-05 07:35:56 -0700 | |
commit | 72336ed7e16d2672543e0ceca9ddb843c63c8df6 (patch) | |
tree | 21e5aa3197ad502577f5a5e90d72b8166a4312aa /src/gpu/GrDrawState.h | |
parent | 36ea6c81c2a249ef344d438943050ec960631f0d (diff) |
Don't compare constant color and coverage between GrDrawStates when they are provided by vertex attributes.
R=egdaniel@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/439273007
Diffstat (limited to 'src/gpu/GrDrawState.h')
-rw-r--r-- | src/gpu/GrDrawState.h | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index a4db89d643..90bdc64507 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -267,38 +267,6 @@ public: this->setColor((a << 24) | (a << 16) | (a << 8) | a); } - /** - * Constructor sets the color to be 'color' which is undone by the destructor. - */ - class AutoColorRestore : public ::SkNoncopyable { - public: - AutoColorRestore() : fDrawState(NULL), fOldColor(0) {} - - AutoColorRestore(GrDrawState* drawState, GrColor color) { - fDrawState = NULL; - this->set(drawState, color); - } - - void reset() { - if (NULL != fDrawState) { - fDrawState->setColor(fOldColor); - fDrawState = NULL; - } - } - - void set(GrDrawState* drawState, GrColor color) { - this->reset(); - fDrawState = drawState; - fOldColor = fDrawState->getColor(); - fDrawState->setColor(color); - } - - ~AutoColorRestore() { this->reset(); } - private: - GrDrawState* fDrawState; - GrColor fOldColor; - }; - /// @} /////////////////////////////////////////////////////////////////////////// @@ -893,10 +861,14 @@ public: if draws can be batched. The return value indicates whether combining is possible and, if so, which of the two inputs should be used. */ static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawState& b) { + bool usingVertexColors = a.hasColorVertexAttribute(); + if (!usingVertexColors && a.fColor != b.fColor) { + return kIncompatible_CombinedState; + } + if (a.fRenderTarget.get() != b.fRenderTarget.get() || a.fColorStages.count() != b.fColorStages.count() || a.fCoverageStages.count() != b.fCoverageStages.count() || - a.fColor != b.fColor || !a.fViewMatrix.cheapEqualTo(b.fViewMatrix) || a.fSrcBlend != b.fSrcBlend || a.fDstBlend != b.fDstBlend || @@ -905,11 +877,15 @@ public: a.fVACount != b.fVACount || memcmp(a.fVAPtr, b.fVAPtr, a.fVACount * sizeof(GrVertexAttrib)) || a.fStencilSettings != b.fStencilSettings || - a.fCoverage != b.fCoverage || a.fDrawFace != b.fDrawFace) { return kIncompatible_CombinedState; } + bool usingVertexCoverage = a.hasCoverageVertexAttribute(); + if (!usingVertexCoverage && a.fCoverage != b.fCoverage) { + return kIncompatible_CombinedState; + } + bool explicitLocalCoords = a.hasLocalCoordAttribute(); for (int i = 0; i < a.fColorStages.count(); i++) { if (!GrEffectStage::AreCompatible(a.fColorStages[i], b.fColorStages[i], |