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 #include "GrGLProgramDesc.h" | 7 #include "GrGLProgramDesc.h" |
8 | 8 |
9 #include "GrProcessor.h" | 9 #include "GrProcessor.h" |
10 #include "GrGLGpu.h" | |
11 #include "GrPipeline.h" | 10 #include "GrPipeline.h" |
12 #include "SkChecksum.h" | 11 #include "SkChecksum.h" |
| 12 #include "gl/GrGLDefines.h" |
| 13 #include "gl/GrGLTexture.h" |
| 14 #include "gl/GrGLTypes.h" |
13 #include "glsl/GrGLSLFragmentProcessor.h" | 15 #include "glsl/GrGLSLFragmentProcessor.h" |
14 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 16 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 17 #include "glsl/GrGLSLCaps.h" |
15 | 18 |
| 19 static uint16_t texture_target_key(GrGLenum target) { |
| 20 SkASSERT((uint32_t)target < SK_MaxU16); |
| 21 return target; |
| 22 } |
16 | 23 |
17 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, | 24 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, |
18 const GrGLSLCaps& caps) { | 25 const GrGLSLCaps& caps) { |
19 int numTextures = proc.numTextures(); | 26 int numTextures = proc.numTextures(); |
20 // Need two bytes per key (swizzle and target). | 27 // Need two bytes per key (swizzle and target). |
21 int word32Count = (proc.numTextures() + 1) / 2; | 28 int word32Count = (proc.numTextures() + 1) / 2; |
22 if (0 == word32Count) { | 29 if (0 == word32Count) { |
23 return; | 30 return; |
24 } | 31 } |
25 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); | 32 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); |
26 for (int i = 0; i < numTextures; ++i) { | 33 for (int i = 0; i < numTextures; ++i) { |
27 const GrTextureAccess& access = proc.textureAccess(i); | 34 const GrTextureAccess& access = proc.textureAccess(i); |
28 bool isExternal = (GR_GL_TEXTURE_EXTERNAL == | 35 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture()); |
29 static_cast<GrGLTexture*>(access.getTexture())->targe
t()); | 36 k16[i] = caps.configTextureSwizzle(texture->config()).asKey() | |
30 k16[i] = caps.configTextureSwizzle(access.getTexture()->config()).asKey(
) | | 37 (texture_target_key(texture->target()) << 16); |
31 (isExternal ? 0xFF00 : 0x0000); | |
32 } | 38 } |
33 // zero the last 16 bits if the number of textures is odd. | 39 // zero the last 16 bits if the number of textures is odd. |
34 if (numTextures & 0x1) { | 40 if (numTextures & 0x1) { |
35 k16[numTextures] = 0; | 41 k16[numTextures] = 0; |
36 } | 42 } |
37 } | 43 } |
38 | 44 |
39 /** | 45 /** |
40 * A function which emits a meta key into the key builder. This is required bec
ause shader code may | 46 * A function which emits a meta key into the key builder. This is required bec
ause shader code may |
41 * be dependent on properties of the effect that the effect itself doesn't use | 47 * be dependent on properties of the effect that the effect itself doesn't use |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } else { | 150 } else { |
145 header->fIgnoresCoverage = 0; | 151 header->fIgnoresCoverage = 0; |
146 } | 152 } |
147 | 153 |
148 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); | 154 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); |
149 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); | 155 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); |
150 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); | 156 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); |
151 glDesc->finalize(); | 157 glDesc->finalize(); |
152 return true; | 158 return true; |
153 } | 159 } |
OLD | NEW |