OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrFragmentProcessor_DEFINED | 8 #ifndef GrFragmentProcessor_DEFINED |
9 #define GrFragmentProcessor_DEFINED | 9 #define GrFragmentProcessor_DEFINED |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 /** Do any of the coordtransforms for this processor require local coords? *
/ | 68 /** Do any of the coordtransforms for this processor require local coords? *
/ |
69 bool usesLocalCoords() const { return fUsesLocalCoords; } | 69 bool usesLocalCoords() const { return fUsesLocalCoords; } |
70 | 70 |
71 /** Returns true if this and other processor conservatively draw identically
. It can only return | 71 /** Returns true if this and other processor conservatively draw identically
. It can only return |
72 true when the two processor are of the same subclass (i.e. they return t
he same object from | 72 true when the two processor are of the same subclass (i.e. they return t
he same object from |
73 from getFactory()). | 73 from getFactory()). |
74 | 74 |
75 A return value of true from isEqual() should not be used to test whether
the processor would | 75 A return value of true from isEqual() should not be used to test whether
the processor would |
76 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 76 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ |
77 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst { | 77 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst; |
78 if (this->classID() != that.classID() || | |
79 !this->hasSameTextureAccesses(that)) { | |
80 return false; | |
81 } | |
82 if (ignoreCoordTransforms) { | |
83 if (this->numTransforms() != that.numTransforms()) { | |
84 return false; | |
85 } | |
86 } else if (!this->hasSameTransforms(that)) { | |
87 return false; | |
88 } | |
89 return this->onIsEqual(that); | |
90 } | |
91 | 78 |
92 /** | 79 /** |
93 * This function is used to perform optimizations. When called the invarient
Ouput param | 80 * This function is used to perform optimizations. When called the invarient
Ouput param |
94 * indicate whether the input components to this processor in the FS will ha
ve known values. | 81 * indicate whether the input components to this processor in the FS will ha
ve known values. |
95 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent | 82 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent |
96 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of | 83 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of |
97 * inout to indicate known values of its output. A component of the color me
mber only has | 84 * inout to indicate known values of its output. A component of the color me
mber only has |
98 * meaning if the corresponding bit in validFlags is set. | 85 * meaning if the corresponding bit in validFlags is set. |
99 */ | 86 */ |
100 void computeInvariantOutput(GrInvariantOutput* inout) const; | 87 void computeInvariantOutput(GrInvariantOutput* inout) const; |
(...skipping 23 matching lines...) Expand all Loading... |
124 * FragmentProcessors they have. | 111 * FragmentProcessors they have. |
125 * This is for processors whose shader code will be composed of nested proce
ssors whose output | 112 * This is for processors whose shader code will be composed of nested proce
ssors whose output |
126 * colors will be combined somehow to produce its output color. Registering
these child | 113 * colors will be combined somehow to produce its output color. Registering
these child |
127 * processors will allow the ProgramBuilder to automatically handle their tr
ansformed coords and | 114 * processors will allow the ProgramBuilder to automatically handle their tr
ansformed coords and |
128 * texture accesses and mangle their uniform and output color names. | 115 * texture accesses and mangle their uniform and output color names. |
129 */ | 116 */ |
130 int registerChildProcessor(const GrFragmentProcessor* child); | 117 int registerChildProcessor(const GrFragmentProcessor* child); |
131 | 118 |
132 /** | 119 /** |
133 * Subclass implements this to support getConstantColorComponents(...). | 120 * Subclass implements this to support getConstantColorComponents(...). |
| 121 * |
| 122 * Note: it's up to the subclass implementation to do any recursive call to
compute the child |
| 123 * procs' output invariants; computeInvariantOutput will not be recursive. |
134 */ | 124 */ |
135 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; | 125 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; |
136 | 126 |
137 private: | 127 private: |
138 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ | 128 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ |
139 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 129 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
140 GrProcessorKeyBuilder* b) const = 0; | 130 GrProcessorKeyBuilder* b) const = 0; |
141 | 131 |
142 /** | 132 /** |
143 * Subclass implements this to support isEqual(). It will only be called if
it is known that | 133 * Subclass implements this to support isEqual(). It will only be called if
it is known that |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 * The same goes for fTextureAccesses with textures. | 165 * The same goes for fTextureAccesses with textures. |
176 */ | 166 */ |
177 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 167 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
178 | 168 |
179 SkTArray<GrFragmentStage, false> fChildProcessors; | 169 SkTArray<GrFragmentStage, false> fChildProcessors; |
180 | 170 |
181 typedef GrProcessor INHERITED; | 171 typedef GrProcessor INHERITED; |
182 }; | 172 }; |
183 | 173 |
184 #endif | 174 #endif |
OLD | NEW |