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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output | 38 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output |
39 color (or coverage). | 39 color (or coverage). |
40 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be | 40 @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). | 41 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 | 42 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 | 43 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. | 44 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 | 45 @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 | 46 can be passed to the builder to emit texture reads i
n the generated |
47 code. | 47 code. |
48 */ | 48 */ |
49 | 49 |
50 struct EmitArgs { | 50 struct EmitArgs { |
51 EmitArgs(GrGLFPBuilder* builder, | 51 EmitArgs(GrGLFPBuilder* builder, |
52 const GrFragmentProcessor& fp, | 52 const GrFragmentProcessor& fp, |
53 const char* outputColor, | 53 const char* outputColor, |
54 const char* inputColor, | 54 const char* inputColor, |
55 const TransformedCoordsArray& coords, | 55 const TransformedCoordsArray& coords, |
56 const TextureSamplerArray& samplers) | 56 const TextureSamplerArray& samplers) |
57 : fBuilder(builder) | 57 : fBuilder(builder) |
58 , fFp(fp) | 58 , fFp(fp) |
(...skipping 15 matching lines...) Expand all Loading... |
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 |
84 * emitChild will automatically extract the coords and samplers of that chil
d and pass them | 84 * emitChild will automatically extract the coords and samplers of that chi
ld and pass them |
85 * on to the child's emitCode(). Also, any uniforms or functions emitted by
the child will | 85 * on to the child's emitCode(). Also, any uniforms or functions emitted by
the child will |
86 * have their names mangled to prevent redefinitions. | 86 * have their names mangled to prevent redefinitions. The output color name
is also mangled |
| 87 * therefore in an in/out param. It will be declared in mangled form by emi
tChild(). It is |
| 88 * legal to pass nullptr as inputColor, since all fragment processors are r
equired to work |
| 89 * without an input color. |
87 */ | 90 */ |
88 void emitChild(int childIndex, const char* inputColor, const char* outputCol
or, EmitArgs& args); | 91 void emitChild(int childIndex, const char* inputColor, SkString* outputColor
, |
| 92 EmitArgs& parentArgs); |
| 93 |
| 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)
; |
89 | 96 |
90 protected: | 97 protected: |
91 /** 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 |
92 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 |
93 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 |
94 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 |
95 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. */ |
96 // TODO update this to pass in GrFragmentProcessor | 103 // TODO update this to pass in GrFragmentProcessor |
97 virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {} | 104 virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {} |
98 | 105 |
99 private: | 106 private: |
| 107 void internalEmitChild(int, const char*, const char*, EmitArgs&); |
| 108 |
100 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; | 109 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; |
101 | 110 |
102 friend class GrFragmentProcessor; | 111 friend class GrFragmentProcessor; |
103 typedef GrGLProcessor INHERITED; | 112 typedef GrGLProcessor INHERITED; |
104 }; | 113 }; |
105 | 114 |
106 #endif | 115 #endif |
OLD | NEW |