Chromium Code Reviews| Index: src/gpu/GrOptDrawState.cpp |
| diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp |
| index 6a79203d1a0bcaded4bb6b0fd83387341f391e80..d20fd28bd5e1b6b1703b114161a881bbd180377a 100644 |
| --- a/src/gpu/GrOptDrawState.cpp |
| +++ b/src/gpu/GrOptDrawState.cpp |
| @@ -9,7 +9,6 @@ |
| #include "GrDrawState.h" |
| #include "GrDrawTargetCaps.h" |
| -#include "GrGpu.h" |
| GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
| BlendOptFlags blendOptFlags, |
| @@ -53,6 +52,36 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
| this->setOutputStateInfo(caps); |
| }; |
| +GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDrawTargetCaps& caps, |
| + GrGpu::DrawType drawType) { |
| + if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCachedCapsID) { |
| + GrBlendCoeff srcCoeff; |
| + GrBlendCoeff dstCoeff; |
| + BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
| + &srcCoeff, |
| + &dstCoeff); |
| + if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && |
|
joshua.litt
2014/10/06 20:40:51
This is pretty self explanatory, but a comment wou
|
| + !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != drawType) { |
| + return NULL; |
| + } |
| + drawState.fCachedOptState = SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff, |
| + dstCoeff, caps)); |
| + drawState.fCachedCapsID = caps.getUniqueID(); |
| + } else { |
| +#ifdef SK_DEBUG |
| + GrBlendCoeff srcCoeff; |
| + GrBlendCoeff dstCoeff; |
| + BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
| + &srcCoeff, |
| + &dstCoeff); |
| + SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, caps) == |
| + *drawState.fCachedOptState); |
| +#endif |
| + } |
| + drawState.fCachedOptState->ref(); |
| + return drawState.fCachedOptState; |
| +} |
| + |
| void GrOptDrawState::setOutputStateInfo(const GrDrawTargetCaps& caps) { |
| // Set this default and then possibly change our mind if there is coverage. |
| fPrimaryOutputType = kModulate_PrimaryOutputType; |