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 "builders/GrGLProgramBuilder.h" | 12 #include "builders/GrGLProgramBuilder.h" |
13 #include "builders/GrGLNvprProgramBuilder.h" | |
14 #include "GrDrawState.h" | 13 #include "GrDrawState.h" |
15 #include "GrGLContext.h" | 14 #include "GrGLContext.h" |
16 #include "GrGLProgramDesc.h" | 15 #include "GrGLProgramDesc.h" |
17 #include "GrGLSL.h" | 16 #include "GrGLSL.h" |
18 #include "GrGLTexture.h" | 17 #include "GrGLTexture.h" |
19 #include "GrGLProgramDataManager.h" | 18 #include "GrGLProgramDataManager.h" |
20 | 19 |
21 #include "SkString.h" | 20 #include "SkString.h" |
22 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
23 | 22 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 const GrProgramDesc&, | 110 const GrProgramDesc&, |
112 const BuiltinUniformHandles&, | 111 const BuiltinUniformHandles&, |
113 GrGLuint programID, | 112 GrGLuint programID, |
114 const UniformInfoArray&, | 113 const UniformInfoArray&, |
115 GrGLInstalledGeoProc* geometryProcessor, | 114 GrGLInstalledGeoProc* geometryProcessor, |
116 GrGLInstalledXferProc* xferProcessor, | 115 GrGLInstalledXferProc* xferProcessor, |
117 GrGLInstalledFragProcs* fragmentProcessors); | 116 GrGLInstalledFragProcs* fragmentProcessors); |
118 | 117 |
119 // Sets the texture units for samplers. | 118 // Sets the texture units for samplers. |
120 void initSamplerUniforms(); | 119 void initSamplerUniforms(); |
121 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); | 120 template <class Proc> |
| 121 void initSamplers(Proc*, int* texUnitIdx); |
122 | 122 |
123 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures | 123 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures |
124 void setFragmentData(const GrOptDrawState&); | 124 void setFragmentData(const GrOptDrawState&); |
125 virtual void setTransformData(const GrPendingFragmentStage&, | 125 virtual void setTransformData(const GrPrimitiveProcessor*, |
126 const SkMatrix& localMatrix, | 126 const GrPendingFragmentStage&, |
| 127 int index, |
127 GrGLInstalledFragProc*); | 128 GrGLInstalledFragProc*); |
128 void bindTextures(const GrGLInstalledProc*, const GrProcessor&); | 129 template <class Proc> |
| 130 void bindTextures(const Proc*, const GrProcessor&); |
129 | 131 |
130 /* | 132 /* |
131 * Legacy NVPR needs a hook here to flush path tex gen settings. | 133 * Legacy NVPR needs a hook here to flush path tex gen settings. |
132 * TODO when legacy nvpr is removed, remove this call. | 134 * TODO when legacy nvpr is removed, remove this call. |
133 */ | 135 */ |
134 virtual void didSetData(GrGpu::DrawType); | 136 virtual void didSetData(GrGpu::DrawType); |
135 | 137 |
136 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 138 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
137 void setRenderTargetState(const GrOptDrawState&); | 139 void setRenderTargetState(const GrOptDrawState&); |
138 virtual void onSetRenderTargetState(const GrOptDrawState&); | 140 virtual void onSetRenderTargetState(const GrOptDrawState&); |
(...skipping 20 matching lines...) Expand all Loading... |
159 typedef SkRefCnt INHERITED; | 161 typedef SkRefCnt INHERITED; |
160 }; | 162 }; |
161 | 163 |
162 /* | 164 /* |
163 * Below are slight specializations of the program object for the different type
s of programs | 165 * Below are slight specializations of the program object for the different type
s of programs |
164 * The default GrGL programs consist of at the very least a vertex and fragment
shader. | 166 * The default GrGL programs consist of at the very least a vertex and fragment
shader. |
165 * Legacy Nvpr only has a fragment shader, 1.3+ Nvpr ignores the vertex shader,
but both require | 167 * Legacy Nvpr only has a fragment shader, 1.3+ Nvpr ignores the vertex shader,
but both require |
166 * specialized methods for setting transform data. Both types of NVPR also requi
re setting the | 168 * specialized methods for setting transform data. Both types of NVPR also requi
re setting the |
167 * projection matrix through a special function call | 169 * projection matrix through a special function call |
168 */ | 170 */ |
169 class GrGLNvprProgramBase : public GrGLProgram { | 171 class GrGLNvprProgram : public GrGLProgram { |
170 protected: | 172 protected: |
171 GrGLNvprProgramBase(GrGLGpu*, | |
172 const GrProgramDesc&, | |
173 const BuiltinUniformHandles&, | |
174 GrGLuint programID, | |
175 const UniformInfoArray&, | |
176 GrGLInstalledGeoProc*, | |
177 GrGLInstalledXferProc* xferProcessor, | |
178 GrGLInstalledFragProcs* fragmentProcessors); | |
179 virtual void onSetRenderTargetState(const GrOptDrawState&); | |
180 | |
181 typedef GrGLProgram INHERITED; | |
182 }; | |
183 | |
184 class GrGLNvprProgram : public GrGLNvprProgramBase { | |
185 public: | |
186 bool hasVertexShader() const SK_OVERRIDE { return true; } | |
187 | |
188 private: | |
189 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; | |
190 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; | |
191 GrGLNvprProgram(GrGLGpu*, | 173 GrGLNvprProgram(GrGLGpu*, |
192 const GrProgramDesc&, | 174 const GrProgramDesc&, |
193 const BuiltinUniformHandles&, | 175 const BuiltinUniformHandles&, |
194 GrGLuint programID, | 176 GrGLuint programID, |
195 const UniformInfoArray&, | 177 const UniformInfoArray&, |
196 GrGLInstalledGeoProc*, | 178 GrGLInstalledGeoProc*, |
197 GrGLInstalledXferProc* xferProcessor, | 179 GrGLInstalledXferProc* xferProcessor, |
198 GrGLInstalledFragProcs* fragmentProcessors, | 180 GrGLInstalledFragProcs* fragmentProcessors); |
199 const SeparableVaryingInfoArray& separableVaryings); | 181 |
| 182 private: |
200 void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 183 void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
201 virtual void setTransformData(const GrPendingFragmentStage&, | 184 virtual void setTransformData(const GrPrimitiveProcessor*, |
202 const SkMatrix& localMatrix, | 185 const GrPendingFragmentStage&, |
| 186 int index, |
203 GrGLInstalledFragProc*) SK_OVERRIDE; | 187 GrGLInstalledFragProc*) SK_OVERRIDE; |
204 | 188 virtual void onSetRenderTargetState(const GrOptDrawState&); |
205 struct Varying { | |
206 GrGLint fLocation; | |
207 SkDEBUGCODE( | |
208 GrSLType fType; | |
209 ); | |
210 }; | |
211 SkTArray<Varying, true> fVaryings; | |
212 | 189 |
213 friend class GrGLNvprProgramBuilder; | 190 friend class GrGLNvprProgramBuilder; |
214 | 191 |
215 typedef GrGLNvprProgramBase INHERITED; | 192 typedef GrGLProgram INHERITED; |
216 }; | |
217 | |
218 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { | |
219 public: | |
220 bool hasVertexShader() const SK_OVERRIDE { return false; } | |
221 | |
222 private: | |
223 GrGLLegacyNvprProgram(GrGLGpu* gpu, | |
224 const GrProgramDesc& desc, | |
225 const BuiltinUniformHandles&, | |
226 GrGLuint programID, | |
227 const UniformInfoArray&, | |
228 GrGLInstalledGeoProc*, | |
229 GrGLInstalledXferProc* xp, | |
230 GrGLInstalledFragProcs* fps, | |
231 int texCoordSetCnt); | |
232 void didSetData(GrGpu::DrawType) SK_OVERRIDE; | |
233 virtual void setTransformData(const GrPendingFragmentStage&, | |
234 const SkMatrix& localMatrix, | |
235 GrGLInstalledFragProc*) SK_OVERRIDE; | |
236 | |
237 int fTexCoordSetCnt; | |
238 | |
239 friend class GrGLLegacyNvprProgramBuilder; | |
240 | |
241 typedef GrGLNvprProgramBase INHERITED; | |
242 }; | 193 }; |
243 | 194 |
244 #endif | 195 #endif |
OLD | NEW |