aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-05-13 06:19:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-13 06:19:04 -0700
commitc2e4bb39d4ac987cc011d171c89e18922ac06e75 (patch)
treeb654bc8f7162e5311a38525b6b0684f7ac733dbb /src/core
parent9837740dd59fa2461e5d6e6cd36cdc93567b5717 (diff)
Recognize more sRGB gammas
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkColorSpace.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp
index 996158c8c0..f12959f77c 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]) &&
+ 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]) &&
+ 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.