Chromium Code Reviews| 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. |
| 86 * | |
| 87 * Note: this function will NOT be recursive; it will be up to the parent pr oc to figure out | |
|
bsalomon
2015/08/18 14:15:43
Let's remove the comment here and just leave the o
wangyix
2015/08/18 14:20:59
Done.
| |
| 88 * what invariants its output can have given its children. | |
| 99 */ | 89 */ |
| 100 void computeInvariantOutput(GrInvariantOutput* inout) const; | 90 void computeInvariantOutput(GrInvariantOutput* inout) const; |
| 101 | 91 |
| 102 protected: | 92 protected: |
| 103 /** | 93 /** |
| 104 * Fragment Processor subclasses call this from their constructor to registe r coordinate | 94 * Fragment Processor subclasses call this from their constructor to registe r coordinate |
| 105 * transformations. Coord transforms provide a mechanism for a processor to receive coordinates | 95 * transformations. Coord transforms provide a mechanism for a processor to receive coordinates |
| 106 * in their FS code. The matrix expresses a transformation from local space. For a given | 96 * in their FS code. The matrix expresses a transformation from local space. For a given |
| 107 * fragment the matrix will be applied to the local coordinate that maps to the fragment. | 97 * fragment the matrix will be applied to the local coordinate that maps to the fragment. |
| 108 * | 98 * |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 124 * FragmentProcessors they have. | 114 * FragmentProcessors they have. |
| 125 * This is for processors whose shader code will be composed of nested proce ssors whose output | 115 * 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 | 116 * 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 | 117 * processors will allow the ProgramBuilder to automatically handle their tr ansformed coords and |
| 128 * texture accesses and mangle their uniform and output color names. | 118 * texture accesses and mangle their uniform and output color names. |
| 129 */ | 119 */ |
| 130 int registerChildProcessor(const GrFragmentProcessor* child); | 120 int registerChildProcessor(const GrFragmentProcessor* child); |
| 131 | 121 |
| 132 /** | 122 /** |
| 133 * Subclass implements this to support getConstantColorComponents(...). | 123 * Subclass implements this to support getConstantColorComponents(...). |
| 124 * | |
| 125 * Note: it's up to the subclass implementation to do any recursive call to compute the child | |
| 126 * procs' output invariants; computeInvariantOutput will not be recursive. | |
| 134 */ | 127 */ |
| 135 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; | 128 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; |
| 136 | 129 |
| 137 private: | 130 private: |
| 138 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */ | 131 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */ |
| 139 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 132 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 140 GrProcessorKeyBuilder* b) const = 0; | 133 GrProcessorKeyBuilder* b) const = 0; |
| 141 | 134 |
| 142 /** | 135 /** |
| 143 * Subclass implements this to support isEqual(). It will only be called if it is known that | 136 * 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. | 168 * The same goes for fTextureAccesses with textures. |
| 176 */ | 169 */ |
| 177 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 170 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
| 178 | 171 |
| 179 SkTArray<GrFragmentStage, false> fChildProcessors; | 172 SkTArray<GrFragmentStage, false> fChildProcessors; |
| 180 | 173 |
| 181 typedef GrProcessor INHERITED; | 174 typedef GrProcessor INHERITED; |
| 182 }; | 175 }; |
| 183 | 176 |
| 184 #endif | 177 #endif |
| OLD | NEW |