From e79c815bca39fa552983b7a8107219aa5084acdb Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Thu, 29 Mar 2012 19:07:12 +0000 Subject: Don't look at current vertex layout when vertex source hasn't been set Review URL: http://codereview.appspot.com/5959047 git-svn-id: http://skia.googlecode.com/svn/trunk@3545 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrDrawTarget.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/gpu/GrDrawTarget.cpp') diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 5cce435916..ef03a61417 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -853,9 +853,7 @@ bool GrDrawTarget::canTweakAlphaForCoverage() const { kISC_BlendCoeff == dstCoeff; } - -bool GrDrawTarget::srcAlphaWillBeOne() const { - const GrVertexLayout& layout = this->getGeomSrc().fVertexLayout; +bool GrDrawTarget::srcAlphaWillBeOne(GrVertexLayout layout) const { const GrDrawState& drawState = this->getDrawState(); // Check if per-vertex or constant color may have partial alpha @@ -882,12 +880,28 @@ bool GrDrawTarget::srcAlphaWillBeOne() const { return true; } +namespace { +GrVertexLayout default_blend_opts_vertex_layout() { + GrVertexLayout layout = 0; + for (int s = 0; s < GrDrawState::kNumStages; ++s) { + layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s); + } + return layout; +} +} + GrDrawTarget::BlendOptFlags GrDrawTarget::getBlendOpts(bool forceCoverage, GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const { - const GrVertexLayout& layout = this->getGeomSrc().fVertexLayout; + GrVertexLayout layout; + if (kNone_GeometrySrcType == this->getGeomSrc().fVertexSrc) { + layout = default_blend_opts_vertex_layout(); + } else { + layout = this->getVertexLayout(); + } + const GrDrawState& drawState = this->getDrawState(); GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; @@ -917,7 +931,7 @@ GrDrawTarget::getBlendOpts(bool forceCoverage, *dstCoeff = kOne_BlendCoeff; } - bool srcAIsOne = this->srcAlphaWillBeOne(); + bool srcAIsOne = this->srcAlphaWillBeOne(layout); bool dstCoeffIsOne = kOne_BlendCoeff == *dstCoeff || (kSA_BlendCoeff == *dstCoeff && srcAIsOne); bool dstCoeffIsZero = kZero_BlendCoeff == *dstCoeff || @@ -1022,11 +1036,6 @@ bool GrDrawTarget::canApplyCoverage() const { kNone_BlendOpt != this->getBlendOpts(true); } -bool GrDrawTarget::drawWillReadDst() const { - return SkToBool((kDisableBlend_BlendOptFlag | kSkipDraw_BlendOptFlag) & - this->getBlendOpts()); -} - //////////////////////////////////////////////////////////////////////////////// void GrDrawTarget::drawIndexedInstances(GrPrimitiveType type, -- cgit v1.2.3