OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef GrGLProgramBuilder_DEFINED | 8 #ifndef GrGLProgramBuilder_DEFINED |
9 #define GrGLProgramBuilder_DEFINED | 9 #define GrGLProgramBuilder_DEFINED |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 class GrGLProgramBuilder : public GrGLGPBuilder, | 162 class GrGLProgramBuilder : public GrGLGPBuilder, |
163 public GrGLFPBuilder { | 163 public GrGLFPBuilder { |
164 public: | 164 public: |
165 /** Generates a shader program. | 165 /** Generates a shader program. |
166 * | 166 * |
167 * The program implements what is specified in the stages given as input. | 167 * The program implements what is specified in the stages given as input. |
168 * After successful generation, the builder result objects are available | 168 * After successful generation, the builder result objects are available |
169 * to be used. | 169 * to be used. |
170 * @return true if generation was successful. | 170 * @return true if generation was successful. |
171 */ | 171 */ |
172 static GrGLProgram* CreateProgram(const GrOptDrawState&, | 172 static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpu::DrawType, Gr
GpuGL*); |
173 const GrGLProgramDesc&, | |
174 GrGpu::DrawType, | |
175 GrGpuGL* gpu); | |
176 | 173 |
177 virtual UniformHandle addUniform(uint32_t visibility, | 174 virtual UniformHandle addUniform(uint32_t visibility, |
178 GrSLType type, | 175 GrSLType type, |
179 const char* name, | 176 const char* name, |
180 const char** outName = NULL) SK_OVERRIDE { | 177 const char** outName = NULL) SK_OVERRIDE { |
181 return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNon
Array, outName); | 178 return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNon
Array, outName); |
182 } | 179 } |
183 virtual UniformHandle addUniformArray(uint32_t visibility, | 180 virtual UniformHandle addUniformArray(uint32_t visibility, |
184 GrSLType type, | 181 GrSLType type, |
185 const char* name, | 182 const char* name, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // origin_upper_left is not supported. | 214 // origin_upper_left is not supported. |
218 UniformHandle fRTHeightUni; | 215 UniformHandle fRTHeightUni; |
219 | 216 |
220 // Uniforms for computing texture coords to do the dst-copy lookup | 217 // Uniforms for computing texture coords to do the dst-copy lookup |
221 UniformHandle fDstCopyTopLeftUni; | 218 UniformHandle fDstCopyTopLeftUni; |
222 UniformHandle fDstCopyScaleUni; | 219 UniformHandle fDstCopyScaleUni; |
223 UniformHandle fDstCopySamplerUni; | 220 UniformHandle fDstCopySamplerUni; |
224 }; | 221 }; |
225 | 222 |
226 protected: | 223 protected: |
227 typedef GrGLProgramDesc::ProcKeyProvider ProcKeyProvider; | 224 typedef GrProgramDesc::ProcKeyProvider ProcKeyProvider; |
228 typedef GrGLProgramDataManager::UniformInfo UniformInfo; | 225 typedef GrGLProgramDataManager::UniformInfo UniformInfo; |
229 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 226 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
230 | 227 |
231 static GrGLProgramBuilder* CreateProgramBuilder(const GrGLProgramDesc&, | 228 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, |
232 const GrOptDrawState&, | |
233 GrGpu::DrawType, | 229 GrGpu::DrawType, |
234 bool hasGeometryProcessor, | 230 bool hasGeometryProcessor, |
235 GrGpuGL*); | 231 GrGpuGL*); |
236 | 232 |
237 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&); | 233 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&); |
238 | 234 |
239 const GrOptDrawState& optState() const { return fOptState; } | 235 const GrOptDrawState& optState() const { return fOptState; } |
240 const GrGLProgramDesc& desc() const { return fDesc; } | 236 const GrProgramDesc& desc() const { return fDesc; } |
241 const GrGLProgramDesc::KeyHeader& header() const { return fDesc.getHeader();
} | 237 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
242 | 238 |
243 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 239 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
244 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 240 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
245 // generating stage code. | 241 // generating stage code. |
246 void nameVariable(SkString* out, char prefix, const char* name); | 242 void nameVariable(SkString* out, char prefix, const char* name); |
247 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r4* inputCoverage); | 243 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r4* inputCoverage); |
248 void emitAndInstallProcs(const GrOptDrawState& optState, | 244 void emitAndInstallProcs(const GrOptDrawState& optState, |
249 GrGLSLExpr4* inputColor, | 245 GrGLSLExpr4* inputColor, |
250 GrGLSLExpr4* inputCoverage); | 246 GrGLSLExpr4* inputCoverage); |
251 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); | 247 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); |
252 template <class Proc> | 248 template <class Proc> |
253 void emitAndInstallProc(const Proc&, | 249 void emitAndInstallProc(const Proc&, |
254 int index, | 250 int index, |
255 const ProcKeyProvider, | 251 const ProcKeyProvider&, |
256 const GrGLSLExpr4& input, | 252 const GrGLSLExpr4& input, |
257 GrGLSLExpr4* output); | 253 GrGLSLExpr4* output); |
258 | 254 |
259 // these emit functions help to keep the createAndEmitProcessors template ge
neral | 255 // these emit functions help to keep the createAndEmitProcessors template ge
neral |
260 void emitAndInstallProc(const GrFragmentStage&, | 256 void emitAndInstallProc(const GrFragmentStage&, |
261 const GrProcessorKey&, | 257 const GrProcessorKey&, |
262 const char* outColor, | 258 const char* outColor, |
263 const char* inColor); | 259 const char* inColor); |
264 void emitAndInstallProc(const GrGeometryProcessor&, | 260 void emitAndInstallProc(const GrGeometryProcessor&, |
265 const GrProcessorKey&, | 261 const GrProcessorKey&, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 GrGLVertexBuilder fVS; | 321 GrGLVertexBuilder fVS; |
326 GrGLGeometryBuilder fGS; | 322 GrGLGeometryBuilder fGS; |
327 GrGLFragmentShaderBuilder fFS; | 323 GrGLFragmentShaderBuilder fFS; |
328 bool fOutOfStage; | 324 bool fOutOfStage; |
329 int fStageIndex; | 325 int fStageIndex; |
330 | 326 |
331 GrGLInstalledGeoProc* fGeometryProcessor; | 327 GrGLInstalledGeoProc* fGeometryProcessor; |
332 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 328 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
333 | 329 |
334 const GrOptDrawState& fOptState; | 330 const GrOptDrawState& fOptState; |
335 const GrGLProgramDesc& fDesc; | 331 const GrProgramDesc& fDesc; |
336 GrGpuGL* fGpu; | 332 GrGpuGL* fGpu; |
337 UniformInfoArray fUniforms; | 333 UniformInfoArray fUniforms; |
338 | 334 |
339 friend class GrGLShaderBuilder; | 335 friend class GrGLShaderBuilder; |
340 friend class GrGLVertexBuilder; | 336 friend class GrGLVertexBuilder; |
341 friend class GrGLFragmentShaderBuilder; | 337 friend class GrGLFragmentShaderBuilder; |
342 friend class GrGLGeometryBuilder; | 338 friend class GrGLGeometryBuilder; |
343 }; | 339 }; |
344 | 340 |
345 /** | 341 /** |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 SkSTArray<2, Transform, true> fTransforms; | 385 SkSTArray<2, Transform, true> fTransforms; |
390 bool fLocalCoordAttrib; | 386 bool fLocalCoordAttrib; |
391 }; | 387 }; |
392 | 388 |
393 struct GrGLInstalledFragProcs : public SkRefCnt { | 389 struct GrGLInstalledFragProcs : public SkRefCnt { |
394 virtual ~GrGLInstalledFragProcs(); | 390 virtual ~GrGLInstalledFragProcs(); |
395 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; | 391 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; |
396 }; | 392 }; |
397 | 393 |
398 #endif | 394 #endif |
OLD | NEW |