Diff
Modified: branches/safari-612.1.5-branch/Source/WebCore/ChangeLog (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/ChangeLog 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/ChangeLog 2021-03-03 03:09:13 UTC (rev 273800)
@@ -1,5 +1,97 @@
2021-03-02 Alan Coon <[email protected]>
+ Cherry-pick r273568. rdar://problem/74952680
+
+ [GPUP] Allow painting of GPUP hosted video from the WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=222461
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<>
+ rather than just a raw pointer.
+
+ - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer
+ and to reconstitute a CVPixelBuffer from an IOSurface.
+
+ * platform/cocoa/CoreVideoSoftLink.cpp:
+ * platform/cocoa/CoreVideoSoftLink.h:
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::pixelBufferForCurrentTime):
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
+ * platform/graphics/cocoa/IOSurface.h:
+ * platform/graphics/cocoa/IOSurface.mm:
+ (WebCore::IOSurface::createFromPixelBuffer):
+ (WebCore::IOSurface::createPixelBuffer):
+ * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+ (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
+
+ Source/WebKit:
+
+ Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime().
+ Use those methods to implement paintCurrentFrameInContext().
+
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+ * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+ (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime):
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+ (WebKit::MediaPlayerPrivateRemote::paint):
+ (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+ * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+ (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-26 Jer Noble <[email protected]>
+
+ [GPUP] Allow painting of GPUP hosted video from the WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=222461
+
+ Reviewed by Eric Carlson.
+
+ - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<>
+ rather than just a raw pointer.
+
+ - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer
+ and to reconstitute a CVPixelBuffer from an IOSurface.
+
+ * platform/cocoa/CoreVideoSoftLink.cpp:
+ * platform/cocoa/CoreVideoSoftLink.h:
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::pixelBufferForCurrentTime):
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
+ * platform/graphics/cocoa/IOSurface.h:
+ * platform/graphics/cocoa/IOSurface.mm:
+ (WebCore::IOSurface::createFromPixelBuffer):
+ (WebCore::IOSurface::createPixelBuffer):
+ * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+ (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
+
+2021-03-02 Alan Coon <[email protected]>
+
Cherry-pick r273513. rdar://problem/74953307
[Cocoa] Appending a partial segment of a WebM audio file results in no additional samples
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2021-03-03 03:09:13 UTC (rev 273800)
@@ -46,6 +46,8 @@
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferPoolCreate, CVReturn,(CFAllocatorRef allocator, CFDictionaryRef poolAttributes, CFDictionaryRef pixelBufferAttributes, CVPixelBufferPoolRef* poolOut), (allocator, poolAttributes, pixelBufferAttributes, poolOut))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferPoolCreatePixelBuffer, CVReturn, (CFAllocatorRef allocator, CVPixelBufferPoolRef pixelBufferPool, CVPixelBufferRef* pixelBufferOut), (allocator, pixelBufferPool, pixelBufferOut))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetIOSurface, IOSurfaceRef, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVImageBufferGetColorSpace, CGColorSpaceRef, (CVImageBufferRef pixelBuffer), (pixelBuffer))
+
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(WebCore, CoreVideo, kCVPixelBufferPixelFormatTypeKey, CFStringRef, WEBCORE_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferCGBitmapContextCompatibilityKey, CFStringRef)
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferCGImageCompatibilityKey, CFStringRef)
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -62,6 +62,8 @@
#define CVPixelBufferGetIOSurface softLink_CoreVideo_CVPixelBufferGetIOSurface
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferPoolGetPixelBufferAttributes, CFDictionaryRef, (CVPixelBufferPoolRef pool), (pool))
#define CVPixelBufferPoolGetPixelBufferAttributes softLink_CoreVideo_CVPixelBufferPoolGetPixelBufferAttributes
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVImageBufferGetColorSpace, CGColorSpaceRef, (CVImageBufferRef pixelBuffer), (pixelBuffer))
+#define CVImageBufferGetColorSpace softLink_CoreVideo_CVImageBufferGetColorSpace
SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferPixelFormatTypeKey, CFStringRef)
#define kCVPixelBufferPixelFormatTypeKey get_CoreVideo_kCVPixelBufferPixelFormatTypeKey()
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp 2021-03-03 03:09:13 UTC (rev 273800)
@@ -1015,7 +1015,7 @@
#else
-CVPixelBufferRef MediaPlayer::pixelBufferForCurrentTime()
+RetainPtr<CVPixelBufferRef> MediaPlayer::pixelBufferForCurrentTime()
{
return m_private->pixelBufferForCurrentTime();
}
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -444,7 +444,7 @@
#if !USE(AVFOUNDATION)
bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
#else
- CVPixelBufferRef pixelBufferForCurrentTime();
+ RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime();
#endif
RefPtr<NativeImage> nativeImageForCurrentTime();
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -164,7 +164,7 @@
#if !USE(AVFOUNDATION)
virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; }
#else
- virtual CVPixelBufferRef pixelBufferForCurrentTime() { return nullptr; }
+ virtual RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() { return nullptr; }
#endif
virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; }
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -254,7 +254,7 @@
RefPtr<NativeImage> nativeImageForCurrentTime() final;
void waitForVideoOutputMediaDataWillChange();
- CVPixelBufferRef pixelBufferForCurrentTime() final;
+ RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
void keyAdded() final;
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-03-03 03:09:13 UTC (rev 273800)
@@ -2388,13 +2388,13 @@
}
-CVPixelBufferRef MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()
+RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()
{
updateLastPixelBuffer();
if (!m_lastPixelBuffer)
return nullptr;
- return m_lastPixelBuffer.get();
+ return m_lastPixelBuffer;
}
RefPtr<NativeImage> MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime()
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -221,7 +221,7 @@
bool updateLastImage();
void paint(GraphicsContext&, const FloatRect&) override;
void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
- CVPixelBufferRef pixelBufferForCurrentTime() final;
+ RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
bool supportsAcceleratedRendering() const override;
// called when the rendering system flips the into or out of accelerated rendering mode.
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2021-03-03 03:09:13 UTC (rev 273800)
@@ -623,7 +623,7 @@
context.drawNativeImage(*image, imageRect.size(), outputRect, imageRect);
}
-CVPixelBufferRef MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()
+RetainPtr<CVPixelBufferRef> MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()
{
// We have been asked to paint into a WebGL canvas, so take that as a signal to create
// a decompression session, even if that means the native video can't also be displayed
@@ -638,7 +638,7 @@
return nullptr;
}
- return m_lastPixelBuffer.get();
+ return m_lastPixelBuffer;
}
bool MediaPlayerPrivateMediaSourceAVFObjC::hasAvailableVideoFrame() const
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -35,6 +35,8 @@
#define HAVE_IOSURFACE_RGB10 1
#endif
+using CVPixelBufferRef = struct __CVBuffer*;
+
namespace WTF {
class MachSendRight;
class TextStream;
@@ -104,6 +106,7 @@
WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const WTF::MachSendRight&&, CGColorSpaceRef);
static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, CGColorSpaceRef);
WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef);
+ WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromPixelBuffer(CVPixelBufferRef);
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
static std::unique_ptr<IOSurface> createFromImageBuffer(RefPtr<ImageBuffer>);
@@ -122,6 +125,7 @@
// the surface, or an expensive GPU readback can result.
WEBCORE_EXPORT RetainPtr<CGImageRef> createImage();
WEBCORE_EXPORT static RetainPtr<CGImageRef> sinkIntoImage(std::unique_ptr<IOSurface>);
+ WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> createPixelBuffer();
#ifdef __OBJC__
id asLayerContents() const { return (__bridge id)m_surface.get(); }
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2021-03-03 03:09:13 UTC (rev 273800)
@@ -40,6 +40,8 @@
#import <wtf/MathExtras.h>
#import <wtf/text/TextStream.h>
+#import <WebCore/CoreVideoSoftLink.h>
+
namespace WebCore {
inline std::unique_ptr<IOSurface> IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
@@ -102,6 +104,22 @@
return surface;
}
+std::unique_ptr<IOSurface> IOSurface::createFromPixelBuffer(CVPixelBufferRef pixelBuffer)
+{
+ if (!pixelBuffer)
+ return nullptr;
+
+ auto surface = CVPixelBufferGetIOSurface(pixelBuffer);
+ if (!surface)
+ return nullptr;
+
+ auto colorSpace = CVImageBufferGetColorSpace(pixelBuffer);
+ if (!colorSpace)
+ return nullptr;
+
+ return createFromSurface(surface, colorSpace);
+}
+
void IOSurface::moveToPool(std::unique_ptr<IOSurface>&& surface)
{
IOSurfacePool::sharedPool().addSurface(WTFMove(surface));
@@ -280,6 +298,16 @@
return adoptCF(CGIOSurfaceContextCreateImageReference(surface->ensurePlatformContext()));
}
+RetainPtr<CVPixelBufferRef> IOSurface::createPixelBuffer()
+{
+ CVPixelBufferRef rawBuffer = nullptr;
+ auto status = CVPixelBufferCreateWithIOSurface(kCFAllocatorDefault, m_surface.get(), nullptr, &rawBuffer);
+ if (status == noErr && rawBuffer)
+ return adoptCF(rawBuffer);
+
+ return nullptr;
+}
+
void IOSurface::setContextSize(IntSize contextSize)
{
if (contextSize == m_contextSize)
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp 2021-03-03 03:09:13 UTC (rev 273800)
@@ -271,7 +271,7 @@
UNUSED_VARIABLE(premultiplyAlpha);
ASSERT_UNUSED(outputTarget, outputTarget == GraphicsContextGL::TEXTURE_2D);
- return contextCV->copyPixelBufferToTexture(pixelBuffer, outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));
+ return contextCV->copyPixelBufferToTexture(pixelBuffer.get(), outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));
#else
return player.copyVideoTextureToPlatformTexture(this, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY);
#endif
Modified: branches/safari-612.1.5-branch/Source/WebKit/ChangeLog (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/ChangeLog 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/ChangeLog 2021-03-03 03:09:13 UTC (rev 273800)
@@ -1,5 +1,88 @@
2021-03-02 Alan Coon <[email protected]>
+ Cherry-pick r273568. rdar://problem/74952680
+
+ [GPUP] Allow painting of GPUP hosted video from the WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=222461
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<>
+ rather than just a raw pointer.
+
+ - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer
+ and to reconstitute a CVPixelBuffer from an IOSurface.
+
+ * platform/cocoa/CoreVideoSoftLink.cpp:
+ * platform/cocoa/CoreVideoSoftLink.h:
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::pixelBufferForCurrentTime):
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
+ * platform/graphics/cocoa/IOSurface.h:
+ * platform/graphics/cocoa/IOSurface.mm:
+ (WebCore::IOSurface::createFromPixelBuffer):
+ (WebCore::IOSurface::createPixelBuffer):
+ * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+ (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
+
+ Source/WebKit:
+
+ Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime().
+ Use those methods to implement paintCurrentFrameInContext().
+
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+ * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+ (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime):
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+ (WebKit::MediaPlayerPrivateRemote::paint):
+ (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+ * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+ (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-26 Jer Noble <[email protected]>
+
+ [GPUP] Allow painting of GPUP hosted video from the WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=222461
+
+ Reviewed by Eric Carlson.
+
+ Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime().
+ Use those methods to implement paintCurrentFrameInContext().
+
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+ * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+ (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime):
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+ (WebKit::MediaPlayerPrivateRemote::paint):
+ (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+ * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+ (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+
+2021-03-02 Alan Coon <[email protected]>
+
Cherry-pick r273304. rdar://problem/74953207
[macOS] Crash under AuxiliaryProcess::initializeSandbox
Modified: branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -286,6 +286,11 @@
void createAudioSourceProvider();
void setShouldEnableAudioSourceProvider(bool);
+#if PLATFORM(COCOA)
+ void nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
+ void pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
+#endif
+
#if !RELEASE_LOG_DISABLED
const Logger& mediaPlayerLogger() final { return m_logger; }
const void* mediaPlayerLogIdentifier() { return reinterpret_cast<const void*>(m_configuration.logIdentifier); }
Modified: branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2021-03-03 03:09:13 UTC (rev 273800)
@@ -126,6 +126,11 @@
CreateAudioSourceProvider()
SetShouldEnableAudioSourceProvider(bool shouldEnable)
#endif
+
+#if PLATFORM(COCOA)
+ NativeImageForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous
+ PixelBufferForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous
+#endif
}
#endif
Modified: branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2021-03-03 03:09:13 UTC (rev 273800)
@@ -31,6 +31,7 @@
#import "LayerHostingContext.h"
#import "MediaPlayerPrivateRemoteMessages.h"
#import <QuartzCore/QuartzCore.h>
+#import <WebCore/IOSurface.h>
#import <WebCore/IntSize.h>
#import <wtf/MachSendRight.h>
@@ -76,6 +77,60 @@
setVideoInlineSizeIfPossible(*m_inlineLayerHostingContext, size);
}
+void RemoteMediaPlayerProxy::nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&& completionHandler)
+{
+ if (!m_player) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ auto nativeImage = m_player->nativeImageForCurrentTime();
+ if (!nativeImage) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ auto platformImage = nativeImage->platformImage();
+ if (!platformImage) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ auto surface = WebCore::IOSurface::createFromImage(platformImage.get());
+ if (!surface) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ completionHandler(surface->createSendRight());
+}
+
+void RemoteMediaPlayerProxy::pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&& completionHandler)
+{
+#if !USE(AVFOUNDATION)
+ completionHandler(WTF::nullopt);
+#else
+ if (!m_player) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ auto pixelBuffer = m_player->pixelBufferForCurrentTime();
+ if (!pixelBuffer) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ auto surface = WebCore::IOSurface::createFromPixelBuffer(pixelBuffer.get());
+ if (!surface) {
+ completionHandler(WTF::nullopt);
+ return;
+ }
+
+ completionHandler(surface->createSendRight());
+#endif
+}
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
Modified: branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2021-03-03 03:09:13 UTC (rev 273800)
@@ -42,6 +42,7 @@
#include "WebProcess.h"
#include <_javascript_Core/GenericTypedArrayViewInlines.h>
#include <_javascript_Core/TypedArrayType.h>
+#include <WebCore/GraphicsContext.h>
#include <WebCore/MediaPlayer.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/PlatformLayer.h>
@@ -838,14 +839,22 @@
}
#endif
-void MediaPlayerPrivateRemote::paint(GraphicsContext&, const FloatRect&)
+void MediaPlayerPrivateRemote::paint(GraphicsContext& context, const FloatRect& rect)
{
- notImplemented();
+ paintCurrentFrameInContext(context, rect);
}
-void MediaPlayerPrivateRemote::paintCurrentFrameInContext(GraphicsContext&, const FloatRect&)
+void MediaPlayerPrivateRemote::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& rect)
{
- notImplemented();
+ if (context.paintingDisabled())
+ return;
+
+ auto nativeImage = nativeImageForCurrentTime();
+ if (!nativeImage)
+ return;
+
+ FloatRect imageRect { FloatPoint::zero(), nativeImage->size() };
+ context.drawNativeImage(*nativeImage, imageRect.size(), rect, imageRect);
}
#if !USE(AVFOUNDATION)
@@ -854,13 +863,21 @@
notImplemented();
return false;
}
+#elif !PLATFORM(COCOA)
+RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime()
+{
+ notImplemented();
+ return false;
+}
#endif
+#if !PLATFORM(COCOA)
RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime()
{
notImplemented();
return nullptr;
}
+#endif
bool MediaPlayerPrivateRemote::hasAvailableVideoFrame() const
{
Modified: branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2021-03-03 03:09:13 UTC (rev 273800)
@@ -283,6 +283,8 @@
void paintCurrentFrameInContext(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
#if !USE(AVFOUNDATION)
bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final;
+#else
+ RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
#endif
RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final;
Modified: branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (273799 => 273800)
--- branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2021-03-03 03:09:07 UTC (rev 273799)
+++ branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2021-03-03 03:09:13 UTC (rev 273800)
@@ -29,8 +29,13 @@
#if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
#import "RemoteAudioSourceProvider.h"
+#import "RemoteMediaPlayerProxyMessages.h"
+#import "WebCoreArgumentCoders.h"
+#import <WebCore/ColorSpaceCG.h>
+#import <WebCore/IOSurface.h>
#import <WebCore/VideoLayerManagerObjC.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
+#import <wtf/MachSendRight.h>
namespace WebKit {
using namespace WebCore;
@@ -57,6 +62,42 @@
}
#endif
+RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime()
+{
+ Optional<MachSendRight> sendRight;
+ if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::NativeImageForCurrentTime(), Messages::RemoteMediaPlayerProxy::NativeImageForCurrentTime::Reply(sendRight), m_id))
+ return nullptr;
+
+ if (!sendRight)
+ return nullptr;
+
+ auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), sRGBColorSpaceRef());
+ if (!surface)
+ return nullptr;
+
+ auto platformImage = WebCore::IOSurface::sinkIntoImage(WTFMove(surface));
+ if (!platformImage)
+ return nullptr;
+
+ return NativeImage::create(WTFMove(platformImage));
+}
+
+RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime()
+{
+ Optional<MachSendRight> sendRight;
+ if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTime(), Messages::RemoteMediaPlayerProxy::NativeImageForCurrentTime::Reply(sendRight), m_id))
+ return nullptr;
+
+ if (!sendRight)
+ return nullptr;
+
+ auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), nullptr);
+ if (!surface)
+ return nullptr;
+
+ return surface->createPixelBuffer();
+}
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)