Changeset 295213 in webkit


Ignore:
Timestamp:
Jun 3, 2022 8:55:01 AM (2 years ago)
Author:
pvollan@apple.com
Message:

Call function to restrict image decoders for all clients
https://bugs.webkit.org/show_bug.cgi?id=240958
<rdar://93794556>

Reviewed by Geoffrey Garen.

Call function to enable HEIC decoding for all clients on iOS. The main motivation behind this patch
is to avoid using IOKit when decoding HEIC or JPEGs with aux HEIC. Calling enableDecodingHEIC() will
make sure IOKit is not being used, as well as enabling HEIC decoding. We previously only did this for
Mail, but decoding of HEIC images should be possible for all clients. We are not enabling this for
all clients on macOS, since macOS is not blocking IOKit in the WebContent process. This patch also
renames the function, since the former name was not accurate.

  • Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:

(WebCore::createImageSourceOptions):
(WebCore::ImageDecoderCG::enableDecodeHEIC):
(WebCore::ImageDecoderCG::decodeHEICEnabled):
(WebCore::ImageDecoderCG::enableRestrictedDecoding): Deleted.
(WebCore::ImageDecoderCG::restrictedDecodingEnabled): Deleted.

  • Source/WebCore/platform/graphics/cg/ImageDecoderCG.h:
  • Source/WebKit/Shared/WebProcessCreationParameters.cpp:

(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):

  • Source/WebKit/Shared/WebProcessCreationParameters.h:
  • Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeWebProcess):

  • Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::platformInitializeWebProcess):

Canonical link: https://commits.webkit.org/251270@main

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp

    r294660 r295213  
    7777
    7878#if HAVE(IMAGE_RESTRICTED_DECODING) && USE(APPLE_INTERNAL_SDK)
    79     if (ImageDecoderCG::restrictedDecodingEnabled())
     79    if (ImageDecoderCG::decodingHEICEnabled())
    8080        CFDictionarySetValue(options.get(), kCGImageSourceEnableRestrictedDecoding, kCFBooleanTrue);
    8181#endif
     
    269269#endif
    270270
    271 bool ImageDecoderCG::s_enableRestrictedDecoding = false;
     271bool ImageDecoderCG::s_enableDecodingHEIC = false;
    272272bool ImageDecoderCG::s_hardwareAcceleratedDecodingDisabled = false;
    273273
     
    612612}
    613613
    614 void ImageDecoderCG::enableRestrictedDecoding()
    615 {
    616     s_enableRestrictedDecoding = true;
    617 }
    618 
    619 bool ImageDecoderCG::restrictedDecodingEnabled()
    620 {
    621     return s_enableRestrictedDecoding;
     614void ImageDecoderCG::enableDecodingHEIC()
     615{
     616    s_enableDecodingHEIC = true;
     617}
     618
     619bool ImageDecoderCG::decodingHEICEnabled()
     620{
     621    return s_enableDecodingHEIC;
    622622}
    623623
  • trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h

    r292035 r295213  
    7171    void clearFrameBufferCache(size_t) final { }
    7272
    73     WEBCORE_EXPORT static void enableRestrictedDecoding();
    74     static bool restrictedDecodingEnabled();
     73    WEBCORE_EXPORT static void enableDecodingHEIC();
     74    static bool decodingHEICEnabled();
    7575
    7676    WEBCORE_EXPORT static void disableHardwareAcceleratedDecoding();
     
    8181    mutable EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::Unknown };
    8282    RetainPtr<CGImageSourceRef> m_nativeDecoder;
    83     static bool s_enableRestrictedDecoding;
     83    static bool s_enableDecodingHEIC;
    8484    static bool s_hardwareAcceleratedDecodingDisabled;
    8585};
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r294397 r295213  
    164164    encoder << trustdExtensionHandle;
    165165#endif
    166     encoder << restrictImageAndVideoDecoders;
     166    encoder << enableDecodingHEIC;
    167167#endif
    168168
     
    451451    parameters.trustdExtensionHandle = WTFMove(*trustdExtensionHandle);
    452452#endif
    453     std::optional<bool> restrictImageAndVideoDecoders;
    454     decoder >> restrictImageAndVideoDecoders;
    455     if (!restrictImageAndVideoDecoders)
    456         return false;
    457     parameters.restrictImageAndVideoDecoders = *restrictImageAndVideoDecoders;
     453    std::optional<bool> enableDecodingHEIC;
     454    decoder >> enableDecodingHEIC;
     455    if (!enableDecodingHEIC)
     456        return false;
     457    parameters.enableDecodingHEIC = *enableDecodingHEIC;
    458458#endif
    459459
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r294397 r295213  
    205205    SandboxExtension::Handle trustdExtensionHandle;
    206206#endif
    207     bool restrictImageAndVideoDecoders { false };
     207    bool enableDecodingHEIC { false };
    208208#endif
    209209
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r295087 r295213  
    397397        if (auto trustdExtensionHandle = SandboxExtension::createHandleForMachLookup("com.apple.trustd.agent"_s, std::nullopt))
    398398            parameters.trustdExtensionHandle = WTFMove(*trustdExtensionHandle);
    399         parameters.restrictImageAndVideoDecoders = true;
     399        parameters.enableDecodingHEIC = true;
    400400    }
    401401#else
    402     parameters.restrictImageAndVideoDecoders = IOSApplication::isMobileMail() || IOSApplication::isMailCompositionService() || CocoaApplication::isWebkitTestRunner();
     402    parameters.enableDecodingHEIC = true;
    403403#endif // PLATFORM(MAC)
    404404#endif // HAVE(VIDEO_RESTRICTED_DECODING)
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r295087 r295213  
    257257#endif // PLATFORM(MAC)
    258258#if USE(APPLE_INTERNAL_SDK)
    259     if (parameters.restrictImageAndVideoDecoders) {
    260         ImageDecoderCG::enableRestrictedDecoding();
    261         restrictImageAndVideoDecoders();
     259    if (parameters.enableDecodingHEIC) {
     260        ImageDecoderCG::enableDecodingHEIC();
     261        enableDecodingHEIC();
    262262    }
    263263#endif
Note: See TracChangeset for help on using the changeset viewer.