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

Unified Diff: src/ports/SkImageDecoder_CG.cpp

Issue 712363003: guard call to CGColorSpaceCopyICCProfile in case we're building for iOS (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/ports/SkImageDecoder_CG.cpp
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index 8d8d0c8b17a32d31a8763b66d460378bf224b06c..87476abf5c423914d772211a4e68f06379f238ef 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -105,6 +105,7 @@ static void force_opaque(SkBitmap* bm) {
#define BITMAP_INFO (kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast)
+#ifndef SK_BUILD_FOR_IOS
static bool icc_profile_is_sRGB(const void* data, size_t length) {
mtklein 2014/11/11 15:08:51 Seems like a good candidate to inline into colorsp
reed1 2014/11/11 15:19:05 Done.
// found by inspection -- need a cleaner way to sniff a profile
const size_t ICC_PROFILE_OFFSET_TO_SRGB_TAG = 52;
@@ -114,6 +115,29 @@ static bool icc_profile_is_sRGB(const void* data, size_t length) {
}
return false;
}
+#endif
+
+class AutoCFDataRelease {
+ CFDataRef fDR;
+public:
+ AutoCFDataRelease(CFDataRef dr) : fDR(dr) {}
+ ~AutoCFDataRelease() { if (fDR) { CFRelease(fDR); } }
+
+ operator CFDataRef () { return fDR; }
+ CFDataRef get() { return fDR; }
mtklein 2014/11/11 15:08:52 get() is dead?
reed1 2014/11/11 15:19:05 Done.
+};
+
+static bool colorspace_is_sRGB(CGColorSpaceRef cs) {
+#ifdef SK_BUILD_FOR_IOS
+ return true; // iOS seems to define itself to always return sRGB...I think
mtklein 2014/11/11 15:08:52 I think -> reed thinks?
reed1 2014/11/11 15:19:05 Done.
+#else
+ AutoCFDataRelease data(CGColorSpaceCopyICCProfile(cs));
+ if (data && icc_profile_is_sRGB(CFDataGetBytePtr(data), CFDataGetLength(data))) {
+ return true;
+ }
+ return false;
+#endif
+}
SkImageDecoder::Result SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
CGImageSourceRef imageSrc = SkStreamToCGImageSource(stream);
@@ -136,12 +160,8 @@ SkImageDecoder::Result SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* b
CGColorSpaceRef cs = CGImageGetColorSpace(image);
if (cs) {
CGColorSpaceModel m = CGColorSpaceGetModel(cs);
- if (kCGColorSpaceModelRGB == m) {
- CFDataRef data = CGColorSpaceCopyICCProfile(cs);
- if (data && icc_profile_is_sRGB(CFDataGetBytePtr(data), CFDataGetLength(data))) {
- cpType = kSRGB_SkColorProfileType;
- CFRelease(data);
- }
+ if (kCGColorSpaceModelRGB == m && colorspace_is_sRGB(cs)) {
+ cpType = kSRGB_SkColorProfileType;
}
}
« 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