Introduce SkRGBA4f, templated on SkAlphaType
Most functionality is shared, but this lets us get type safety.
SkColor4f = SkRGBA4f<kUnpremul>
SkPMColor4f = SkRGBA4f<kPremul>
Change-Id: I27408565dc92e722f42a185cecbf7af15d1dde3f
Reviewed-on: https://skia-review.googlesource.com/156243
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index b5e3d13..9014114 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -151,10 +151,10 @@
input = input.opaque();
GrColor4f srcColor = ConstantOutputForConstantInput(this->childProcessor(0), input);
GrColor4f dstColor = ConstantOutputForConstantInput(this->childProcessor(1), input);
- SkColor4f src = srcColor.toSkColor4f();
- SkColor4f dst = dstColor.toSkColor4f();
- SkColor4f res = SkBlendMode_Apply(fMode, src, dst);
- return GrColor4f::FromSkColor4f(res).mulByScalar(alpha);
+ SkPMColor4f src = srcColor.asRGBA4f<kPremul_SkAlphaType>();
+ SkPMColor4f dst = dstColor.asRGBA4f<kPremul_SkAlphaType>();
+ SkPMColor4f res = SkBlendMode_Apply(fMode, src, dst);
+ return GrColor4f::FromRGBA4f(res).mulByScalar(alpha);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
@@ -406,16 +406,16 @@
GrColor4f constantOutputForConstantInput(GrColor4f inputColor) const override {
GrColor4f childColor =
ConstantOutputForConstantInput(this->childProcessor(0), GrColor4f::OpaqueWhite());
- SkColor4f src, dst;
+ SkPMColor4f src, dst;
if (kSrc_Child == fChild) {
- src = childColor.toSkColor4f();
- dst = inputColor.toSkColor4f();
+ src = childColor.asRGBA4f<kPremul_SkAlphaType>();
+ dst = inputColor.asRGBA4f<kPremul_SkAlphaType>();
} else {
- src = inputColor.toSkColor4f();
- dst = childColor.toSkColor4f();
+ src = inputColor.asRGBA4f<kPremul_SkAlphaType>();
+ dst = childColor.asRGBA4f<kPremul_SkAlphaType>();
}
- SkColor4f res = SkBlendMode_Apply(fMode, src, dst);
- return GrColor4f::FromSkColor4f(res);
+ SkPMColor4f res = SkBlendMode_Apply(fMode, src, dst);
+ return GrColor4f::FromRGBA4f(res);
}
private: