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

Unified Diff: src/core/SkColorSpace_ICC.cpp

Issue 2093193002: SkColorSpace::NewICC() warn instead of fail on bad input (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 5 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 e4be8f4e4e6c92623cd31ef076d9f210dc70e048..5585fbbb386f2f33dd2c289ea12e01489e465185 100644
--- a/src/core/SkColorSpace_ICC.cpp
+++ b/src/core/SkColorSpace_ICC.cpp
@@ -46,12 +46,13 @@ static constexpr size_t kICCHeaderSize = 132;
// Contains a signature (4), offset (4), and size (4).
static constexpr size_t kICCTagTableEntrySize = 12;
-static constexpr uint32_t kRGB_ColorSpace = SkSetFourByteTag('R', 'G', 'B', ' ');
-static constexpr uint32_t kDisplay_Profile = SkSetFourByteTag('m', 'n', 't', 'r');
-static constexpr uint32_t kInput_Profile = SkSetFourByteTag('s', 'c', 'n', 'r');
-static constexpr uint32_t kOutput_Profile = SkSetFourByteTag('p', 'r', 't', 'r');
-static constexpr uint32_t kXYZ_PCSSpace = SkSetFourByteTag('X', 'Y', 'Z', ' ');
-static constexpr uint32_t kACSP_Signature = SkSetFourByteTag('a', 'c', 's', 'p');
+static constexpr uint32_t kRGB_ColorSpace = SkSetFourByteTag('R', 'G', 'B', ' ');
+static constexpr uint32_t kDisplay_Profile = SkSetFourByteTag('m', 'n', 't', 'r');
+static constexpr uint32_t kInput_Profile = SkSetFourByteTag('s', 'c', 'n', 'r');
+static constexpr uint32_t kOutput_Profile = SkSetFourByteTag('p', 'r', 't', 'r');
+static constexpr uint32_t kColorSpace_Profile = SkSetFourByteTag('s', 'p', 'a', 'c');
+static constexpr uint32_t kXYZ_PCSSpace = SkSetFourByteTag('X', 'Y', 'Z', ' ');
+static constexpr uint32_t kACSP_Signature = SkSetFourByteTag('a', 'c', 's', 'p');
struct ICCProfileHeader {
uint32_t fSize;
@@ -114,12 +115,13 @@ struct ICCProfileHeader {
uint8_t majorVersion = fVersion >> 24;
return_if_false(majorVersion <= 4, "Unsupported version");
- // These are the three basic classes of profiles that we might expect to see embedded
- // in images. Four additional classes exist, but they generally are used as a convenient
+ // These are the four basic classes of profiles that we might expect to see embedded
+ // in images. Additional classes exist, but they generally are used as a convenient
// way for CMMs to store calculated transforms.
return_if_false(fProfileClass == kDisplay_Profile ||
fProfileClass == kInput_Profile ||
- fProfileClass == kOutput_Profile,
+ fProfileClass == kOutput_Profile ||
+ fProfileClass == kColorSpace_Profile,
"Unsupported profile");
// TODO (msarett):
@@ -136,7 +138,11 @@ struct ICCProfileHeader {
// Should we treat different rendering intents differently?
// Valid rendering intents include kPerceptual (0), kRelative (1),
// kSaturation (2), and kAbsolute (3).
- return_if_false(fRenderingIntent <= 3, "Bad rendering intent");
+ if (fRenderingIntent <= 3) {
+ // Warn rather than fail here. Occasionally, we see perfectly
+ // normal profiles with wacky rendering intents.
+ SkColorSpacePrintf("Warning, bad rendering intent.\n");
+ }
return_if_false(color_space_almost_equal(SkFixedToFloat(fIlluminantXYZ[0]), 0.96420f) &&
color_space_almost_equal(SkFixedToFloat(fIlluminantXYZ[1]), 1.00000f) &&
« 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