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" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
12 #include "GrGpu.h" | |
13 | 12 |
14 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, | 13 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
15 BlendOptFlags blendOptFlags, | 14 BlendOptFlags blendOptFlags, |
16 GrBlendCoeff optSrcCoeff, | 15 GrBlendCoeff optSrcCoeff, |
17 GrBlendCoeff optDstCoeff, | 16 GrBlendCoeff optDstCoeff, |
18 const GrDrawTargetCaps& caps) { | 17 const GrDrawTargetCaps& caps) { |
19 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), | 18 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), |
20 GrIORef::kWrite_IOType); | 19 GrIORef::kWrite_IOType); |
21 fColor = drawState.getColor(); | 20 fColor = drawState.getColor(); |
22 fCoverage = drawState.getCoverage(); | 21 fCoverage = drawState.getCoverage(); |
(...skipping 23 matching lines...) Expand all Loading... | |
46 fGeometryProcessor.reset(NULL); | 45 fGeometryProcessor.reset(NULL); |
47 } | 46 } |
48 | 47 |
49 this->copyEffectiveColorStages(drawState); | 48 this->copyEffectiveColorStages(drawState); |
50 this->copyEffectiveCoverageStages(drawState); | 49 this->copyEffectiveCoverageStages(drawState); |
51 this->adjustFromBlendOpts(); | 50 this->adjustFromBlendOpts(); |
52 this->getStageStats(); | 51 this->getStageStats(); |
53 this->setOutputStateInfo(caps); | 52 this->setOutputStateInfo(caps); |
54 }; | 53 }; |
55 | 54 |
55 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra wTargetCaps& caps, | |
56 GrGpu::DrawType drawType) { | |
57 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa chedCapsID) { | |
58 GrBlendCoeff srcCoeff; | |
59 GrBlendCoeff dstCoeff; | |
60 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | |
61 &srcCo eff, | |
62 &dstCo eff); | |
63 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && | |
joshua.litt
2014/10/06 20:40:51
This is pretty self explanatory, but a comment wou
| |
64 !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != drawType) { | |
65 return NULL; | |
66 } | |
67 drawState.fCachedOptState = SkNEW_ARGS(GrOptDrawState, (drawState, blend Flags, srcCoeff, | |
68 dstCoeff, caps)) ; | |
69 drawState.fCachedCapsID = caps.getUniqueID(); | |
70 } else { | |
71 #ifdef SK_DEBUG | |
72 GrBlendCoeff srcCoeff; | |
73 GrBlendCoeff dstCoeff; | |
74 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | |
75 &srcCo eff, | |
76 &dstCo eff); | |
77 SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, caps) == | |
78 *drawState.fCachedOptState); | |
79 #endif | |
80 } | |
81 drawState.fCachedOptState->ref(); | |
82 return drawState.fCachedOptState; | |
83 } | |
84 | |
56 void GrOptDrawState::setOutputStateInfo(const GrDrawTargetCaps& caps) { | 85 void GrOptDrawState::setOutputStateInfo(const GrDrawTargetCaps& caps) { |
57 // Set this default and then possibly change our mind if there is coverage. | 86 // Set this default and then possibly change our mind if there is coverage. |
58 fPrimaryOutputType = kModulate_PrimaryOutputType; | 87 fPrimaryOutputType = kModulate_PrimaryOutputType; |
59 fSecondaryOutputType = kNone_SecondaryOutputType; | 88 fSecondaryOutputType = kNone_SecondaryOutputType; |
60 | 89 |
61 // If we do have coverage determine whether it matters. | 90 // If we do have coverage determine whether it matters. |
62 bool separateCoverageFromColor = this->hasGeometryProcessor(); | 91 bool separateCoverageFromColor = this->hasGeometryProcessor(); |
63 if (!this->isCoverageDrawing() && | 92 if (!this->isCoverageDrawing() && |
64 (this->numCoverageStages() > 0 || | 93 (this->numCoverageStages() > 0 || |
65 this->hasGeometryProcessor() || | 94 this->hasGeometryProcessor() || |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 } | 360 } |
332 } | 361 } |
333 | 362 |
334 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, | 363 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, |
335 that.fFixedFunctionVertexAttribIndices, | 364 that.fFixedFunctionVertexAttribIndices, |
336 sizeof(this->fFixedFunctionVertexAttribIndices))); | 365 sizeof(this->fFixedFunctionVertexAttribIndices))); |
337 | 366 |
338 return true; | 367 return true; |
339 } | 368 } |
340 | 369 |
OLD | NEW |