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

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: 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') | src/core/SkColorSpace.h » ('J')
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 float value = png_inverted_fixed_point_to_float(gamma); 228 float value = png_inverted_fixed_point_to_float(gamma);
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 237
238 return SkColorSpace::NewRGB(toXYZD50, std::move(gammas)); 238 return SkColorSpace::NewRGB(std::move(gammas), toXYZD50);
239 } 239 }
240 240
241 // Last, check for gamma. 241 // Last, check for gamma.
242 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) { 242 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) {
243 243
244 // Guess a default value for cHRM? Or should we just give up? 244 // Guess a default value for cHRM? Or should we just give up?
245 // Here we use the identity matrix as a default. 245 // Here we use the identity matrix as a default.
246 // FIXME (msarett): Should SkFloat3x3 have a method to set the identity matrix? 246 // FIXME (msarett): Should SkFloat3x3 have a method to set the identity matrix?
247 memset(toXYZD50.fMat, 0, 9 * sizeof(float)); 247 memset(toXYZD50.fMat, 0, 9 * sizeof(float));
248 toXYZD50.fMat[0] = toXYZD50.fMat[4] = toXYZD50.fMat[8] = 1.0f; 248 toXYZD50.fMat[0] = toXYZD50.fMat[4] = toXYZD50.fMat[8] = 1.0f;
249 249
250 // Set the gammas. 250 // Set the gammas.
251 float value = png_inverted_fixed_point_to_float(gamma); 251 float value = png_inverted_fixed_point_to_float(gamma);
252 gammas = SkColorSpace::SkGammas(value, value, value); 252 gammas = SkColorSpace::SkGammas(value, value, value);
253 253
254 return SkColorSpace::NewRGB(toXYZD50, std::move(gammas)); 254 return SkColorSpace::NewRGB(std::move(gammas), toXYZD50);
255 } 255 }
256 256
257 #endif // LIBPNG >= 1.6 257 #endif // LIBPNG >= 1.6
258 258
259 // Finally, what should we do if there is no color space information in the PNG? 259 // Finally, what should we do if there is no color space information in the PNG?
260 // The specification says that this indicates "gamma is unknown" and that th e 260 // The specification says that this indicates "gamma is unknown" and that th e
261 // "color is device dependent". I'm assuming we can represent this with NUL L. 261 // "color is device dependent". I'm assuming we can represent this with NUL L.
262 // But should we guess sRGB? Most images are sRGB, even if they don't speci fy. 262 // But should we guess sRGB? Most images are sRGB, even if they don't speci fy.
263 return nullptr; 263 return nullptr;
264 } 264 }
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 SkCodec* outCodec; 798 SkCodec* outCodec;
799 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { 799 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) {
800 // Codec has taken ownership of the stream. 800 // Codec has taken ownership of the stream.
801 SkASSERT(outCodec); 801 SkASSERT(outCodec);
802 streamDeleter.release(); 802 streamDeleter.release();
803 return outCodec; 803 return outCodec;
804 } 804 }
805 805
806 return nullptr; 806 return nullptr;
807 } 807 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkColorSpace.h » ('j') | src/core/SkColorSpace.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698