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 "gl/builders/GrGLFragmentShaderBuilder.h" | 8 #include "gl/builders/GrGLFragmentShaderBuilder.h" |
9 #include "GrGLProgramDesc.h" | 9 #include "GrGLProgramDesc.h" |
10 #include "GrBackendProcessorFactory.h" | 10 #include "GrBackendProcessorFactory.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // below here. | 250 // below here. |
251 KeyHeader* header = desc->header(); | 251 KeyHeader* header = desc->header(); |
252 | 252 |
253 // make sure any padding in the header is zeroed. | 253 // make sure any padding in the header is zeroed. |
254 memset(header, 0, kHeaderSize); | 254 memset(header, 0, kHeaderSize); |
255 | 255 |
256 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); | 256 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); |
257 | 257 |
258 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; | 258 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; |
259 | 259 |
260 if (gpu->caps()->pathRenderingSupport() && | 260 bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType); |
261 GrGpu::IsPathRenderingDrawType(drawType) && | 261 if (gpu->caps()->pathRenderingSupport() && isPathRendering) { |
262 gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunct
ion_TexturingMode) { | 262 header->fUseNvpr = true; |
263 header->fUseFragShaderOnly = true; | |
264 SkASSERT(!optState.hasGeometryProcessor()); | 263 SkASSERT(!optState.hasGeometryProcessor()); |
265 } else { | 264 } else { |
266 header->fUseFragShaderOnly = false; | 265 header->fUseNvpr = false; |
267 } | 266 } |
268 | 267 |
269 bool defaultToUniformInputs = GrGpu::IsPathRenderingDrawType(drawType) || | 268 bool hasUniformColor = inputColorIsUsed && |
270 GR_GL_NO_CONSTANT_ATTRIBUTES; | 269 (isPathRendering || !optState.hasColorVertexAttribute
()); |
| 270 |
| 271 bool hasUniformCoverage = inputCoverageIsUsed && |
| 272 (isPathRendering || !optState.hasCoverageVertexAtt
ribute()); |
271 | 273 |
272 if (!inputColorIsUsed) { | 274 if (!inputColorIsUsed) { |
273 header->fColorInput = kAllOnes_ColorInput; | 275 header->fColorInput = kAllOnes_ColorInput; |
274 } else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) { | 276 } else if (hasUniformColor) { |
275 header->fColorInput = kUniform_ColorInput; | 277 header->fColorInput = kUniform_ColorInput; |
276 } else { | 278 } else { |
277 header->fColorInput = kAttribute_ColorInput; | 279 header->fColorInput = kAttribute_ColorInput; |
278 SkASSERT(!header->fUseFragShaderOnly); | 280 SkASSERT(!header->fUseNvpr); |
279 } | 281 } |
280 | 282 |
281 bool covIsSolidWhite = !optState.hasCoverageVertexAttribute() && | 283 bool covIsSolidWhite = !optState.hasCoverageVertexAttribute() && |
282 0xffffffff == optState.getCoverageColor(); | 284 0xffffffff == optState.getCoverageColor(); |
283 | 285 |
284 if (covIsSolidWhite || !inputCoverageIsUsed) { | 286 if (covIsSolidWhite || !inputCoverageIsUsed) { |
285 header->fCoverageInput = kAllOnes_ColorInput; | 287 header->fCoverageInput = kAllOnes_ColorInput; |
286 } else if (defaultToUniformInputs && !optState.hasCoverageVertexAttribute())
{ | 288 } else if (hasUniformCoverage) { |
287 header->fCoverageInput = kUniform_ColorInput; | 289 header->fCoverageInput = kUniform_ColorInput; |
288 } else { | 290 } else { |
289 header->fCoverageInput = kAttribute_ColorInput; | 291 header->fCoverageInput = kAttribute_ColorInput; |
290 SkASSERT(!header->fUseFragShaderOnly); | 292 SkASSERT(!header->fUseNvpr); |
291 } | 293 } |
292 | 294 |
293 if (optState.readsDst()) { | 295 if (optState.readsDst()) { |
294 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); | 296 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); |
295 const GrTexture* dstCopyTexture = NULL; | 297 const GrTexture* dstCopyTexture = NULL; |
296 if (dstCopy) { | 298 if (dstCopy) { |
297 dstCopyTexture = dstCopy->texture(); | 299 dstCopyTexture = dstCopy->texture(); |
298 } | 300 } |
299 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, | 301 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, |
300 gpu->glCa
ps()); | 302 gpu->glCa
ps()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 *checksum = 0; | 356 *checksum = 0; |
355 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 357 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
356 } | 358 } |
357 | 359 |
358 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 360 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
359 size_t keyLength = other.keyLength(); | 361 size_t keyLength = other.keyLength(); |
360 fKey.reset(keyLength); | 362 fKey.reset(keyLength); |
361 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 363 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
362 return *this; | 364 return *this; |
363 } | 365 } |
OLD | NEW |