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

Side by Side Diff: src/gpu/GrOptDrawState.cpp

Issue 739673002: Create GrOptDrawState before recording draw in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused function in pendingprogramelement 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') | src/gpu/GrPendingFragmentStage.h » ('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 BlendOptFlags blendOptFlags, 17 BlendOptFlags blendOptFlags,
18 GrBlendCoeff optSrcCoeff, 18 GrBlendCoeff optSrcCoeff,
19 GrBlendCoeff optDstCoeff, 19 GrBlendCoeff optDstCoeff,
20 GrGpu* gpu, 20 GrGpu* gpu,
21 const GrDeviceCoordTexture* dstCopy, 21 const GrDeviceCoordTexture* dstCopy,
22 GrGpu::DrawType drawType) { 22 GrGpu::DrawType drawType)
23 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); 23 : fRenderTarget(drawState.fRenderTarget.get()) {
24 fViewMatrix = drawState.getViewMatrix(); 24 fViewMatrix = drawState.getViewMatrix();
25 fBlendConstant = drawState.getBlendConstant(); 25 fBlendConstant = drawState.getBlendConstant();
26 fFlagBits = drawState.getFlagBits(); 26 fFlagBits = drawState.getFlagBits();
27 fVAPtr = drawState.getVertexAttribs(); 27 fVAPtr = drawState.getVertexAttribs();
28 fVACount = drawState.getVertexAttribCount(); 28 fVACount = drawState.getVertexAttribCount();
29 fVAStride = drawState.getVertexStride(); 29 fVAStride = drawState.getVertexStride();
30 fStencilSettings = drawState.getStencil(); 30 fStencilSettings = drawState.getStencil();
31 fDrawFace = (DrawFace)drawState.getDrawFace(); 31 fDrawFace = (DrawFace)drawState.getDrawFace();
32 fBlendOptFlags = blendOptFlags; 32 fBlendOptFlags = blendOptFlags;
33 fSrcBlend = optSrcCoeff; 33 fSrcBlend = optSrcCoeff;
(...skipping 25 matching lines...) Expand all
59 // Should not be setting any more FFVA to be removed at this point 59 // Should not be setting any more FFVA to be removed at this point
60 if (0 != fixedFunctionVAToRemove) { 60 if (0 != fixedFunctionVAToRemove) {
61 this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInf o); 61 this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInf o);
62 } 62 }
63 this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, &d escInfo); 63 this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, &d escInfo);
64 64
65 // Copy GeometryProcesssor from DS or ODS 65 // Copy GeometryProcesssor from DS or ODS
66 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) || 66 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) ||
67 GrGpu::kStencilPath_DrawType || 67 GrGpu::kStencilPath_DrawType ||
68 drawState.hasGeometryProcessor()); 68 drawState.hasGeometryProcessor());
69 if (drawState.hasGeometryProcessor()) { 69 fGeometryProcessor.reset(drawState.getGeometryProcessor());
70 fGeometryProcessor.initAndRef(drawState.fGeometryProcessor); 70
71 } else { 71 // Copy Stages from DS to ODS
72 fGeometryProcessor.reset(NULL); 72 bool explicitLocalCoords = descInfo.hasLocalCoordAttribute();
73
74 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) {
75 SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
76 GrPendingFragmentStage,
77 (drawState.fColorStages[i], explicitLocalCoords)) ;
73 } 78 }
74
75 // Copy Color Stages from DS to ODS
76 if (firstColorStageIdx < drawState.numColorStages()) {
77 fFragmentStages.reset(&drawState.getColorStage(firstColorStageIdx),
78 drawState.numColorStages() - firstColorStageIdx);
79 } else {
80 fFragmentStages.reset();
81 }
82
83 fNumColorStages = fFragmentStages.count(); 79 fNumColorStages = fFragmentStages.count();
84 80 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) {
85 // Copy Coverage Stages from DS to ODS 81 SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
86 if (firstCoverageStageIdx < drawState.numCoverageStages()) { 82 GrPendingFragmentStage,
87 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag eStageIdx, 83 (drawState.fCoverageStages[i], explicitLocalCoord s));
88 &drawState.getCoverageStage(firstCoverageSta geIdx));
89 } 84 }
90 85
91 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo); 86 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo);
92 87
93 // now create a key 88 // now create a key
94 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); 89 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc);
95 }; 90 };
96 91
97 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, 92 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
98 GrGpu* gpu, 93 GrGpu* gpu,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 245 }
251 if (ds.hasGeometryProcessor()) { 246 if (ds.hasGeometryProcessor()) {
252 const GrGeometryProcessor& gp = *ds.getGeometryProcessor(); 247 const GrGeometryProcessor& gp = *ds.getGeometryProcessor();
253 descInfo->fReadsFragPosition = descInfo->fReadsFragPosition || gp.willRe adFragmentPosition(); 248 descInfo->fReadsFragPosition = descInfo->fReadsFragPosition || gp.willRe adFragmentPosition();
254 } 249 }
255 } 250 }
256 251
257 //////////////////////////////////////////////////////////////////////////////// 252 ////////////////////////////////////////////////////////////////////////////////
258 253
259 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { 254 bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
260 return this->isEqual(that);
261 }
262
263 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
264 if (this->fDesc != that.fDesc) { 255 if (this->fDesc != that.fDesc) {
265 return false; 256 return false;
266 } 257 }
267 bool usingVertexColors = that.fDesc.header().fColorAttributeIndex != -1; 258 bool usingVertexColors = that.fDesc.header().fColorAttributeIndex != -1;
268 if (!usingVertexColors && this->fColor != that.fColor) { 259 if (!usingVertexColors && this->fColor != that.fColor) {
269 return false; 260 return false;
270 } 261 }
271 262
272 if (this->getRenderTarget() != that.getRenderTarget() || 263 if (this->getRenderTarget() != that.getRenderTarget() ||
273 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || 264 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) ||
(...skipping 17 matching lines...) Expand all
291 if (this->hasGeometryProcessor()) { 282 if (this->hasGeometryProcessor()) {
292 if (!that.hasGeometryProcessor()) { 283 if (!that.hasGeometryProcessor()) {
293 return false; 284 return false;
294 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) { 285 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) {
295 return false; 286 return false;
296 } 287 }
297 } else if (that.hasGeometryProcessor()) { 288 } else if (that.hasGeometryProcessor()) {
298 return false; 289 return false;
299 } 290 }
300 291
301 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1; 292 // The program desc comparison should have already assured that the stage co unts match.
293 SkASSERT(this->numFragmentStages() == that.numFragmentStages());
302 for (int i = 0; i < this->numFragmentStages(); i++) { 294 for (int i = 0; i < this->numFragmentStages(); i++) {
303 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i), 295
304 explicitLocalCoords)) { 296 if (this->getFragmentStage(i) != that.getFragmentStage(i)) {
305 return false; 297 return false;
306 } 298 }
307 } 299 }
308 return true; 300 return true;
309 } 301 }
310 302
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrPendingFragmentStage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698