Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: src/gpu/GrOptDrawState.cpp

Issue 742853002: Don't use NULL GrOptDrawState to indicate that draw should be skipped. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make bool cast work Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOptDrawState.cpp
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 4f2d24f03a23d14b9ec5cfbc1c29c1419d30799b..a494b171de3a77e652191d0abf153ff548cd5586 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);
fScissorState = scissorState;
fViewMatrix = drawState.getViewMatrix();
fBlendConstant = drawState.getBlendConstant();
@@ -106,28 +127,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
gpu->buildProgramDesc(*this, descInfo, drawType, &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,
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698