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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 /** Returns the coordinate transformation at index. index must be valid acco
rding to | 55 /** Returns the coordinate transformation at index. index must be valid acco
rding to |
56 numTransforms(). */ | 56 numTransforms(). */ |
57 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran
sforms[index]; } | 57 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran
sforms[index]; } |
58 | 58 |
59 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { | 59 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { |
60 return fCoordTransforms; | 60 return fCoordTransforms; |
61 } | 61 } |
62 | 62 |
| 63 /** Gather the coord transforms into an array. We use preorder traversal */ |
| 64 void gatherCoordTransforms(SkTArray<const GrCoordTransform*, true>* outTrans
forms) const { |
| 65 SkASSERT(outTransforms); |
| 66 outTransforms->push_back_n(fCoordTransforms.count(), fCoordTransforms.be
gin()); |
| 67 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 68 fChildProcessors[i]->gatherCoordTransforms(outTransforms); |
| 69 } |
| 70 } |
| 71 |
63 int numChildProcessors() const { return fChildProcessors.count(); } | 72 int numChildProcessors() const { return fChildProcessors.count(); } |
64 | 73 |
65 GrFragmentProcessor* childProcessor(int index) const { return fChildProcesso
rs[index]; } | 74 GrFragmentProcessor* childProcessor(int index) const { return fChildProcesso
rs[index]; } |
66 | 75 |
67 const SkTArray<GrFragmentProcessor*, false>& childProcessors() const { | 76 const SkTArray<GrFragmentProcessor*, false>& childProcessors() const { |
68 return fChildProcessors; | 77 return fChildProcessors; |
69 } | 78 } |
70 | 79 |
71 int numTexturesIncludeChildProcs() const { | 80 int numTexturesIncludeChildProcs() const { |
72 int numTextures = this->numTextures(); | 81 int numTextures = this->numTextures(); |
73 for (int i = 0; i < fChildProcessors.count(); ++i) { | 82 for (int i = 0; i < fChildProcessors.count(); ++i) { |
74 numTextures += fChildProcessors[i]->numTexturesIncludeChildProcs(); | 83 numTextures += fChildProcessors[i]->numTexturesIncludeChildProcs(); |
75 } | 84 } |
76 return numTextures; | 85 return numTextures; |
77 } | 86 } |
78 | 87 |
79 /** Do any of the coordtransforms for this processor require local coords? *
/ | 88 /** Do any of the coordtransforms for this processor require local coords? *
/ |
80 bool usesLocalCoords() const { return fUsesLocalCoords; } | 89 bool usesLocalCoords() const { return fUsesLocalCoords; } |
81 | 90 |
82 /** Returns true if this and other processor conservatively draw identically
. It can only return | 91 /** Returns true if this and other processor conservatively draw identically
. It can only return |
83 true when the two processor are of the same subclass (i.e. they return t
he same object from | 92 true when the two processor are of the same subclass (i.e. they return t
he same object from |
84 from getFactory()). | 93 from getFactory()). |
85 | 94 |
86 A return value of true from isEqual() should not be used to test whether
the processor would | 95 A return value of true from isEqual() should not be used to test whether
the processor would |
87 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 96 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ |
88 bool isEqual(const GrFragmentProcessor& that) const { | 97 bool isEqual(const GrFragmentProcessor& that, bool ignoreCoordTransforms) co
nst { |
89 if (this->classID() != that.classID() || | 98 if (this->classID() != that.classID() || |
90 !this->hasSameTransforms(that) || | |
91 !this->hasSameTextureAccesses(that)) { | 99 !this->hasSameTextureAccesses(that)) { |
92 return false; | 100 return false; |
93 } | 101 } |
| 102 if (ignoreCoordTransforms) { |
| 103 if (this->numTransforms() != that.numTransforms()) { |
| 104 return false; |
| 105 } |
| 106 } else if (!this->hasSameTransforms(that)) { |
| 107 return false; |
| 108 } |
94 return this->onIsEqual(that); | 109 return this->onIsEqual(that); |
95 } | 110 } |
96 | 111 |
97 /** | 112 /** |
98 * This function is used to perform optimizations. When called the invarient
Ouput param | 113 * This function is used to perform optimizations. When called the invarient
Ouput param |
99 * indicate whether the input components to this processor in the FS will ha
ve known values. | 114 * indicate whether the input components to this processor in the FS will ha
ve known values. |
100 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent | 115 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th
e isSingleComponent |
101 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of | 116 * member indicates whether the input will be 1 or 4 bytes. The function upd
ates the members of |
102 * inout to indicate known values of its output. A component of the color me
mber only has | 117 * inout to indicate known values of its output. A component of the color me
mber only has |
103 * meaning if the corresponding bit in validFlags is set. | 118 * meaning if the corresponding bit in validFlags is set. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 bool hasSameTransforms(const GrFragmentProcessor&) const; | 169 bool hasSameTransforms(const GrFragmentProcessor&) const; |
155 | 170 |
156 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 171 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
157 bool fUsesLocalCoords; | 172 bool fUsesLocalCoords; |
158 SkTArray<GrFragmentProcessor*, false> fChildProcessors; | 173 SkTArray<GrFragmentProcessor*, false> fChildProcessors; |
159 | 174 |
160 typedef GrProcessor INHERITED; | 175 typedef GrProcessor INHERITED; |
161 }; | 176 }; |
162 | 177 |
163 #endif | 178 #endif |
OLD | NEW |