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

Unified Diff: src/effects/gradients/Sk4fGradientPriv.h

Issue 1825333003: Planar ramp() for S32 linear gradients (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
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,
« no previous file with comments | « no previous file | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | src/effects/gradients/Sk4fLinearGradient.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698