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

Unified Diff: src/core/SkColorSpace.cpp

Issue 1975883003: Recognize more sRGB gammas (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpace.cpp
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp
index 996158c8c0504fe0bce665221ea7eabed8ff0ed0..f12959f77c6eb154762357cd7e09357057c80e9f 100644
--- a/src/core/SkColorSpace.cpp
+++ b/src/core/SkColorSpace.cpp
@@ -336,15 +336,20 @@ bool SkColorSpace::LoadGammas(SkGammaCurve* gammas, uint32_t numGammas, const ui
// calculation necessary. We encounter identical gamma curves over and
// over again, but relatively few variations.
if (1024 == count) {
+ // The magic values were chosen because they match a very common sRGB
+ // gamma table and the less common Canon sRGB gamma table (which use
+ // different rounding rules).
if (0 == read_big_endian_short((const uint8_t*) &table[0]) &&
- 3341 == read_big_endian_short((const uint8_t*) &table[256]) &&
- 14057 == read_big_endian_short((const uint8_t*) &table[512]) &&
+ 3366 == read_big_endian_short((const uint8_t*) &table[257]) &&
scroggo 2016/05/13 12:45:24 Does still correctly identify images that were rec
msarett 2016/05/13 12:51:48 Yes!
+ 14116 == read_big_endian_short((const uint8_t*) &table[513]) &&
34318 == read_big_endian_short((const uint8_t*) &table[768]) &&
65535 == read_big_endian_short((const uint8_t*) &table[1023])) {
gammas[i].fValue = 2.2f;
break;
}
} else if (26 == count) {
+ // The magic values were chosen because they match a very common sRGB
+ // gamma table.
if (0 == read_big_endian_short((const uint8_t*) &table[0]) &&
3062 == read_big_endian_short((const uint8_t*) &table[6]) &&
12824 == read_big_endian_short((const uint8_t*) &table[12]) &&
@@ -353,6 +358,17 @@ bool SkColorSpace::LoadGammas(SkGammaCurve* gammas, uint32_t numGammas, const ui
gammas[i].fValue = 2.2f;
break;
}
+ } else if (4096 == count) {
+ // The magic values were chosen because they match Nikon, Epson, and
+ // LCMS sRGB gamma tables (all of which use different rounding rules).
+ if (0 == read_big_endian_short((const uint8_t*) &table[0]) &&
scroggo 2016/05/13 12:45:24 As we add more of these, it makes me wonder if we
msarett 2016/05/13 12:51:48 I think this is a really good idea.
+ 950 == read_big_endian_short((const uint8_t*) &table[515]) &&
+ 3342 == read_big_endian_short((const uint8_t*) &table[1025]) &&
+ 14079 == read_big_endian_short((const uint8_t*) &table[2051]) &&
+ 65535 == read_big_endian_short((const uint8_t*) &table[4095])) {
+ gammas[i].fValue = 2.2f;
+ break;
+ }
}
// Otherwise, fill in the interpolation table.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698