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 "GrGLProcessor.h" | 11 #include "glsl/GrGLSLProcessorTypes.h" |
12 #include "glsl/GrGLSLProgramDataManager.h" | 12 #include "glsl/GrGLSLProgramDataManager.h" |
| 13 #include "glsl/GrGLSLTextureSampler.h" |
13 | 14 |
| 15 class GrProcessor; |
| 16 class GrProcessorKeyBuilder; |
14 class GrGLFPBuilder; | 17 class GrGLFPBuilder; |
15 class GrGLSLCaps; | 18 class GrGLSLCaps; |
16 | 19 |
17 class GrGLFragmentProcessor { | 20 class GrGLFragmentProcessor { |
18 public: | 21 public: |
19 GrGLFragmentProcessor() {} | 22 GrGLFragmentProcessor() {} |
20 | 23 |
21 virtual ~GrGLFragmentProcessor() { | 24 virtual ~GrGLFragmentProcessor() { |
22 for (int i = 0; i < fChildProcessors.count(); ++i) { | 25 for (int i = 0; i < fChildProcessors.count(); ++i) { |
23 delete fChildProcessors[i]; | 26 delete fChildProcessors[i]; |
24 } | 27 } |
25 } | 28 } |
26 | 29 |
27 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 30 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
28 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; | 31 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; |
29 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; | |
30 | 32 |
31 /** 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 |
32 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 |
33 stages. | 35 stages. |
34 | 36 |
35 @param builder Interface used to emit code in the shaders. | 37 @param builder Interface used to emit code in the shaders. |
36 @param processor The processor that generated this program stage. | 38 @param processor The processor that generated this program stage. |
37 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. | 39 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. |
38 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output | 40 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output |
39 color (or coverage). | 41 color (or coverage). |
40 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be | 42 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be |
41 nullptr in which case the implied input is solid whi
te (all ones). | 43 nullptr in which case the implied input is solid whi
te (all ones). |
42 TODO: Better system for communicating optimization i
nfo (e.g. input | 44 TODO: Better system for communicating optimization i
nfo (e.g. input |
43 color is solid white, trans black, known to be opaqu
e, etc.) that allows | 45 color is solid white, trans black, known to be opaqu
e, etc.) that allows |
44 the processor to communicate back similar known info
about its output. | 46 the processor to communicate back similar known info
about its output. |
45 @param samplers Contains one entry for each GrTextureAccess of the G
rProcessor. These | 47 @param samplers Contains one entry for each GrTextureAccess of the G
rProcessor. These |
46 can be passed to the builder to emit texture reads i
n the generated | 48 can be passed to the builder to emit texture reads i
n the generated |
47 code. | 49 code. |
48 */ | 50 */ |
49 | 51 |
50 struct EmitArgs { | 52 struct EmitArgs { |
51 EmitArgs(GrGLFPBuilder* builder, | 53 EmitArgs(GrGLFPBuilder* builder, |
52 const GrFragmentProcessor& fp, | 54 const GrFragmentProcessor& fp, |
53 const char* outputColor, | 55 const char* outputColor, |
54 const char* inputColor, | 56 const char* inputColor, |
55 const TransformedCoordsArray& coords, | 57 const GrGLSLTransformedCoordsArray& coords, |
56 const TextureSamplerArray& samplers) | 58 const TextureSamplerArray& samplers) |
57 : fBuilder(builder) | 59 : fBuilder(builder) |
58 , fFp(fp) | 60 , fFp(fp) |
59 , fOutputColor(outputColor) | 61 , fOutputColor(outputColor) |
60 , fInputColor(inputColor) | 62 , fInputColor(inputColor) |
61 , fCoords(coords) | 63 , fCoords(coords) |
62 , fSamplers(samplers) {} | 64 , fSamplers(samplers) {} |
63 GrGLFPBuilder* fBuilder; | 65 GrGLFPBuilder* fBuilder; |
64 const GrFragmentProcessor& fFp; | 66 const GrFragmentProcessor& fFp; |
65 const char* fOutputColor; | 67 const char* fOutputColor; |
66 const char* fInputColor; | 68 const char* fInputColor; |
67 const TransformedCoordsArray& fCoords; | 69 const GrGLSLTransformedCoordsArray& fCoords; |
68 const TextureSamplerArray& fSamplers; | 70 const TextureSamplerArray& fSamplers; |
69 }; | 71 }; |
70 | 72 |
71 virtual void emitCode(EmitArgs&) = 0; | 73 virtual void emitCode(EmitArgs&) = 0; |
72 | 74 |
73 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); | 75 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); |
74 | 76 |
75 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | 77 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
76 | 78 |
77 int numChildProcessors() const { return fChildProcessors.count(); } | 79 int numChildProcessors() const { return fChildProcessors.count(); } |
(...skipping 24 matching lines...) Expand all Loading... |
102 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 GrGLFragment
Processor. */ |
103 // TODO update this to pass in GrFragmentProcessor | 105 // TODO update this to pass in GrFragmentProcessor |
104 virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
{} | 106 virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
{} |
105 | 107 |
106 private: | 108 private: |
107 void internalEmitChild(int, const char*, const char*, EmitArgs&); | 109 void internalEmitChild(int, const char*, const char*, EmitArgs&); |
108 | 110 |
109 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; | 111 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; |
110 | 112 |
111 friend class GrFragmentProcessor; | 113 friend class GrFragmentProcessor; |
112 typedef GrGLProcessor INHERITED; | |
113 }; | 114 }; |
114 | 115 |
115 #endif | 116 #endif |
OLD | NEW |