remove pin in SkColor4f::premul()
As prep for fusing SkPM4f into SkColor4f, we noticed this pin. It's usually premature to pin when premultiplying here if the output format is wide. We might want to replace this with pinThenPremul(), and add a new premul() that starts fresh without a pin? Change-Id: I0a8df58060ccab249f4df86eb88289dbf5934fb4 Reviewed-on: https://skia-review.googlesource.com/156002 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
63fd39701a
commit
7780c4c4e1
@ -168,9 +168,6 @@ SkColor4f SkColor4f::Pin(float r, float g, float b, float a) {
|
||||
}
|
||||
|
||||
SkPM4f SkColor4f::premul() const {
|
||||
auto src = Sk4f::Load(this->pin().vec());
|
||||
float srcAlpha = src[3]; // need the pinned version of our alpha
|
||||
src = src * Sk4f(srcAlpha, srcAlpha, srcAlpha, 1);
|
||||
|
||||
return SkPM4f::From4f(src);
|
||||
auto rgba = Sk4f::Load(this->vec());
|
||||
return SkPM4f::From4f(rgba * Sk4f(rgba[3], rgba[3], rgba[3], 1));
|
||||
}
|
||||
|
@ -12,10 +12,17 @@
|
||||
namespace {
|
||||
|
||||
Sk4f pack_color(const SkColor4f& c4f, bool premul, const Sk4f& component_scale) {
|
||||
const Sk4f pm4f = premul
|
||||
Sk4f pm4f = premul
|
||||
? c4f.premul().to4f()
|
||||
: Sk4f{c4f.fR, c4f.fG, c4f.fB, c4f.fA};
|
||||
|
||||
if (premul) {
|
||||
// If the stops are premul, we clamp them to gamut now.
|
||||
// If the stops are unpremul, the colors will eventually go through Sk4f_toL32(),
|
||||
// which ends up clamping to gamut then.
|
||||
pm4f = Sk4f::Max(0, Sk4f::Min(pm4f, pm4f[3]));
|
||||
}
|
||||
|
||||
return pm4f * component_scale;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user