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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 | 217 |
218 int numStages = optState.numTotalStages(); | 218 int numStages = optState.numTotalStages(); |
219 | 219 |
220 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); | 220 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); |
221 // Make room for everything up to and including the array of offsets to effe ct keys. | 221 // Make room for everything up to and including the array of offsets to effe ct keys. |
222 desc->fKey.reset(); | 222 desc->fKey.reset(); |
223 desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_ t) * numStages); | 223 desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_ t) * numStages); |
224 | 224 |
225 int offsetAndSizeIndex = 0; | 225 int offsetAndSizeIndex = 0; |
226 | 226 |
227 // We can only have one effect which touches the vertex shader | 227 bool noGP = gpu->caps()->pathRenderingSupport() && GrGpu::IsPathRenderingDra wType(drawType); |
228 if (optState.hasGeometryProcessor()) { | 228 |
229 // We can only have one effect which touches the vertex shader, optState wil l install a | |
230 // default GP if none are available | |
231 if (!noGP) { | |
229 if (!BuildStagedProcessorKey<GeometryProcessorKeyBuilder>(*optState.getG eometryProcessor(), | 232 if (!BuildStagedProcessorKey<GeometryProcessorKeyBuilder>(*optState.getG eometryProcessor(), |
230 gpu->glCaps(), | 233 gpu->glCaps(), |
231 false, | 234 false, |
232 desc, | 235 desc, |
233 &offsetAndSize Index)) { | 236 &offsetAndSize Index)) { |
234 return false; | 237 return false; |
235 } | 238 } |
236 } | 239 } |
237 | 240 |
238 for (int s = 0; s < optState.numFragmentStages(); ++s) { | 241 for (int s = 0; s < optState.numFragmentStages(); ++s) { |
239 if (!BuildStagedProcessorKey<FragmentProcessorKeyBuilder>(optState.getFr agmentStage(s), | 242 if (!BuildStagedProcessorKey<FragmentProcessorKeyBuilder>(optState.getFr agmentStage(s), |
240 gpu->glCaps(), | 243 gpu->glCaps(), |
241 requiresLocalC oordAttrib, | 244 requiresLocalC oordAttrib, |
242 desc, | 245 desc, |
243 &offsetAndSize Index)) { | 246 &offsetAndSize Index)) { |
244 return false; | 247 return false; |
245 } | 248 } |
246 } | 249 } |
247 | 250 |
248 // --------DO NOT MOVE HEADER ABOVE THIS LINE------------------------------- ------------------- | 251 // --------DO NOT MOVE HEADER ABOVE THIS LINE------------------------------- ------------------- |
249 // Because header is a pointer into the dynamic array, we can't push any new data into the key | 252 // Because header is a pointer into the dynamic array, we can't push any new data into the key |
250 // below here. | 253 // below here. |
251 KeyHeader* header = desc->header(); | 254 KeyHeader* header = desc->header(); |
252 | 255 |
253 // make sure any padding in the header is zeroed. | 256 // make sure any padding in the header is zeroed. |
254 memset(header, 0, kHeaderSize); | 257 memset(header, 0, kHeaderSize); |
255 | 258 |
256 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); | |
257 | |
258 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; | 259 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; |
259 | 260 |
260 if (gpu->caps()->pathRenderingSupport() && | 261 if (noGP && |
261 GrGpu::IsPathRenderingDrawType(drawType) && | |
262 gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunct ion_TexturingMode) { | 262 gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunct ion_TexturingMode) { |
263 // We still have a default geometry processor installed on the opt draw state, but it is | |
bsalomon
2014/10/27 13:43:43
I think we will have to figure out how to make the
| |
264 // ignored for generating keys, and also ignored in the programbuilder | |
263 header->fUseFragShaderOnly = true; | 265 header->fUseFragShaderOnly = true; |
264 SkASSERT(!optState.hasGeometryProcessor()); | |
265 } else { | 266 } else { |
266 header->fUseFragShaderOnly = false; | 267 header->fUseFragShaderOnly = false; |
267 } | 268 } |
268 | 269 |
269 bool defaultToUniformInputs = GrGpu::IsPathRenderingDrawType(drawType) || | 270 bool defaultToUniformInputs = GrGpu::IsPathRenderingDrawType(drawType) || |
270 GR_GL_NO_CONSTANT_ATTRIBUTES; | 271 GR_GL_NO_CONSTANT_ATTRIBUTES; |
271 | 272 |
272 if (!inputColorIsUsed) { | 273 if (!inputColorIsUsed) { |
273 header->fColorInput = kAllOnes_ColorInput; | 274 header->fColorInput = kAllOnes_ColorInput; |
274 } else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) { | 275 } else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 *checksum = 0; | 355 *checksum = 0; |
355 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k eyLength); | 356 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k eyLength); |
356 } | 357 } |
357 | 358 |
358 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 359 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
359 size_t keyLength = other.keyLength(); | 360 size_t keyLength = other.keyLength(); |
360 fKey.reset(keyLength); | 361 fKey.reset(keyLength); |
361 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 362 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
362 return *this; | 363 return *this; |
363 } | 364 } |
OLD | NEW |