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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
11 #include "GrDrawState.h" 11 #include "GrDrawState.h"
12 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrProcOptInfo.h" 14 #include "GrProcOptInfo.h"
15 15
16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
17 GrDrawState::BlendOpt blendOpt,
18 GrBlendCoeff optSrcCoeff,
19 GrBlendCoeff optDstCoeff,
20 GrGpu* gpu, 17 GrGpu* gpu,
21 const ScissorState& scissorState, 18 const ScissorState& scissorState,
22 const GrDeviceCoordTexture* dstCopy, 19 const GrDeviceCoordTexture* dstCopy,
23 GrGpu::DrawType drawType) 20 GrGpu::DrawType drawType) {
24 : fRenderTarget(drawState.fRenderTarget.get()) { 21
22 GrBlendCoeff optSrcCoeff;
23 GrBlendCoeff optDstCoeff;
24 GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &optSrcCoeff, &optDstCoeff);
25
26 // When path rendering the stencil settings are not always set on the draw s tate
27 // so we must check the draw type. In cases where we will skip drawing we si mply return a
28 // null GrOptDrawState.
29 if (GrDrawState::kSkipDraw_BlendOpt == blendOpt && GrGpu::kStencilPath_DrawT ype != drawType) {
30 // Set the fields that don't default init and return. The lack of a rend er target will
31 // indicate that this can be skipped.
32 fFlags = 0;
33 fVAPtr = NULL;
34 fVACount = 0;
35 fVAStride = 0;
36 fDrawFace = GrDrawState::kInvalid_DrawFace;
37 fSrcBlend = kZero_GrBlendCoeff;
38 fDstBlend = kZero_GrBlendCoeff;
39 fBlendConstant = 0x0;
40 fViewMatrix.reset();
41 return;
42 }
43
44 fRenderTarget.reset(drawState.fRenderTarget.get());
45 SkASSERT(fRenderTarget);
25 fScissorState = scissorState; 46 fScissorState = scissorState;
26 fViewMatrix = drawState.getViewMatrix(); 47 fViewMatrix = drawState.getViewMatrix();
27 fBlendConstant = drawState.getBlendConstant(); 48 fBlendConstant = drawState.getBlendConstant();
28 fVAPtr = drawState.getVertexAttribs(); 49 fVAPtr = drawState.getVertexAttribs();
29 fVACount = drawState.getVertexAttribCount(); 50 fVACount = drawState.getVertexAttribCount();
30 fVAStride = drawState.getVertexStride(); 51 fVAStride = drawState.getVertexStride();
31 fStencilSettings = drawState.getStencil(); 52 fStencilSettings = drawState.getStencil();
32 fDrawFace = drawState.getDrawFace(); 53 fDrawFace = drawState.getDrawFace();
33 fSrcBlend = optSrcCoeff; 54 fSrcBlend = optSrcCoeff;
34 fDstBlend = optDstCoeff; 55 fDstBlend = optDstCoeff;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 GrPendingFragmentStage, 120 GrPendingFragmentStage,
100 (drawState.fCoverageStages[i], explicitLocalCoord s)); 121 (drawState.fCoverageStages[i], explicitLocalCoord s));
101 } 122 }
102 123
103 this->setOutputStateInfo(drawState, blendOpt, *gpu->caps(), &descInfo); 124 this->setOutputStateInfo(drawState, blendOpt, *gpu->caps(), &descInfo);
104 125
105 // now create a key 126 // now create a key
106 gpu->buildProgramDesc(*this, descInfo, drawType, &fDesc); 127 gpu->buildProgramDesc(*this, descInfo, drawType, &fDesc);
107 }; 128 };
108 129
109 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
110 GrGpu* gpu,
111 const ScissorState& scissorState,
112 const GrDeviceCoordTexture* dstCopy,
113 GrGpu::DrawType drawType) {
114 GrBlendCoeff srcCoeff;
115 GrBlendCoeff dstCoeff;
116 GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &srcCoeff, &ds tCoeff);
117
118 // If our blend coeffs are set to 0,1 we know we will not end up drawing unl ess we are
119 // stenciling. When path rendering the stencil settings are not always set o n the draw state
120 // so we must check the draw type. In cases where we will skip drawing we si mply return a
121 // null GrOptDrawState.
122 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff &&
123 !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != d rawType) {
124 return NULL;
125 }
126
127 return SkNEW_ARGS(GrOptDrawState, (drawState, blendOpt, srcCoeff,
128 dstCoeff, gpu, scissorState, dstCopy, dra wType));
129 }
130
131 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, 130 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
132 GrDrawState::BlendOpt blendOpt, 131 GrDrawState::BlendOpt blendOpt,
133 const GrDrawTargetCaps& caps, 132 const GrDrawTargetCaps& caps,
134 GrProgramDesc::DescInfo* descInfo) { 133 GrProgramDesc::DescInfo* descInfo) {
135 // Set this default and then possibly change our mind if there is coverage. 134 // Set this default and then possibly change our mind if there is coverage.
136 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; 135 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
137 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; 136 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
138 137
139 // Determine whether we should use dual source blending or shader code to ke ep coverage 138 // Determine whether we should use dual source blending or shader code to ke ep coverage
140 // separate from color. 139 // separate from color.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); 307 SkASSERT(this->numFragmentStages() == that.numFragmentStages());
309 for (int i = 0; i < this->numFragmentStages(); i++) { 308 for (int i = 0; i < this->numFragmentStages(); i++) {
310 309
311 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { 310 if (this->getFragmentStage(i) != that.getFragmentStage(i)) {
312 return false; 311 return false;
313 } 312 }
314 } 313 }
315 return true; 314 return true;
316 } 315 }
317 316
OLDNEW
« 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