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

Side by Side Diff: src/codec/SkPngCodec.cpp

Issue 1945693002: Create a single, unique pointer to sRGB color space (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase + Test Created 4 years, 7 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 | « no previous file | src/core/SkColorSpace.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 2015 Google Inc. 2 * Copyright 2015 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 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 gammas = SkColorSpace::SkGammas(value, value, value); 229 gammas = SkColorSpace::SkGammas(value, value, value);
230 230
231 } else { 231 } else {
232 // Default to sRGB (gamma = 2.2f) if the image has color space infor mation, 232 // Default to sRGB (gamma = 2.2f) if the image has color space infor mation,
233 // but does not specify gamma. 233 // but does not specify gamma.
234 gammas = SkColorSpace::SkGammas(2.2f, 2.2f, 2.2f); 234 gammas = SkColorSpace::SkGammas(2.2f, 2.2f, 2.2f);
235 } 235 }
236 236
237 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); 237 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
238 mat.set3x3ColMajorf(toXYZD50); 238 mat.set3x3ColMajorf(toXYZD50);
239 return SkColorSpace::NewRGB(mat, std::move(gammas)); 239 return SkColorSpace::NewRGB(std::move(gammas), mat);
240 } 240 }
241 241
242 // Last, check for gamma. 242 // Last, check for gamma.
243 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) { 243 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) {
244 244
245 // Guess a default value for cHRM? Or should we just give up? 245 // Guess a default value for cHRM? Or should we just give up?
246 // Here we use the identity matrix as a default. 246 // Here we use the identity matrix as a default.
247 247
248 // Set the gammas. 248 // Set the gammas.
249 float value = png_inverted_fixed_point_to_float(gamma); 249 float value = png_inverted_fixed_point_to_float(gamma);
250 gammas = SkColorSpace::SkGammas(value, value, value); 250 gammas = SkColorSpace::SkGammas(value, value, value);
251 251
252 return SkColorSpace::NewRGB(SkMatrix44::I(), std::move(gammas)); 252 return SkColorSpace::NewRGB(std::move(gammas), SkMatrix44::I());
253 } 253 }
254 254
255 #endif // LIBPNG >= 1.6 255 #endif // LIBPNG >= 1.6
256 256
257 // Finally, what should we do if there is no color space information in the PNG? 257 // Finally, what should we do if there is no color space information in the PNG?
258 // The specification says that this indicates "gamma is unknown" and that th e 258 // The specification says that this indicates "gamma is unknown" and that th e
259 // "color is device dependent". I'm assuming we can represent this with NUL L. 259 // "color is device dependent". I'm assuming we can represent this with NUL L.
260 // But should we guess sRGB? Most images are sRGB, even if they don't speci fy. 260 // But should we guess sRGB? Most images are sRGB, even if they don't speci fy.
261 return nullptr; 261 return nullptr;
262 } 262 }
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 SkCodec* outCodec; 796 SkCodec* outCodec;
797 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { 797 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) {
798 // Codec has taken ownership of the stream. 798 // Codec has taken ownership of the stream.
799 SkASSERT(outCodec); 799 SkASSERT(outCodec);
800 streamDeleter.release(); 800 streamDeleter.release();
801 return outCodec; 801 return outCodec;
802 } 802 }
803 803
804 return nullptr; 804 return nullptr;
805 } 805 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkColorSpace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698