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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 60 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ |
61 bool isEqual(const GrFragmentProcessor& that) const { | 61 bool isEqual(const GrFragmentProcessor& that) const { |
62 if (this->classID() != that.classID() || | 62 if (this->classID() != that.classID() || |
63 !this->hasSameTransforms(that) || | 63 !this->hasSameTransforms(that) || |
64 !this->hasSameTextureAccesses(that)) { | 64 !this->hasSameTextureAccesses(that)) { |
65 return false; | 65 return false; |
66 } | 66 } |
67 return this->onIsEqual(that); | 67 return this->onIsEqual(that); |
68 } | 68 } |
69 | 69 |
| 70 /** |
| 71 * This function is used to perform optimizations. When called the invarient
Ouput param |
| 72 * indicate whether the input components to this processor in the FS will ha
ve known values. |
| 73 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent |
| 74 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of |
| 75 * inout to indicate known values of its output. A component of the color me
mber only has |
| 76 * meaning if the corresponding bit in validFlags is set. |
| 77 */ |
| 78 void computeInvariantOutput(GrInvariantOutput* inout) const; |
| 79 |
70 protected: | 80 protected: |
71 /** | 81 /** |
72 * Fragment Processor subclasses call this from their constructor to registe
r coordinate | 82 * Fragment Processor subclasses call this from their constructor to registe
r coordinate |
73 * transformations. Coord transforms provide a mechanism for a processor to
receive coordinates | 83 * transformations. Coord transforms provide a mechanism for a processor to
receive coordinates |
74 * in their FS code. The matrix expresses a transformation from local space.
For a given | 84 * in their FS code. The matrix expresses a transformation from local space.
For a given |
75 * fragment the matrix will be applied to the local coordinate that maps to
the fragment. | 85 * fragment the matrix will be applied to the local coordinate that maps to
the fragment. |
76 * | 86 * |
77 * When the transformation has perspective, the transformed coordinates will
have | 87 * When the transformation has perspective, the transformed coordinates will
have |
78 * 3 components. Otherwise they'll have 2. | 88 * 3 components. Otherwise they'll have 2. |
79 * | 89 * |
(...skipping 14 matching lines...) Expand all Loading... |
94 */ | 104 */ |
95 void setWillReadDstColor() { fWillReadDstColor = true; } | 105 void setWillReadDstColor() { fWillReadDstColor = true; } |
96 | 106 |
97 /** | 107 /** |
98 * If the prceossor will generate a result that does not depend on the input
color value then it | 108 * If the prceossor will generate a result that does not depend on the input
color value then it |
99 * must call this function from its constructor. Otherwise, when its generat
ed backend-specific | 109 * must call this function from its constructor. Otherwise, when its generat
ed backend-specific |
100 * code might fail during variable binding due to unused variables. | 110 * code might fail during variable binding due to unused variables. |
101 */ | 111 */ |
102 void setWillNotUseInputColor() { fWillUseInputColor = false; } | 112 void setWillNotUseInputColor() { fWillUseInputColor = false; } |
103 | 113 |
| 114 /** |
| 115 * Subclass implements this to support getConstantColorComponents(...). |
| 116 */ |
| 117 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; |
| 118 |
104 private: | 119 private: |
105 /** | 120 /** |
106 * Subclass implements this to support isEqual(). It will only be called if
it is known that | 121 * Subclass implements this to support isEqual(). It will only be called if
it is known that |
107 * the two processors are of the same subclass (i.e. they return the same ob
ject from | 122 * the two processors are of the same subclass (i.e. they return the same ob
ject from |
108 * getFactory()). The processor subclass should not compare its coord transf
orms as that will | 123 * getFactory()). The processor subclass should not compare its coord transf
orms as that will |
109 * be performed automatically in the non-virtual isEqual(). | 124 * be performed automatically in the non-virtual isEqual(). |
110 */ | 125 */ |
111 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; | 126 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; |
112 | 127 |
113 bool hasSameTransforms(const GrFragmentProcessor&) const; | 128 bool hasSameTransforms(const GrFragmentProcessor&) const; |
114 | 129 |
115 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 130 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
116 bool fWillReadDstColor; | 131 bool fWillReadDstColor; |
117 bool fWillUseInputColor; | 132 bool fWillUseInputColor; |
118 | 133 |
119 typedef GrProcessor INHERITED; | 134 typedef GrProcessor INHERITED; |
120 }; | 135 }; |
121 | 136 |
122 #endif | 137 #endif |
OLD | NEW |