Chromium Code Reviews| Index: src/gpu/GrOptDrawState.cpp |
| diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp |
| index 93cc04798bbcada8a20737ea257acfbdd6cb54d5..29f0b6fcf60420a23ffa3f896d55b79898b05ca5 100644 |
| --- a/src/gpu/GrOptDrawState.cpp |
| +++ b/src/gpu/GrOptDrawState.cpp |
| @@ -14,14 +14,35 @@ |
| #include "GrProcOptInfo.h" |
| GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
| - GrDrawState::BlendOpt blendOpt, |
| - GrBlendCoeff optSrcCoeff, |
| - GrBlendCoeff optDstCoeff, |
| GrGpu* gpu, |
| const ScissorState& scissorState, |
| const GrDeviceCoordTexture* dstCopy, |
| - GrGpu::DrawType drawType) |
| -: fRenderTarget(drawState.fRenderTarget.get()) { |
| + GrGpu::DrawType drawType) { |
| + |
| + GrBlendCoeff optSrcCoeff; |
| + GrBlendCoeff optDstCoeff; |
| + GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &optSrcCoeff, &optDstCoeff); |
| + |
| + // When path rendering the stencil settings are not always set on the draw state |
| + // so we must check the draw type. In cases where we will skip drawing we simply return a |
| + // null GrOptDrawState. |
| + if (GrDrawState::kSkipDraw_BlendOpt == blendOpt && GrGpu::kStencilPath_DrawType != drawType) { |
| + // Set the fields that don't default init and return. The lack of a render target will |
| + // indicate that this can be skipped. |
| + fFlags = 0; |
| + fVAPtr = NULL; |
| + fVACount = 0; |
| + fVAStride = 0; |
| + fDrawFace = GrDrawState::kInvalid_DrawFace; |
| + fSrcBlend = kZero_GrBlendCoeff; |
| + fDstBlend = kZero_GrBlendCoeff; |
| + fBlendConstant = 0x0; |
| + fViewMatrix.reset(); |
| + return; |
| + } |
| + |
| + fRenderTarget.reset(drawState.fRenderTarget.get()); |
| + SkASSERT(fRenderTarget); |
|
egdaniel
2014/11/20 15:45:19
Will just checking fRenderTarget do what we want?
bsalomon
2014/11/20 15:46:48
yup, has a bool cast operator.
|
| fScissorState = scissorState; |
| fViewMatrix = drawState.getViewMatrix(); |
| fBlendConstant = drawState.getBlendConstant(); |
| @@ -100,28 +121,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
| gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); |
| }; |
| -GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, |
| - GrGpu* gpu, |
| - const ScissorState& scissorState, |
| - const GrDeviceCoordTexture* dstCopy, |
| - GrGpu::DrawType drawType) { |
| - GrBlendCoeff srcCoeff; |
| - GrBlendCoeff dstCoeff; |
| - GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &srcCoeff, &dstCoeff); |
| - |
| - // If our blend coeffs are set to 0,1 we know we will not end up drawing unless we are |
| - // stenciling. When path rendering the stencil settings are not always set on the draw state |
| - // so we must check the draw type. In cases where we will skip drawing we simply return a |
| - // null GrOptDrawState. |
| - if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && |
| - !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != drawType) { |
| - return NULL; |
| - } |
| - |
| - return SkNEW_ARGS(GrOptDrawState, (drawState, blendOpt, srcCoeff, |
| - dstCoeff, gpu, scissorState, dstCopy, drawType)); |
| -} |
| - |
| void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
| GrDrawState::BlendOpt blendOpt, |
| const GrDrawTargetCaps& caps, |