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 "GrFragmentProcessor.h" |
12 #include "glsl/GrGLSLProcessorTypes.h" | 12 #include "GrShaderVar.h" |
13 #include "glsl/GrGLSLProgramDataManager.h" | 13 #include "glsl/GrGLSLProgramDataManager.h" |
14 #include "glsl/GrGLSLSampler.h" | 14 #include "glsl/GrGLSLSampler.h" |
15 | 15 |
16 class GrProcessor; | 16 class GrProcessor; |
17 class GrProcessorKeyBuilder; | 17 class GrProcessorKeyBuilder; |
18 class GrGLSLCaps; | 18 class GrGLSLCaps; |
19 class GrGLSLFPBuilder; | 19 class GrGLSLFPBuilder; |
20 class GrGLSLFPFragmentBuilder; | 20 class GrGLSLFPFragmentBuilder; |
21 class GrGLSLUniformHandler; | 21 class GrGLSLUniformHandler; |
22 | 22 |
23 class GrGLSLFragmentProcessor { | 23 class GrGLSLFragmentProcessor { |
24 public: | 24 public: |
25 GrGLSLFragmentProcessor() {} | 25 GrGLSLFragmentProcessor() {} |
26 | 26 |
27 virtual ~GrGLSLFragmentProcessor() { | 27 virtual ~GrGLSLFragmentProcessor() { |
28 for (int i = 0; i < fChildProcessors.count(); ++i) { | 28 for (int i = 0; i < fChildProcessors.count(); ++i) { |
29 delete fChildProcessors[i]; | 29 delete fChildProcessors[i]; |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 33 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
34 typedef GrGLSLProgramDataManager::UniformHandle SamplerHandle; | 34 typedef GrGLSLProgramDataManager::UniformHandle SamplerHandle; |
35 | 35 |
36 /** 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 |
37 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 |
38 stages. | 38 stages. |
39 | 39 |
40 @param builder Interface used to emit code in the shaders. | 40 @param fragBuilder Interface used to emit code in the shaders. |
41 @param processor The processor that generated this program stage. | 41 @param fp The processor that generated this program stage
. |
42 @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
generating |
43 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output | 43 GrProcessor. |
44 color (or coverage). | 44 @param outputColor A predefined vec4 in the FS in which the stage
should place its |
45 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be | 45 output color (or coverage). |
46 nullptr in which case the implied input is solid whi
te (all ones). | 46 @param inputColor A vec4 that holds the input color to the stage
in the FS. This may |
47 TODO: Better system for communicating optimization i
nfo (e.g. input | 47 be nullptr in which case the implied input is s
olid white (all |
48 color is solid white, trans black, known to be opaqu
e, etc.) that allows | 48 ones). TODO: Better system for communicating op
timization info |
49 the processor to communicate back similar known info
about its output. | 49 (e.g. input color is solid white, trans black,
known to be opaque, |
50 @param samplers Contains one entry for each GrTextureAccess of the G
rProcessor. These | 50 etc.) that allows the processor to communicate
back similar known |
51 can be passed to the builder to emit texture reads i
n the generated | 51 info about its output. |
52 code. | 52 @param transformedCoords Fragment shader variables containing the coords
computed using |
| 53 each of the GrFragmentProcessor's Coord Transfo
rms. |
| 54 @param texSamplers Contains one entry for each GrTextureAccess of
the GrProcessor. |
| 55 These can be passed to the builder to emit text
ure reads in the |
| 56 generated code. |
| 57 @param bufferSamplers Contains one entry for each GrBufferAccess of t
he GrProcessor. |
| 58 These can be passed to the builder to emit buff
er reads in the |
| 59 generated code. |
53 */ | 60 */ |
54 | |
55 struct EmitArgs { | 61 struct EmitArgs { |
56 EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder, | 62 EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder, |
57 GrGLSLUniformHandler* uniformHandler, | 63 GrGLSLUniformHandler* uniformHandler, |
58 const GrGLSLCaps* caps, | 64 const GrGLSLCaps* caps, |
59 const GrFragmentProcessor& fp, | 65 const GrFragmentProcessor& fp, |
60 const char* outputColor, | 66 const char* outputColor, |
61 const char* inputColor, | 67 const char* inputColor, |
62 const GrGLSLTransformedCoordsArray& coords, | 68 const SkTArray<GrShaderVar>& transformedCoords, |
63 const SamplerHandle* texSamplers, | 69 const SamplerHandle* texSamplers, |
64 const SamplerHandle* bufferSamplers, | 70 const SamplerHandle* bufferSamplers, |
65 bool gpImplementsDistanceVector) | 71 bool gpImplementsDistanceVector) |
66 : fFragBuilder(fragBuilder) | 72 : fFragBuilder(fragBuilder) |
67 , fUniformHandler(uniformHandler) | 73 , fUniformHandler(uniformHandler) |
68 , fGLSLCaps(caps) | 74 , fGLSLCaps(caps) |
69 , fFp(fp) | 75 , fFp(fp) |
70 , fOutputColor(outputColor) | 76 , fOutputColor(outputColor) |
71 , fInputColor(inputColor) | 77 , fInputColor(inputColor) |
72 , fCoords(coords) | 78 , fTransformedCoords(transformedCoords) |
73 , fTexSamplers(texSamplers) | 79 , fTexSamplers(texSamplers) |
74 , fBufferSamplers(bufferSamplers) | 80 , fBufferSamplers(bufferSamplers) |
75 , fGpImplementsDistanceVector(gpImplementsDistanceVector){} | 81 , fGpImplementsDistanceVector(gpImplementsDistanceVector) {} |
76 GrGLSLFPFragmentBuilder* fFragBuilder; | 82 GrGLSLFPFragmentBuilder* fFragBuilder; |
77 GrGLSLUniformHandler* fUniformHandler; | 83 GrGLSLUniformHandler* fUniformHandler; |
78 const GrGLSLCaps* fGLSLCaps; | 84 const GrGLSLCaps* fGLSLCaps; |
79 const GrFragmentProcessor& fFp; | 85 const GrFragmentProcessor& fFp; |
80 const char* fOutputColor; | 86 const char* fOutputColor; |
81 const char* fInputColor; | 87 const char* fInputColor; |
82 const GrGLSLTransformedCoordsArray& fCoords; | 88 const SkTArray<GrShaderVar>& fTransformedCoords; |
83 const SamplerHandle* fTexSamplers; | 89 const SamplerHandle* fTexSamplers; |
84 const SamplerHandle* fBufferSamplers; | 90 const SamplerHandle* fBufferSamplers; |
85 bool fGpImplementsDistanceVector; | 91 bool fGpImplementsDistanceVector; |
86 }; | 92 }; |
87 | 93 |
88 virtual void emitCode(EmitArgs&) = 0; | 94 virtual void emitCode(EmitArgs&) = 0; |
89 | 95 |
90 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); | 96 void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcesso
r& processor); |
91 | 97 |
92 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | 98 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
(...skipping 29 matching lines...) Expand all Loading... |
122 | 128 |
123 private: | 129 private: |
124 void internalEmitChild(int, const char*, const char*, EmitArgs&); | 130 void internalEmitChild(int, const char*, const char*, EmitArgs&); |
125 | 131 |
126 SkTArray<GrGLSLFragmentProcessor*, true> fChildProcessors; | 132 SkTArray<GrGLSLFragmentProcessor*, true> fChildProcessors; |
127 | 133 |
128 friend class GrFragmentProcessor; | 134 friend class GrFragmentProcessor; |
129 }; | 135 }; |
130 | 136 |
131 #endif | 137 #endif |
OLD | NEW |