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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag
eStageIdx, | 83 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag
eStageIdx, |
84 &drawState.getCoverageStage(firstCoverageSta
geIdx)); | 84 &drawState.getCoverageStage(firstCoverageSta
geIdx)); |
85 } | 85 } |
86 | 86 |
87 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo); | 87 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo); |
88 | 88 |
89 // now create a key | 89 // now create a key |
90 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); | 90 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); |
91 }; | 91 }; |
92 | 92 |
93 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, | 93 GrOptDrawState* GrOptDrawState::Create(GrGpu* gpu, |
94 GrGpu* gpu, | 94 const GrDrawState& drawState, |
95 const GrDeviceCoordTexture* dstCopy, | 95 const GrDeviceCoordTexture* dstCopy, |
96 GrGpu::DrawType drawType) { | 96 GrGpu::DrawType drawType) { |
97 GrBlendCoeff srcCoeff; | 97 GrBlendCoeff srcCoeff; |
98 GrBlendCoeff dstCoeff; | 98 GrBlendCoeff dstCoeff; |
99 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | 99 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
100 &srcCoeff, | 100 &srcCoeff, |
101 &dstCoeff)
; | 101 &dstCoeff)
; |
102 | 102 |
103 // If our blend coeffs are set to 0,1 we know we will not end up drawing unl
ess we are | 103 // If our blend coeffs are set to 0,1 we know we will not end up drawing unl
ess we are |
104 // stenciling. When path rendering the stencil settings are not always set o
n the draw state | 104 // stenciling. When path rendering the stencil settings are not always set o
n the draw state |
105 // so we must check the draw type. In cases where we will skip drawing we si
mply return a | 105 // so we must check the draw type. In cases where we will skip drawing we si
mply return a |
106 // null GrOptDrawState. | 106 // null GrOptDrawState. |
107 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && | 107 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && |
108 !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != d
rawType) { | 108 !drawState.getStencil().doesWrite() && GrGpu::kStencilPath_DrawType != d
rawType) { |
109 return NULL; | 109 return NULL; |
110 } | 110 } |
111 | 111 |
112 return SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff, | 112 return SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff, dstCoeff
, gpu, dstCopy, |
113 dstCoeff, gpu, dstCopy, drawType)); | 113 drawType)); |
114 } | 114 } |
115 | 115 |
116 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, | 116 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
117 const GrDrawTargetCaps& caps, | 117 const GrDrawTargetCaps& caps, |
118 GrProgramDesc::DescInfo* descInfo) { | 118 GrProgramDesc::DescInfo* descInfo) { |
119 // Set this default and then possibly change our mind if there is coverage. | 119 // Set this default and then possibly change our mind if there is coverage. |
120 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; | 120 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; |
121 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; | 121 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; |
122 | 122 |
123 // If we do have coverage determine whether it matters. Dual source blendin
g is expensive so | 123 // If we do have coverage determine whether it matters. Dual source blendin
g is expensive so |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex !=
-1; | 359 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex !=
-1; |
360 for (int i = 0; i < this->numFragmentStages(); i++) { | 360 for (int i = 0; i < this->numFragmentStages(); i++) { |
361 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF
ragmentStage(i), | 361 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF
ragmentStage(i), |
362 explicitLocalCoords)) { | 362 explicitLocalCoords)) { |
363 return false; | 363 return false; |
364 } | 364 } |
365 } | 365 } |
366 return true; | 366 return true; |
367 } | 367 } |
368 | 368 |
OLD | NEW |