| 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 GrGLFragmentProcessor_DEFINED |
| 9 #define GrGLFragmentProcessor_DEFINED | 9 #define GrGLFragmentProcessor_DEFINED |
| 10 | 10 |
| 11 #include "GrGLProgramDataManager.h" | |
| 12 #include "GrGLProcessor.h" | 11 #include "GrGLProcessor.h" |
| 13 #include "GrTextureAccess.h" | 12 #include "glsl/GrGLSLProgramDataManager.h" |
| 14 | 13 |
| 15 class GrGLFPBuilder; | 14 class GrGLFPBuilder; |
| 15 class GrGLSLCaps; |
| 16 | 16 |
| 17 class GrGLFragmentProcessor { | 17 class GrGLFragmentProcessor { |
| 18 public: | 18 public: |
| 19 GrGLFragmentProcessor() {} | 19 GrGLFragmentProcessor() {} |
| 20 | 20 |
| 21 virtual ~GrGLFragmentProcessor() { | 21 virtual ~GrGLFragmentProcessor() { |
| 22 for (int i = 0; i < fChildProcessors.count(); ++i) { | 22 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 23 delete fChildProcessors[i]; | 23 delete fChildProcessors[i]; |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 27 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
| 28 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; | 28 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; |
| 29 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; | 29 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; |
| 30 | 30 |
| 31 /** Called when the program stage should insert its code into the shaders. T
he code in each | 31 /** Called when the program stage should insert its code into the shaders. T
he code in each |
| 32 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 32 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
| 33 stages. | 33 stages. |
| 34 | 34 |
| 35 @param builder Interface used to emit code in the shaders. | 35 @param builder Interface used to emit code in the shaders. |
| 36 @param processor The processor that generated this program stage. | 36 @param processor The processor that generated this program stage. |
| 37 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. | 37 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 GrGLFPBuilder* fBuilder; | 63 GrGLFPBuilder* fBuilder; |
| 64 const GrFragmentProcessor& fFp; | 64 const GrFragmentProcessor& fFp; |
| 65 const char* fOutputColor; | 65 const char* fOutputColor; |
| 66 const char* fInputColor; | 66 const char* fInputColor; |
| 67 const TransformedCoordsArray& fCoords; | 67 const TransformedCoordsArray& fCoords; |
| 68 const TextureSamplerArray& fSamplers; | 68 const TextureSamplerArray& fSamplers; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 virtual void emitCode(EmitArgs&) = 0; | 71 virtual void emitCode(EmitArgs&) = 0; |
| 72 | 72 |
| 73 void setData(const GrGLProgramDataManager& pdman, const GrFragmentProcessor&
processor); | 73 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); |
| 74 | 74 |
| 75 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | 75 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
| 76 | 76 |
| 77 int numChildProcessors() const { return fChildProcessors.count(); } | 77 int numChildProcessors() const { return fChildProcessors.count(); } |
| 78 | 78 |
| 79 GrGLFragmentProcessor* childProcessor(int index) const { | 79 GrGLFragmentProcessor* childProcessor(int index) const { |
| 80 return fChildProcessors[index]; | 80 return fChildProcessors[index]; |
| 81 } | 81 } |
| 82 | 82 |
| 83 /** Will emit the code of a child proc in its own scope. Pass in the parent'
s EmitArgs and | 83 /** Will emit the code of a child proc in its own scope. Pass in the parent'
s EmitArgs and |
| (...skipping 10 matching lines...) Expand all Loading... |
| 94 /** Variation that uses the parent's output color variable to hold the child
's output.*/ | 94 /** Variation that uses the parent's output color variable to hold the child
's output.*/ |
| 95 void emitChild(int childIndex, const char* inputColor, EmitArgs& parentArgs)
; | 95 void emitChild(int childIndex, const char* inputColor, EmitArgs& parentArgs)
; |
| 96 | 96 |
| 97 protected: | 97 protected: |
| 98 /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProces
sor that produces | 98 /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProces
sor that produces |
| 99 the same stage key; this function reads data from a GrFragmentProcessor and
uploads any | 99 the same stage key; this function reads data from a GrFragmentProcessor and
uploads any |
| 100 uniform variables required by the shaders created in emitCode(). The GrFragm
entProcessor | 100 uniform variables required by the shaders created in emitCode(). The GrFragm
entProcessor |
| 101 parameter is guaranteed to be of the same type that created this GrGLFragmen
tProcessor and | 101 parameter is guaranteed to be of the same type that created this GrGLFragmen
tProcessor and |
| 102 to have an identical processor key as the one that created this GrGLFragment
Processor. */ | 102 to have an identical processor key as the one that created this GrGLFragment
Processor. */ |
| 103 // TODO update this to pass in GrFragmentProcessor | 103 // TODO update this to pass in GrFragmentProcessor |
| 104 virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {} | 104 virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
{} |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 void internalEmitChild(int, const char*, const char*, EmitArgs&); | 107 void internalEmitChild(int, const char*, const char*, EmitArgs&); |
| 108 | 108 |
| 109 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; | 109 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; |
| 110 | 110 |
| 111 friend class GrFragmentProcessor; | 111 friend class GrFragmentProcessor; |
| 112 typedef GrGLProcessor INHERITED; | 112 typedef GrGLProcessor INHERITED; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 #endif | 115 #endif |
| OLD | NEW |