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

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

Issue 2324843003: Fix storage of gamut transform matrices in SkColorSpace (Closed)
Patch Set: Created 4 years, 3 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
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // fixed point -> double -> float. 188 // fixed point -> double -> float.
189 return ((float) x) * 0.00001f; 189 return ((float) x) * 0.00001f;
190 } 190 }
191 191
192 static float png_inverted_fixed_point_to_float(png_fixed_point x) { 192 static float png_inverted_fixed_point_to_float(png_fixed_point x) {
193 // This is necessary because the gAMA chunk actually stores 1/gamma. 193 // This is necessary because the gAMA chunk actually stores 1/gamma.
194 return 1.0f / png_fixed_point_to_float(x); 194 return 1.0f / png_fixed_point_to_float(x);
195 } 195 }
196 196
197 static constexpr float gSRGB_toXYZD50[] { 197 static constexpr float gSRGB_toXYZD50[] {
198 0.4358f, 0.2224f, 0.0139f, // * R 198 0.4358f, 0.3853f, 0.1430f, // Rx, Gx, Bx
199 0.3853f, 0.7170f, 0.0971f, // * G 199 0.2224f, 0.7170f, 0.0606f, // Ry, Gy, Gz
200 0.1430f, 0.0606f, 0.7139f, // * B 200 0.0139f, 0.0971f, 0.7139f, // Rz, Gz, Bz
201 }; 201 };
202 202
203 static bool convert_to_D50(SkMatrix44* toXYZD50, float toXYZ[9], float whitePoin t[2]) { 203 static bool convert_to_D50(SkMatrix44* toXYZD50, float toXYZ[9], float whitePoin t[2]) {
204 float wX = whitePoint[0]; 204 float wX = whitePoint[0];
205 float wY = whitePoint[1]; 205 float wY = whitePoint[1];
206 if (wX < 0.0f || wY < 0.0f || (wX + wY > 1.0f)) { 206 if (wX < 0.0f || wY < 0.0f || (wX + wY > 1.0f)) {
207 return false; 207 return false;
208 } 208 }
209 209
210 // Calculate the XYZ illuminant. Call this the src illuminant. 210 // Calculate the XYZ illuminant. Call this the src illuminant.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DXToD50[4] = dstCone.fY / srcCone.fY; 244 DXToD50[4] = dstCone.fY / srcCone.fY;
245 DXToD50[8] = dstCone.fZ / srcCone.fZ; 245 DXToD50[8] = dstCone.fZ / srcCone.fZ;
246 DXToD50.postConcat(mAInv); 246 DXToD50.postConcat(mAInv);
247 DXToD50.preConcat(mA); 247 DXToD50.preConcat(mA);
248 248
249 SkMatrix toXYZ3x3; 249 SkMatrix toXYZ3x3;
250 toXYZ3x3.setAll(toXYZ[0], toXYZ[3], toXYZ[6], toXYZ[1], toXYZ[4], toXYZ[7], toXYZ[2], toXYZ[5], 250 toXYZ3x3.setAll(toXYZ[0], toXYZ[3], toXYZ[6], toXYZ[1], toXYZ[4], toXYZ[7], toXYZ[2], toXYZ[5],
251 toXYZ[8]); 251 toXYZ[8]);
252 toXYZ3x3.postConcat(DXToD50); 252 toXYZ3x3.postConcat(DXToD50);
253 253
254 toXYZD50->set3x3(toXYZ3x3[0], toXYZ3x3[1], toXYZ3x3[2], toXYZ3x3[3], toXYZ3x 3[4], toXYZ3x3[5], 254 toXYZD50->set3x3(toXYZ3x3[0], toXYZ3x3[3], toXYZ3x3[6],
255 toXYZ3x3[6], toXYZ3x3[7], toXYZ3x3[8]); 255 toXYZ3x3[1], toXYZ3x3[4], toXYZ3x3[7],
256 toXYZ3x3[2], toXYZ3x3[5], toXYZ3x3[8]);
256 return true; 257 return true;
257 } 258 }
258 259
259 // Returns a colorSpace object that represents any color space information in 260 // Returns a colorSpace object that represents any color space information in
260 // the encoded data. If the encoded data contains no color space, this will 261 // the encoded data. If the encoded data contains no color space, this will
261 // return NULL. 262 // return NULL.
262 sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) { 263 sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) {
263 264
264 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6) 265 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6)
265 266
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 SkCodec* outCodec; 942 SkCodec* outCodec;
942 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { 943 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) {
943 // Codec has taken ownership of the stream. 944 // Codec has taken ownership of the stream.
944 SkASSERT(outCodec); 945 SkASSERT(outCodec);
945 streamDeleter.release(); 946 streamDeleter.release();
946 return outCodec; 947 return outCodec;
947 } 948 }
948 949
949 return nullptr; 950 return nullptr;
950 } 951 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698