| 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 GrGLSLFragmentProcessor_DEFINED | 8 #ifndef GrGLSLFragmentProcessor_DEFINED |
| 9 #define GrGLSLFragmentProcessor_DEFINED | 9 #define GrGLSLFragmentProcessor_DEFINED |
| 10 | 10 |
| 11 #include "GrFragmentProcessor.h" |
| 11 #include "glsl/GrGLSLProcessorTypes.h" | 12 #include "glsl/GrGLSLProcessorTypes.h" |
| 12 #include "glsl/GrGLSLProgramDataManager.h" | 13 #include "glsl/GrGLSLProgramDataManager.h" |
| 13 #include "glsl/GrGLSLTextureSampler.h" | 14 #include "glsl/GrGLSLSampler.h" |
| 14 | 15 |
| 15 class GrProcessor; | 16 class GrProcessor; |
| 16 class GrProcessorKeyBuilder; | 17 class GrProcessorKeyBuilder; |
| 17 class GrGLSLCaps; | 18 class GrGLSLCaps; |
| 18 class GrGLSLFPBuilder; | 19 class GrGLSLFPBuilder; |
| 19 class GrGLSLFPFragmentBuilder; | 20 class GrGLSLFPFragmentBuilder; |
| 20 class GrGLSLUniformHandler; | 21 class GrGLSLUniformHandler; |
| 21 | 22 |
| 22 class GrGLSLFragmentProcessor { | 23 class GrGLSLFragmentProcessor { |
| 23 public: | 24 public: |
| 24 GrGLSLFragmentProcessor() {} | 25 GrGLSLFragmentProcessor() {} |
| 25 | 26 |
| 26 virtual ~GrGLSLFragmentProcessor() { | 27 virtual ~GrGLSLFragmentProcessor() { |
| 27 for (int i = 0; i < fChildProcessors.count(); ++i) { | 28 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 28 delete fChildProcessors[i]; | 29 delete fChildProcessors[i]; |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 33 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
| 33 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; | 34 typedef GrGLSLSampler::SamplerArray SamplerArray; |
| 34 | 35 |
| 35 /** Called when the program stage should insert its code into the shaders. T
he code in each | 36 /** Called when the program stage should insert its code into the shaders. T
he code in each |
| 36 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 37 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
| 37 stages. | 38 stages. |
| 38 | 39 |
| 39 @param builder Interface used to emit code in the shaders. | 40 @param builder Interface used to emit code in the shaders. |
| 40 @param processor The processor that generated this program stage. | 41 @param processor The processor that generated this program stage. |
| 41 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. | 42 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. |
| 42 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output | 43 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output |
| 43 color (or coverage). | 44 color (or coverage). |
| 44 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be | 45 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be |
| 45 nullptr in which case the implied input is solid whi
te (all ones). | 46 nullptr in which case the implied input is solid whi
te (all ones). |
| 46 TODO: Better system for communicating optimization i
nfo (e.g. input | 47 TODO: Better system for communicating optimization i
nfo (e.g. input |
| 47 color is solid white, trans black, known to be opaqu
e, etc.) that allows | 48 color is solid white, trans black, known to be opaqu
e, etc.) that allows |
| 48 the processor to communicate back similar known info
about its output. | 49 the processor to communicate back similar known info
about its output. |
| 49 @param samplers Contains one entry for each GrTextureAccess of the G
rProcessor. These | 50 @param samplers Contains one entry for each GrTextureAccess of the G
rProcessor. These |
| 50 can be passed to the builder to emit texture reads i
n the generated | 51 can be passed to the builder to emit texture reads i
n the generated |
| 51 code. | 52 code. |
| 52 */ | 53 */ |
| 53 | 54 |
| 54 struct EmitArgs { | 55 struct EmitArgs { |
| 55 EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder, | 56 EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder, |
| 56 GrGLSLUniformHandler* uniformHandler, | 57 GrGLSLUniformHandler* uniformHandler, |
| 57 const GrGLSLCaps* caps, | 58 const GrGLSLCaps* caps, |
| 58 const GrFragmentProcessor& fp, | 59 const GrFragmentProcessor& fp, |
| 59 const char* outputColor, | 60 const char* outputColor, |
| 60 const char* inputColor, | 61 const char* inputColor, |
| 61 const GrGLSLTransformedCoordsArray& coords, | 62 const GrGLSLTransformedCoordsArray& coords, |
| 62 const TextureSamplerArray& samplers) | 63 const SamplerArray& texSamplers) |
| 63 : fFragBuilder(fragBuilder) | 64 : fFragBuilder(fragBuilder) |
| 64 , fUniformHandler(uniformHandler) | 65 , fUniformHandler(uniformHandler) |
| 65 , fGLSLCaps(caps) | 66 , fGLSLCaps(caps) |
| 66 , fFp(fp) | 67 , fFp(fp) |
| 67 , fOutputColor(outputColor) | 68 , fOutputColor(outputColor) |
| 68 , fInputColor(inputColor) | 69 , fInputColor(inputColor) |
| 69 , fCoords(coords) | 70 , fCoords(coords) |
| 70 , fSamplers(samplers) {} | 71 , fTexSamplers(texSamplers) {} |
| 71 GrGLSLFPFragmentBuilder* fFragBuilder; | 72 GrGLSLFPFragmentBuilder* fFragBuilder; |
| 72 GrGLSLUniformHandler* fUniformHandler; | 73 GrGLSLUniformHandler* fUniformHandler; |
| 73 const GrGLSLCaps* fGLSLCaps; | 74 const GrGLSLCaps* fGLSLCaps; |
| 74 const GrFragmentProcessor& fFp; | 75 const GrFragmentProcessor& fFp; |
| 75 const char* fOutputColor; | 76 const char* fOutputColor; |
| 76 const char* fInputColor; | 77 const char* fInputColor; |
| 77 const GrGLSLTransformedCoordsArray& fCoords; | 78 const GrGLSLTransformedCoordsArray& fCoords; |
| 78 const TextureSamplerArray& fSamplers; | 79 const SamplerArray& fTexSamplers; |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 virtual void emitCode(EmitArgs&) = 0; | 82 virtual void emitCode(EmitArgs&) = 0; |
| 82 | 83 |
| 83 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); | 84 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); |
| 84 | 85 |
| 85 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | 86 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
| 86 | 87 |
| 87 int numChildProcessors() const { return fChildProcessors.count(); } | 88 int numChildProcessors() const { return fChildProcessors.count(); } |
| 88 | 89 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 115 | 116 |
| 116 private: | 117 private: |
| 117 void internalEmitChild(int, const char*, const char*, EmitArgs&); | 118 void internalEmitChild(int, const char*, const char*, EmitArgs&); |
| 118 | 119 |
| 119 SkTArray<GrGLSLFragmentProcessor*, true> fChildProcessors; | 120 SkTArray<GrGLSLFragmentProcessor*, true> fChildProcessors; |
| 120 | 121 |
| 121 friend class GrFragmentProcessor; | 122 friend class GrFragmentProcessor; |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 #endif | 125 #endif |
| OLD | NEW |