Diff
Modified: trunk/Source/WebCore/ChangeLog (272624 => 272625)
--- trunk/Source/WebCore/ChangeLog 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/ChangeLog 2021-02-10 01:18:45 UTC (rev 272625)
@@ -1,3 +1,39 @@
+2021-02-09 Peng Liu <[email protected]>
+
+ [GPUP] Run ImageDecoderAVFObjC in the GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=221317
+
+ Reviewed by Jer Noble.
+
+ Modify `ImageDecoder` and `ImageDecoderAVFObjC` classes in order to run `ImageDecoderAVFObjC`
+ in the GPU process.
+ - Add install/reset factory methods to `ImageDecoder` class.
+ - Add a struct `FrameInfo`.
+ - Export some methods of `ImageDecoderAVFObjC` to WebKit.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/ImageDecoder.cpp:
+ (WebCore::platformRegisterFactories):
+ (WebCore::installedFactories):
+ (WebCore::ImageDecoder::installFactory):
+ (WebCore::ImageDecoder::resetFactories):
+ (WebCore::ImageDecoder::clearFactories):
+ (WebCore::ImageDecoder::create):
+ (WebCore::ImageDecoder::supportsMediaType):
+ * platform/graphics/ImageDecoder.h:
+ (WebCore::ImageDecoder::FrameInfo::encode const):
+ (WebCore::ImageDecoder::FrameInfo::decode):
+ * platform/graphics/ImageDecoderIdentifier.h: Added.
+ * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
+ (WebCore::ImageDecoderAVFObjC::hasTrack const):
+ * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
+ (WebCore::ImageDecoderAVFObjC::frameInfos const):
+ (WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex):
+ * platform/graphics/cocoa/WebCoreDecompressionSession.h:
+ * platform/graphics/cocoa/WebCoreDecompressionSession.mm:
+ (WebCore::WebCoreDecompressionSession::ensureDecompressionSessionForSample):
+ Update the attribute so that we can create an IOSurface from a decoded frame.
+
2021-02-09 Ryosuke Niwa <[email protected]>
Reduce the overhead of HTMLDocumentParser in innerHTML setter
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (272624 => 272625)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-02-10 01:18:45 UTC (rev 272625)
@@ -636,6 +636,7 @@
1D2F8E042344751600993B68 /* EnterPictureInPictureEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DEF06CA233C3D0B00EE228D /* EnterPictureInPictureEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
1D2F8E052344751D00993B68 /* HTMLVideoElementPictureInPicture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DEF06CC233C3D2000EE228D /* HTMLVideoElementPictureInPicture.h */; settings = {ATTRIBUTES = (Private, ); }; };
1D2F8E062344752300993B68 /* PictureInPictureWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DEF06CD233C3D2A00EE228D /* PictureInPictureWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 1D47658E25CCA778007AF312 /* ImageDecoderIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D47658D25CCA778007AF312 /* ImageDecoderIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
1D9F0FC12122029B005D8FD4 /* ShareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DC55400211BA8C8004B780E /* ShareData.h */; settings = {ATTRIBUTES = (Private, ); }; };
1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B31A12379DC8300883FDE /* WebVideoContainerLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
1DAB3114251D725C00FC9485 /* VideoLayerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DAB3113251D725C00FC9485 /* VideoLayerManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4231,8 +4232,8 @@
CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD17A45D213740810079EC7B /* UnifiedSource62-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */; };
CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
- CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEA61F573972000C42FB /* ImageDecoder.h */; };
- CD19FEAE1F574B6D000C42FB /* ImageDecoderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEAC1F574B6D000C42FB /* ImageDecoderAVFObjC.h */; };
+ CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEA61F573972000C42FB /* ImageDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ CD19FEAE1F574B6D000C42FB /* ImageDecoderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEAC1F574B6D000C42FB /* ImageDecoderAVFObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD19FEAF1F574B6D000C42FB /* ImageDecoderAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD19FEAD1F574B6D000C42FB /* ImageDecoderAVFObjC.mm */; };
CD225C0B1C46FBF400140761 /* WebCoreNSURLSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */; };
CD225C0C1C46FBF400140761 /* WebCoreNSURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CD225C0A1C46FBF400140761 /* WebCoreNSURLSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6899,6 +6900,7 @@
1D0026A82374F9D900CA6CDF /* JSEnterPictureInPictureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEnterPictureInPictureEvent.h; sourceTree = "<group>"; };
1D0026A92374F9D900CA6CDF /* JSEnterPictureInPictureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEnterPictureInPictureEvent.cpp; sourceTree = "<group>"; };
1D2C82B6236A3F6A0055D6C5 /* PictureInPictureSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureSupport.h; sourceTree = "<group>"; };
+ 1D47658D25CCA778007AF312 /* ImageDecoderIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoderIdentifier.h; sourceTree = "<group>"; };
1DAB3113251D725C00FC9485 /* VideoLayerManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VideoLayerManager.h; sourceTree = "<group>"; };
1DB66D37253678EA00B671B9 /* AudioOutputUnitAdaptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioOutputUnitAdaptor.h; sourceTree = "<group>"; };
1DB66D38253678EA00B671B9 /* AudioOutputUnitAdaptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AudioOutputUnitAdaptor.cpp; sourceTree = "<group>"; };
@@ -26705,6 +26707,7 @@
B2A10C910B3818BD00099AA4 /* ImageBufferPipe.h */,
CD19FEA71F573972000C42FB /* ImageDecoder.cpp */,
CD19FEA61F573972000C42FB /* ImageDecoder.h */,
+ 1D47658D25CCA778007AF312 /* ImageDecoderIdentifier.h */,
5576A5621D88A70800CCC04C /* ImageFrame.cpp */,
5576A5631D88A70800CCC04C /* ImageFrame.h */,
BC7F44A70B9E324E00A9D081 /* ImageObserver.h */,
@@ -32566,6 +32569,7 @@
CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */,
CD19FEAE1F574B6D000C42FB /* ImageDecoderAVFObjC.h in Headers */,
555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */,
+ 1D47658E25CCA778007AF312 /* ImageDecoderIdentifier.h in Headers */,
97205AB61239291000B17380 /* ImageDocument.h in Headers */,
F48B7D5325C341E6009E75DD /* ImageExtractionResult.h in Headers */,
5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */,
Modified: trunk/Source/WebCore/platform/graphics/ImageDecoder.cpp (272624 => 272625)
--- trunk/Source/WebCore/platform/graphics/ImageDecoder.cpp 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/platform/graphics/ImageDecoder.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -26,6 +26,8 @@
#include "config.h"
#include "ImageDecoder.h"
+#include <wtf/NeverDestroyed.h>
+
#if USE(CG)
#include "ImageDecoderCG.h"
#elif USE(DIRECT2D)
@@ -44,14 +46,59 @@
namespace WebCore {
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+using FactoryVector = Vector<ImageDecoder::ImageDecoderFactory>;
+
+static void platformRegisterFactories(FactoryVector& factories)
+{
+ factories.append({ ImageDecoderAVFObjC::supportsMediaType, ImageDecoderAVFObjC::canDecodeType, ImageDecoderAVFObjC::create });
+}
+
+static FactoryVector& installedFactories()
+{
+ static auto factories = makeNeverDestroyed<FactoryVector>({ });
+ static std::once_flag registerDefaults;
+ std::call_once(registerDefaults, [&] {
+ platformRegisterFactories(factories);
+ });
+
+ return factories;
+}
+
+void ImageDecoder::installFactory(ImageDecoder::ImageDecoderFactory&& factory)
+{
+ installedFactories().append(WTFMove(factory));
+}
+
+void ImageDecoder::resetFactories()
+{
+ installedFactories().clear();
+ platformRegisterFactories(installedFactories());
+}
+
+void ImageDecoder::clearFactories()
+{
+ installedFactories().clear();
+}
+#endif
+
RefPtr<ImageDecoder> ImageDecoder::create(SharedBuffer& data, const String& mimeType, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
{
UNUSED_PARAM(mimeType);
#if HAVE(AVASSETREADER)
- if (!ImageDecoderCG::canDecodeType(mimeType) && ImageDecoderAVFObjC::canDecodeType(mimeType))
- return ImageDecoderAVFObjC::create(data, mimeType, alphaOption, gammaAndColorProfileOption);
+ if (!ImageDecoderCG::canDecodeType(mimeType)) {
+#if ENABLE(GPU_PROCESS)
+ for (auto& factory : installedFactories()) {
+ if (factory.canDecodeType(mimeType))
+ return factory.createImageDecoder(data, mimeType, alphaOption, gammaAndColorProfileOption);
+ }
+#else
+ if (ImageDecoderAVFObjC::canDecodeType(mimeType))
+ return ImageDecoderAVFObjC::create(data, mimeType, alphaOption, gammaAndColorProfileOption);
#endif
+ }
+#endif
#if USE(GSTREAMER) && ENABLE(VIDEO)
if (ImageDecoderGStreamer::canDecodeType(mimeType))
@@ -81,9 +128,16 @@
#endif
#if HAVE(AVASSETREADER)
+#if ENABLE(GPU_PROCESS)
+ for (auto& factory : installedFactories()) {
+ if (factory.supportsMediaType(type))
+ return true;
+ }
+#else
if (ImageDecoderAVFObjC::supportsMediaType(type))
return true;
#endif
+#endif
#if USE(GSTREAMER) && ENABLE(VIDEO)
if (ImageDecoderGStreamer::supportsMediaType(type))
Modified: trunk/Source/WebCore/platform/graphics/ImageDecoder.h (272624 => 272625)
--- trunk/Source/WebCore/platform/graphics/ImageDecoder.h 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/platform/graphics/ImageDecoder.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -56,8 +56,55 @@
Optional<IntSize> densityCorrectedSize;
};
+ struct FrameInfo {
+ bool hasAlpha;
+ Seconds duration;
+
+ template<class Encoder>
+ void encode(Encoder& encoder) const
+ {
+ encoder << hasAlpha;
+ encoder << duration;
+ }
+
+ template<class Decoder>
+ static Optional<FrameInfo> decode(Decoder& decoder)
+ {
+ Optional<bool> hasAlpha;
+ decoder >> hasAlpha;
+ if (!hasAlpha)
+ return WTF::nullopt;
+
+ Optional<Seconds> duration;
+ decoder >> duration;
+ if (!duration)
+ return WTF::nullopt;
+
+ return {{
+ *hasAlpha,
+ *duration
+ }};
+ }
+ };
+
static bool supportsMediaType(MediaType);
+#if ENABLE(GPU_PROCESS)
+ using SupportsMediaTypeFunc = WTF::Function<bool(MediaType)>;
+ using CanDecodeTypeFunc = WTF::Function<bool(const String&)>;
+ using CreateImageDecoderFunc = WTF::Function<RefPtr<ImageDecoder>(SharedBuffer&, const String&, AlphaOption, GammaAndColorProfileOption)>;
+
+ struct ImageDecoderFactory {
+ SupportsMediaTypeFunc supportsMediaType;
+ CanDecodeTypeFunc canDecodeType;
+ CreateImageDecoderFunc createImageDecoder;
+ };
+
+ WEBCORE_EXPORT static void installFactory(ImageDecoderFactory&&);
+ WEBCORE_EXPORT static void resetFactories();
+ WEBCORE_EXPORT static void clearFactories();
+#endif
+
virtual size_t bytesDecodedToDetermineProperties() const = 0;
virtual EncodedDataStatus encodedDataStatus() const = 0;
Added: trunk/Source/WebCore/platform/graphics/ImageDecoderIdentifier.h (0 => 272625)
--- trunk/Source/WebCore/platform/graphics/ImageDecoderIdentifier.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ImageDecoderIdentifier.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebCore {
+
+enum ImageDecoderIdentifierType { };
+using ImageDecoderIdentifier = ObjectIdentifier<ImageDecoderIdentifierType>;
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h (272624 => 272625)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -53,21 +53,21 @@
class ImageDecoderAVFObjC : public ImageDecoder {
public:
- static RefPtr<ImageDecoderAVFObjC> create(SharedBuffer&, const String& mimeType, AlphaOption, GammaAndColorProfileOption);
+ WEBCORE_EXPORT static RefPtr<ImageDecoderAVFObjC> create(SharedBuffer&, const String& mimeType, AlphaOption, GammaAndColorProfileOption);
virtual ~ImageDecoderAVFObjC();
- static bool supportsMediaType(MediaType);
+ WEBCORE_EXPORT static bool supportsMediaType(MediaType);
static bool supportsContainerType(const String&);
size_t bytesDecodedToDetermineProperties() const override { return 0; }
- static bool canDecodeType(const String& mimeType);
+ WEBCORE_EXPORT static bool canDecodeType(const String& mimeType);
const String& mimeType() const { return m_mimeType; }
- void setEncodedDataStatusChangeCallback(WTF::Function<void(EncodedDataStatus)>&&) final;
+ WEBCORE_EXPORT void setEncodedDataStatusChangeCallback(WTF::Function<void(EncodedDataStatus)>&&) final;
EncodedDataStatus encodedDataStatus() const final;
- IntSize size() const final;
- size_t frameCount() const final;
+ WEBCORE_EXPORT IntSize size() const final;
+ WEBCORE_EXPORT size_t frameCount() const final;
RepetitionCount repetitionCount() const final;
String uti() const final;
String filenameExtension() const final;
@@ -82,13 +82,16 @@
bool frameAllowSubsamplingAtIndex(size_t) const final;
unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
- PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
+ WEBCORE_EXPORT PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
- void setExpectedContentSize(long long) final;
- void setData(SharedBuffer&, bool allDataReceived) final;
+ WEBCORE_EXPORT void setExpectedContentSize(long long) final;
+ WEBCORE_EXPORT void setData(SharedBuffer&, bool allDataReceived) final;
bool isAllDataReceived() const final { return m_isAllDataReceived; }
void clearFrameBufferCache(size_t) final;
+ bool hasTrack() const { return !!m_track; }
+ WEBCORE_EXPORT Vector<ImageDecoder::FrameInfo> frameInfos() const;
+
private:
ImageDecoderAVFObjC(SharedBuffer&, const String& mimeType, AlphaOption, GammaAndColorProfileOption);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm (272624 => 272625)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm 2021-02-10 01:18:45 UTC (rev 272625)
@@ -533,6 +533,20 @@
return sampleData ? sampleData->hasAlpha() : false;
}
+Vector<ImageDecoder::FrameInfo> ImageDecoderAVFObjC::frameInfos() const
+{
+ if (m_sampleData.empty())
+ return { };
+
+ Vector<ImageDecoder::FrameInfo> infos;
+ for (auto& sample : m_sampleData.presentationOrder()) {
+ auto* imageSample = (ImageDecoderAVFObjCSample*)sample.second.get();
+ infos.append({ imageSample->hasAlpha(), Seconds(imageSample->duration().toDouble())});
+ }
+
+ return infos;
+}
+
bool ImageDecoderAVFObjC::frameAllowSubsamplingAtIndex(size_t index) const
{
return index <= m_sampleData.size();
@@ -572,7 +586,6 @@
} while (--m_cursor != m_sampleData.decodeOrder().begin());
}
- RetainPtr<CGImageRef> image;
while (true) {
if (decodeTime < m_cursor->second->decodeTime())
return nullptr;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.h (272624 => 272625)
--- trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.h 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -41,7 +41,6 @@
typedef struct __CVBuffer *CVPixelBufferRef;
typedef struct __CVBuffer *CVImageBufferRef;
typedef UInt32 VTDecodeInfoFlags;
-typedef UInt32 VTDecodeInfoFlags;
typedef struct OpaqueVTDecompressionSession* VTDecompressionSessionRef;
namespace WebCore {
Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm (272624 => 272625)
--- trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm 2021-02-10 01:18:45 UTC (rev 272625)
@@ -217,10 +217,8 @@
auto videoDecoderSpecification = @{ (__bridge NSString *)kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder: @( m_hardwareDecoderEnabled ) };
NSDictionary *attributes;
- if (m_mode == OpenGL)
- attributes = @{ (__bridge NSString*)kCVPixelBufferIOSurfacePropertiesKey: @{ /* empty dictionary */ } };
- else {
- ASSERT(m_mode == RGB);
+ attributes = @{ (__bridge NSString*)kCVPixelBufferIOSurfacePropertiesKey: @{ /* empty dictionary */ } };
+ if (m_mode == RGB) {
attributes = @{ (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA) };
}
VTDecompressionSessionRef decompressionSessionOut = nullptr;
Modified: trunk/Source/WebKit/ChangeLog (272624 => 272625)
--- trunk/Source/WebKit/ChangeLog 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/ChangeLog 2021-02-10 01:18:45 UTC (rev 272625)
@@ -1,3 +1,90 @@
+2021-02-09 Peng Liu <[email protected]>
+
+ [GPUP] Run ImageDecoderAVFObjC in the GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=221317
+
+ Reviewed by Jer Noble.
+
+ This patch adds the support to run `ImageDecoderAVFObjC` in the GPU process when the
+ "GPU Process: Media" preference is on. The `RemoteImageDecoderAVF` running in the Web
+ process forwards video data to the `RemoteImageDecoderAVFProxy` running in the GPU process,
+ which parses the data and returns frame information ("hasAlpha" and "duration") to the
+ Web process. `RemoteImageDecoderAVFProxy` will generate (decode) frames (images) after
+ receiving requests from `RemoteImageDecoderAVF`. The decoded frames are transferred to
+ the Web process through IOSurfaces, and the frames will be cached in the Web process.
+
+ * DerivedSources-input.xcfilelist:
+ * DerivedSources-output.xcfilelist:
+ * DerivedSources.make:
+
+ * GPUProcess/GPUConnectionToWebProcess.cpp:
+ (WebKit::GPUConnectionToWebProcess::imageDecoderAVFProxy):
+ (WebKit::GPUConnectionToWebProcess::dispatchMessage):
+ (WebKit::GPUConnectionToWebProcess::dispatchSyncMessage):
+ * GPUProcess/GPUConnectionToWebProcess.h:
+
+ * GPUProcess/media/RemoteImageDecoderAVFProxy.cpp: Added.
+ (WebKit::RemoteImageDecoderAVFProxy::RemoteImageDecoderAVFProxy):
+ (WebKit::RemoteImageDecoderAVFProxy::createDecoder):
+ (WebKit::RemoteImageDecoderAVFProxy::deleteDecoder):
+ (WebKit::RemoteImageDecoderAVFProxy::encodedDataStatusChanged):
+ (WebKit::RemoteImageDecoderAVFProxy::setExpectedContentSize):
+ (WebKit::RemoteImageDecoderAVFProxy::setData):
+ (WebKit::RemoteImageDecoderAVFProxy::createFrameImageAtIndex):
+ * GPUProcess/media/RemoteImageDecoderAVFProxy.h: Added.
+ * GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in: Added.
+
+ * Scripts/webkit/messages.py:
+ * SourcesCocoa.txt:
+ * WebKit.xcodeproj/project.pbxproj:
+
+ * WebProcess/GPU/media/RemoteImageDecoderAVF.cpp: Added.
+ (WebKit::RemoteImageDecoderAVF::RemoteImageDecoderAVF):
+ (WebKit::RemoteImageDecoderAVF::~RemoteImageDecoderAVF):
+ (WebKit::RemoteImageDecoderAVF::gpuProcessConnection const):
+ (WebKit::RemoteImageDecoderAVF::canDecodeType):
+ (WebKit::RemoteImageDecoderAVF::supportsMediaType):
+ (WebKit::RemoteImageDecoderAVF::encodedDataStatus const):
+ (WebKit::RemoteImageDecoderAVF::setEncodedDataStatusChangeCallback):
+ (WebKit::RemoteImageDecoderAVF::size const):
+ (WebKit::RemoteImageDecoderAVF::frameCount const):
+ (WebKit::RemoteImageDecoderAVF::repetitionCount const):
+ (WebKit::RemoteImageDecoderAVF::uti const):
+ (WebKit::RemoteImageDecoderAVF::filenameExtension const):
+ (WebKit::RemoteImageDecoderAVF::frameSizeAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::frameIsCompleteAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::frameMetadataAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::frameDurationAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::frameHasAlphaAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::frameAllowSubsamplingAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::frameBytesAtIndex const):
+ (WebKit::RemoteImageDecoderAVF::createFrameImageAtIndex):
+ (WebKit::RemoteImageDecoderAVF::setExpectedContentSize):
+ (WebKit::RemoteImageDecoderAVF::setData):
+ (WebKit::RemoteImageDecoderAVF::clearFrameBufferCache):
+ (WebKit::RemoteImageDecoderAVF::encodedDataStatusChanged):
+ * WebProcess/GPU/media/RemoteImageDecoderAVF.h: Added.
+
+ * WebProcess/GPU/media/RemoteImageDecoderAVFManager.cpp: Added.
+ (WebKit::RemoteImageDecoderAVFManager::createImageDecoder):
+ (WebKit::RemoteImageDecoderAVFManager::deleteRemoteImageDecoder):
+ (WebKit::RemoteImageDecoderAVFManager::RemoteImageDecoderAVFManager):
+ (WebKit::RemoteImageDecoderAVFManager::~RemoteImageDecoderAVFManager):
+ (WebKit::RemoteImageDecoderAVFManager::supplementName):
+ (WebKit::RemoteImageDecoderAVFManager::gpuProcessConnection const):
+ (WebKit::RemoteImageDecoderAVFManager::setUseGPUProcess):
+ (WebKit::RemoteImageDecoderAVFManager::encodedDataStatusChanged):
+ * WebProcess/GPU/media/RemoteImageDecoderAVFManager.h: Added.
+ * WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in: Added.
+
+ * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: Fix unified build failures.
+ * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: Ditto.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::setUseGPUProcessForMedia):
+
2021-02-09 Eric Carlson <[email protected]>
[macOS] Add internal preference to control how AVOutputContext is allocated
Modified: trunk/Source/WebKit/DerivedSources-input.xcfilelist (272624 => 272625)
--- trunk/Source/WebKit/DerivedSources-input.xcfilelist 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/DerivedSources-input.xcfilelist 2021-02-10 01:18:45 UTC (rev 272625)
@@ -31,6 +31,7 @@
$(PROJECT_DIR)/GPUProcess/media/RemoteCDMInstanceProxy.messages.in
$(PROJECT_DIR)/GPUProcess/media/RemoteCDMInstanceSessionProxy.messages.in
$(PROJECT_DIR)/GPUProcess/media/RemoteCDMProxy.messages.in
+$(PROJECT_DIR)/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in
$(PROJECT_DIR)/GPUProcess/media/RemoteLegacyCDMFactoryProxy.messages.in
$(PROJECT_DIR)/GPUProcess/media/RemoteLegacyCDMProxy.messages.in
$(PROJECT_DIR)/GPUProcess/media/RemoteLegacyCDMSessionProxy.messages.in
@@ -145,6 +146,8 @@
$(PROJECT_DIR)/WebProcess/GPU/media/RemoteAudioSourceProviderManager.messages.in
$(PROJECT_DIR)/WebProcess/GPU/media/RemoteCDMInstance.messages.in
$(PROJECT_DIR)/WebProcess/GPU/media/RemoteCDMInstanceSession.messages.in
+$(PROJECT_DIR)/WebProcess/GPU/media/RemoteImageDecoderAVF.messages.in
+$(PROJECT_DIR)/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in
$(PROJECT_DIR)/WebProcess/GPU/media/RemoteLegacyCDMSession.messages.in
$(PROJECT_DIR)/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in
$(PROJECT_DIR)/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.messages.in
Modified: trunk/Source/WebKit/DerivedSources-output.xcfilelist (272624 => 272625)
--- trunk/Source/WebKit/DerivedSources-output.xcfilelist 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/DerivedSources-output.xcfilelist 2021-02-10 01:18:45 UTC (rev 272625)
@@ -186,6 +186,15 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteGraphicsContextGLProxyMessageReceiver.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteGraphicsContextGLProxyMessages.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteGraphicsContextGLProxyMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFManagerMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFManagerMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFManagerMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFProxyMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFProxyMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteImageDecoderAVFProxyMessagesReplies.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteLayerTreeDrawingAreaProxyMessages.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteLayerTreeDrawingAreaProxyMessagesReplies.h
Modified: trunk/Source/WebKit/DerivedSources.make (272624 => 272625)
--- trunk/Source/WebKit/DerivedSources.make 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/DerivedSources.make 2021-02-10 01:18:45 UTC (rev 272625)
@@ -182,6 +182,7 @@
WebProcess/GPU/media/RemoteAudioSourceProviderManager \
WebProcess/GPU/media/RemoteCDMInstance \
WebProcess/GPU/media/RemoteCDMInstanceSession \
+ WebProcess/GPU/media/RemoteImageDecoderAVFManager \
WebProcess/GPU/media/RemoteLegacyCDMSession \
WebProcess/GPU/media/SourceBufferPrivateRemote \
WebProcess/GPU/media/ios/RemoteMediaSessionHelper \
@@ -241,6 +242,7 @@
GPUProcess/webrtc/RemoteMediaRecorder \
GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer \
GPUProcess/GPUProcess \
+ GPUProcess/media/RemoteImageDecoderAVFProxy \
GPUProcess/media/RemoteLegacyCDMSessionProxy \
GPUProcess/media/RemoteLegacyCDMFactoryProxy \
GPUProcess/media/RemoteAudioSessionProxy \
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (272624 => 272625)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -106,6 +106,11 @@
#include "RemoteLegacyCDMSessionProxyMessages.h"
#endif
+#if HAVE(AVASSETREADER)
+#include "RemoteImageDecoderAVFProxy.h"
+#include "RemoteImageDecoderAVFProxyMessages.h"
+#endif
+
#if ENABLE(GPU_PROCESS)
#include "RemoteMediaEngineConfigurationFactoryProxy.h"
#include "RemoteMediaEngineConfigurationFactoryProxyMessages.h"
@@ -295,6 +300,16 @@
}
#endif
+#if HAVE(AVASSETREADER)
+RemoteImageDecoderAVFProxy& GPUConnectionToWebProcess::imageDecoderAVFProxy()
+{
+ if (!m_imageDecoderAVFProxy)
+ m_imageDecoderAVFProxy = makeUnique<RemoteImageDecoderAVFProxy>(*this);
+
+ return *m_imageDecoderAVFProxy;
+}
+#endif
+
void GPUConnectionToWebProcess::createRenderingBackend(RenderingBackendIdentifier identifier, IPC::Semaphore&& resumeDisplayListSemaphore)
{
auto addResult = m_remoteRenderingBackendMap.ensure(identifier, [&]() {
@@ -468,6 +483,12 @@
mediaEngineConfigurationFactoryProxy().didReceiveMessageFromWebProcess(connection, decoder);
return true;
}
+#if HAVE(AVASSETREADER)
+ if (decoder.messageReceiverName() == Messages::RemoteImageDecoderAVFProxy::messageReceiverName()) {
+ imageDecoderAVFProxy().didReceiveMessage(connection, decoder);
+ return true;
+ }
+#endif
return messageReceiverMap().dispatchMessage(connection, decoder);
}
@@ -521,6 +542,12 @@
return true;
}
#endif
+#if HAVE(AVASSETREADER)
+ if (decoder.messageReceiverName() == Messages::RemoteImageDecoderAVFProxy::messageReceiverName()) {
+ imageDecoderAVFProxy().didReceiveSyncMessage(connection, decoder, replyEncoder);
+ return true;
+ }
+#endif
return messageReceiverMap().dispatchSyncMessage(connection, decoder, replyEncoder);
}
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (272624 => 272625)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -54,6 +54,7 @@
class RemoteAudioSessionProxy;
class RemoteAudioSessionProxyManager;
class RemoteCDMFactoryProxy;
+class RemoteImageDecoderAVFProxy;
class RemoteLegacyCDMFactoryProxy;
class RemoteMediaEngineConfigurationFactoryProxy;
class RemoteMediaPlayerManagerProxy;
@@ -102,9 +103,8 @@
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
RemoteLegacyCDMFactoryProxy& legacyCdmFactoryProxy();
#endif
-#if ENABLE(GPU_PROCESS)
+
RemoteMediaEngineConfigurationFactoryProxy& mediaEngineConfigurationFactoryProxy();
-#endif
RemoteMediaPlayerManagerProxy& remoteMediaPlayerManagerProxy() { return *m_remoteMediaPlayerManagerProxy; }
#if USE(AUDIO_SESSION)
@@ -111,6 +111,10 @@
RemoteAudioSessionProxyManager& audioSessionManager();
#endif
+#if HAVE(AVASSETREADER)
+ RemoteImageDecoderAVFProxy& imageDecoderAVFProxy();
+#endif
+
void terminateWebProcess();
private:
@@ -221,9 +225,11 @@
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
std::unique_ptr<RemoteLegacyCDMFactoryProxy> m_legacyCdmFactoryProxy;
#endif
-#if ENABLE(GPU_PROCESS)
+#if HAVE(AVASSETREADER)
+ std::unique_ptr<RemoteImageDecoderAVFProxy> m_imageDecoderAVFProxy;
+#endif
+
std::unique_ptr<RemoteMediaEngineConfigurationFactoryProxy> m_mediaEngineConfigurationFactoryProxy;
-#endif
};
} // namespace WebKit
Added: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp (0 => 272625)
--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RemoteImageDecoderAVFProxy.h"
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+#include "GPUConnectionToWebProcess.h"
+#include "RemoteImageDecoderAVFManagerMessages.h"
+#include "RemoteImageDecoderAVFProxyMessages.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/IOSurface.h>
+#include <WebCore/ImageDecoderAVFObjC.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+RemoteImageDecoderAVFProxy::RemoteImageDecoderAVFProxy(GPUConnectionToWebProcess& connectionToWebProcess)
+ : m_connectionToWebProcess(connectionToWebProcess)
+{
+}
+
+void RemoteImageDecoderAVFProxy::createDecoder(const IPC::DataReference& data, const String& mimeType, CompletionHandler<void(Optional<ImageDecoderIdentifier>&&)>&& completionHandler)
+{
+ auto imageDecoder = ImageDecoderAVFObjC::create(SharedBuffer::create(data.data(), data.size()), mimeType, AlphaOption::Premultiplied, GammaAndColorProfileOption::Ignored);
+
+ Optional<ImageDecoderIdentifier> imageDecoderIdentifier;
+ if (!imageDecoder)
+ return completionHandler(WTFMove(imageDecoderIdentifier));
+
+ auto identifier = ImageDecoderIdentifier::generate();
+ m_imageDecoders.add(identifier, imageDecoder.copyRef());
+
+ imageDecoder->setEncodedDataStatusChangeCallback([this, identifier](auto) mutable {
+ encodedDataStatusChanged(identifier);
+ });
+
+ imageDecoderIdentifier = identifier;
+ completionHandler(WTFMove(imageDecoderIdentifier));
+}
+
+void RemoteImageDecoderAVFProxy::deleteDecoder(const ImageDecoderIdentifier& identifier)
+{
+ ASSERT(m_imageDecoders.contains(identifier));
+ if (!m_imageDecoders.contains(identifier))
+ return;
+
+ m_imageDecoders.take(identifier);
+}
+
+void RemoteImageDecoderAVFProxy::encodedDataStatusChanged(const ImageDecoderIdentifier& identifier)
+{
+ if (!m_imageDecoders.contains(identifier))
+ return;
+
+ auto imageDecoder = m_imageDecoders.get(identifier);
+ m_connectionToWebProcess.connection().send(Messages::RemoteImageDecoderAVFManager::EncodedDataStatusChanged(identifier, imageDecoder->frameCount(), imageDecoder->size(), imageDecoder->hasTrack()), 0);
+}
+
+void RemoteImageDecoderAVFProxy::setExpectedContentSize(const ImageDecoderIdentifier& identifier, long long expectedContentSize)
+{
+ ASSERT(m_imageDecoders.contains(identifier));
+ if (!m_imageDecoders.contains(identifier))
+ return;
+
+ m_imageDecoders.get(identifier)->setExpectedContentSize(expectedContentSize);
+}
+
+void RemoteImageDecoderAVFProxy::setData(const ImageDecoderIdentifier& identifier, const IPC::DataReference& data, bool allDataReceived, CompletionHandler<void(size_t frameCount, const IntSize& size, bool hasTrack, Optional<Vector<ImageDecoder::FrameInfo>>&&)>&& completionHandler)
+{
+ ASSERT(m_imageDecoders.contains(identifier));
+ if (!m_imageDecoders.contains(identifier)) {
+ completionHandler(0, { }, false, WTF::nullopt);
+ return;
+ }
+
+ auto imageDecoder = m_imageDecoders.get(identifier);
+ imageDecoder->setData(SharedBuffer::create(data.data(), data.size()), allDataReceived);
+
+ auto frameCount = imageDecoder->frameCount();
+
+ Optional<Vector<ImageDecoder::FrameInfo>> frameInfos;
+ if (frameCount)
+ frameInfos = imageDecoder->frameInfos();
+
+ completionHandler(frameCount, imageDecoder->size(), imageDecoder->hasTrack(), WTFMove(frameInfos));
+}
+
+void RemoteImageDecoderAVFProxy::createFrameImageAtIndex(const ImageDecoderIdentifier& identifier, size_t index, CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&& completionHandler)
+{
+ ASSERT(m_imageDecoders.contains(identifier));
+ Optional<WTF::MachSendRight> sendRight;
+ if (!m_imageDecoders.contains(identifier)) {
+ completionHandler(WTFMove(sendRight));
+ return;
+ }
+
+ auto frameImage = m_imageDecoders.get(identifier)->createFrameImageAtIndex(index);
+ if (!frameImage) {
+ completionHandler(WTFMove(sendRight));
+ return;
+ }
+
+ if (auto surface = IOSurface::createFromImage(frameImage.get()))
+ sendRight = surface->createSendRight();
+
+ completionHandler(WTFMove(sendRight));
+}
+
+}
+
+#endif
Added: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.h (0 => 272625)
--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.h (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+#include "DataReference.h"
+#include "MessageReceiver.h"
+#include <WebCore/ImageDecoderAVFObjC.h>
+#include <WebCore/ImageDecoderIdentifier.h>
+#include <wtf/CompletionHandler.h>
+#include <wtf/HashMap.h>
+#include <wtf/MachSendRight.h>
+
+namespace WebKit {
+class GPUConnectionToWebProcess;
+
+class RemoteImageDecoderAVFProxy : private IPC::MessageReceiver {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit RemoteImageDecoderAVFProxy(GPUConnectionToWebProcess&);
+ virtual ~RemoteImageDecoderAVFProxy() = default;
+
+ // IPC::MessageReceiver
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+ void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final;
+
+private:
+ void createDecoder(const IPC::DataReference&, const String& mimeType, CompletionHandler<void(Optional<WebCore::ImageDecoderIdentifier>&&)>&&);
+ void deleteDecoder(const WebCore::ImageDecoderIdentifier&);
+ void setExpectedContentSize(const WebCore::ImageDecoderIdentifier&, long long expectedContentSize);
+ void setData(const WebCore::ImageDecoderIdentifier&, const IPC::DataReference&, bool allDataReceived, CompletionHandler<void(size_t frameCount, const WebCore::IntSize& size, bool hasTrack, Optional<Vector<WebCore::ImageDecoder::FrameInfo>>&&)>&&);
+ void createFrameImageAtIndex(const WebCore::ImageDecoderIdentifier&, size_t index, CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
+
+ void encodedDataStatusChanged(const WebCore::ImageDecoderIdentifier&);
+
+ GPUConnectionToWebProcess& m_connectionToWebProcess;
+ HashMap<WebCore::ImageDecoderIdentifier, RefPtr<WebCore::ImageDecoderAVFObjC>> m_imageDecoders;
+};
+
+}
+
+#endif
Added: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in (0 => 272625)
--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+messages -> RemoteImageDecoderAVFProxy NotRefCounted {
+ CreateDecoder(IPC::SharedBufferDataReference data, String mimeType) -> (Optional<WebCore::ImageDecoderIdentifier> identifier) Synchronous
+ DeleteDecoder(WebCore::ImageDecoderIdentifier identifier)
+ SetExpectedContentSize(WebCore::ImageDecoderIdentifier identifier, long long expectedContentSize)
+ SetData(WebCore::ImageDecoderIdentifier identifier, IPC::SharedBufferDataReference data, bool allDataReceived) -> (uint32_t frameCount, WebCore::IntSize size, bool hasTrack, Optional<Vector<WebCore::ImageDecoder::FrameInfo>> frameInfos) Synchronous
+ CreateFrameImageAtIndex(WebCore::ImageDecoderIdentifier identifier, uint32_t index) -> (Optional<MachSendRight> sendRight) Async
+}
+
+#endif
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (272624 => 272625)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2021-02-10 01:18:45 UTC (rev 272625)
@@ -268,6 +268,7 @@
'WebCore::FetchIdentifier',
'WebCore::FrameIdentifier',
'WebCore::GraphicsContextGLAttributes',
+ 'WebCore::ImageDecoderIdentifier',
'WebCore::LibWebRTCSocketIdentifier',
'WebCore::PlaybackTargetClientContextIdentifier',
'WebCore::MediaPlayerIdentifier',
Modified: trunk/Source/WebKit/SourcesCocoa.txt (272624 => 272625)
--- trunk/Source/WebKit/SourcesCocoa.txt 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2021-02-10 01:18:45 UTC (rev 272625)
@@ -61,12 +61,11 @@
GPUProcess/ios/GPUProcessIOS.mm
GPUProcess/mac/GPUProcessMac.mm
GPUProcess/media/RemoteAudioSourceProviderProxy.cpp
+GPUProcess/media/RemoteImageDecoderAVFProxy.cpp
GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm
GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp
GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
-
-
Platform/cf/ModuleCF.cpp
Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
@@ -593,6 +592,8 @@
WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp
WebProcess/GPU/media/RemoteAudioSourceProvider.cpp
WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp
+WebProcess/GPU/media/RemoteImageDecoderAVF.cpp
+WebProcess/GPU/media/RemoteImageDecoderAVFManager.cpp
WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm
WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm
WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp
@@ -697,6 +698,8 @@
RemoteAudioMediaStreamTrackRendererManagerMessageReceiver.cpp
RemoteAudioMediaStreamTrackRendererMessageReceiver.cpp
RemoteAudioSourceProviderManagerMessageReceiver.cpp
+RemoteImageDecoderAVFProxyMessageReceiver.cpp
+RemoteImageDecoderAVFManagerMessageReceiver.cpp
RemoteMediaRecorderMessageReceiver.cpp
RemoteMediaRecorderManagerMessageReceiver.cpp
RemoteMediaSessionHelperMessageReceiver.cpp
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (272624 => 272625)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-02-10 01:18:45 UTC (rev 272625)
@@ -2964,6 +2964,20 @@
1D32F8A623A8601900B1EA6A /* RemoteMediaResourceManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteMediaResourceManager.messages.in; sourceTree = "<group>"; };
1D3AB04D23AB0072005C1FF0 /* RemoteMediaResourceLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceLoader.h; sourceTree = "<group>"; };
1D3AB04E23AB009B005C1FF0 /* RemoteMediaResourceLoader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResourceLoader.cpp; sourceTree = "<group>"; };
+ 1D47657825CB3AF6007AF312 /* RemoteImageDecoderAVF.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteImageDecoderAVF.h; sourceTree = "<group>"; };
+ 1D47657925CB3AF6007AF312 /* RemoteImageDecoderAVF.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteImageDecoderAVF.cpp; sourceTree = "<group>"; };
+ 1D47658425CCA416007AF312 /* RemoteImageDecoderAVFProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteImageDecoderAVFProxy.h; sourceTree = "<group>"; };
+ 1D47658525CCA416007AF312 /* RemoteImageDecoderAVFProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteImageDecoderAVFProxy.cpp; sourceTree = "<group>"; };
+ 1D47658C25CCA698007AF312 /* RemoteImageDecoderAVFProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteImageDecoderAVFProxy.messages.in; sourceTree = "<group>"; };
+ 1D47658F25CCCE92007AF312 /* RemoteImageDecoderAVFProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RemoteImageDecoderAVFProxyMessageReceiver.cpp; path = DerivedSources/WebKit2/RemoteImageDecoderAVFProxyMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1D47659025CCCE93007AF312 /* RemoteImageDecoderAVFProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteImageDecoderAVFProxyMessages.h; path = DerivedSources/WebKit2/RemoteImageDecoderAVFProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1D47659125CCCE93007AF312 /* RemoteImageDecoderAVFProxyMessagesReplies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteImageDecoderAVFProxyMessagesReplies.h; path = DerivedSources/WebKit2/RemoteImageDecoderAVFProxyMessagesReplies.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1D47659825CDF649007AF312 /* RemoteImageDecoderAVFManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteImageDecoderAVFManager.messages.in; sourceTree = "<group>"; };
+ 1D47659925CE74AC007AF312 /* RemoteImageDecoderAVFManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteImageDecoderAVFManagerMessages.h; path = DerivedSources/WebKit2/RemoteImageDecoderAVFManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1D47659A25CE74AC007AF312 /* RemoteImageDecoderAVFManagerMessagesReplies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteImageDecoderAVFManagerMessagesReplies.h; path = DerivedSources/WebKit2/RemoteImageDecoderAVFManagerMessagesReplies.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1D47659B25CE74AD007AF312 /* RemoteImageDecoderAVFManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RemoteImageDecoderAVFManagerMessageReceiver.cpp; path = DerivedSources/WebKit2/RemoteImageDecoderAVFManagerMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1D47659F25CF5740007AF312 /* RemoteImageDecoderAVFManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteImageDecoderAVFManager.h; sourceTree = "<group>"; };
+ 1D4765A025CF5740007AF312 /* RemoteImageDecoderAVFManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteImageDecoderAVFManager.cpp; sourceTree = "<group>"; };
1D4D736B23A9DF5500717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; name = RemoteMediaResourceManagerMessageReceiver.cpp; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
1D4D736C23A9DF6000717A25 /* RemoteMediaResourceManagerMessages.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = RemoteMediaResourceManagerMessages.h; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
1D4D737523A9EB6800717A25 /* RemoteMediaResourceManagerMessagesReplies.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = RemoteMediaResourceManagerMessagesReplies.h; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessagesReplies.h; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -2973,7 +2987,7 @@
1DA4089423A80A3E0058C950 /* RemoteMediaResourceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceManager.h; sourceTree = "<group>"; };
1DA4089E23A827780058C950 /* RemoteMediaResourceManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResourceManager.cpp; sourceTree = "<group>"; };
1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKShareSheet.mm; sourceTree = "<group>"; };
- 1DD2A636255DE67500FF7B6F /* MediaSourcePrivateRemote.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = MediaSourcePrivateRemote.cpp; path = /Volumes/Data/webkit/OpenSource/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.cpp; sourceTree = "<absolute>"; };
+ 1DD2A636255DE67500FF7B6F /* MediaSourcePrivateRemote.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourcePrivateRemote.cpp; sourceTree = "<group>"; };
1DD2A637255DE67500FF7B6F /* MediaSourcePrivateRemote.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivateRemote.h; sourceTree = "<group>"; };
1DD2A639255DE6D100FF7B6F /* SourceBufferPrivateRemote.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivateRemote.h; sourceTree = "<group>"; };
1DD2A63A255DE6D100FF7B6F /* SourceBufferPrivateRemote.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SourceBufferPrivateRemote.cpp; sourceTree = "<group>"; };
@@ -5975,6 +5989,11 @@
CDAC20BD23FC2F740021DEE3 /* RemoteCDMInstanceSession.h */,
CD46617F240104580047CA35 /* RemoteCDMInstanceSession.messages.in */,
CDAC20BC23FC2F740021DEE3 /* RemoteCDMInstanceSessionIdentifier.h */,
+ 1D47657925CB3AF6007AF312 /* RemoteImageDecoderAVF.cpp */,
+ 1D47657825CB3AF6007AF312 /* RemoteImageDecoderAVF.h */,
+ 1D4765A025CF5740007AF312 /* RemoteImageDecoderAVFManager.cpp */,
+ 1D47659F25CF5740007AF312 /* RemoteImageDecoderAVFManager.h */,
+ 1D47659825CDF649007AF312 /* RemoteImageDecoderAVFManager.messages.in */,
CDE554EB24058183008A3DDB /* RemoteLegacyCDM.cpp */,
CDE554EA24058183008A3DDB /* RemoteLegacyCDM.h */,
CDE554E324058114008A3DDB /* RemoteLegacyCDMFactory.cpp */,
@@ -6039,6 +6058,9 @@
CDAC208323FB21340021DEE3 /* RemoteCDMProxy.cpp */,
CDAC208223FB21340021DEE3 /* RemoteCDMProxy.h */,
CDAC208623FB21580021DEE3 /* RemoteCDMProxy.messages.in */,
+ 1D47658525CCA416007AF312 /* RemoteImageDecoderAVFProxy.cpp */,
+ 1D47658425CCA416007AF312 /* RemoteImageDecoderAVFProxy.h */,
+ 1D47658C25CCA698007AF312 /* RemoteImageDecoderAVFProxy.messages.in */,
CDE5551D2405A3B7008A3DDB /* RemoteLegacyCDMFactoryProxy.cpp */,
CDE5551C2405A3B7008A3DDB /* RemoteLegacyCDMFactoryProxy.h */,
CDE5551B2405A3B7008A3DDB /* RemoteLegacyCDMFactoryProxy.messages.in */,
@@ -10806,6 +10828,12 @@
CDAC20EF23FC38390021DEE3 /* RemoteCDMProxyMessageReceiver.cpp */,
CDAC20F423FC383A0021DEE3 /* RemoteCDMProxyMessages.h */,
CDAC20F023FC38390021DEE3 /* RemoteCDMProxyMessagesReplies.h */,
+ 1D47659B25CE74AD007AF312 /* RemoteImageDecoderAVFManagerMessageReceiver.cpp */,
+ 1D47659925CE74AC007AF312 /* RemoteImageDecoderAVFManagerMessages.h */,
+ 1D47659A25CE74AC007AF312 /* RemoteImageDecoderAVFManagerMessagesReplies.h */,
+ 1D47658F25CCCE92007AF312 /* RemoteImageDecoderAVFProxyMessageReceiver.cpp */,
+ 1D47659025CCCE93007AF312 /* RemoteImageDecoderAVFProxyMessages.h */,
+ 1D47659125CCCE93007AF312 /* RemoteImageDecoderAVFProxyMessagesReplies.h */,
0FF24A2B1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp */,
0FF24A2C1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessages.h */,
CDE555292406B896008A3DDB /* RemoteLegacyCDMFactoryProxyMessageReceiver.cpp */,
@@ -11865,6 +11893,12 @@
CDAC20B423FB58F20021DEE3 /* RemoteCDMInstanceProxy.h in Headers */,
CDAC20CA23FC2F750021DEE3 /* RemoteCDMInstanceSession.h in Headers */,
CDAC20C923FC2F750021DEE3 /* RemoteCDMInstanceSessionIdentifier.h in Headers */,
+ 1D4765A125CF5740007AF312 /* RemoteImageDecoderAVFManager.h in Headers */,
+ 1D47659C25CE74AD007AF312 /* RemoteImageDecoderAVFManagerMessages.h in Headers */,
+ 1D47659D25CE74AD007AF312 /* RemoteImageDecoderAVFManagerMessagesReplies.h in Headers */,
+ 1D47658625CCA416007AF312 /* RemoteImageDecoderAVFProxy.h in Headers */,
+ 1D47659325CCCE93007AF312 /* RemoteImageDecoderAVFProxyMessages.h in Headers */,
+ 1D47659425CCCE93007AF312 /* RemoteImageDecoderAVFProxyMessagesReplies.h in Headers */,
2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */,
2DDF731518E95060004F5A66 /* RemoteLayerBackingStoreCollection.h in Headers */,
1AB16AEA164B3A8800290D62 /* RemoteLayerTreeContext.h in Headers */,
Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp (0 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RemoteImageDecoderAVF.h"
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+#include "GPUProcessConnection.h"
+#include "RemoteImageDecoderAVFProxyMessages.h"
+#include "SharedBufferDataReference.h"
+#include "WebProcess.h"
+#include <WebCore/AVAssetMIMETypeCache.h>
+#include <WebCore/ColorSpaceCG.h>
+#include <WebCore/IOSurface.h>
+#include <WebCore/ImageTypes.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/SharedBuffer.h>
+#include <WebCore/UTIUtilities.h>
+#include <wtf/MachSendRight.h>
+#include <wtf/threads/BinarySemaphore.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+RemoteImageDecoderAVF::RemoteImageDecoderAVF(RemoteImageDecoderAVFManager& manager, const WebCore::ImageDecoderIdentifier& identifier, const String& mimeType)
+ : ImageDecoder()
+ , m_manager(manager)
+ , m_identifier(identifier)
+ , m_mimeType(mimeType)
+ , m_uti(WebCore::UTIFromMIMEType(mimeType))
+{
+}
+
+RemoteImageDecoderAVF::~RemoteImageDecoderAVF()
+{
+ m_manager.deleteRemoteImageDecoder(m_identifier);
+}
+
+GPUProcessConnection& RemoteImageDecoderAVF::gpuProcessConnection() const
+{
+ return m_manager.gpuProcessConnection();
+}
+
+bool RemoteImageDecoderAVF::canDecodeType(const String& mimeType)
+{
+ // TODO: We may need to remove AVAssetMIMETypeCache in the Web process
+ return AVAssetMIMETypeCache::singleton().canDecodeType(mimeType) != MediaPlayerEnums::SupportsType::IsNotSupported;
+}
+
+bool RemoteImageDecoderAVF::supportsMediaType(MediaType type)
+{
+ // TODO: We may need to remove AVAssetMIMETypeCache in the Web process
+ return type == MediaType::Video && AVAssetMIMETypeCache::singleton().isAvailable();
+}
+
+EncodedDataStatus RemoteImageDecoderAVF::encodedDataStatus() const
+{
+ if (m_frameCount)
+ return EncodedDataStatus::Complete;
+ if (m_size)
+ return EncodedDataStatus::SizeAvailable;
+ if (m_hasTrack)
+ return EncodedDataStatus::TypeAvailable;
+
+ return EncodedDataStatus::Unknown;
+}
+
+void RemoteImageDecoderAVF::setEncodedDataStatusChangeCallback(WTF::Function<void(EncodedDataStatus)>&& callback)
+{
+ m_encodedDataStatusChangedCallback = WTFMove(callback);
+}
+
+IntSize RemoteImageDecoderAVF::size() const
+{
+ if (m_size)
+ return m_size.value();
+ return IntSize();
+}
+
+size_t RemoteImageDecoderAVF::frameCount() const
+{
+ return m_frameCount;
+}
+
+RepetitionCount RemoteImageDecoderAVF::repetitionCount() const
+{
+ return m_frameCount > 1 ? RepetitionCountInfinite : RepetitionCountNone;
+}
+
+String RemoteImageDecoderAVF::uti() const
+{
+ return m_uti;
+}
+
+String RemoteImageDecoderAVF::filenameExtension() const
+{
+ return MIMETypeRegistry::preferredExtensionForMIMEType(m_mimeType);
+}
+
+IntSize RemoteImageDecoderAVF::frameSizeAtIndex(size_t, SubsamplingLevel) const
+{
+ return size();
+}
+
+bool RemoteImageDecoderAVF::frameIsCompleteAtIndex(size_t index) const
+{
+ return index < m_frameCount;
+}
+
+ImageDecoder::FrameMetadata RemoteImageDecoderAVF::frameMetadataAtIndex(size_t) const
+{
+ return { };
+}
+
+Seconds RemoteImageDecoderAVF::frameDurationAtIndex(size_t index) const
+{
+ if (m_frameInfos.isEmpty() || index >= m_frameInfos.size())
+ return { };
+
+ return m_frameInfos[index].duration;
+}
+
+bool RemoteImageDecoderAVF::frameHasAlphaAtIndex(size_t index) const
+{
+ if (m_frameInfos.isEmpty() || index >= m_frameInfos.size())
+ return false;
+
+ return m_frameInfos[index].hasAlpha;
+}
+
+bool RemoteImageDecoderAVF::frameAllowSubsamplingAtIndex(size_t index) const
+{
+ return index < m_frameCount;
+}
+
+unsigned RemoteImageDecoderAVF::frameBytesAtIndex(size_t, SubsamplingLevel) const
+{
+ return (size().area() * 4).unsafeGet();
+}
+
+PlatformImagePtr RemoteImageDecoderAVF::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
+{
+ if (m_frameImages.contains(index))
+ return m_frameImages.get(index);
+
+ // This function might be called in the main thread to run the decoder synchronously
+ if (isMainThread())
+ return nullptr;
+
+ BinarySemaphore decodeSemaphore;
+ callOnMainThread([this, protectedThis = makeRef(*this), index, &decodeSemaphore] {
+ gpuProcessConnection().connection().sendWithAsyncReply(Messages::RemoteImageDecoderAVFProxy::CreateFrameImageAtIndex(m_identifier, index), [&](auto&& sendRight) {
+ if (!sendRight) {
+ decodeSemaphore.signal();
+ return;
+ }
+
+ auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), sRGBColorSpaceRef());
+ if (!surface) {
+ decodeSemaphore.signal();
+ return;
+ }
+
+ auto image = surface->createImage();
+ if (!image) {
+ decodeSemaphore.signal();
+ return;
+ }
+
+ m_frameImages.add(index, image);
+ decodeSemaphore.signal();
+ });
+ });
+
+ decodeSemaphore.wait();
+ if (m_frameImages.contains(index))
+ return m_frameImages.get(index);
+
+ return nullptr;
+}
+
+void RemoteImageDecoderAVF::setExpectedContentSize(long long expectedContentSize)
+{
+ gpuProcessConnection().connection().send(Messages::RemoteImageDecoderAVFProxy::SetExpectedContentSize(m_identifier, expectedContentSize), 0);
+}
+
+// If allDataReceived is true, the caller expects encodedDataStatus() to be >= EncodedDataStatus::SizeAvailable
+// after this function returns (in the same run loop).
+void RemoteImageDecoderAVF::setData(SharedBuffer& data, bool allDataReceived)
+{
+ IPC::SharedBufferDataReference dataReference { data };
+
+ uint32_t frameCount;
+ IntSize size;
+ bool hasTrack;
+ Optional<Vector<ImageDecoder::FrameInfo>> frameInfos;
+ if (!gpuProcessConnection().connection().sendSync(Messages::RemoteImageDecoderAVFProxy::SetData(m_identifier, dataReference, allDataReceived), Messages::RemoteImageDecoderAVFProxy::SetData::Reply(frameCount, size, hasTrack, frameInfos), 0))
+ return;
+
+ m_isAllDataReceived = allDataReceived;
+ m_frameCount = frameCount;
+ if (!size.isEmpty())
+ m_size = size;
+ m_hasTrack = hasTrack;
+
+ if (frameInfos)
+ m_frameInfos.swap(*frameInfos);
+}
+
+void RemoteImageDecoderAVF::clearFrameBufferCache(size_t)
+{
+ m_frameImages.clear();
+}
+
+void RemoteImageDecoderAVF::encodedDataStatusChanged(size_t frameCount, const WebCore::IntSize& size, bool hasTrack)
+{
+ m_frameCount = frameCount;
+ if (!size.isEmpty())
+ m_size = size;
+ m_hasTrack = hasTrack;
+
+ if (m_encodedDataStatusChangedCallback)
+ m_encodedDataStatusChangedCallback(encodedDataStatus());
+}
+
+}
+
+#endif
Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.h (0 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+#include "MessageReceiver.h"
+#include "RemoteImageDecoderAVFManager.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/ImageDecoder.h>
+#include <WebCore/ImageDecoderIdentifier.h>
+#include <wtf/Function.h>
+#include <wtf/HashMap.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebKit {
+
+class GPUProcessConnection;
+class WebProcess;
+
+class RemoteImageDecoderAVF final
+ : public WebCore::ImageDecoder
+ , public CanMakeWeakPtr<RemoteImageDecoderAVF> {
+public:
+ static Ref<RemoteImageDecoderAVF> create(RemoteImageDecoderAVFManager& manager, const WebCore::ImageDecoderIdentifier& identifier, WebCore::SharedBuffer&, const String& mimeType)
+ {
+ return adoptRef(*new RemoteImageDecoderAVF(manager, identifier, mimeType));
+ }
+ RemoteImageDecoderAVF(RemoteImageDecoderAVFManager&, const WebCore::ImageDecoderIdentifier&, const String& mimeType);
+
+ virtual ~RemoteImageDecoderAVF();
+
+ static bool canDecodeType(const String& mimeType);
+ static bool supportsMediaType(MediaType);
+
+ size_t bytesDecodedToDetermineProperties() const override { return 0; }
+
+ WebCore::EncodedDataStatus encodedDataStatus() const final;
+ void setEncodedDataStatusChangeCallback(WTF::Function<void(WebCore::EncodedDataStatus)>&&) final;
+ WebCore::IntSize size() const final;
+ size_t frameCount() const final;
+ WebCore::RepetitionCount repetitionCount() const final;
+ String uti() const final;
+ String filenameExtension() const final;
+ Optional<WebCore::IntPoint> hotSpot() const final { return WTF::nullopt; }
+
+ WebCore::IntSize frameSizeAtIndex(size_t, WebCore::SubsamplingLevel = WebCore::SubsamplingLevel::Default) const final;
+ bool frameIsCompleteAtIndex(size_t) const final;
+ FrameMetadata frameMetadataAtIndex(size_t) const final;
+
+ Seconds frameDurationAtIndex(size_t) const final;
+ bool frameHasAlphaAtIndex(size_t) const final;
+ bool frameAllowSubsamplingAtIndex(size_t) const final;
+ unsigned frameBytesAtIndex(size_t, WebCore::SubsamplingLevel = WebCore::SubsamplingLevel::Default) const final;
+
+ WebCore::PlatformImagePtr createFrameImageAtIndex(size_t, WebCore::SubsamplingLevel = WebCore::SubsamplingLevel::Default, const WebCore::DecodingOptions& = WebCore::DecodingOptions(WebCore::DecodingMode::Synchronous)) final;
+
+ void setExpectedContentSize(long long) final;
+ void setData(WebCore::SharedBuffer&, bool allDataReceived) final;
+ bool isAllDataReceived() const final { return m_isAllDataReceived; }
+ void clearFrameBufferCache(size_t) final;
+
+ void encodedDataStatusChanged(size_t frameCount, const WebCore::IntSize&, bool hasTrack);
+
+private:
+ GPUProcessConnection& gpuProcessConnection() const;
+
+ RemoteImageDecoderAVFManager& m_manager;
+ WebCore::ImageDecoderIdentifier m_identifier;
+
+ String m_mimeType;
+ String m_uti;
+ bool m_isAllDataReceived { false };
+ WTF::Function<void(WebCore::EncodedDataStatus)> m_encodedDataStatusChangedCallback;
+ HashMap<int, WebCore::PlatformImagePtr, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> m_frameImages;
+ Vector<ImageDecoder::FrameInfo> m_frameInfos;
+ size_t m_frameCount { 0 };
+ Optional<WebCore::IntSize> m_size;
+ bool m_hasTrack { false };
+};
+
+}
+#endif
Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.cpp (0 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.cpp (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RemoteImageDecoderAVFManager.h"
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+#include "GPUProcessConnection.h"
+#include "RemoteImageDecoderAVF.h"
+#include "RemoteImageDecoderAVFManagerMessages.h"
+#include "RemoteImageDecoderAVFProxyMessages.h"
+#include "SharedBufferDataReference.h"
+#include "WebProcess.h"
+
+namespace WebKit {
+
+using namespace WebCore;
+
+RefPtr<RemoteImageDecoderAVF> RemoteImageDecoderAVFManager::createImageDecoder(SharedBuffer& data, const String& mimeType, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
+{
+ if (!m_messageReceiverInitialized) {
+ m_messageReceiverInitialized = true;
+ gpuProcessConnection().messageReceiverMap().addMessageReceiver(Messages::RemoteImageDecoderAVFManager::messageReceiverName(), *this);
+ }
+
+ Optional<ImageDecoderIdentifier> imageDecoderIdentifier;
+ IPC::SharedBufferDataReference dataReference { data };
+ if (!gpuProcessConnection().connection().sendSync(Messages::RemoteImageDecoderAVFProxy::CreateDecoder(dataReference, mimeType), Messages::RemoteImageDecoderAVFProxy::CreateDecoder::Reply(imageDecoderIdentifier), 0))
+ return nullptr;
+
+ if (!imageDecoderIdentifier)
+ return nullptr;
+
+ auto remoteImageDecoder = RemoteImageDecoderAVF::create(*this, *imageDecoderIdentifier, data, mimeType);
+ m_remoteImageDecoders.add(*imageDecoderIdentifier, makeWeakPtr(remoteImageDecoder.get()));
+
+ return remoteImageDecoder;
+}
+
+void RemoteImageDecoderAVFManager::deleteRemoteImageDecoder(const ImageDecoderIdentifier& identifier)
+{
+ m_remoteImageDecoders.take(identifier);
+ gpuProcessConnection().connection().send(Messages::RemoteImageDecoderAVFProxy::DeleteDecoder(identifier), 0);
+}
+
+RemoteImageDecoderAVFManager::RemoteImageDecoderAVFManager(WebProcess& process)
+ : m_process(process)
+{
+}
+
+RemoteImageDecoderAVFManager::~RemoteImageDecoderAVFManager()
+{
+ gpuProcessConnection().messageReceiverMap().removeMessageReceiver(Messages::RemoteImageDecoderAVFManager::messageReceiverName());
+}
+
+const char* RemoteImageDecoderAVFManager::supplementName()
+{
+ return "RemoteImageDecoderAVFManager";
+}
+
+GPUProcessConnection& RemoteImageDecoderAVFManager::gpuProcessConnection() const
+{
+ if (!m_gpuProcessConnection)
+ m_gpuProcessConnection = &m_process.ensureGPUProcessConnection();
+
+ return *m_gpuProcessConnection;
+}
+
+void RemoteImageDecoderAVFManager::setUseGPUProcess(bool useGPUProcess)
+{
+ if (!useGPUProcess) {
+ ImageDecoder::resetFactories();
+ return;
+ }
+
+ ImageDecoder::clearFactories();
+ ImageDecoder::installFactory({
+ RemoteImageDecoderAVF::supportsMediaType,
+ RemoteImageDecoderAVF::canDecodeType,
+ [this](SharedBuffer& data, const String& mimeType, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) {
+ return createImageDecoder(data, mimeType, alphaOption, gammaAndColorProfileOption);
+ }
+ });
+}
+
+void RemoteImageDecoderAVFManager::encodedDataStatusChanged(const ImageDecoderIdentifier& identifier, size_t frameCount, const WebCore::IntSize& size, bool hasTrack)
+{
+ if (!m_remoteImageDecoders.contains(identifier))
+ return;
+
+ auto remoteImageDecoder = m_remoteImageDecoders.get(identifier);
+ if (!remoteImageDecoder)
+ return;
+
+ remoteImageDecoder->encodedDataStatusChanged(frameCount, size, hasTrack);
+}
+
+}
+
+#endif
Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.h (0 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+#include "Connection.h"
+#include "MessageReceiver.h"
+#include "WebProcessSupplement.h"
+#include <WebCore/ImageDecoderIdentifier.h>
+#include <WebCore/ImageTypes.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/SharedBuffer.h>
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class GPUProcessConnection;
+class RemoteImageDecoderAVF;
+class WebProcess;
+
+class RemoteImageDecoderAVFManager
+ : public WebProcessSupplement
+ , private IPC::MessageReceiver {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit RemoteImageDecoderAVFManager(WebProcess&);
+ virtual ~RemoteImageDecoderAVFManager();
+
+ void deleteRemoteImageDecoder(const WebCore::ImageDecoderIdentifier&);
+
+ static const char* supplementName();
+
+ void setUseGPUProcess(bool);
+ GPUProcessConnection& gpuProcessConnection() const;
+
+private:
+ RefPtr<RemoteImageDecoderAVF> createImageDecoder(WebCore::SharedBuffer& data, const String& mimeType, WebCore::AlphaOption, WebCore::GammaAndColorProfileOption);
+
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+ void encodedDataStatusChanged(const WebCore::ImageDecoderIdentifier&, size_t frameCount, const WebCore::IntSize&, bool hasTrack);
+
+ HashMap<WebCore::ImageDecoderIdentifier, WeakPtr<RemoteImageDecoderAVF>> m_remoteImageDecoders;
+
+ WebProcess& m_process;
+ mutable GPUProcessConnection* m_gpuProcessConnection { nullptr };
+ bool m_messageReceiverInitialized { false };
+};
+
+}
+
+#endif
Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in (0 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in 2021-02-10 01:18:45 UTC (rev 272625)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+
+messages -> RemoteImageDecoderAVFManager NotRefCounted {
+ EncodedDataStatusChanged(WebCore::ImageDecoderIdentifier identifier, uint32_t frameCount, WebCore::IntSize size, bool hasTrack)
+}
+
+#endif
Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp (272624 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -41,6 +41,8 @@
#include <WebCore/SharedBuffer.h>
#include <WebCore/WebAudioBufferList.h>
+#include <pal/cf/CoreMediaSoftLink.h>
+
namespace WebKit {
using namespace PAL;
using namespace WebCore;
Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h (272624 => 272625)
--- trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h 2021-02-10 01:18:45 UTC (rev 272625)
@@ -87,4 +87,3 @@
}
#endif // PLATFORM(COCOA) && ENABLE(GPU_PROCESS) && ENABLE(MEDIA_STREAM) && HAVE(AVASSETWRITERDELEGATE)
-
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (272624 => 272625)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -347,7 +347,10 @@
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
#include "RemoteLegacyCDMFactory.h"
#endif
+#if HAVE(AVASSETREADER)
+#include "RemoteImageDecoderAVFManager.h"
#endif
+#endif
#if ENABLE(IMAGE_EXTRACTION)
#include <WebCore/ImageExtractionResult.h>
@@ -3849,6 +3852,9 @@
// FIXME: useGPUProcessForMediaEnabled should be a RuntimeEnabledFeature since it's global.
static_cast<WebMediaStrategy&>(platformStrategies()->mediaStrategy()).setUseGPUProcess(m_shouldPlayMediaInGPUProcess);
WebProcess::singleton().supplement<RemoteMediaPlayerManager>()->setUseGPUProcess(m_shouldPlayMediaInGPUProcess);
+#if HAVE(AVASSETREADER)
+ WebProcess::singleton().supplement<RemoteImageDecoderAVFManager>()->setUseGPUProcess(m_shouldPlayMediaInGPUProcess);
+#endif
WebProcess::singleton().setUseGPUProcessForCanvasRendering(m_shouldRenderCanvasInGPUProcess);
WebProcess::singleton().setUseGPUProcessForDOMRendering(m_shouldRenderDOMInGPUProcess && DrawingArea::supportsGPUProcessRendering(m_drawingAreaType));
WebProcess::singleton().setUseGPUProcessForMedia(m_shouldPlayMediaInGPUProcess);
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (272624 => 272625)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2021-02-10 01:04:07 UTC (rev 272624)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2021-02-10 01:18:45 UTC (rev 272625)
@@ -198,6 +198,11 @@
#include "AudioSessionRoutingArbitrator.h"
#endif
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+#include "RemoteImageDecoderAVF.h"
+#include <WebCore/ImageDecoder.h>
+#endif
+
#if PLATFORM(COCOA)
#include <WebCore/VP9UtilitiesCocoa.h>
#endif
@@ -273,6 +278,10 @@
addSupplement<RemoteMediaPlayerManager>();
#endif
+#if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
+ addSupplement<RemoteImageDecoderAVFManager>();
+#endif
+
#if ENABLE(GPU_PROCESS) && ENABLE(ENCRYPTED_MEDIA)
addSupplement<RemoteCDMFactory>();
#endif
@@ -1938,7 +1947,7 @@
else
LegacyCDM::resetFactories();
#endif
-
+
if (useGPUProcessForMedia)
ensureGPUProcessConnection().mediaEngineConfigurationFactory().registerFactory();
else