| OLD | NEW |
| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // FIXME (msarett): Here we are treating XYZ values as D50 even though t
he color | 223 // FIXME (msarett): Here we are treating XYZ values as D50 even though t
he color |
| 224 // temperature is unspecified. I suspect that this ass
umption | 224 // temperature is unspecified. I suspect that this ass
umption |
| 225 // is most often ok, but we could also calculate the co
lor | 225 // is most often ok, but we could also calculate the co
lor |
| 226 // temperature (D value) and then convert the XYZ to D5
0. Maybe | 226 // temperature (D value) and then convert the XYZ to D5
0. Maybe |
| 227 // we should add a new constructor to SkColorSpace that
accepts | 227 // we should add a new constructor to SkColorSpace that
accepts |
| 228 // XYZ with D-Unkown? | 228 // XYZ with D-Unkown? |
| 229 for (int i = 0; i < 9; i++) { | 229 for (int i = 0; i < 9; i++) { |
| 230 toXYZD50[i] = png_fixed_point_to_float(XYZ[i]); | 230 toXYZD50[i] = png_fixed_point_to_float(XYZ[i]); |
| 231 } | 231 } |
| 232 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); | 232 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
| 233 mat.set3x3ColMajorf(toXYZD50); | 233 mat.set3x3RowMajorf(toXYZD50); |
| 234 | 234 |
| 235 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) { | 235 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) { |
| 236 float value = png_inverted_fixed_point_to_float(gamma); | 236 float value = png_inverted_fixed_point_to_float(gamma); |
| 237 gammas[0] = value; | 237 gammas[0] = value; |
| 238 gammas[1] = value; | 238 gammas[1] = value; |
| 239 gammas[2] = value; | 239 gammas[2] = value; |
| 240 | 240 |
| 241 return SkColorSpace_Base::NewRGB(gammas, mat); | 241 return SkColorSpace_Base::NewRGB(gammas, mat); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Default to sRGB gamma if the image has color space information, | 244 // Default to sRGB gamma if the image has color space information, |
| 245 // but does not specify gamma. | 245 // but does not specify gamma. |
| 246 return SkColorSpace::NewRGB(SkColorSpace::kSRGB_GammaNamed, mat); | 246 return SkColorSpace::NewRGB(SkColorSpace::kSRGB_GammaNamed, mat); |
| 247 } | 247 } |
| 248 | 248 |
| 249 // Last, check for gamma. | 249 // Last, check for gamma. |
| 250 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) { | 250 if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) { |
| 251 | 251 |
| 252 // Set the gammas. | 252 // Set the gammas. |
| 253 float value = png_inverted_fixed_point_to_float(gamma); | 253 float value = png_inverted_fixed_point_to_float(gamma); |
| 254 gammas[0] = value; | 254 gammas[0] = value; |
| 255 gammas[1] = value; | 255 gammas[1] = value; |
| 256 gammas[2] = value; | 256 gammas[2] = value; |
| 257 | 257 |
| 258 // Since there is no cHRM, we will guess sRGB gamut. | 258 // Since there is no cHRM, we will guess sRGB gamut. |
| 259 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); | 259 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
| 260 mat.set3x3ColMajorf(gSRGB_toXYZD50); | 260 mat.set3x3RowMajorf(gSRGB_toXYZD50); |
| 261 | 261 |
| 262 return SkColorSpace_Base::NewRGB(gammas, mat); | 262 return SkColorSpace_Base::NewRGB(gammas, mat); |
| 263 } | 263 } |
| 264 | 264 |
| 265 #endif // LIBPNG >= 1.6 | 265 #endif // LIBPNG >= 1.6 |
| 266 | 266 |
| 267 // Report that there is no color space information in the PNG. SkPngCodec i
s currently | 267 // Report that there is no color space information in the PNG. SkPngCodec i
s currently |
| 268 // implemented to guess sRGB in this case. | 268 // implemented to guess sRGB in this case. |
| 269 return nullptr; | 269 return nullptr; |
| 270 } | 270 } |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 SkCodec* outCodec; | 809 SkCodec* outCodec; |
| 810 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { | 810 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { |
| 811 // Codec has taken ownership of the stream. | 811 // Codec has taken ownership of the stream. |
| 812 SkASSERT(outCodec); | 812 SkASSERT(outCodec); |
| 813 streamDeleter.release(); | 813 streamDeleter.release(); |
| 814 return outCodec; | 814 return outCodec; |
| 815 } | 815 } |
| 816 | 816 |
| 817 return nullptr; | 817 return nullptr; |
| 818 } | 818 } |
| OLD | NEW |