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

Side by Side Diff: src/core/SkPM4fPriv.h

Issue 2097003003: remove experimental treat-skcolor-as-srgb flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix toSkColor Created 4 years, 6 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/SkColor.cpp ('k') | tests/SkColor4fTest.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 SkPM4fPriv_DEFINED 8 #ifndef SkPM4fPriv_DEFINED
9 #define SkPM4fPriv_DEFINED 9 #define SkPM4fPriv_DEFINED
10 10
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkPM4f.h" 12 #include "SkPM4f.h"
13 13
14 extern bool gTreatSkColorAsSRGB;
15
16 static inline float get_alpha(const Sk4f& f4) { 14 static inline float get_alpha(const Sk4f& f4) {
17 return f4[SkPM4f::A]; 15 return f4[SkPM4f::A];
18 } 16 }
19 17
20 static inline Sk4f set_alpha(const Sk4f& f4, float alpha) { 18 static inline Sk4f set_alpha(const Sk4f& f4, float alpha) {
21 static_assert(3 == SkPM4f::A, ""); 19 static_assert(3 == SkPM4f::A, "");
22 return Sk4f(f4[0], f4[1], f4[2], alpha); 20 return Sk4f(f4[0], f4[1], f4[2], alpha);
23 } 21 }
24 22
25 static inline uint32_t to_4b(const Sk4f& f4) { 23 static inline uint32_t to_4b(const Sk4f& f4) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 99 }
102 100
103 static inline Sk4f Sk4f_fromS32(uint32_t src) { 101 static inline Sk4f Sk4f_fromS32(uint32_t src) {
104 return srgb_to_linear(to_4f(src) * Sk4f(1.0f/255)); 102 return srgb_to_linear(to_4f(src) * Sk4f(1.0f/255));
105 } 103 }
106 104
107 // Color handling: 105 // Color handling:
108 // SkColor has an ordering of (b, g, r, a) if cast to an Sk4f, so the code swi zzles r and b to 106 // SkColor has an ordering of (b, g, r, a) if cast to an Sk4f, so the code swi zzles r and b to
109 // produce the needed (r, g, b, a) ordering. 107 // produce the needed (r, g, b, a) ordering.
110 static inline Sk4f Sk4f_from_SkColor(SkColor color) { 108 static inline Sk4f Sk4f_from_SkColor(SkColor color) {
111 return swizzle_rb(gTreatSkColorAsSRGB ? Sk4f_fromS32(color) : Sk4f_fromL32(c olor)); 109 return swizzle_rb(Sk4f_fromS32(color));
112 } 110 }
113 111
114 static inline uint32_t Sk4f_toL32(const Sk4f& x4) { 112 static inline uint32_t Sk4f_toL32(const Sk4f& x4) {
115 return to_4b(x4 * Sk4f(255) + Sk4f(0.5f)); 113 return to_4b(x4 * Sk4f(255) + Sk4f(0.5f));
116 } 114 }
117 115
118 static inline uint32_t Sk4f_toS32(const Sk4f& x4) { 116 static inline uint32_t Sk4f_toS32(const Sk4f& x4) {
119 return to_4b(linear_to_srgb(x4) * Sk4f(255) + Sk4f(0.5f)); 117 return to_4b(linear_to_srgb(x4) * Sk4f(255) + Sk4f(0.5f));
120 } 118 }
121 119
122 static inline Sk4f exact_Sk4f_fromS32(uint32_t src) { 120 static inline Sk4f exact_Sk4f_fromS32(uint32_t src) {
123 return exact_srgb_to_linear(to_4f(src) * Sk4f(1.0f/255)); 121 return exact_srgb_to_linear(to_4f(src) * Sk4f(1.0f/255));
124 } 122 }
125 static inline uint32_t exact_Sk4f_toS32(const Sk4f& x4) { 123 static inline uint32_t exact_Sk4f_toS32(const Sk4f& x4) {
126 return to_4b(exact_linear_to_srgb(x4) * Sk4f(255) + Sk4f(0.5f)); 124 return to_4b(exact_linear_to_srgb(x4) * Sk4f(255) + Sk4f(0.5f));
127 } 125 }
128 126
129 #endif 127 #endif
OLDNEW
« no previous file with comments | « src/core/SkColor.cpp ('k') | tests/SkColor4fTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698