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 "GrDrawState.h" | 10 #include "GrDrawState.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Copy GeometryProcesssor from DS or ODS | 55 // Copy GeometryProcesssor from DS or ODS |
56 if (drawState.hasGeometryProcessor()) { | 56 if (drawState.hasGeometryProcessor()) { |
57 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom
etryProcessor()))); | 57 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom
etryProcessor()))); |
58 } else { | 58 } else { |
59 fGeometryProcessor.reset(NULL); | 59 fGeometryProcessor.reset(NULL); |
60 } | 60 } |
61 | 61 |
62 // Copy Color Stages from DS to ODS | 62 // Copy Color Stages from DS to ODS |
63 if (firstColorStageIdx < drawState.numColorStages()) { | 63 if (firstColorStageIdx < drawState.numColorStages()) { |
64 fColorStages.reset(&drawState.getColorStage(firstColorStageIdx), | 64 fFragmentStages.reset(&drawState.getColorStage(firstColorStageIdx), |
65 drawState.numColorStages() - firstColorStageIdx); | 65 drawState.numColorStages() - firstColorStageIdx); |
66 } else { | 66 } else { |
67 fColorStages.reset(); | 67 fFragmentStages.reset(); |
68 } | 68 } |
69 | 69 |
| 70 fNumColorStages = fFragmentStages.count(); |
| 71 |
70 // Copy Coverage Stages from DS to ODS | 72 // Copy Coverage Stages from DS to ODS |
71 if (firstCoverageStageIdx < drawState.numCoverageStages() && separateCoverag
eFromColor) { | 73 if (firstCoverageStageIdx < drawState.numCoverageStages()) { |
72 fCoverageStages.reset(&drawState.getCoverageStage(firstCoverageStageIdx)
, | 74 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag
eStageIdx, |
73 drawState.numCoverageStages() - firstCoverageStage
Idx); | 75 &drawState.getCoverageStage(firstCoverageSta
geIdx)); |
74 } else { | 76 if (!separateCoverageFromColor) { |
75 fCoverageStages.reset(); | 77 fNumColorStages = fFragmentStages.count(); |
76 if (firstCoverageStageIdx < drawState.numCoverageStages()) { | |
77 // TODO: Once we have flag to know if we only multiply on stages, on
ly push coverage | |
78 // into color stages if everything is multiply | |
79 fColorStages.push_back_n(drawState.numCoverageStages() - firstCovera
geStageIdx, | |
80 &drawState.getCoverageStage(firstCoverageSt
ageIdx)); | |
81 } | 78 } |
82 } | 79 } |
83 }; | 80 }; |
84 | 81 |
85 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra
wTargetCaps& caps, | 82 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra
wTargetCaps& caps, |
86 GrGpu::DrawType drawType) { | 83 GrGpu::DrawType drawType) { |
87 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa
chedCapsID) { | 84 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa
chedCapsID) { |
88 GrBlendCoeff srcCoeff; | 85 GrBlendCoeff srcCoeff; |
89 GrBlendCoeff dstCoeff; | 86 GrBlendCoeff dstCoeff; |
90 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | 87 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 return this->isEqual(that); | 316 return this->isEqual(that); |
320 } | 317 } |
321 | 318 |
322 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const { | 319 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const { |
323 bool usingVertexColors = this->hasColorVertexAttribute(); | 320 bool usingVertexColors = this->hasColorVertexAttribute(); |
324 if (!usingVertexColors && this->fColor != that.fColor) { | 321 if (!usingVertexColors && this->fColor != that.fColor) { |
325 return false; | 322 return false; |
326 } | 323 } |
327 | 324 |
328 if (this->getRenderTarget() != that.getRenderTarget() || | 325 if (this->getRenderTarget() != that.getRenderTarget() || |
329 this->fColorStages.count() != that.fColorStages.count() || | 326 this->fFragmentStages.count() != that.fFragmentStages.count() || |
330 this->fCoverageStages.count() != that.fCoverageStages.count() || | 327 this->fNumColorStages != that.fNumColorStages || |
331 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || | 328 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || |
332 this->fSrcBlend != that.fSrcBlend || | 329 this->fSrcBlend != that.fSrcBlend || |
333 this->fDstBlend != that.fDstBlend || | 330 this->fDstBlend != that.fDstBlend || |
334 this->fBlendConstant != that.fBlendConstant || | 331 this->fBlendConstant != that.fBlendConstant || |
335 this->fFlagBits != that.fFlagBits || | 332 this->fFlagBits != that.fFlagBits || |
336 this->fVACount != that.fVACount || | 333 this->fVACount != that.fVACount || |
337 this->fVAStride != that.fVAStride || | 334 this->fVAStride != that.fVAStride || |
338 memcmp(this->fVAPtr, that.fVAPtr, this->fVACount * sizeof(GrVertexAttrib
)) || | 335 memcmp(this->fVAPtr, that.fVAPtr, this->fVACount * sizeof(GrVertexAttrib
)) || |
339 this->fStencilSettings != that.fStencilSettings || | 336 this->fStencilSettings != that.fStencilSettings || |
340 this->fDrawFace != that.fDrawFace || | 337 this->fDrawFace != that.fDrawFace || |
(...skipping 18 matching lines...) Expand all Loading... |
359 return false; | 356 return false; |
360 } else if (!GrProcessorStage::AreCompatible(*this->getGeometryProcessor(
), | 357 } else if (!GrProcessorStage::AreCompatible(*this->getGeometryProcessor(
), |
361 *that.getGeometryProcessor()
, | 358 *that.getGeometryProcessor()
, |
362 explicitLocalCoords)) { | 359 explicitLocalCoords)) { |
363 return false; | 360 return false; |
364 } | 361 } |
365 } else if (that.hasGeometryProcessor()) { | 362 } else if (that.hasGeometryProcessor()) { |
366 return false; | 363 return false; |
367 } | 364 } |
368 | 365 |
369 for (int i = 0; i < this->numColorStages(); i++) { | 366 for (int i = 0; i < this->numFragmentStages(); i++) { |
370 if (!GrProcessorStage::AreCompatible(this->getColorStage(i), that.getCol
orStage(i), | 367 if (!GrProcessorStage::AreCompatible(this->getFragmentStage(i), that.get
FragmentStage(i), |
371 explicitLocalCoords)) { | 368 explicitLocalCoords)) { |
372 return false; | 369 return false; |
373 } | 370 } |
374 } | |
375 for (int i = 0; i < this->numCoverageStages(); i++) { | |
376 if (!GrProcessorStage::AreCompatible(this->getCoverageStage(i), that.get
CoverageStage(i), | |
377 explicitLocalCoords)) { | |
378 return false; | |
379 } | |
380 } | 371 } |
381 | 372 |
382 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, | 373 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, |
383 that.fFixedFunctionVertexAttribIndices, | 374 that.fFixedFunctionVertexAttribIndices, |
384 sizeof(this->fFixedFunctionVertexAttribIndices))); | 375 sizeof(this->fFixedFunctionVertexAttribIndices))); |
385 | 376 |
386 return true; | 377 return true; |
387 } | 378 } |
388 | 379 |
OLD | NEW |