| 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 "GrDrawState.h" | 12 #include "GrDrawState.h" |
| 13 #include "GrGLContext.h" | 13 #include "GrGLContext.h" |
| 14 #include "GrGLCoordTransform.h" |
| 14 #include "GrGLProgramDesc.h" | 15 #include "GrGLProgramDesc.h" |
| 15 #include "GrGLShaderBuilder.h" | 16 #include "GrGLShaderBuilder.h" |
| 16 #include "GrGLSL.h" | 17 #include "GrGLSL.h" |
| 17 #include "GrGLTexture.h" | 18 #include "GrGLTexture.h" |
| 18 #include "GrGLUniformManager.h" | 19 #include "GrGLUniformManager.h" |
| 19 | 20 |
| 20 #include "SkString.h" | 21 #include "SkString.h" |
| 21 #include "SkXfermode.h" | 22 #include "SkXfermode.h" |
| 22 | 23 |
| 23 class GrBinHashKeyBuilder; | 24 class GrBinHashKeyBuilder; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // We use the render target height to provide a y-down frag coord when s
pecifying | 142 // We use the render target height to provide a y-down frag coord when s
pecifying |
| 142 // origin_upper_left is not supported. | 143 // origin_upper_left is not supported. |
| 143 UniformHandle fRTHeightUni; | 144 UniformHandle fRTHeightUni; |
| 144 | 145 |
| 145 // Uniforms for computing texture coords to do the dst-copy lookup | 146 // Uniforms for computing texture coords to do the dst-copy lookup |
| 146 UniformHandle fDstCopyTopLeftUni; | 147 UniformHandle fDstCopyTopLeftUni; |
| 147 UniformHandle fDstCopyScaleUni; | 148 UniformHandle fDstCopyScaleUni; |
| 148 UniformHandle fDstCopySamplerUni; | 149 UniformHandle fDstCopySamplerUni; |
| 149 }; | 150 }; |
| 150 | 151 |
| 152 typedef SkSTArray<4, GrGLCoordTransform, false> CoordTransformSArray; |
| 151 typedef SkSTArray<4, UniformHandle, true> SamplerUniSArray; | 153 typedef SkSTArray<4, UniformHandle, true> SamplerUniSArray; |
| 152 typedef SkSTArray<4, int, true> TextureUnitSArray; | 154 typedef SkSTArray<4, int, true> TextureUnitSArray; |
| 153 | 155 |
| 154 struct EffectAndSamplers { | 156 struct EffectAndSamplers { |
| 155 EffectAndSamplers() : fGLEffect(NULL) {} | 157 EffectAndSamplers() : fGLEffect(NULL) {} |
| 156 ~EffectAndSamplers() { delete fGLEffect; } | 158 ~EffectAndSamplers() { delete fGLEffect; } |
| 157 GrGLEffect* fGLEffect; | 159 GrGLEffect* fGLEffect; |
| 158 SamplerUniSArray fSamplerUnis; // sampler uni handles for effect's G
rTextureAccess | 160 CoordTransformSArray fCoordTransforms; |
| 159 TextureUnitSArray fTextureUnits; // texture unit used for each entry o
f fSamplerUnis | 161 SamplerUniSArray fSamplerUnis; // sampler uni handles for effect's
GrTextureAccess |
| 162 TextureUnitSArray fTextureUnits; // texture unit used for each entry
of fSamplerUnis |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 GrGLProgram(GrGpuGL* gpu, | 165 GrGLProgram(GrGpuGL* gpu, |
| 163 const GrGLProgramDesc& desc, | 166 const GrGLProgramDesc& desc, |
| 164 const GrEffectStage* colorStages[], | 167 const GrEffectStage* colorStages[], |
| 165 const GrEffectStage* coverageStages[]); | 168 const GrEffectStage* coverageStages[]); |
| 166 | 169 |
| 167 bool succeeded() const { return 0 != fProgramID; } | 170 bool succeeded() const { return 0 != fProgramID; } |
| 168 | 171 |
| 169 /** | 172 /** |
| 170 * This is the heavy initialization routine for building a GLProgram. colorS
tages and | 173 * This is the heavy initialization routine for building a GLProgram. colorS
tages and |
| 171 * coverageStages correspond to the output of GrGLProgramDesc::Build(). | 174 * coverageStages correspond to the output of GrGLProgramDesc::Build(). |
| 172 */ | 175 */ |
| 173 bool genProgram(const GrEffectStage* colorStages[], const GrEffectStage* cov
erageStages[]); | 176 bool genProgram(const GrEffectStage* colorStages[], const GrEffectStage* cov
erageStages[]); |
| 174 | 177 |
| 175 // Sets the texture units for samplers | 178 // Sets the texture units for samplers |
| 176 void initSamplerUniforms(); | 179 void initSamplerUniforms(); |
| 177 void initEffectSamplerUniforms(EffectAndSamplers* effect, int* texUnitIdx); | 180 void initEffectSamplerUniforms(EffectAndSamplers* effect, int* texUnitIdx); |
| 178 | 181 |
| 179 // Helper for setData(). | 182 // Helper for setData(). |
| 180 void setEffectData(const GrEffectStage& stage, const EffectAndSamplers& effe
ct); | 183 void setEffectData(const GrEffectStage& stage, EffectAndSamplers& effect); |
| 181 | 184 |
| 182 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not | 185 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not |
| 183 // per-vertex colors. | 186 // per-vertex colors. |
| 184 void setColor(const GrDrawState&, GrColor color, SharedGLState*); | 187 void setColor(const GrDrawState&, GrColor color, SharedGLState*); |
| 185 | 188 |
| 186 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not | 189 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not |
| 187 // per-vertex coverages. | 190 // per-vertex coverages. |
| 188 void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*); | 191 void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*); |
| 189 | 192 |
| 190 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 193 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 GrGLProgramDesc fDesc; | 209 GrGLProgramDesc fDesc; |
| 207 GrGpuGL* fGpu; | 210 GrGpuGL* fGpu; |
| 208 | 211 |
| 209 GrGLUniformManager fUniformManager; | 212 GrGLUniformManager fUniformManager; |
| 210 UniformHandles fUniformHandles; | 213 UniformHandles fUniformHandles; |
| 211 | 214 |
| 212 typedef SkRefCnt INHERITED; | 215 typedef SkRefCnt INHERITED; |
| 213 }; | 216 }; |
| 214 | 217 |
| 215 #endif | 218 #endif |
| OLD | NEW |