| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 * series. The original input is passed to the first, the first's output is
passed to the | 58 * series. The original input is passed to the first, the first's output is
passed to the |
| 59 * second, etc. The output of the returned processor is the output of the la
st processor of the | 59 * second, etc. The output of the returned processor is the output of the la
st processor of the |
| 60 * series. | 60 * series. |
| 61 * | 61 * |
| 62 * The array elements with be moved. | 62 * The array elements with be moved. |
| 63 */ | 63 */ |
| 64 static sk_sp<GrFragmentProcessor> RunInSeries(sk_sp<GrFragmentProcessor>*, i
nt cnt); | 64 static sk_sp<GrFragmentProcessor> RunInSeries(sk_sp<GrFragmentProcessor>*, i
nt cnt); |
| 65 | 65 |
| 66 GrFragmentProcessor() | 66 GrFragmentProcessor() |
| 67 : INHERITED() | 67 : INHERITED() |
| 68 , fUsesDistanceVectorField(false) | |
| 69 , fUsesLocalCoords(false) | 68 , fUsesLocalCoords(false) |
| 70 , fNumTexturesExclChildren(0) | 69 , fNumTexturesExclChildren(0) |
| 71 , fNumBuffersExclChildren(0) | 70 , fNumBuffersExclChildren(0) |
| 72 , fNumTransformsExclChildren(0) {} | 71 , fNumTransformsExclChildren(0) {} |
| 73 | 72 |
| 74 ~GrFragmentProcessor() override; | 73 ~GrFragmentProcessor() override; |
| 75 | 74 |
| 76 GrGLSLFragmentProcessor* createGLSLInstance() const; | 75 GrGLSLFragmentProcessor* createGLSLInstance() const; |
| 77 | 76 |
| 78 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst { | 77 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 104 } | 103 } |
| 105 } | 104 } |
| 106 | 105 |
| 107 int numChildProcessors() const { return fChildProcessors.count(); } | 106 int numChildProcessors() const { return fChildProcessors.count(); } |
| 108 | 107 |
| 109 const GrFragmentProcessor& childProcessor(int index) const { return *fChildP
rocessors[index]; } | 108 const GrFragmentProcessor& childProcessor(int index) const { return *fChildP
rocessors[index]; } |
| 110 | 109 |
| 111 /** Do any of the coordtransforms for this processor require local coords? *
/ | 110 /** Do any of the coordtransforms for this processor require local coords? *
/ |
| 112 bool usesLocalCoords() const { return fUsesLocalCoords; } | 111 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 113 | 112 |
| 114 /** Does this FP need a vector to the nearest edge? */ | |
| 115 bool usesDistanceVectorField() const { return fUsesDistanceVectorField; } | |
| 116 | |
| 117 /** Returns true if this and other processor conservatively draw identically
. It can only return | 113 /** Returns true if this and other processor conservatively draw identically
. It can only return |
| 118 true when the two processor are of the same subclass (i.e. they return t
he same object from | 114 true when the two processor are of the same subclass (i.e. they return t
he same object from |
| 119 from getFactory()). | 115 from getFactory()). |
| 120 | 116 |
| 121 A return value of true from isEqual() should not be used to test whether
the processor would | 117 A return value of true from isEqual() should not be used to test whether
the processor would |
| 122 generate the same shader code. To test for identical code generation use
getGLSLProcessorKey | 118 generate the same shader code. To test for identical code generation use
getGLSLProcessorKey |
| 123 */ | 119 */ |
| 124 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst; | 120 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst; |
| 125 | 121 |
| 126 /** | 122 /** |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 int registerChildProcessor(sk_sp<GrFragmentProcessor> child); | 166 int registerChildProcessor(sk_sp<GrFragmentProcessor> child); |
| 171 | 167 |
| 172 /** | 168 /** |
| 173 * Subclass implements this to support getConstantColorComponents(...). | 169 * Subclass implements this to support getConstantColorComponents(...). |
| 174 * | 170 * |
| 175 * Note: it's up to the subclass implementation to do any recursive call to
compute the child | 171 * Note: it's up to the subclass implementation to do any recursive call to
compute the child |
| 176 * procs' output invariants; computeInvariantOutput will not be recursive. | 172 * procs' output invariants; computeInvariantOutput will not be recursive. |
| 177 */ | 173 */ |
| 178 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; | 174 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; |
| 179 | 175 |
| 180 /* Sub-classes should set this to true in their constructors if they need ac
cess to a distance | |
| 181 * vector field to the nearest edge | |
| 182 */ | |
| 183 bool fUsesDistanceVectorField; | |
| 184 | |
| 185 private: | 176 private: |
| 186 void notifyRefCntIsZero() const final; | 177 void notifyRefCntIsZero() const final; |
| 187 | 178 |
| 188 /** Returns a new instance of the appropriate *GL* implementation class | 179 /** Returns a new instance of the appropriate *GL* implementation class |
| 189 for the given GrFragmentProcessor; caller is responsible for deleting | 180 for the given GrFragmentProcessor; caller is responsible for deleting |
| 190 the object. */ | 181 the object. */ |
| 191 virtual GrGLSLFragmentProcessor* onCreateGLSLInstance() const = 0; | 182 virtual GrGLSLFragmentProcessor* onCreateGLSLInstance() const = 0; |
| 192 | 183 |
| 193 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ | 184 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ |
| 194 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 185 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 /** | 228 /** |
| 238 * This is not SkSTArray<1, sk_sp<GrFragmentProcessor>> because this class h
olds strong | 229 * This is not SkSTArray<1, sk_sp<GrFragmentProcessor>> because this class h
olds strong |
| 239 * references until notifyRefCntIsZero and then it holds pending executions. | 230 * references until notifyRefCntIsZero and then it holds pending executions. |
| 240 */ | 231 */ |
| 241 SkSTArray<1, GrFragmentProcessor*, true> fChildProcessors; | 232 SkSTArray<1, GrFragmentProcessor*, true> fChildProcessors; |
| 242 | 233 |
| 243 typedef GrProcessor INHERITED; | 234 typedef GrProcessor INHERITED; |
| 244 }; | 235 }; |
| 245 | 236 |
| 246 #endif | 237 #endif |
| OLD | NEW |