Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: include/gpu/GrInvariantOutput.h

Issue 978713002: Add constant color GrFP. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/effects/GrColorProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; }
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/effects/GrColorProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698