OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #include "GrPaint.h" | 9 #include "GrPaint.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 } | 46 } |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, | 50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, |
51 uint32_t* solidColorKnownComponents) const
{ | 51 uint32_t* solidColorKnownComponents) const
{ |
52 | 52 |
53 // TODO: Share this implementation with GrDrawState | 53 // TODO: Share this implementation with GrDrawState |
54 | 54 |
55 GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverag
e); | 55 GrProcessor::InvariantOutput inout; |
56 uint32_t coverageComps = kRGBA_GrColorComponentFlags; | 56 inout.fColor = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage); |
| 57 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
| 58 inout.fIsSingleComponent = false; |
57 int count = fCoverageStages.count(); | 59 int count = fCoverageStages.count(); |
58 for (int i = 0; i < count; ++i) { | 60 for (int i = 0; i < count; ++i) { |
59 fCoverageStages[i].getProcessor()->getConstantColorComponents(&coverage,
&coverageComps); | 61 fCoverageStages[i].getProcessor()->computeInvariantOutput(&inout); |
60 } | 62 } |
61 if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage)
{ | 63 if (!inout.isSolidWhite()) { |
62 return false; | 64 return false; |
63 } | 65 } |
64 | 66 |
65 GrColor color = fColor; | 67 inout.fColor = fColor; |
66 uint32_t colorComps = kRGBA_GrColorComponentFlags; | 68 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
| 69 inout.fIsSingleComponent = false; |
67 count = fColorStages.count(); | 70 count = fColorStages.count(); |
68 for (int i = 0; i < count; ++i) { | 71 for (int i = 0; i < count; ++i) { |
69 fColorStages[i].getProcessor()->getConstantColorComponents(&color, &colo
rComps); | 72 fColorStages[i].getProcessor()->computeInvariantOutput(&inout); |
70 } | 73 } |
71 | 74 |
72 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); | 75 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); |
73 | 76 |
74 GrBlendCoeff srcCoeff = fSrcBlendCoeff; | 77 GrBlendCoeff srcCoeff = fSrcBlendCoeff; |
75 GrBlendCoeff dstCoeff = fDstBlendCoeff; | 78 GrBlendCoeff dstCoeff = fDstBlendCoeff; |
76 GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0); | 79 GrSimplifyBlend(&srcCoeff, &dstCoeff, inout.fColor, inout.fValidFlags, |
| 80 0, 0, 0); |
77 | 81 |
78 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef
f); | 82 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef
f); |
79 if (solidColor) { | 83 if (solidColor) { |
80 if (opaque) { | 84 if (opaque) { |
81 switch (srcCoeff) { | 85 switch (srcCoeff) { |
82 case kZero_GrBlendCoeff: | 86 case kZero_GrBlendCoeff: |
83 *solidColor = 0; | 87 *solidColor = 0; |
84 *solidColorKnownComponents = kRGBA_GrColorComponentFlags; | 88 *solidColorKnownComponents = kRGBA_GrColorComponentFlags; |
85 break; | 89 break; |
86 | 90 |
87 case kOne_GrBlendCoeff: | 91 case kOne_GrBlendCoeff: |
88 *solidColor = color; | 92 *solidColor = inout.fColor; |
89 *solidColorKnownComponents = colorComps; | 93 *solidColorKnownComponents = inout.fValidFlags; |
90 break; | 94 break; |
91 | 95 |
92 // The src coeff should never refer to the src and if it refers
to dst then opaque | 96 // The src coeff should never refer to the src and if it refers
to dst then opaque |
93 // should have been false. | 97 // should have been false. |
94 case kSC_GrBlendCoeff: | 98 case kSC_GrBlendCoeff: |
95 case kISC_GrBlendCoeff: | 99 case kISC_GrBlendCoeff: |
96 case kDC_GrBlendCoeff: | 100 case kDC_GrBlendCoeff: |
97 case kIDC_GrBlendCoeff: | 101 case kIDC_GrBlendCoeff: |
98 case kSA_GrBlendCoeff: | 102 case kSA_GrBlendCoeff: |
99 case kISA_GrBlendCoeff: | 103 case kISA_GrBlendCoeff: |
(...skipping 10 matching lines...) Expand all Loading... |
110 case kIConstA_GrBlendCoeff: | 114 case kIConstA_GrBlendCoeff: |
111 *solidColorKnownComponents = 0; | 115 *solidColorKnownComponents = 0; |
112 break; | 116 break; |
113 } | 117 } |
114 } else { | 118 } else { |
115 solidColorKnownComponents = 0; | 119 solidColorKnownComponents = 0; |
116 } | 120 } |
117 } | 121 } |
118 return opaque; | 122 return opaque; |
119 } | 123 } |
OLD | NEW |