diff --git a/src/core/SkColor.cpp b/src/core/SkColor.cpp index bee114b1e8..c77a5dcce0 100644 --- a/src/core/SkColor.cpp +++ b/src/core/SkColor.cpp @@ -108,7 +108,11 @@ SkColor SkHSVToColor(U8CPU a, const SkScalar hsv[3]) { #include "SkHalf.h" SkPM4f SkPM4f::FromPMColor(SkPMColor c) { - return From4f(swizzle_rb_if_bgra(Sk4f_fromL32(c))); + return From4f(swizzle_rb_if_bgra(Sk4f_fromS32(c))); +} + +SkPMColor SkPM4f::toPMColor() const { + return Sk4f_toS32(swizzle_rb_if_bgra(this->to4f())); } SkColor4f SkPM4f::unpremul() const { diff --git a/src/core/SkPM4f.h b/src/core/SkPM4f.h index f983101f41..4690e023fa 100644 --- a/src/core/SkPM4f.h +++ b/src/core/SkPM4f.h @@ -50,12 +50,7 @@ struct SkPM4f { Sk4f to4f_bgra() const { return swizzle_rb(this->to4f()); } Sk4f to4f_pmorder() const { return swizzle_rb_if_bgra(this->to4f()); } - SkPMColor toPMColor() const { - Sk4f value = swizzle_rb_if_bgra(this->to4f()); - SkPMColor result; - SkNx_cast(value * Sk4f(255) + Sk4f(0.5f)).store(&result); - return result; - } + SkPMColor toPMColor() const; void toF16(uint16_t[4]) const; uint64_t toF16() const; // 4 float16 values packed into uint64_t