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