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