Index: src/effects/gradients/Sk4fGradientPriv.h |
diff --git a/src/effects/gradients/Sk4fGradientPriv.h b/src/effects/gradients/Sk4fGradientPriv.h |
index 4f71d3f14df6929d403872c1c22f7a014090ca42..ae6fe7ce466acd7197aabddfc5cf2fc50273a02e 100644 |
--- a/src/effects/gradients/Sk4fGradientPriv.h |
+++ b/src/effects/gradients/Sk4fGradientPriv.h |
@@ -108,19 +108,19 @@ struct DstTraits<DstType::S32, premul> { |
using PM = PremulTraits<premul>; |
using Type = SkPMColor; |
- // TODO: prescale by something like (255^2, 255^2, 255^2, 255) and use |
- // linear_to_srgb to save a mult in store? |
static Sk4f load(const SkPM4f& c) { |
- return c.to4f_pmorder(); |
+ // Prescaling by (255^2, 255^2, 255^2, 255) on load, to avoid a 255 multiply on |
+ // each store (S32 conversion yields a uniform 255 factor). |
+ return c.to4f_pmorder() * Sk4f(255 * 255, 255 * 255, 255 * 255, 255); |
} |
static void store(const Sk4f& c, Type* dst) { |
// FIXME: this assumes opaque colors. Handle unpremultiplication. |
- *dst = Sk4f_toS32(PM::apply(c)); |
+ *dst = to_4b(linear_to_srgb(PM::apply(c))); |
} |
static void store(const Sk4f& c, Type* dst, int n) { |
- sk_memset32(dst, Sk4f_toS32(PM::apply(c)), n); |
+ sk_memset32(dst, to_4b(linear_to_srgb(PM::apply(c))), n); |
} |
static void store4x(const Sk4f& c0, const Sk4f& c1, |