Chromium Code Reviews| Index: include/gpu/GrInvariantOutput.h |
| diff --git a/include/gpu/GrInvariantOutput.h b/include/gpu/GrInvariantOutput.h |
| index 4977333de4e80779432c0eb20289ad5065f47ae3..acc9cde2d9cecdf6c65288bc8d3f6e50f4fc2419 100644 |
| --- a/include/gpu/GrInvariantOutput.h |
| +++ b/include/gpu/GrInvariantOutput.h |
| @@ -116,10 +116,66 @@ public: |
| SkMulDiv255Round(GrColorUnpackG(fColor), alpha), |
| SkMulDiv255Round(GrColorUnpackB(fColor), alpha), |
| SkMulDiv255Round(GrColorUnpackA(fColor), alpha)); |
| + // We don't need to change fIsSingleComponent in this case |
| } |
| } |
| } |
| + void mulByKnownFourComponents(GrColor color) { |
| + if (0 == color) { |
| + this->internalSetToTransparentBlack(); |
| + } else { |
| + if (color != 0xffffffff) { |
| + fColor = GrColorPackRGBA( |
| + SkMulDiv255Round(GrColorUnpackR(fColor), GrColorUnpackR(color)), |
| + SkMulDiv255Round(GrColorUnpackG(fColor), GrColorUnpackG(color)), |
| + SkMulDiv255Round(GrColorUnpackB(fColor), GrColorUnpackB(color)), |
| + SkMulDiv255Round(GrColorUnpackA(fColor), GrColorUnpackA(color))); |
| + this->updateIsSingleComponent(); |
|
egdaniel
2015/03/04 15:17:03
at least with what is in the updateISC function no
bsalomon
2015/03/04 19:43:36
Done.
|
| + } |
| + } |
| + } |
| + |
| + // Ignores the incoming color's RGB and muls its alpha by color. |
| + void mulAlphaByKnownFourComponents(GrColor color) { |
| + if (0 == color || 0 == this->hasZeroAlpha()) { |
| + this->internalSetToTransparentBlack(); |
| + } else { |
| + if (fValidFlags & kA_GrColorComponentFlag) { |
| + GrColor alpha = GrColorUnpackA(fColor); |
| + fColor = GrColorPackRGBA( |
| + SkMulDiv255Round(alpha, GrColorUnpackR(color)), |
| + SkMulDiv255Round(alpha, GrColorUnpackG(color)), |
| + SkMulDiv255Round(alpha, GrColorUnpackB(color)), |
| + SkMulDiv255Round(alpha, GrColorUnpackA(color))); |
| + fValidFlags = kRGBA_GrColorComponentFlags; |
| + } else { |
| + fValidFlags = 0; |
| + } |
| + // If color is single channel then so are we. |
| + GrColor a = GrColorUnpackA(color); |
| + fIsSingleComponent = a == GrColorUnpackR(color) && a == GrColorUnpackG(color) && |
| + a == GrColorUnpackB(color); |
| + } |
| + } |
| + |
| + // Ignores the incoming color's RGB and muls its alpha by the alpha param. |
| + void mulAlphaByKnownSingleComponent(uint8_t alpha) { |
| + if (0 == alpha || 0 == this->hasZeroAlpha()) { |
| + this->internalSetToTransparentBlack(); |
| + } else { |
| + if (fValidFlags & kA_GrColorComponentFlag) { |
| + GrColor a = GrColorUnpackA(fColor); |
| + a = SkMulDiv255Round(alpha, a); |
| + fColor = GrColorPackRGBA(a, a, a, a); |
| + fValidFlags = kRGBA_GrColorComponentFlags; |
| + } else { |
| + fValidFlags = 0; |
| + } |
| + fIsSingleComponent = true; |
| + } |
| + } |
| + |
| void invalidateComponents(uint8_t invalidateFlags, ReadInput readsInput) { |
| fValidFlags &= ~invalidateFlags; |
| fIsSingleComponent = false; |
| @@ -205,6 +261,14 @@ private: |
| return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor); |
| } |
| + void updateIsSingleComponent() { |
|
egdaniel
2015/03/04 15:17:03
In general I am not a big fan of this function or
|
| + if (kRGBA_GrColorComponentFlags == fValidFlags) { |
| + GrColor a = GrColorUnpackA(fColor); |
| + fIsSingleComponent = a == GrColorUnpackR(fColor) && a == GrColorUnpackG(fColor) && |
| + a == GrColorUnpackB(fColor); |
| + } |
| + |
| + } |
| bool isSingleComponent() const { return fIsSingleComponent; } |
| bool willUseInputColor() const { return fWillUseInputColor; } |