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

Unified Diff: src/codec/SkPngCodec.cpp

Issue 2067833003: Differentiate between sRGBGamma and 2Dot2Gamma (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response 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 side-by-side diff with in-line comments
Download patch
Index: src/codec/SkPngCodec.cpp
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 43d1580c176b0b0cfff9b3fda103fd6627f0b765..583a8ee8462416e9e67609d778d66d4c4fdb2680 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -8,7 +8,7 @@
#include "SkBitmap.h"
#include "SkCodecPriv.h"
#include "SkColorPriv.h"
-#include "SkColorSpace.h"
+#include "SkColorSpace_Base.h"
#include "SkColorTable.h"
#include "SkMath.h"
#include "SkOpts.h"
@@ -223,6 +223,8 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) {
for (int i = 0; i < 9; i++) {
toXYZD50[i] = png_fixed_point_to_float(XYZ[i]);
}
+ SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
+ mat.set3x3ColMajorf(toXYZD50);
if (PNG_INFO_gAMA == png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) {
float value = png_inverted_fixed_point_to_float(gamma);
@@ -231,16 +233,12 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) {
gammas[2] = value;
} else {
- // Default to sRGB (gamma = 2.2f) if the image has color space information,
+ // Default to sRGB gamma if the image has color space information,
// but does not specify gamma.
- gammas[0] = 2.2f;
- gammas[1] = 2.2f;
- gammas[2] = 2.2f;
+ return SkColorSpace::NewRGB(SkColorSpace::kSRGB_GammaNamed, mat);
}
- SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
- mat.set3x3ColMajorf(toXYZD50);
- return SkColorSpace::NewRGB(gammas, mat);
+ return SkColorSpace_Base::NewRGB(gammas, mat);
Brian Osman 2016/06/15 13:26:59 Nit: Now that we're returning sRGB in the else cas
msarett 2016/06/15 14:33:48 Yup that makes a lot more sense. Done.
}
// Last, check for gamma.
@@ -255,7 +253,7 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) {
gammas[1] = value;
gammas[2] = value;
- return SkColorSpace::NewRGB(gammas, SkMatrix44::I());
+ return SkColorSpace_Base::NewRGB(gammas, SkMatrix44::I());
}
#endif // LIBPNG >= 1.6

Powered by Google App Engine
This is Rietveld 408576698