egdaniel | 605dd0f | 2014-11-12 08:35:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrInvariantOutput.h" |
| 9 | |
| 10 | #ifdef SK_DEBUG |
| 11 | |
| 12 | void GrInvariantOutput::validate() const { |
| 13 | if (fIsSingleComponent) { |
| 14 | SkASSERT(0 == fValidFlags || kRGBA_GrColorComponentFlags == fValidFlags); |
| 15 | if (kRGBA_GrColorComponentFlags == fValidFlags) { |
| 16 | SkASSERT(this->colorComponentsAllEqual()); |
| 17 | } |
| 18 | } |
| 19 | |
egdaniel | 605dd0f | 2014-11-12 08:35:25 -0800 | [diff] [blame] | 20 | // If we claim that we are not using the input color we must not be modulating the input. |
| 21 | SkASSERT(fNonMulStageFound || fWillUseInputColor); |
| 22 | } |
| 23 | |
| 24 | bool GrInvariantOutput::colorComponentsAllEqual() const { |
| 25 | unsigned colorA = GrColorUnpackA(fColor); |
| 26 | return(GrColorUnpackR(fColor) == colorA && |
| 27 | GrColorUnpackG(fColor) == colorA && |
| 28 | GrColorUnpackB(fColor) == colorA); |
| 29 | } |
| 30 | |
egdaniel | 605dd0f | 2014-11-12 08:35:25 -0800 | [diff] [blame] | 31 | #endif // end DEBUG |