OLD | NEW |
---|---|
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 Loading... | |
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 SkASSERT(0 == fFragmentStages.count()); |
joshualitt
2014/11/19 14:22:39
Will this ever be not true?
bsalomon
2014/11/19 15:04:43
I'll remove it... it was for my own sanity as I wa
| |
73 bool explicitLocalCoords = | |
74 -1 != descInfo.fFixedFunctionVertexAttribIndices[kLocalCoord_GrVertexAtt ribBinding]; | |
joshualitt
2014/11/19 14:22:39
descInfo.hasLocalCoordAttribute()
bsalomon
2014/11/19 15:04:43
tx!
| |
75 | |
76 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { | |
77 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | |
78 GrPendingFragmentStage, | |
79 (drawState.fColorStages[i], explicitLocalCoords)) ; | |
73 } | 80 } |
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(); | 81 fNumColorStages = fFragmentStages.count(); |
84 | 82 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) { |
85 // Copy Coverage Stages from DS to ODS | 83 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
86 if (firstCoverageStageIdx < drawState.numCoverageStages()) { | 84 GrPendingFragmentStage, |
87 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag eStageIdx, | 85 (drawState.fCoverageStages[i], explicitLocalCoord s)); |
88 &drawState.getCoverageStage(firstCoverageSta geIdx)); | |
89 } | 86 } |
90 | 87 |
91 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo); | 88 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo); |
92 | 89 |
93 // now create a key | 90 // now create a key |
94 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); | 91 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); |
95 }; | 92 }; |
96 | 93 |
97 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, | 94 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, |
98 GrGpu* gpu, | 95 GrGpu* gpu, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 } | 247 } |
251 if (ds.hasGeometryProcessor()) { | 248 if (ds.hasGeometryProcessor()) { |
252 const GrGeometryProcessor& gp = *ds.getGeometryProcessor(); | 249 const GrGeometryProcessor& gp = *ds.getGeometryProcessor(); |
253 descInfo->fReadsFragPosition = descInfo->fReadsFragPosition || gp.willRe adFragmentPosition(); | 250 descInfo->fReadsFragPosition = descInfo->fReadsFragPosition || gp.willRe adFragmentPosition(); |
254 } | 251 } |
255 } | 252 } |
256 | 253 |
257 //////////////////////////////////////////////////////////////////////////////// | 254 //////////////////////////////////////////////////////////////////////////////// |
258 | 255 |
259 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { | 256 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) { | 257 if (this->fDesc != that.fDesc) { |
265 return false; | 258 return false; |
266 } | 259 } |
267 bool usingVertexColors = that.fDesc.header().fColorAttributeIndex != -1; | 260 bool usingVertexColors = that.fDesc.header().fColorAttributeIndex != -1; |
268 if (!usingVertexColors && this->fColor != that.fColor) { | 261 if (!usingVertexColors && this->fColor != that.fColor) { |
269 return false; | 262 return false; |
270 } | 263 } |
271 | 264 |
272 if (this->getRenderTarget() != that.getRenderTarget() || | 265 if (this->getRenderTarget() != that.getRenderTarget() || |
273 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || | 266 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || |
(...skipping 17 matching lines...) Expand all Loading... | |
291 if (this->hasGeometryProcessor()) { | 284 if (this->hasGeometryProcessor()) { |
292 if (!that.hasGeometryProcessor()) { | 285 if (!that.hasGeometryProcessor()) { |
293 return false; | 286 return false; |
294 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) { | 287 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) { |
295 return false; | 288 return false; |
296 } | 289 } |
297 } else if (that.hasGeometryProcessor()) { | 290 } else if (that.hasGeometryProcessor()) { |
298 return false; | 291 return false; |
299 } | 292 } |
300 | 293 |
301 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1; | 294 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
joshualitt
2014/11/19 14:22:39
does this get tested with the desc equality test?
bsalomon
2014/11/19 15:04:43
Yeah, it has these fields:
SkBool8
| |
302 for (int i = 0; i < this->numFragmentStages(); i++) { | 295 for (int i = 0; i < this->numFragmentStages(); i++) { |
303 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i), | 296 |
304 explicitLocalCoords)) { | 297 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
305 return false; | 298 return false; |
306 } | 299 } |
307 } | 300 } |
308 return true; | 301 return true; |
309 } | 302 } |
310 | 303 |
OLD | NEW |