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 #include "GrGLProgramDesc.h" | 7 #include "GrGLProgramDesc.h" |
8 | 8 |
9 #include "GrGLProcessor.h" | 9 #include "GrGLProcessor.h" |
10 #include "GrProcessor.h" | 10 #include "GrProcessor.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); | 215 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); |
216 | 216 |
217 bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType); | 217 bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType); |
218 if (gpu->caps()->pathRenderingSupport() && isPathRendering) { | 218 if (gpu->caps()->pathRenderingSupport() && isPathRendering) { |
219 header->fUseNvpr = true; | 219 header->fUseNvpr = true; |
220 SkASSERT(!optState.hasGeometryProcessor()); | 220 SkASSERT(!optState.hasGeometryProcessor()); |
221 } else { | 221 } else { |
222 header->fUseNvpr = false; | 222 header->fUseNvpr = false; |
223 } | 223 } |
224 | 224 |
225 bool hasUniformColor = inputColorIsUsed && (isPathRendering || !descInfo.fHa
sVertexColor); | 225 if (!optState.newStyle()) { |
| 226 bool hasUniformColor = inputColorIsUsed && (isPathRendering || !descInfo
.fHasVertexColor); |
226 | 227 |
227 if (!inputColorIsUsed) { | 228 if (!inputColorIsUsed) { |
228 header->fColorInput = GrProgramDesc::kAllOnes_ColorInput; | 229 header->fColorInput = GrProgramDesc::kAllOnes_ColorInput; |
229 } else if (hasUniformColor) { | 230 } else if (hasUniformColor) { |
230 header->fColorInput = GrProgramDesc::kUniform_ColorInput; | 231 header->fColorInput = GrProgramDesc::kUniform_ColorInput; |
| 232 } else { |
| 233 header->fColorInput = GrProgramDesc::kAttribute_ColorInput; |
| 234 SkASSERT(!header->fUseNvpr); |
| 235 } |
| 236 |
| 237 bool hasVertexCoverage = !isPathRendering && descInfo.fHasVertexCoverage
; |
| 238 |
| 239 bool covIsSolidWhite = !hasVertexCoverage && 0xffffffff == optState.getC
overageColor(); |
| 240 |
| 241 if (covIsSolidWhite || !inputCoverageIsUsed) { |
| 242 header->fCoverageInput = GrProgramDesc::kAllOnes_ColorInput; |
| 243 } else if (!hasVertexCoverage) { |
| 244 header->fCoverageInput = GrProgramDesc::kUniform_ColorInput; |
| 245 } else { |
| 246 header->fCoverageInput = GrProgramDesc::kAttribute_ColorInput; |
| 247 SkASSERT(!header->fUseNvpr); |
| 248 } |
231 } else { | 249 } else { |
232 header->fColorInput = GrProgramDesc::kAttribute_ColorInput; | 250 header->fColorInput = GrProgramDesc::kAttribute_ColorInput; |
233 SkASSERT(!header->fUseNvpr); | |
234 } | |
235 | |
236 bool hasVertexCoverage = !isPathRendering && descInfo.fHasVertexCoverage; | |
237 | |
238 bool covIsSolidWhite = !hasVertexCoverage && 0xffffffff == optState.getCover
ageColor(); | |
239 | |
240 if (covIsSolidWhite || !inputCoverageIsUsed) { | |
241 header->fCoverageInput = GrProgramDesc::kAllOnes_ColorInput; | |
242 } else if (!hasVertexCoverage) { | |
243 header->fCoverageInput = GrProgramDesc::kUniform_ColorInput; | |
244 } else { | |
245 header->fCoverageInput = GrProgramDesc::kAttribute_ColorInput; | 251 header->fCoverageInput = GrProgramDesc::kAttribute_ColorInput; |
246 SkASSERT(!header->fUseNvpr); | |
247 } | 252 } |
248 | 253 |
249 if (descInfo.fReadsDst) { | 254 if (descInfo.fReadsDst) { |
250 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy(); | 255 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy(); |
251 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); | 256 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); |
252 const GrTexture* dstCopyTexture = NULL; | 257 const GrTexture* dstCopyTexture = NULL; |
253 if (dstCopy) { | 258 if (dstCopy) { |
254 dstCopyTexture = dstCopy->texture(); | 259 dstCopyTexture = dstCopy->texture(); |
255 } | 260 } |
256 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, | 261 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, |
257 gpu->glCa
ps()); | 262 gpu->glCa
ps()); |
258 SkASSERT(0 != header->fDstReadKey); | 263 SkASSERT(0 != header->fDstReadKey); |
259 } else { | 264 } else { |
260 header->fDstReadKey = 0; | 265 header->fDstReadKey = 0; |
261 } | 266 } |
262 | 267 |
263 if (descInfo.fReadsFragPosition) { | 268 if (descInfo.fReadsFragPosition) { |
264 header->fFragPosKey = | 269 header->fFragPosKey = |
265 GrGLFragmentShaderBuilder::KeyForFragmentPosition(optState.getRe
nderTarget(), | 270 GrGLFragmentShaderBuilder::KeyForFragmentPosition(optState.getRe
nderTarget(), |
266 gpu->glCaps())
; | 271 gpu->glCaps())
; |
267 } else { | 272 } else { |
268 header->fFragPosKey = 0; | 273 header->fFragPosKey = 0; |
269 } | 274 } |
270 | 275 |
271 header->fColorEffectCnt = optState.numColorStages(); | 276 header->fColorEffectCnt = optState.numColorStages(); |
272 header->fCoverageEffectCnt = optState.numCoverageStages(); | 277 header->fCoverageEffectCnt = optState.numCoverageStages(); |
273 desc->finalize(); | 278 desc->finalize(); |
274 return true; | 279 return true; |
275 } | 280 } |
OLD | NEW |