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

Side by Side Diff: src/effects/gradients/Sk4fGradientPriv.h

Issue 2163683002: Correct sRGB <-> linear everywhere. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: back to brute Created 4 years, 5 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
« no previous file with comments | « src/core/SkXfermode4f.cpp ('k') | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static Sk4f load(const SkPM4f& c) { 111 static Sk4f load(const SkPM4f& c) {
112 // Prescaling by (255^2, 255^2, 255^2, 255) on load, to avoid a 255 mult iply on 112 return c.to4f_pmorder();
113 // each store (S32 conversion yields a uniform 255 factor).
114 return c.to4f_pmorder() * Sk4f(255 * 255, 255 * 255, 255 * 255, 255);
115 } 113 }
116 114
117 static void store(const Sk4f& c, Type* dst) { 115 static void store(const Sk4f& c, Type* dst) {
118 // FIXME: this assumes opaque colors. Handle unpremultiplication. 116 // FIXME: this assumes opaque colors. Handle unpremultiplication.
119 *dst = to_4b(linear_to_srgb(PM::apply(c))); 117 *dst = Sk4f_toS32(PM::apply(c));
120 } 118 }
121 119
122 static void store(const Sk4f& c, Type* dst, int n) { 120 static void store(const Sk4f& c, Type* dst, int n) {
123 sk_memset32(dst, to_4b(linear_to_srgb(PM::apply(c))), n); 121 sk_memset32(dst, Sk4f_toS32(PM::apply(c)), n);
124 } 122 }
125 123
126 static void store4x(const Sk4f& c0, const Sk4f& c1, 124 static void store4x(const Sk4f& c0, const Sk4f& c1,
127 const Sk4f& c2, const Sk4f& c3, 125 const Sk4f& c2, const Sk4f& c3,
128 Type* dst) { 126 Type* dst) {
129 store(c0, dst + 0); 127 store(c0, dst + 0);
130 store(c1, dst + 1); 128 store(c1, dst + 1);
131 store(c2, dst + 2); 129 store(c2, dst + 2);
132 store(c3, dst + 3); 130 store(c3, dst + 3);
133 } 131 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 store(c0, dst + 0); 186 store(c0, dst + 0);
189 store(c1, dst + 1); 187 store(c1, dst + 1);
190 store(c2, dst + 2); 188 store(c2, dst + 2);
191 store(c3, dst + 3); 189 store(c3, dst + 3);
192 } 190 }
193 }; 191 };
194 192
195 } // anonymous namespace 193 } // anonymous namespace
196 194
197 #endif // Sk4fGradientPriv_DEFINED 195 #endif // Sk4fGradientPriv_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkXfermode4f.cpp ('k') | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698