| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // to a canonical value to avoid duplicate programs with different keys. | 95 // to a canonical value to avoid duplicate programs with different keys. |
| 96 | 96 |
| 97 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute()
; | 97 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute()
; |
| 98 bool requiresCoverageAttrib = !skipCoverage && drawState.hasCoverageVertexAt
tribute(); | 98 bool requiresCoverageAttrib = !skipCoverage && drawState.hasCoverageVertexAt
tribute(); |
| 99 // we only need the local coords if we're actually going to generate effect
code | 99 // we only need the local coords if we're actually going to generate effect
code |
| 100 bool requiresLocalCoordAttrib = !(skipCoverage && skipColor) && | 100 bool requiresLocalCoordAttrib = !(skipCoverage && skipColor) && |
| 101 drawState.hasLocalCoordAttribute(); | 101 drawState.hasLocalCoordAttribute(); |
| 102 | 102 |
| 103 bool readsDst = false; | 103 bool readsDst = false; |
| 104 bool readFragPosition = false; | 104 bool readFragPosition = false; |
| 105 // We use vertexshader-less shader programs only when drawing paths. | 105 |
| 106 bool hasVertexCode = !(GrGpu::kDrawPath_DrawType == drawType || | 106 // Provide option for shader programs without vertex shader only when drawin
g paths. |
| 107 GrGpu::kDrawPaths_DrawType == drawType); | 107 bool hasVertexCode = !GrGpu::IsPathRenderingDrawType(drawType); |
| 108 |
| 108 int numStages = 0; | 109 int numStages = 0; |
| 109 if (!skipColor) { | 110 if (!skipColor) { |
| 110 numStages += drawState.numColorStages() - firstEffectiveColorStage; | 111 numStages += drawState.numColorStages() - firstEffectiveColorStage; |
| 111 } | 112 } |
| 112 if (!skipCoverage) { | 113 if (!skipCoverage) { |
| 113 numStages += drawState.numCoverageStages() - firstEffectiveCoverageStage
; | 114 numStages += drawState.numCoverageStages() - firstEffectiveCoverageStage
; |
| 114 } | 115 } |
| 115 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); | 116 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); |
| 116 // Make room for everything up to and including the array of offsets to effe
ct keys. | 117 // Make room for everything up to and including the array of offsets to effe
ct keys. |
| 117 desc->fKey.reset(); | 118 desc->fKey.reset(); |
| 118 desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_
t) * numStages); | 119 desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_
t) * numStages); |
| 119 | 120 |
| 120 int offsetAndSizeIndex = 0; | 121 int offsetAndSizeIndex = 0; |
| 121 | |
| 122 bool effectKeySuccess = true; | 122 bool effectKeySuccess = true; |
| 123 if (!skipColor) { | 123 if (!skipColor) { |
| 124 for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); +
+s) { | 124 for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); +
+s) { |
| 125 uint16_t* offsetAndSize = | 125 uint16_t* offsetAndSize = |
| 126 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffse
tsAndLengthOffset + | 126 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffse
tsAndLengthOffset + |
| 127 offsetAndSizeIndex * 2 * sizeof(uint
16_t)); | 127 offsetAndSizeIndex * 2 * sizeof(uint
16_t)); |
| 128 | 128 |
| 129 GrEffectKeyBuilder b(&desc->fKey); | 129 GrEffectKeyBuilder b(&desc->fKey); |
| 130 uint16_t effectKeySize; | 130 uint16_t effectKeySize; |
| 131 uint32_t effectOffset = desc->fKey.count(); | 131 uint32_t effectOffset = desc->fKey.count(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 *checksum = 0; | 315 *checksum = 0; |
| 316 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 316 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
| 317 } | 317 } |
| 318 | 318 |
| 319 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 319 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
| 320 size_t keyLength = other.keyLength(); | 320 size_t keyLength = other.keyLength(); |
| 321 fKey.reset(keyLength); | 321 fKey.reset(keyLength); |
| 322 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 322 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
| 323 return *this; | 323 return *this; |
| 324 } | 324 } |
| OLD | NEW |