OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
11 | 11 |
| 12 #include "GrAllocator.h" |
12 #include "GrDrawState.h" | 13 #include "GrDrawState.h" |
13 #include "GrGLContext.h" | 14 #include "GrGLContext.h" |
14 #include "GrGLProgramDesc.h" | 15 #include "GrGLProgramDesc.h" |
15 #include "GrGLSL.h" | 16 #include "GrGLSL.h" |
16 #include "GrGLTexture.h" | 17 #include "GrGLTexture.h" |
17 #include "GrGLUniformManager.h" | 18 #include "GrGLUniform.h" |
18 | 19 |
19 #include "SkString.h" | 20 #include "SkString.h" |
20 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
21 | 22 |
22 class GrBinHashKeyBuilder; | 23 class GrBinHashKeyBuilder; |
23 class GrGLEffect; | 24 class GrGLEffect; |
24 class GrGLShaderBuilder; | 25 class GrGLShaderBuilder; |
25 | 26 |
26 /** | 27 /** |
27 * This class manages a GPU program and records per-program information. | 28 * This class manages a GPU program and records per-program information. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 * GrGpuGL object to bind the textures required by the GrGLEffects. The colo
r and coverage | 108 * GrGpuGL object to bind the textures required by the GrGLEffects. The colo
r and coverage |
108 * stages come from GrGLProgramDesc::Build(). | 109 * stages come from GrGLProgramDesc::Build(). |
109 */ | 110 */ |
110 void setData(GrGpuGL*, | 111 void setData(GrGpuGL*, |
111 GrDrawState::BlendOptFlags, | 112 GrDrawState::BlendOptFlags, |
112 const GrEffectStage* colorStages[], | 113 const GrEffectStage* colorStages[], |
113 const GrEffectStage* coverageStages[], | 114 const GrEffectStage* coverageStages[], |
114 const GrDeviceCoordTexture* dstCopy, // can be NULL | 115 const GrDeviceCoordTexture* dstCopy, // can be NULL |
115 SharedGLState*); | 116 SharedGLState*); |
116 | 117 |
| 118 |
| 119 /** |
| 120 * Called by the GrGLShaderBuilder to create uniforms. |
| 121 */ |
| 122 GrGLUniform* appendUniform() { |
| 123 GrGLUniform& uni = fUniforms.push_back(); |
| 124 return &uni; |
| 125 } |
| 126 |
117 private: | 127 private: |
118 typedef GrGLUniformManager::UniformHandle UniformHandle; | |
119 | |
120 // handles for uniforms (aside from per-effect samplers) | 128 // handles for uniforms (aside from per-effect samplers) |
121 struct UniformHandles { | 129 struct NamedUniforms { |
122 UniformHandle fViewMatrixUni; | 130 GrGLUniform* fViewMatrixUni; |
123 UniformHandle fColorUni; | 131 GrGLUniform* fColorUni; |
124 UniformHandle fCoverageUni; | 132 GrGLUniform* fCoverageUni; |
125 UniformHandle fColorFilterUni; | 133 GrGLUniform* fColorFilterUni; |
126 | 134 |
127 // We use the render target height to provide a y-down frag coord when s
pecifying | 135 // We use the render target height to provide a y-down frag coord when s
pecifying |
128 // origin_upper_left is not supported. | 136 // origin_upper_left is not supported. |
129 UniformHandle fRTHeightUni; | 137 GrGLUniform* fRTHeightUni; |
130 | 138 |
131 // Uniforms for computing texture coords to do the dst-copy lookup | 139 // Uniforms for computing texture coords to do the dst-copy lookup |
132 UniformHandle fDstCopyTopLeftUni; | 140 GrGLUniform* fDstCopyTopLeftUni; |
133 UniformHandle fDstCopyScaleUni; | 141 GrGLUniform* fDstCopyScaleUni; |
134 UniformHandle fDstCopySamplerUni; | 142 GrGLUniform* fDstCopySamplerUni; |
135 | 143 |
136 UniformHandles() { | 144 NamedUniforms() |
137 fViewMatrixUni = GrGLUniformManager::kInvalidUniformHandle; | 145 : fViewMatrixUni(NULL) |
138 fColorUni = GrGLUniformManager::kInvalidUniformHandle; | 146 , fColorUni(NULL) |
139 fCoverageUni = GrGLUniformManager::kInvalidUniformHandle; | 147 , fCoverageUni(NULL) |
140 fColorFilterUni = GrGLUniformManager::kInvalidUniformHandle; | 148 , fColorFilterUni(NULL) |
141 fRTHeightUni = GrGLUniformManager::kInvalidUniformHandle; | 149 , fRTHeightUni(NULL) |
142 fDstCopyTopLeftUni = GrGLUniformManager::kInvalidUniformHandle; | 150 , fDstCopyTopLeftUni(NULL) |
143 fDstCopyScaleUni = GrGLUniformManager::kInvalidUniformHandle; | 151 , fDstCopyScaleUni(NULL) |
144 fDstCopySamplerUni = GrGLUniformManager::kInvalidUniformHandle; | 152 , fDstCopySamplerUni(NULL) { |
145 } | 153 } |
146 }; | 154 }; |
147 | 155 |
148 typedef SkSTArray<4, UniformHandle, true> SamplerUniSArray; | 156 typedef SkSTArray<4, GrGLUniform*, true> SamplerUniSArray; |
149 typedef SkSTArray<4, int, true> TextureUnitSArray; | 157 typedef SkSTArray<4, int, true> TextureUnitSArray; |
150 | 158 |
151 struct EffectAndSamplers { | 159 struct EffectAndSamplers { |
152 EffectAndSamplers() : fGLEffect(NULL) {} | 160 EffectAndSamplers() : fGLEffect(NULL) {} |
153 ~EffectAndSamplers() { delete fGLEffect; } | 161 ~EffectAndSamplers() { delete fGLEffect; } |
154 GrGLEffect* fGLEffect; | 162 GrGLEffect* fGLEffect; |
155 SamplerUniSArray fSamplerUnis; // sampler uni handles for effect's G
rTextureAccess | 163 SamplerUniSArray fSamplerUnis; // sampler uni handles for effect's G
rTextureAccess |
156 TextureUnitSArray fTextureUnits; // texture unit used for each entry o
f fSamplerUnis | 164 TextureUnitSArray fTextureUnits; // texture unit used for each entry o
f fSamplerUnis |
157 }; | 165 }; |
158 | 166 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 GrColor fCoverage; | 222 GrColor fCoverage; |
215 GrColor fColorFilterColor; | 223 GrColor fColorFilterColor; |
216 int fDstCopyTexUnit; | 224 int fDstCopyTexUnit; |
217 | 225 |
218 SkTArray<EffectAndSamplers> fColorEffects; | 226 SkTArray<EffectAndSamplers> fColorEffects; |
219 SkTArray<EffectAndSamplers> fCoverageEffects; | 227 SkTArray<EffectAndSamplers> fCoverageEffects; |
220 | 228 |
221 GrGLProgramDesc fDesc; | 229 GrGLProgramDesc fDesc; |
222 const GrGLContext& fContext; | 230 const GrGLContext& fContext; |
223 | 231 |
224 GrGLUniformManager fUniformManager; | 232 GrTAllocator<GrGLUniform> fUniforms; |
225 UniformHandles fUniformHandles; | 233 NamedUniforms fNamedUniforms; |
226 | 234 |
227 typedef GrRefCnt INHERITED; | 235 typedef GrRefCnt INHERITED; |
228 }; | 236 }; |
229 | 237 |
230 #endif | 238 #endif |
OLD | NEW |