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 GrInvariantOutput_DEFINED | 8 #ifndef GrInvariantOutput_DEFINED |
9 #define GrInvariantOutput_DEFINED | 9 #define GrInvariantOutput_DEFINED |
10 | 10 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 fIsSingleComponent = false; | 215 fIsSingleComponent = false; |
216 fNonMulStageFound = true; | 216 fNonMulStageFound = true; |
217 if (kWillNot_ReadInput == readsInput) { | 217 if (kWillNot_ReadInput == readsInput) { |
218 fWillUseInputColor = false; | 218 fWillUseInputColor = false; |
219 } | 219 } |
220 if (kRGBA_GrColorComponentFlags == fValidFlags) { | 220 if (kRGBA_GrColorComponentFlags == fValidFlags) { |
221 uint32_t a; | 221 uint32_t a; |
222 if (GetAlphaAndCheckSingleChannel(color, &a)) { | 222 if (GetAlphaAndCheckSingleChannel(color, &a)) { |
223 fIsSingleComponent = true; | 223 fIsSingleComponent = true; |
224 } | 224 } |
225 } else if (kA_GrColorComponentFlag & fValidFlags) { | |
226 // Assuming fColor is premul means if a is 0 the color must be all 0
s. | |
227 if (!GrColorUnpackA(fColor)) { | |
228 this->internalSetToTransparentBlack(); | |
229 } | |
230 } | 225 } |
231 SkDEBUGCODE(this->validate()); | 226 SkDEBUGCODE(this->validate()); |
232 } | 227 } |
233 | 228 |
234 void setToUnknown(ReadInput readsInput) { | 229 void setToUnknown(ReadInput readsInput) { |
235 SkDEBUGCODE(this->validate()); | 230 SkDEBUGCODE(this->validate()); |
236 this->internalSetToUnknown(); | 231 this->internalSetToUnknown(); |
237 fNonMulStageFound= true; | 232 fNonMulStageFound= true; |
238 if (kWillNot_ReadInput == readsInput) { | 233 if (kWillNot_ReadInput == readsInput) { |
239 fWillUseInputColor = false; | 234 fWillUseInputColor = false; |
240 } | 235 } |
241 SkDEBUGCODE(this->validate()); | 236 SkDEBUGCODE(this->validate()); |
242 } | 237 } |
243 | 238 |
244 // Temporary setter to handle LCD text correctly until we improve texture pi
xel config queries | 239 // Temporary setter to handle LCD text correctly until we improve texture pi
xel config queries |
245 // and thus can rely solely on number of coverage components for RGA vs sing
le channel coverage. | 240 // and thus can rely solely on number of coverage components for RGA vs sing
le channel coverage. |
246 void setUsingLCDCoverage() { | 241 void setUsingLCDCoverage() { |
247 fIsLCDCoverage = true; | 242 fIsLCDCoverage = true; |
248 } | 243 } |
249 | 244 |
250 GrColor color() const { return fColor; } | 245 GrColor color() const { return fColor; } |
251 GrColorComponentFlags validFlags() const { return fValidFlags; } | 246 GrColorComponentFlags validFlags() const { return fValidFlags; } |
| 247 bool willUseInputColor() const { return fWillUseInputColor; } |
252 | 248 |
253 /** | 249 /** |
254 * If isSingleComponent is true, then the flag values for r, g, b, and a mus
t all be the | 250 * If isSingleComponent is true, then the flag values for r, g, b, and a mus
t all be the |
255 * same. If the flags are all set then all color components must be equal. | 251 * same. If the flags are all set then all color components must be equal. |
256 */ | 252 */ |
257 SkDEBUGCODE(void validate() const;) | 253 SkDEBUGCODE(void validate() const;) |
258 | 254 |
259 private: | 255 private: |
260 friend class GrProcOptInfo; | 256 friend class GrProcOptInfo; |
261 | 257 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 bool isOpaque() const { | 297 bool isOpaque() const { |
302 return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpack
A(fColor)); | 298 return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpack
A(fColor)); |
303 } | 299 } |
304 | 300 |
305 bool isSolidWhite() const { | 301 bool isSolidWhite() const { |
306 return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fCol
or); | 302 return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fCol
or); |
307 } | 303 } |
308 | 304 |
309 bool isSingleComponent() const { return fIsSingleComponent; } | 305 bool isSingleComponent() const { return fIsSingleComponent; } |
310 | 306 |
311 bool willUseInputColor() const { return fWillUseInputColor; } | |
312 void resetWillUseInputColor() { fWillUseInputColor = true; } | 307 void resetWillUseInputColor() { fWillUseInputColor = true; } |
313 | 308 |
314 bool allStagesMulInput() const { return !fNonMulStageFound; } | 309 bool allStagesMulInput() const { return !fNonMulStageFound; } |
315 void resetNonMulStageFound() { fNonMulStageFound = false; } | 310 void resetNonMulStageFound() { fNonMulStageFound = false; } |
316 | 311 |
317 bool isLCDCoverage() const { return fIsLCDCoverage; } | 312 bool isLCDCoverage() const { return fIsLCDCoverage; } |
318 | 313 |
319 SkDEBUGCODE(bool colorComponentsAllEqual() const;) | 314 SkDEBUGCODE(bool colorComponentsAllEqual() const;) |
320 /** | 315 /** |
321 * If alpha is valid, check that any valid R,G,B values are <= A | 316 * If alpha is valid, check that any valid R,G,B values are <= A |
322 */ | 317 */ |
323 SkDEBUGCODE(bool validPreMulColor() const;) | 318 SkDEBUGCODE(bool validPreMulColor() const;) |
324 | 319 |
325 GrColor fColor; | 320 GrColor fColor; |
326 GrColorComponentFlags fValidFlags; | 321 GrColorComponentFlags fValidFlags; |
327 bool fIsSingleComponent; | 322 bool fIsSingleComponent; |
328 bool fNonMulStageFound; | 323 bool fNonMulStageFound; |
329 bool fWillUseInputColor; | 324 bool fWillUseInputColor; |
330 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are
updated | 325 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are
updated |
331 | 326 |
332 }; | 327 }; |
333 | 328 |
334 #endif | 329 #endif |
335 | 330 |
OLD | NEW |