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/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrGLProgramDesc.h" | 9 #include "GrGLProgramDesc.h" |
10 #include "GrBackendEffectFactory.h" | 10 #include "GrBackendEffectFactory.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 b)) { | 32 b)) { |
33 return false; | 33 return false; |
34 } | 34 } |
35 return true; | 35 return true; |
36 } | 36 } |
37 | 37 |
38 bool GrGLProgramDesc::Build(const GrOptDrawState& optState, | 38 bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
39 GrGpu::DrawType drawType, | 39 GrGpu::DrawType drawType, |
40 GrBlendCoeff srcCoeff, | 40 GrBlendCoeff srcCoeff, |
41 GrBlendCoeff dstCoeff, | 41 GrBlendCoeff dstCoeff, |
42 const GrGpuGL* gpu, | 42 GrGpuGL* gpu, |
43 const GrDeviceCoordTexture* dstCopy, | 43 const GrDeviceCoordTexture* dstCopy, |
44 const GrEffectStage** geometryProcessor, | 44 const GrEffectStage** geometryProcessor, |
45 SkTArray<const GrEffectStage*, true>* colorStages, | 45 SkTArray<const GrEffectStage*, true>* colorStages, |
46 SkTArray<const GrEffectStage*, true>* coverageStages , | 46 SkTArray<const GrEffectStage*, true>* coverageStages , |
47 GrGLProgramDesc* desc) { | 47 GrGLProgramDesc* desc) { |
48 colorStages->reset(); | 48 colorStages->reset(); |
49 coverageStages->reset(); | 49 coverageStages->reset(); |
50 | 50 |
51 bool inputColorIsUsed = optState.inputColorIsUsed(); | 51 bool inputColorIsUsed = optState.inputColorIsUsed(); |
52 bool inputCoverageIsUsed = optState.inputColorIsUsed(); | 52 bool inputCoverageIsUsed = optState.inputColorIsUsed(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 } | 129 } |
130 | 130 |
131 if (!effectKeySuccess) { | 131 if (!effectKeySuccess) { |
132 desc->fKey.reset(); | 132 desc->fKey.reset(); |
133 return false; | 133 return false; |
134 } | 134 } |
135 | 135 |
136 // Because header is a pointer into the dynamic array, we can't push any new data into the key | 136 // Because header is a pointer into the dynamic array, we can't push any new data into the key |
137 // below here. | 137 // below here. |
138 | 138 |
139 // We will only require a vertex shader if we have more than just the positi on VA attrib. | 139 header->fDoPathRendering = gpu->caps()->pathRenderingSupport() && |
egdaniel
2014/09/19 17:18:45
in a future CL I may move this logic into ODS.
| |
140 // If we have a geom processor we must us a vertex shader and we should not have a geometry | 140 GrGpu::IsPathRenderingDrawType(drawType) && |
141 // processor if we are doing path rendering. | 141 gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunct ion_TexturingMode; |
142 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType) || !optState.requiresVert exShader()); | 142 SkASSERT(!header->fDoPathRendering || !optState.hasGeometryProcessor()); |
143 header->fRequiresVertexShader = optState.requiresVertexShader() || | 143 |
144 !GrGpu::IsPathRenderingDrawType(drawType); | |
145 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; | 144 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; |
146 | 145 |
147 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything | 146 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything |
148 // other than pass through values from the VS to the FS anyway). | 147 // other than pass through values from the VS to the FS anyway). |
149 #if GR_GL_EXPERIMENTAL_GS | 148 #if GR_GL_EXPERIMENTAL_GS |
150 #if 0 | 149 #if 0 |
151 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); | 150 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); |
152 #else | 151 #else |
153 header->fExperimentalGS = false; | 152 header->fExperimentalGS = false; |
154 #endif | 153 #endif |
155 #endif | 154 #endif |
156 bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || gpu->caps()->p athRenderingSupport(); | 155 bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || header->fDoPat hRendering; |
157 | 156 |
158 if (!inputColorIsUsed) { | 157 if (!inputColorIsUsed) { |
159 header->fColorInput = kAllOnes_ColorInput; | 158 header->fColorInput = kAllOnes_ColorInput; |
160 } else if (defaultToUniformInputs && !requiresColorAttrib) { | 159 } else if (defaultToUniformInputs && !requiresColorAttrib) { |
161 header->fColorInput = kUniform_ColorInput; | 160 header->fColorInput = kUniform_ColorInput; |
162 } else { | 161 } else { |
163 header->fColorInput = kAttribute_ColorInput; | 162 header->fColorInput = kAttribute_ColorInput; |
164 header->fRequiresVertexShader = true; | 163 header->fDoPathRendering = false; |
165 } | 164 } |
166 | 165 |
167 bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == optState.get CoverageColor(); | 166 bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == optState.get CoverageColor(); |
168 | 167 |
169 if (covIsSolidWhite || !inputCoverageIsUsed) { | 168 if (covIsSolidWhite || !inputCoverageIsUsed) { |
170 header->fCoverageInput = kAllOnes_ColorInput; | 169 header->fCoverageInput = kAllOnes_ColorInput; |
171 } else if (defaultToUniformInputs && !requiresCoverageAttrib) { | 170 } else if (defaultToUniformInputs && !requiresCoverageAttrib) { |
172 header->fCoverageInput = kUniform_ColorInput; | 171 header->fCoverageInput = kUniform_ColorInput; |
173 } else { | 172 } else { |
174 header->fCoverageInput = kAttribute_ColorInput; | 173 header->fCoverageInput = kAttribute_ColorInput; |
175 header->fRequiresVertexShader = true; | 174 header->fDoPathRendering = false; |
176 } | 175 } |
177 | 176 |
178 if (optState.readsDst()) { | 177 if (optState.readsDst()) { |
179 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); | 178 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); |
180 const GrTexture* dstCopyTexture = NULL; | 179 const GrTexture* dstCopyTexture = NULL; |
181 if (dstCopy) { | 180 if (dstCopy) { |
182 dstCopyTexture = dstCopy->texture(); | 181 dstCopyTexture = dstCopy->texture(); |
183 } | 182 } |
184 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe xture, | 183 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe xture, |
185 gpu->glCaps()); | 184 gpu->glCaps()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 *checksum = 0; | 282 *checksum = 0; |
284 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k eyLength); | 283 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k eyLength); |
285 } | 284 } |
286 | 285 |
287 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 286 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
288 size_t keyLength = other.keyLength(); | 287 size_t keyLength = other.keyLength(); |
289 fKey.reset(keyLength); | 288 fKey.reset(keyLength); |
290 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 289 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
291 return *this; | 290 return *this; |
292 } | 291 } |
OLD | NEW |