OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrGLProgramDesc.h" | 8 #include "GrGLProgramDesc.h" |
9 #include "GrBackendEffectFactory.h" | 9 #include "GrBackendEffectFactory.h" |
10 #include "GrDrawEffect.h" | 10 #include "GrDrawEffect.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 GrBlendCoeff dstCoeff, | 39 GrBlendCoeff dstCoeff, |
40 const GrGpuGL* gpu, | 40 const GrGpuGL* gpu, |
41 const GrDeviceCoordTexture* dstCopy, | 41 const GrDeviceCoordTexture* dstCopy, |
42 SkTArray<const GrEffectStage*, true>* colorStages, | 42 SkTArray<const GrEffectStage*, true>* colorStages, |
43 SkTArray<const GrEffectStage*, true>* coverageStages
, | 43 SkTArray<const GrEffectStage*, true>* coverageStages
, |
44 GrGLProgramDesc* desc) { | 44 GrGLProgramDesc* desc) { |
45 colorStages->reset(); | 45 colorStages->reset(); |
46 coverageStages->reset(); | 46 coverageStages->reset(); |
47 | 47 |
48 // This should already have been caught | 48 // This should already have been caught |
49 GrAssert(!(GrDrawState::kSkipDraw_BlendOptFlag & blendOpts)); | 49 SkASSERT(!(GrDrawState::kSkipDraw_BlendOptFlag & blendOpts)); |
50 | 50 |
51 bool skipCoverage = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendO
ptFlag); | 51 bool skipCoverage = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendO
ptFlag); |
52 | 52 |
53 bool skipColor = SkToBool(blendOpts & (GrDrawState::kEmitTransBlack_BlendOpt
Flag | | 53 bool skipColor = SkToBool(blendOpts & (GrDrawState::kEmitTransBlack_BlendOpt
Flag | |
54 GrDrawState::kEmitCoverage_BlendOptFl
ag)); | 54 GrDrawState::kEmitCoverage_BlendOptFl
ag)); |
55 | 55 |
56 // The descriptor is used as a cache key. Thus when a field of the | 56 // The descriptor is used as a cache key. Thus when a field of the |
57 // descriptor will not affect program generation (because of the attribute | 57 // descriptor will not affect program generation (because of the attribute |
58 // bindings in use or other descriptor field settings) it should be set | 58 // bindings in use or other descriptor field settings) it should be set |
59 // to a canonical value to avoid duplicate programs with different keys. | 59 // to a canonical value to avoid duplicate programs with different keys. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 header->fCoverageInput = kTransBlack_ColorInput; | 130 header->fCoverageInput = kTransBlack_ColorInput; |
131 } else if (covIsSolidWhite) { | 131 } else if (covIsSolidWhite) { |
132 header->fCoverageInput = kSolidWhite_ColorInput; | 132 header->fCoverageInput = kSolidWhite_ColorInput; |
133 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresCoverageAttrib) { | 133 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresCoverageAttrib) { |
134 header->fCoverageInput = kUniform_ColorInput; | 134 header->fCoverageInput = kUniform_ColorInput; |
135 } else { | 135 } else { |
136 header->fCoverageInput = kAttribute_ColorInput; | 136 header->fCoverageInput = kAttribute_ColorInput; |
137 } | 137 } |
138 | 138 |
139 if (readsDst) { | 139 if (readsDst) { |
140 GrAssert(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport()); | 140 SkASSERT(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport()); |
141 const GrTexture* dstCopyTexture = NULL; | 141 const GrTexture* dstCopyTexture = NULL; |
142 if (NULL != dstCopy) { | 142 if (NULL != dstCopy) { |
143 dstCopyTexture = dstCopy->texture(); | 143 dstCopyTexture = dstCopy->texture(); |
144 } | 144 } |
145 header->fDstReadKey = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, g
pu->glCaps()); | 145 header->fDstReadKey = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, g
pu->glCaps()); |
146 GrAssert(0 != header->fDstReadKey); | 146 SkASSERT(0 != header->fDstReadKey); |
147 } else { | 147 } else { |
148 header->fDstReadKey = 0; | 148 header->fDstReadKey = 0; |
149 } | 149 } |
150 | 150 |
151 if (readFragPosition) { | 151 if (readFragPosition) { |
152 header->fFragPosKey = GrGLShaderBuilder::KeyForFragmentPosition(drawStat
e.getRenderTarget(), | 152 header->fFragPosKey = GrGLShaderBuilder::KeyForFragmentPosition(drawStat
e.getRenderTarget(), |
153 gpu->glCap
s()); | 153 gpu->glCap
s()); |
154 } else { | 154 } else { |
155 header->fFragPosKey = 0; | 155 header->fFragPosKey = 0; |
156 } | 156 } |
157 | 157 |
158 // Record attribute indices | 158 // Record attribute indices |
159 header->fPositionAttributeIndex = drawState.positionAttributeIndex(); | 159 header->fPositionAttributeIndex = drawState.positionAttributeIndex(); |
160 header->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex(); | 160 header->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex(); |
161 | 161 |
162 // For constant color and coverage we need an attribute with an index beyond
those already set | 162 // For constant color and coverage we need an attribute with an index beyond
those already set |
163 int availableAttributeIndex = drawState.getVertexAttribCount(); | 163 int availableAttributeIndex = drawState.getVertexAttribCount(); |
164 if (requiresColorAttrib) { | 164 if (requiresColorAttrib) { |
165 header->fColorAttributeIndex = drawState.colorVertexAttributeIndex(); | 165 header->fColorAttributeIndex = drawState.colorVertexAttributeIndex(); |
166 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) { | 166 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) { |
167 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); | 167 SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); |
168 header->fColorAttributeIndex = availableAttributeIndex; | 168 header->fColorAttributeIndex = availableAttributeIndex; |
169 availableAttributeIndex++; | 169 availableAttributeIndex++; |
170 } else { | 170 } else { |
171 header->fColorAttributeIndex = -1; | 171 header->fColorAttributeIndex = -1; |
172 } | 172 } |
173 | 173 |
174 if (requiresCoverageAttrib) { | 174 if (requiresCoverageAttrib) { |
175 header->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex
(); | 175 header->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex
(); |
176 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput)
{ | 176 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput)
{ |
177 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); | 177 SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); |
178 header->fCoverageAttributeIndex = availableAttributeIndex; | 178 header->fCoverageAttributeIndex = availableAttributeIndex; |
179 } else { | 179 } else { |
180 header->fCoverageAttributeIndex = -1; | 180 header->fCoverageAttributeIndex = -1; |
181 } | 181 } |
182 | 182 |
183 // Here we deal with whether/how we handle color and coverage separately. | 183 // Here we deal with whether/how we handle color and coverage separately. |
184 | 184 |
185 // Set these defaults and then possibly change our mind if there is coverage
. | 185 // Set these defaults and then possibly change our mind if there is coverage
. |
186 header->fDiscardIfZeroCoverage = false; | 186 header->fDiscardIfZeroCoverage = false; |
187 header->fCoverageOutput = kModulate_CoverageOutput; | 187 header->fCoverageOutput = kModulate_CoverageOutput; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 253 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
254 fInitialized = other.fInitialized; | 254 fInitialized = other.fInitialized; |
255 if (fInitialized) { | 255 if (fInitialized) { |
256 size_t keyLength = other.keyLength(); | 256 size_t keyLength = other.keyLength(); |
257 fKey.reset(keyLength); | 257 fKey.reset(keyLength); |
258 memcpy(fKey.get(), other.fKey.get(), keyLength); | 258 memcpy(fKey.get(), other.fKey.get(), keyLength); |
259 } | 259 } |
260 return *this; | 260 return *this; |
261 } | 261 } |
OLD | NEW |