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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 static const GrFragmentProcessor* RunInSeries(const GrFragmentProcessor*[],
int cnt); | 56 static const GrFragmentProcessor* RunInSeries(const GrFragmentProcessor*[],
int cnt); |
57 | 57 |
58 GrFragmentProcessor() | 58 GrFragmentProcessor() |
59 : INHERITED() | 59 : INHERITED() |
60 , fUsesLocalCoords(false) | 60 , fUsesLocalCoords(false) |
61 , fNumTexturesExclChildren(0) | 61 , fNumTexturesExclChildren(0) |
62 , fNumTransformsExclChildren(0) {} | 62 , fNumTransformsExclChildren(0) {} |
63 | 63 |
64 ~GrFragmentProcessor() override; | 64 ~GrFragmentProcessor() override; |
65 | 65 |
66 GrGLSLFragmentProcessor* createGLInstance() const; | 66 GrGLSLFragmentProcessor* createGLSLInstance() const; |
67 | 67 |
68 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st { | 68 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst { |
69 this->onGetGLProcessorKey(caps, b); | 69 this->onGetGLSLProcessorKey(caps, b); |
70 for (int i = 0; i < fChildProcessors.count(); ++i) { | 70 for (int i = 0; i < fChildProcessors.count(); ++i) { |
71 fChildProcessors[i]->getGLProcessorKey(caps, b); | 71 fChildProcessors[i]->getGLSLProcessorKey(caps, b); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 int numTexturesExclChildren() const { return fNumTexturesExclChildren; } | 75 int numTexturesExclChildren() const { return fNumTexturesExclChildren; } |
76 | 76 |
77 int numTransformsExclChildren() const { return fNumTransformsExclChildren; } | 77 int numTransformsExclChildren() const { return fNumTransformsExclChildren; } |
78 | 78 |
79 int numTransforms() const { return fCoordTransforms.count(); } | 79 int numTransforms() const { return fCoordTransforms.count(); } |
80 | 80 |
81 /** Returns the coordinate transformation at index. index must be valid acco
rding to | 81 /** Returns the coordinate transformation at index. index must be valid acco
rding to |
(...skipping 15 matching lines...) Expand all Loading... |
97 const GrFragmentProcessor& childProcessor(int index) const { return *fChildP
rocessors[index]; } | 97 const GrFragmentProcessor& childProcessor(int index) const { return *fChildP
rocessors[index]; } |
98 | 98 |
99 /** Do any of the coordtransforms for this processor require local coords? *
/ | 99 /** Do any of the coordtransforms for this processor require local coords? *
/ |
100 bool usesLocalCoords() const { return fUsesLocalCoords; } | 100 bool usesLocalCoords() const { return fUsesLocalCoords; } |
101 | 101 |
102 /** Returns true if this and other processor conservatively draw identically
. It can only return | 102 /** Returns true if this and other processor conservatively draw identically
. It can only return |
103 true when the two processor are of the same subclass (i.e. they return t
he same object from | 103 true when the two processor are of the same subclass (i.e. they return t
he same object from |
104 from getFactory()). | 104 from getFactory()). |
105 | 105 |
106 A return value of true from isEqual() should not be used to test whether
the processor would | 106 A return value of true from isEqual() should not be used to test whether
the processor would |
107 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 107 generate the same shader code. To test for identical code generation use
getGLSLProcessorKey |
| 108 */ |
108 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst; | 109 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst; |
109 | 110 |
110 /** | 111 /** |
111 * This function is used to perform optimizations. When called the invarient
Ouput param | 112 * This function is used to perform optimizations. When called the invarient
Ouput param |
112 * indicate whether the input components to this processor in the FS will ha
ve known values. | 113 * indicate whether the input components to this processor in the FS will ha
ve known values. |
113 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent | 114 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent |
114 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of | 115 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of |
115 * inout to indicate known values of its output. A component of the color me
mber only has | 116 * inout to indicate known values of its output. A component of the color me
mber only has |
116 * meaning if the corresponding bit in validFlags is set. | 117 * meaning if the corresponding bit in validFlags is set. |
117 */ | 118 */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 * procs' output invariants; computeInvariantOutput will not be recursive. | 160 * procs' output invariants; computeInvariantOutput will not be recursive. |
160 */ | 161 */ |
161 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; | 162 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; |
162 | 163 |
163 private: | 164 private: |
164 void notifyRefCntIsZero() const final; | 165 void notifyRefCntIsZero() const final; |
165 | 166 |
166 /** Returns a new instance of the appropriate *GL* implementation class | 167 /** Returns a new instance of the appropriate *GL* implementation class |
167 for the given GrFragmentProcessor; caller is responsible for deleting | 168 for the given GrFragmentProcessor; caller is responsible for deleting |
168 the object. */ | 169 the object. */ |
169 virtual GrGLSLFragmentProcessor* onCreateGLInstance() const = 0; | 170 virtual GrGLSLFragmentProcessor* onCreateGLSLInstance() const = 0; |
170 | 171 |
171 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ | 172 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ |
172 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 173 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
173 GrProcessorKeyBuilder* b) const = 0; | 174 GrProcessorKeyBuilder* b) const = 0; |
174 | 175 |
175 /** | 176 /** |
176 * Subclass implements this to support isEqual(). It will only be called if
it is known that | 177 * Subclass implements this to support isEqual(). It will only be called if
it is known that |
177 * the two processors are of the same subclass (i.e. they return the same ob
ject from | 178 * the two processors are of the same subclass (i.e. they return the same ob
ject from |
178 * getFactory()). The processor subclass should not compare its coord transf
orms as that will | 179 * getFactory()). The processor subclass should not compare its coord transf
orms as that will |
179 * be performed automatically in the non-virtual isEqual(). | 180 * be performed automatically in the non-virtual isEqual(). |
180 */ | 181 */ |
181 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; | 182 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; |
182 | 183 |
183 bool hasSameTransforms(const GrFragmentProcessor&) const; | 184 bool hasSameTransforms(const GrFragmentProcessor&) const; |
(...skipping 29 matching lines...) Expand all Loading... |
213 int fNumTransformsExclChildren; | 214 int fNumTransformsExclChildren; |
214 | 215 |
215 // TODO: These must convert their processors to pending-execution refs when
the parent is | 216 // TODO: These must convert their processors to pending-execution refs when
the parent is |
216 // converted (do this automatically in GrProgramElement?). | 217 // converted (do this automatically in GrProgramElement?). |
217 SkTArray<const GrFragmentProcessor*, true> fChildProcessors; | 218 SkTArray<const GrFragmentProcessor*, true> fChildProcessors; |
218 | 219 |
219 typedef GrProcessor INHERITED; | 220 typedef GrProcessor INHERITED; |
220 }; | 221 }; |
221 | 222 |
222 #endif | 223 #endif |
OLD | NEW |