| 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" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 // now create a key | 94 // now create a key |
| 95 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); | 95 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, | 98 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, |
| 99 GrGpu* gpu, | 99 GrGpu* gpu, |
| 100 const GrDeviceCoordTexture* dstCopy, | 100 const GrDeviceCoordTexture* dstCopy, |
| 101 GrGpu::DrawType drawType) { | 101 GrGpu::DrawType drawType) { |
| 102 const GrDrawTargetCaps& caps = *gpu->caps(); | 102 GrBlendCoeff srcCoeff; |
| 103 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa
chedCapsID) { | 103 GrBlendCoeff dstCoeff; |
| 104 GrBlendCoeff srcCoeff; | 104 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
| 105 GrBlendCoeff dstCoeff; | 105 &srcCoeff, |
| 106 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | 106 &dstCoeff)
; |
| 107 &srcCo
eff, | |
| 108 &dstCo
eff); | |
| 109 | 107 |
| 110 // If our blend coeffs are set to 0,1 we know we will not end up drawing
unless we are | 108 // If our blend coeffs are set to 0,1 we know we will not end up drawing unl
ess we are |
| 111 // stenciling. When path rendering the stencil settings are not always s
et on the draw state | 109 // stenciling. When path rendering the stencil settings are not always set o
n the draw state |
| 112 // so we must check the draw type. In cases where we will skip drawing w
e simply return a | 110 // so we must check the draw type. In cases where we will skip drawing we si
mply return a |
| 113 // null GrOptDrawState. | 111 // null GrOptDrawState. |
| 114 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && | 112 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && |
| 115 !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType
!= drawType) { | 113 !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != d
rawType) { |
| 116 return NULL; | 114 return NULL; |
| 117 } | 115 } |
| 118 | 116 |
| 119 drawState.fCachedOptState = SkNEW_ARGS(GrOptDrawState, (drawState, blend
Flags, srcCoeff, | 117 return SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff, |
| 120 dstCoeff, gpu, d
stCopy, drawType)); | 118 dstCoeff, gpu, dstCopy, drawType)); |
| 121 drawState.fCachedCapsID = caps.getUniqueID(); | |
| 122 } else { | |
| 123 #ifdef SK_DEBUG | |
| 124 GrBlendCoeff srcCoeff; | |
| 125 GrBlendCoeff dstCoeff; | |
| 126 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | |
| 127 &srcCo
eff, | |
| 128 &dstCo
eff); | |
| 129 SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, gpu,
dstCopy, | |
| 130 drawType) == *drawState.fCachedOptState); | |
| 131 #endif | |
| 132 } | |
| 133 drawState.fCachedOptState->ref(); | |
| 134 return drawState.fCachedOptState; | |
| 135 } | 119 } |
| 136 | 120 |
| 137 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, | 121 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
| 138 const GrDrawTargetCaps& caps, | 122 const GrDrawTargetCaps& caps, |
| 139 int firstCoverageStageIdx, | 123 int firstCoverageStageIdx, |
| 140 GrProgramDesc::DescInfo* descInfo, | 124 GrProgramDesc::DescInfo* descInfo, |
| 141 bool* separateCoverageFromColor) { | 125 bool* separateCoverageFromColor) { |
| 142 // Set this default and then possibly change our mind if there is coverage. | 126 // Set this default and then possibly change our mind if there is coverage. |
| 143 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; | 127 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; |
| 144 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; | 128 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex !=
-1; | 371 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex !=
-1; |
| 388 for (int i = 0; i < this->numFragmentStages(); i++) { | 372 for (int i = 0; i < this->numFragmentStages(); i++) { |
| 389 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF
ragmentStage(i), | 373 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF
ragmentStage(i), |
| 390 explicitLocalCoords)) { | 374 explicitLocalCoords)) { |
| 391 return false; | 375 return false; |
| 392 } | 376 } |
| 393 } | 377 } |
| 394 return true; | 378 return true; |
| 395 } | 379 } |
| 396 | 380 |
| OLD | NEW |