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

Side by Side Diff: src/core/SkLinearBitmapPipeline_sample.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/SkColorMatrixFilterRowMajor255.cpp ('k') | src/core/SkPM4fPriv.h » ('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 SkLinearBitmapPipeline_sampler_DEFINED 8 #ifndef SkLinearBitmapPipeline_sampler_DEFINED
9 #define SkLinearBitmapPipeline_sampler_DEFINED 9 #define SkLinearBitmapPipeline_sampler_DEFINED
10 10
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 Sk4f* fColorTable; 163 Sk4f* fColorTable;
164 }; 164 };
165 165
166 template <SkGammaType gammaType> 166 template <SkGammaType gammaType>
167 class PixelConverter<kGray_8_SkColorType, gammaType> { 167 class PixelConverter<kGray_8_SkColorType, gammaType> {
168 public: 168 public:
169 using Element = uint8_t; 169 using Element = uint8_t;
170 PixelConverter(const SkPixmap& srcPixmap) { } 170 PixelConverter(const SkPixmap& srcPixmap) { }
171 171
172 Sk4f toSk4f(Element pixel) const { 172 Sk4f toSk4f(Element pixel) const {
173 float gray = pixel * (1.0f/255.0f); 173 float gray = (gammaType == kSRGB_SkGammaType)
174 Sk4f result = Sk4f{gray, gray, gray, 1.0f}; 174 ? sk_linear_from_srgb[pixel]
175 return gammaType == kSRGB_SkGammaType 175 : pixel * (1/255.0f);
176 ? srgb_to_linear(result) 176 return {gray, gray, gray, 1.0f};
177 : result;
178 } 177 }
179 }; 178 };
180 179
181 template <> 180 template <>
182 class PixelConverter<kRGBA_F16_SkColorType, kLinear_SkGammaType> { 181 class PixelConverter<kRGBA_F16_SkColorType, kLinear_SkGammaType> {
183 public: 182 public:
184 using Element = uint64_t; 183 using Element = uint64_t;
185 PixelConverter(const SkPixmap& srcPixmap) { } 184 PixelConverter(const SkPixmap& srcPixmap) { }
186 185
187 Sk4f toSk4f(const Element pixel) const { 186 Sk4f toSk4f(const Element pixel) const {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 } 824 }
826 } 825 }
827 826
828 Next* const fNext; 827 Next* const fNext;
829 Accessor fAccessor; 828 Accessor fAccessor;
830 }; 829 };
831 830
832 } // namespace 831 } // namespace
833 832
834 #endif // SkLinearBitmapPipeline_sampler_DEFINED 833 #endif // SkLinearBitmapPipeline_sampler_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkColorMatrixFilterRowMajor255.cpp ('k') | src/core/SkPM4fPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698