OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef GrPaint_DEFINED | 10 #ifndef GrPaint_DEFINED |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 return *this; | 160 return *this; |
161 } | 161 } |
162 | 162 |
163 /** | 163 /** |
164 * Returns true if the paint's output color will be constant after blending.
If the result is | 164 * Returns true if the paint's output color will be constant after blending.
If the result is |
165 * true, constantColor will be updated to contain the constant color. Note t
hat we can conflate | 165 * true, constantColor will be updated to contain the constant color. Note t
hat we can conflate |
166 * coverage and color, so the actual values written to pixels with partial c
overage may still | 166 * coverage and color, so the actual values written to pixels with partial c
overage may still |
167 * not seem constant, even if this function returns true. | 167 * not seem constant, even if this function returns true. |
168 */ | 168 */ |
169 bool isConstantBlendedColor(GrColor* constantColor) const; | 169 bool isConstantBlendedColor(GrColor* constantColor) const { |
| 170 GrColor paintColor = this->getColor(); |
| 171 if (!fXPFactory && fColorFragmentProcessors.empty()) { |
| 172 if (!GrColorIsOpaque(paintColor)) { |
| 173 return false; |
| 174 } |
| 175 *constantColor = paintColor; |
| 176 return true; |
| 177 } |
| 178 return this->internalIsConstantBlendedColor(paintColor, constantColor); |
| 179 } |
170 | 180 |
171 private: | 181 private: |
| 182 bool internalIsConstantBlendedColor(GrColor paintColor, GrColor* constantCol
or) const; |
| 183 |
172 mutable sk_sp<GrXPFactory> fXPFactory; | 184 mutable sk_sp<GrXPFactory> fXPFactory; |
173 SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors; | 185 SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors; |
174 SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors; | 186 SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors; |
175 | 187 |
176 bool fAntiAlias; | 188 bool fAntiAlias; |
177 bool fDisableOutputConversionToSRGB; | 189 bool fDisableOutputConversionToSRGB; |
178 bool fAllowSRGBInputs; | 190 bool fAllowSRGBInputs; |
179 bool fUsesDistanceVectorField; | 191 bool fUsesDistanceVectorField; |
180 | 192 |
181 GrColor4f fColor; | 193 GrColor4f fColor; |
182 }; | 194 }; |
183 | 195 |
184 #endif | 196 #endif |
OLD | NEW |