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

Unified Diff: src/core/SkColorSpace_ICC.cpp

Issue 2261213002: Detect all named gammas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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_ICC.cpp
diff --git a/src/core/SkColorSpace_ICC.cpp b/src/core/SkColorSpace_ICC.cpp
index e28a7464aa7669bf8097eac269af5f3c79088542..9ab1da007d16e8dee5aa5dae7b0a358d65effcb9 100755
--- a/src/core/SkColorSpace_ICC.cpp
+++ b/src/core/SkColorSpace_ICC.cpp
@@ -716,6 +716,18 @@ static bool load_matrix(SkMatrix44* toXYZ, const uint8_t* src, size_t len) {
return true;
}
+static inline SkColorSpace::GammaNamed is_named(const sk_sp<SkGammas>& gammas) {
+ if (gammas->isNamed(0) && gammas->isNamed(1) && gammas->isNamed(2) &&
+ gammas->fRedData.fNamed == gammas->fGreenData.fNamed &&
+ gammas->fRedData.fNamed == gammas->fBlueData.fNamed)
+ {
+ return gammas->fRedData.fNamed;
+ }
+
+ return SkColorSpace::kNonStandard_GammaNamed;
+}
+
+
static bool load_a2b0(sk_sp<SkColorLookUpTable>* colorLUT, SkColorSpace::GammaNamed* gammaNamed,
sk_sp<SkGammas>* gammas, SkMatrix44* toXYZ, const uint8_t* src, size_t len) {
if (len < 32) {
@@ -849,6 +861,14 @@ static bool load_a2b0(sk_sp<SkColorLookUpTable>* colorLUT, SkColorSpace::GammaNa
*gammaNamed = SkColorSpace::kInvalid_GammaNamed;
}
+ if (SkColorSpace::kNonStandard_GammaNamed == *gammaNamed) {
+ *gammaNamed = is_named(*gammas);
+ if (SkColorSpace::kNonStandard_GammaNamed != *gammaNamed) {
+ // No need to keep the gammas struct, the enum is enough.
+ *gammas = nullptr;
+ }
+ }
+
uint32_t offsetToMatrix = read_big_endian_i32(src + 16);
if (0 != offsetToMatrix && offsetToMatrix < len) {
if (!load_matrix(toXYZ, src + offsetToMatrix, len - offsetToMatrix)) {
@@ -1042,12 +1062,17 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
}
if (kNonStandard_GammaNamed == gammaNamed) {
- return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, gammaNamed,
- std::move(gammas), mat,
- std::move(data)));
- } else {
- return SkColorSpace_Base::NewRGB(gammaNamed, mat);
+ // It's possible that we'll initially detect non-matching gammas, only for
+ // them to evaluate to the same named gamma curve.
+ gammaNamed = is_named(gammas);
+ if (kNonStandard_GammaNamed == gammaNamed) {
+ return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, gammaNamed,
+ std::move(gammas), mat,
+ std::move(data)));
+ }
}
+
+ return SkColorSpace_Base::NewRGB(gammaNamed, mat);
}
// Recognize color profile specified by A2B0 tag.
@@ -1066,9 +1091,9 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
return sk_sp<SkColorSpace>(new SkColorSpace_Base(std::move(colorLUT),
gammaNamed, std::move(gammas),
toXYZ, std::move(data)));
- } else {
- return SkColorSpace_Base::NewRGB(gammaNamed, toXYZ);
}
+
+ return SkColorSpace_Base::NewRGB(gammaNamed, toXYZ);
}
}
default:
« 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