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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef Sk4fGradientPriv_DEFINED 8 #ifndef Sk4fGradientPriv_DEFINED
9 #define Sk4fGradientPriv_DEFINED 9 #define Sk4fGradientPriv_DEFINED
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 store(c3, dst + 3); 101 store(c3, dst + 3);
102 } 102 }
103 } 103 }
104 }; 104 };
105 105
106 template <ApplyPremul premul> 106 template <ApplyPremul premul>
107 struct DstTraits<DstType::S32, premul> { 107 struct DstTraits<DstType::S32, premul> {
108 using PM = PremulTraits<premul>; 108 using PM = PremulTraits<premul>;
109 using Type = SkPMColor; 109 using Type = SkPMColor;
110 110
111 // TODO: prescale by something like (255^2, 255^2, 255^2, 255) and use
112 // linear_to_srgb to save a mult in store?
113 static Sk4f load(const SkPM4f& c) { 111 static Sk4f load(const SkPM4f& c) {
114 return c.to4f_pmorder(); 112 // Prescaling by (255^2, 255^2, 255^2, 255) on load, to avoid a 255 mult iply on
113 // each store (S32 conversion yields a uniform 255 factor).
114 return c.to4f_pmorder() * Sk4f(255 * 255, 255 * 255, 255 * 255, 255);
115 } 115 }
116 116
117 static void store(const Sk4f& c, Type* dst) { 117 static void store(const Sk4f& c, Type* dst) {
118 // FIXME: this assumes opaque colors. Handle unpremultiplication. 118 // FIXME: this assumes opaque colors. Handle unpremultiplication.
119 *dst = Sk4f_toS32(PM::apply(c)); 119 *dst = to_4b(linear_to_srgb(PM::apply(c)));
120 } 120 }
121 121
122 static void store(const Sk4f& c, Type* dst, int n) { 122 static void store(const Sk4f& c, Type* dst, int n) {
123 sk_memset32(dst, Sk4f_toS32(PM::apply(c)), n); 123 sk_memset32(dst, to_4b(linear_to_srgb(PM::apply(c))), n);
124 } 124 }
125 125
126 static void store4x(const Sk4f& c0, const Sk4f& c1, 126 static void store4x(const Sk4f& c0, const Sk4f& c1,
127 const Sk4f& c2, const Sk4f& c3, 127 const Sk4f& c2, const Sk4f& c3,
128 Type* dst) { 128 Type* dst) {
129 store(c0, dst + 0); 129 store(c0, dst + 0);
130 store(c1, dst + 1); 130 store(c1, dst + 1);
131 store(c2, dst + 2); 131 store(c2, dst + 2);
132 store(c3, dst + 3); 132 store(c3, dst + 3);
133 } 133 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 store(c0, dst + 0); 186 store(c0, dst + 0);
187 store(c1, dst + 1); 187 store(c1, dst + 1);
188 store(c2, dst + 2); 188 store(c2, dst + 2);
189 store(c3, dst + 3); 189 store(c3, dst + 3);
190 } 190 }
191 }; 191 };
192 192
193 } // anonymous namespace 193 } // anonymous namespace
194 194
195 #endif // Sk4fGradientPriv_DEFINED 195 #endif // Sk4fGradientPriv_DEFINED
OLDNEW
« 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