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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 const GrOptDrawState& optState() const { return fOptState; } | 235 const GrOptDrawState& optState() const { return fOptState; } |
236 const GrProgramDesc& desc() const { return fDesc; } | 236 const GrProgramDesc& desc() const { return fDesc; } |
237 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } | 237 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
238 | 238 |
239 // 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 |
240 // 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 |
241 // generating stage code. | 241 // generating stage code. |
242 void nameVariable(SkString* out, char prefix, const char* name); | 242 void nameVariable(SkString* out, char prefix, const char* name); |
243 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r1* inputCoverage); | 243 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r1* inputCoverage); |
244 void emitAndInstallProcs(GrGLSLExpr4* inputColor, | 244 void emitAndInstallProcs(const GrOptDrawState& optState, |
| 245 GrGLSLExpr4* inputColor, |
245 GrGLSLExpr4* inputCoverage); | 246 GrGLSLExpr4* inputCoverage); |
246 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); | 247 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); |
247 template <class Proc> | 248 template <class Proc> |
248 void emitAndInstallProc(const Proc&, | 249 void emitAndInstallProc(const Proc&, |
249 int index, | 250 int index, |
250 const ProcKeyProvider&, | 251 const ProcKeyProvider&, |
251 const GrGLSLExpr4& input, | 252 const GrGLSLExpr4& input, |
252 GrGLSLExpr4* output); | 253 GrGLSLExpr4* output); |
253 | 254 |
254 // these emit functions help to keep the createAndEmitProcessors template ge
neral | 255 // these emit functions help to keep the createAndEmitProcessors template ge
neral |
255 void emitAndInstallProc(const GrFragmentStage&, | 256 void emitAndInstallProc(const GrFragmentStage&, |
256 const GrProcessorKey&, | 257 const GrProcessorKey&, |
257 const char* outColor, | 258 const char* outColor, |
258 const char* inColor); | 259 const char* inColor); |
259 void emitAndInstallProc(const GrGeometryProcessor&, | 260 void emitAndInstallProc(const GrGeometryProcessor&, |
260 const GrProcessorKey&, | 261 const GrProcessorKey&, |
261 const char* outCoverage, | 262 const char* outColor, |
262 const char* inCoverage); | 263 const char* inColor); |
263 void verify(const GrGeometryProcessor&); | 264 void verify(const GrGeometryProcessor&); |
264 void verify(const GrFragmentProcessor&); | 265 void verify(const GrFragmentProcessor&); |
265 void emitSamplers(const GrProcessor&, | 266 void emitSamplers(const GrProcessor&, |
266 GrGLProcessor::TextureSamplerArray* outSamplers, | 267 GrGLProcessor::TextureSamplerArray* outSamplers, |
267 GrGLInstalledProc*); | 268 GrGLInstalledProc*); |
268 | 269 |
269 // each specific program builder has a distinct transform and must override
this function | 270 // each specific program builder has a distinct transform and must override
this function |
270 virtual void emitTransforms(const GrFragmentStage&, | 271 virtual void emitTransforms(const GrFragmentStage&, |
271 GrGLProcessor::TransformedCoordsArray* outCoords
, | 272 GrGLProcessor::TransformedCoordsArray* outCoords
, |
272 GrGLInstalledFragProc*); | 273 GrGLInstalledFragProc*); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 public: | 307 public: |
307 AutoStageAdvance(GrGLProgramBuilder* pb) : fPB(pb) { fPB->reset(); } | 308 AutoStageAdvance(GrGLProgramBuilder* pb) : fPB(pb) { fPB->reset(); } |
308 ~AutoStageAdvance() { fPB->exitStage(); } | 309 ~AutoStageAdvance() { fPB->exitStage(); } |
309 private: | 310 private: |
310 GrGLProgramBuilder* fPB; | 311 GrGLProgramBuilder* fPB; |
311 }; | 312 }; |
312 void exitStage() { fOutOfStage = true; } | 313 void exitStage() { fOutOfStage = true; } |
313 void enterStage() { fOutOfStage = false; } | 314 void enterStage() { fOutOfStage = false; } |
314 int stageIndex() const { return fStageIndex; } | 315 int stageIndex() const { return fStageIndex; } |
315 | 316 |
316 struct TransformVarying { | |
317 TransformVarying(const GrGLVarying& v, const char* uniName, const char*
sourceCoords) | |
318 : fV(v), fUniName(uniName), fSourceCoords(sourceCoords) {} | |
319 GrGLVarying fV; | |
320 SkString fUniName; | |
321 SkString fSourceCoords; | |
322 }; | |
323 | |
324 void addCoordVarying(const char* name, GrGLVarying* v, const char* uniName, | |
325 const char* sourceCoords) { | |
326 this->addVarying(name, v); | |
327 fCoordVaryings.push_back(TransformVarying(*v, uniName, sourceCoords)); | |
328 } | |
329 | |
330 const char* rtAdjustment() const { return "rtAdjustment"; } | |
331 | |
332 // number of each input/output type in a single allocation block, used by ma
ny builders | 317 // number of each input/output type in a single allocation block, used by ma
ny builders |
333 static const int kVarsPerBlock; | 318 static const int kVarsPerBlock; |
334 | 319 |
335 BuiltinUniformHandles fUniformHandles; | 320 BuiltinUniformHandles fUniformHandles; |
336 GrGLVertexBuilder fVS; | 321 GrGLVertexBuilder fVS; |
337 GrGLGeometryBuilder fGS; | 322 GrGLGeometryBuilder fGS; |
338 GrGLFragmentShaderBuilder fFS; | 323 GrGLFragmentShaderBuilder fFS; |
339 bool fOutOfStage; | 324 bool fOutOfStage; |
340 int fStageIndex; | 325 int fStageIndex; |
341 | 326 |
342 GrGLInstalledGeoProc* fGeometryProcessor; | 327 GrGLInstalledGeoProc* fGeometryProcessor; |
343 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 328 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
344 | 329 |
345 const GrOptDrawState& fOptState; | 330 const GrOptDrawState& fOptState; |
346 const GrProgramDesc& fDesc; | 331 const GrProgramDesc& fDesc; |
347 GrGpuGL* fGpu; | 332 GrGpuGL* fGpu; |
348 UniformInfoArray fUniforms; | 333 UniformInfoArray fUniforms; |
349 SkSTArray<16, TransformVarying, true> fCoordVaryings; | |
350 | 334 |
351 friend class GrGLShaderBuilder; | 335 friend class GrGLShaderBuilder; |
352 friend class GrGLVertexBuilder; | 336 friend class GrGLVertexBuilder; |
353 friend class GrGLFragmentShaderBuilder; | 337 friend class GrGLFragmentShaderBuilder; |
354 friend class GrGLGeometryBuilder; | 338 friend class GrGLGeometryBuilder; |
355 }; | 339 }; |
356 | 340 |
357 /** | 341 /** |
358 * The below structs represent processors installed in programs. All processors
can have texture | 342 * The below structs represent processors installed in programs. All processors
can have texture |
359 * samplers, but only frag processors have coord transforms, hence the need for
different structs | 343 * samplers, but only frag processors have coord transforms, hence the need for
different structs |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 SkSTArray<2, Transform, true> fTransforms; | 385 SkSTArray<2, Transform, true> fTransforms; |
402 bool fLocalCoordAttrib; | 386 bool fLocalCoordAttrib; |
403 }; | 387 }; |
404 | 388 |
405 struct GrGLInstalledFragProcs : public SkRefCnt { | 389 struct GrGLInstalledFragProcs : public SkRefCnt { |
406 virtual ~GrGLInstalledFragProcs(); | 390 virtual ~GrGLInstalledFragProcs(); |
407 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; | 391 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; |
408 }; | 392 }; |
409 | 393 |
410 #endif | 394 #endif |
OLD | NEW |