| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLFragmentProcessor_DEFINED | 8 #ifndef GrGLSLFragmentProcessor_DEFINED |
| 9 #define GrGLFragmentProcessor_DEFINED | 9 #define GrGLSLFragmentProcessor_DEFINED |
| 10 | 10 |
| 11 #include "glsl/GrGLSLProcessorTypes.h" | 11 #include "glsl/GrGLSLProcessorTypes.h" |
| 12 #include "glsl/GrGLSLProgramDataManager.h" | 12 #include "glsl/GrGLSLProgramDataManager.h" |
| 13 #include "glsl/GrGLSLTextureSampler.h" | 13 #include "glsl/GrGLSLTextureSampler.h" |
| 14 | 14 |
| 15 class GrProcessor; | 15 class GrProcessor; |
| 16 class GrProcessorKeyBuilder; | 16 class GrProcessorKeyBuilder; |
| 17 class GrGLSLFPBuilder; | 17 class GrGLSLFPBuilder; |
| 18 class GrGLSLCaps; | 18 class GrGLSLCaps; |
| 19 | 19 |
| 20 class GrGLFragmentProcessor { | 20 class GrGLSLFragmentProcessor { |
| 21 public: | 21 public: |
| 22 GrGLFragmentProcessor() {} | 22 GrGLSLFragmentProcessor() {} |
| 23 | 23 |
| 24 virtual ~GrGLFragmentProcessor() { | 24 virtual ~GrGLSLFragmentProcessor() { |
| 25 for (int i = 0; i < fChildProcessors.count(); ++i) { | 25 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 26 delete fChildProcessors[i]; | 26 delete fChildProcessors[i]; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 30 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
| 31 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; | 31 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; |
| 32 | 32 |
| 33 /** Called when the program stage should insert its code into the shaders. T
he code in each | 33 /** Called when the program stage should insert its code into the shaders. T
he code in each |
| 34 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 34 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 virtual void emitCode(EmitArgs&) = 0; | 73 virtual void emitCode(EmitArgs&) = 0; |
| 74 | 74 |
| 75 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); | 75 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); |
| 76 | 76 |
| 77 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | 77 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
| 78 | 78 |
| 79 int numChildProcessors() const { return fChildProcessors.count(); } | 79 int numChildProcessors() const { return fChildProcessors.count(); } |
| 80 | 80 |
| 81 GrGLFragmentProcessor* childProcessor(int index) const { | 81 GrGLSLFragmentProcessor* childProcessor(int index) const { |
| 82 return fChildProcessors[index]; | 82 return fChildProcessors[index]; |
| 83 } | 83 } |
| 84 | 84 |
| 85 /** Will emit the code of a child proc in its own scope. Pass in the parent'
s EmitArgs and | 85 /** Will emit the code of a child proc in its own scope. Pass in the parent'
s EmitArgs and |
| 86 * emitChild will automatically extract the coords and samplers of that chi
ld and pass them | 86 * emitChild will automatically extract the coords and samplers of that chi
ld and pass them |
| 87 * on to the child's emitCode(). Also, any uniforms or functions emitted by
the child will | 87 * on to the child's emitCode(). Also, any uniforms or functions emitted by
the child will |
| 88 * have their names mangled to prevent redefinitions. The output color name
is also mangled | 88 * have their names mangled to prevent redefinitions. The output color name
is also mangled |
| 89 * therefore in an in/out param. It will be declared in mangled form by emi
tChild(). It is | 89 * therefore in an in/out param. It will be declared in mangled form by emi
tChild(). It is |
| 90 * legal to pass nullptr as inputColor, since all fragment processors are r
equired to work | 90 * legal to pass nullptr as inputColor, since all fragment processors are r
equired to work |
| 91 * without an input color. | 91 * without an input color. |
| 92 */ | 92 */ |
| 93 void emitChild(int childIndex, const char* inputColor, SkString* outputColor
, | 93 void emitChild(int childIndex, const char* inputColor, SkString* outputColor
, |
| 94 EmitArgs& parentArgs); | 94 EmitArgs& parentArgs); |
| 95 | 95 |
| 96 /** Variation that uses the parent's output color variable to hold the child
's output.*/ | 96 /** Variation that uses the parent's output color variable to hold the child
's output.*/ |
| 97 void emitChild(int childIndex, const char* inputColor, EmitArgs& parentArgs)
; | 97 void emitChild(int childIndex, const char* inputColor, EmitArgs& parentArgs)
; |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProces
sor that produces | 100 /** A GrGLSLFragmentProcessor instance can be reused with any GrFragmentProc
essor that produces |
| 101 the same stage key; this function reads data from a GrFragmentProcessor and
uploads any | 101 the same stage key; this function reads data from a GrFragmentProcessor and
uploads any |
| 102 uniform variables required by the shaders created in emitCode(). The GrFragm
entProcessor | 102 uniform variables required by the shaders created in emitCode(). The GrFragm
entProcessor |
| 103 parameter is guaranteed to be of the same type that created this GrGLFragmen
tProcessor and | 103 parameter is guaranteed to be of the same type that created this GrGLSLFragm
entProcessor and |
| 104 to have an identical processor key as the one that created this GrGLFragment
Processor. */ | 104 to have an identical processor key as the one that created this GrGLSLFragme
ntProcessor. */ |
| 105 // TODO update this to pass in GrFragmentProcessor | 105 // TODO update this to pass in GrFragmentProcessor |
| 106 virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
{} | 106 virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
{} |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 void internalEmitChild(int, const char*, const char*, EmitArgs&); | 109 void internalEmitChild(int, const char*, const char*, EmitArgs&); |
| 110 | 110 |
| 111 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; | 111 SkTArray<GrGLSLFragmentProcessor*, true> fChildProcessors; |
| 112 | 112 |
| 113 friend class GrFragmentProcessor; | 113 friend class GrFragmentProcessor; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 #endif | 116 #endif |
| OLD | NEW |