Skip to content
Permalink
Browse files
Use kCGImageSourceCreateUnpremultipliedPNG on iOS family to correctly…
… read PNG files without premultiplication.

https://bugs.webkit.org/show_bug.cgi?id=240137
<rdar://93198134>

Patch by John Cunningham <johncunningham@apple.com> on 2022-05-23
Reviewed by Simon Fraser.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::createImageSourceOptions):

Canonical link: https://commits.webkit.org/250880@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294660 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
SausCode authored and webkit-commit-queue committed May 23, 2022
1 parent ee06a48 commit 44338a67af147876b1a064989a1c100c629caf0d
Showing 2 changed files with 14 additions and 0 deletions.
@@ -1169,6 +1169,12 @@
#define HAVE_SKADNETWORK_v4 1
#endif

#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MAX_ALLOWED >= 90000) \
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 160000)
#define HAVE_IMAGEIO_CREATE_UNPREMULTIPLIED_PNG 1
#endif

#if !defined(HAVE_UI_CONTEXT_MENU_PREVIEW_ITEM_IDENTIFIER) \
&& (((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 90000) \
@@ -61,6 +61,10 @@ const CFStringRef kCGImageSourceUseHardwareAcceleration = CFSTR("kCGImageSourceU

const CFStringRef kCGImageSourceEnableRestrictedDecoding = CFSTR("kCGImageSourceEnableRestrictedDecoding");

#if HAVE(IMAGEIO_CREATE_UNPREMULTIPLIED_PNG)
const CFStringRef kCGImageSourceCreateUnpremultipliedPNG = CFSTR("kCGImageSourceCreateUnpremultipliedPNG");
#endif

static RetainPtr<CFMutableDictionaryRef> createImageSourceOptions()
{
RetainPtr<CFMutableDictionaryRef> options = adoptCF(CFDictionaryCreateMutable(nullptr, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
@@ -75,6 +79,10 @@ static RetainPtr<CFMutableDictionaryRef> createImageSourceOptions()
if (ImageDecoderCG::restrictedDecodingEnabled())
CFDictionarySetValue(options.get(), kCGImageSourceEnableRestrictedDecoding, kCFBooleanTrue);
#endif

#if HAVE(IMAGEIO_CREATE_UNPREMULTIPLIED_PNG)
CFDictionarySetValue(options.get(), kCGImageSourceCreateUnpremultipliedPNG, kCFBooleanTrue);
#endif
return options;
}

0 comments on commit 44338a6

Please sign in to comment.