Changeset 273568 in webkit
- Timestamp:
- Feb 26, 2021, 11:28:35 AM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/cocoa/CoreVideoSoftLink.cpp (modified) (1 diff)
-
WebCore/platform/cocoa/CoreVideoSoftLink.h (modified) (1 diff)
-
WebCore/platform/graphics/MediaPlayer.cpp (modified) (1 diff)
-
WebCore/platform/graphics/MediaPlayer.h (modified) (1 diff)
-
WebCore/platform/graphics/MediaPlayerPrivate.h (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (2 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (modified) (2 diffs)
-
WebCore/platform/graphics/cocoa/IOSurface.h (modified) (3 diffs)
-
WebCore/platform/graphics/cocoa/IOSurface.mm (modified) (3 diffs)
-
WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (modified) (1 diff)
-
WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (modified) (1 diff)
-
WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (modified) (2 diffs)
-
WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (modified) (4 diffs)
-
WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (modified) (1 diff)
-
WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273564 r273568 1 2021-02-26 Jer Noble <jer.noble@apple.com> 2 3 [GPUP] Allow painting of GPUP hosted video from the WebContent process 4 https://bugs.webkit.org/show_bug.cgi?id=222461 5 6 Reviewed by Eric Carlson. 7 8 - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<> 9 rather than just a raw pointer. 10 11 - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer 12 and to reconstitute a CVPixelBuffer from an IOSurface. 13 14 * platform/cocoa/CoreVideoSoftLink.cpp: 15 * platform/cocoa/CoreVideoSoftLink.h: 16 * platform/graphics/MediaPlayer.cpp: 17 (WebCore::MediaPlayer::pixelBufferForCurrentTime): 18 * platform/graphics/MediaPlayer.h: 19 * platform/graphics/MediaPlayerPrivate.h: 20 (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime): 21 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 22 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 23 (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime): 24 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 25 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 26 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime): 27 * platform/graphics/cocoa/IOSurface.h: 28 * platform/graphics/cocoa/IOSurface.mm: 29 (WebCore::IOSurface::createFromPixelBuffer): 30 (WebCore::IOSurface::createPixelBuffer): 31 * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp: 32 (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia): 33 1 34 2021-02-26 Per Arne <pvollan@apple.com> 2 35 -
trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp
r269371 r273568 47 47 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferPoolCreatePixelBuffer, CVReturn, (CFAllocatorRef allocator, CVPixelBufferPoolRef pixelBufferPool, CVPixelBufferRef* pixelBufferOut), (allocator, pixelBufferPool, pixelBufferOut)) 48 48 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetIOSurface, IOSurfaceRef, (CVPixelBufferRef pixelBuffer), (pixelBuffer)) 49 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVImageBufferGetColorSpace, CGColorSpaceRef, (CVImageBufferRef pixelBuffer), (pixelBuffer)) 50 49 51 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(WebCore, CoreVideo, kCVPixelBufferPixelFormatTypeKey, CFStringRef, WEBCORE_EXPORT) 50 52 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferCGBitmapContextCompatibilityKey, CFStringRef) -
trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h
r265073 r273568 63 63 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferPoolGetPixelBufferAttributes, CFDictionaryRef, (CVPixelBufferPoolRef pool), (pool)) 64 64 #define CVPixelBufferPoolGetPixelBufferAttributes softLink_CoreVideo_CVPixelBufferPoolGetPixelBufferAttributes 65 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVImageBufferGetColorSpace, CGColorSpaceRef, (CVImageBufferRef pixelBuffer), (pixelBuffer)) 66 #define CVImageBufferGetColorSpace softLink_CoreVideo_CVImageBufferGetColorSpace 65 67 66 68 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferPixelFormatTypeKey, CFStringRef) -
trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp
r273213 r273568 1016 1016 #else 1017 1017 1018 CVPixelBufferRefMediaPlayer::pixelBufferForCurrentTime()1018 RetainPtr<CVPixelBufferRef> MediaPlayer::pixelBufferForCurrentTime() 1019 1019 { 1020 1020 return m_private->pixelBufferForCurrentTime(); -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r273272 r273568 445 445 bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY); 446 446 #else 447 CVPixelBufferRefpixelBufferForCurrentTime();447 RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime(); 448 448 #endif 449 449 -
trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
r273213 r273568 165 165 virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; } 166 166 #else 167 virtual CVPixelBufferRefpixelBufferForCurrentTime() { return nullptr; }167 virtual RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() { return nullptr; } 168 168 #endif 169 169 virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r273213 r273568 255 255 void waitForVideoOutputMediaDataWillChange(); 256 256 257 CVPixelBufferRefpixelBufferForCurrentTime() final;257 RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final; 258 258 259 259 #if ENABLE(LEGACY_ENCRYPTED_MEDIA) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r273498 r273568 2392 2392 } 2393 2393 2394 CVPixelBufferRefMediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()2394 RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime() 2395 2395 { 2396 2396 updateLastPixelBuffer(); … … 2398 2398 return nullptr; 2399 2399 2400 return m_lastPixelBuffer .get();2400 return m_lastPixelBuffer; 2401 2401 } 2402 2402 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r273213 r273568 222 222 void paint(GraphicsContext&, const FloatRect&) override; 223 223 void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override; 224 CVPixelBufferRefpixelBufferForCurrentTime() final;224 RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final; 225 225 226 226 bool supportsAcceleratedRendering() const override; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r273213 r273568 624 624 } 625 625 626 CVPixelBufferRefMediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()626 RetainPtr<CVPixelBufferRef> MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime() 627 627 { 628 628 // We have been asked to paint into a WebGL canvas, so take that as a signal to create … … 639 639 } 640 640 641 return m_lastPixelBuffer .get();641 return m_lastPixelBuffer; 642 642 } 643 643 -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h
r271673 r273568 35 35 #define HAVE_IOSURFACE_RGB10 1 36 36 #endif 37 38 using CVPixelBufferRef = struct __CVBuffer*; 37 39 38 40 namespace WTF { … … 105 107 static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, CGColorSpaceRef); 106 108 WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef); 109 WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromPixelBuffer(CVPixelBufferRef); 107 110 108 111 #if USE(IOSURFACE_CANVAS_BACKING_STORE) … … 123 126 WEBCORE_EXPORT RetainPtr<CGImageRef> createImage(); 124 127 WEBCORE_EXPORT static RetainPtr<CGImageRef> sinkIntoImage(std::unique_ptr<IOSurface>); 128 WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> createPixelBuffer(); 125 129 126 130 #ifdef __OBJC__ -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
r272616 r273568 41 41 #import <wtf/text/TextStream.h> 42 42 43 #import <WebCore/CoreVideoSoftLink.h> 44 43 45 namespace WebCore { 44 46 … … 101 103 CGContextFlush(surfaceContext); 102 104 return surface; 105 } 106 107 std::unique_ptr<IOSurface> IOSurface::createFromPixelBuffer(CVPixelBufferRef pixelBuffer) 108 { 109 if (!pixelBuffer) 110 return nullptr; 111 112 auto surface = CVPixelBufferGetIOSurface(pixelBuffer); 113 if (!surface) 114 return nullptr; 115 116 auto colorSpace = CVImageBufferGetColorSpace(pixelBuffer); 117 if (!colorSpace) 118 return nullptr; 119 120 return createFromSurface(surface, colorSpace); 103 121 } 104 122 … … 281 299 } 282 300 301 RetainPtr<CVPixelBufferRef> IOSurface::createPixelBuffer() 302 { 303 CVPixelBufferRef rawBuffer = nullptr; 304 auto status = CVPixelBufferCreateWithIOSurface(kCFAllocatorDefault, m_surface.get(), nullptr, &rawBuffer); 305 if (status == noErr && rawBuffer) 306 return adoptCF(rawBuffer); 307 308 return nullptr; 309 } 310 283 311 void IOSurface::setContextSize(IntSize contextSize) 284 312 { -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp
r273213 r273568 272 272 UNUSED_VARIABLE(premultiplyAlpha); 273 273 ASSERT_UNUSED(outputTarget, outputTarget == GraphicsContextGL::TEXTURE_2D); 274 return contextCV->copyPixelBufferToTexture(pixelBuffer , outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));274 return contextCV->copyPixelBufferToTexture(pixelBuffer.get(), outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY)); 275 275 #else 276 276 return player.copyVideoTextureToPlatformTexture(this, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY); -
trunk/Source/WebKit/ChangeLog
r273564 r273568 1 2021-02-26 Jer Noble <jer.noble@apple.com> 2 3 [GPUP] Allow painting of GPUP hosted video from the WebContent process 4 https://bugs.webkit.org/show_bug.cgi?id=222461 5 6 Reviewed by Eric Carlson. 7 8 Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime(). 9 Use those methods to implement paintCurrentFrameInContext(). 10 11 * GPUProcess/media/RemoteMediaPlayerProxy.h: 12 * GPUProcess/media/RemoteMediaPlayerProxy.messages.in: 13 * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm: 14 (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime): 15 (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime): 16 * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp: 17 (WebKit::MediaPlayerPrivateRemote::paint): 18 (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext): 19 (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime): 20 * WebProcess/GPU/media/MediaPlayerPrivateRemote.h: 21 * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm: 22 (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime): 23 (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime): 24 1 25 2021-02-26 Per Arne <pvollan@apple.com> 2 26 -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h
r273473 r273568 287 287 void setShouldEnableAudioSourceProvider(bool); 288 288 289 #if PLATFORM(COCOA) 290 void nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&); 291 void pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&); 292 #endif 293 289 294 #if !RELEASE_LOG_DISABLED 290 295 const Logger& mediaPlayerLogger() final { return m_logger; } -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in
r272600 r273568 127 127 SetShouldEnableAudioSourceProvider(bool shouldEnable) 128 128 #endif 129 130 #if PLATFORM(COCOA) 131 NativeImageForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous 132 PixelBufferForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous 133 #endif 129 134 } 130 135 -
trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm
r272414 r273568 32 32 #import "MediaPlayerPrivateRemoteMessages.h" 33 33 #import <QuartzCore/QuartzCore.h> 34 #import <WebCore/IOSurface.h> 34 35 #import <WebCore/IntSize.h> 35 36 #import <wtf/MachSendRight.h> … … 77 78 } 78 79 80 void RemoteMediaPlayerProxy::nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&& completionHandler) 81 { 82 if (!m_player) { 83 completionHandler(WTF::nullopt); 84 return; 85 } 86 87 auto nativeImage = m_player->nativeImageForCurrentTime(); 88 if (!nativeImage) { 89 completionHandler(WTF::nullopt); 90 return; 91 } 92 93 auto platformImage = nativeImage->platformImage(); 94 if (!platformImage) { 95 completionHandler(WTF::nullopt); 96 return; 97 } 98 99 auto surface = WebCore::IOSurface::createFromImage(platformImage.get()); 100 if (!surface) { 101 completionHandler(WTF::nullopt); 102 return; 103 } 104 105 completionHandler(surface->createSendRight()); 106 } 107 108 void RemoteMediaPlayerProxy::pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&& completionHandler) 109 { 110 #if !USE(AVFOUNDATION) 111 completionHandler(WTF::nullopt); 112 #else 113 if (!m_player) { 114 completionHandler(WTF::nullopt); 115 return; 116 } 117 118 auto pixelBuffer = m_player->pixelBufferForCurrentTime(); 119 if (!pixelBuffer) { 120 completionHandler(WTF::nullopt); 121 return; 122 } 123 124 auto surface = WebCore::IOSurface::createFromPixelBuffer(pixelBuffer.get()); 125 if (!surface) { 126 completionHandler(WTF::nullopt); 127 return; 128 } 129 130 completionHandler(surface->createSendRight()); 131 #endif 132 } 133 79 134 } // namespace WebKit 80 135 -
trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
r273213 r273568 43 43 #include <JavaScriptCore/GenericTypedArrayViewInlines.h> 44 44 #include <JavaScriptCore/TypedArrayType.h> 45 #include <WebCore/GraphicsContext.h> 45 46 #include <WebCore/MediaPlayer.h> 46 47 #include <WebCore/NotImplemented.h> … … 839 840 #endif 840 841 841 void MediaPlayerPrivateRemote::paint(GraphicsContext&, const FloatRect&) 842 { 843 notImplemented(); 844 } 845 846 void MediaPlayerPrivateRemote::paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) 847 { 848 notImplemented(); 842 void MediaPlayerPrivateRemote::paint(GraphicsContext& context, const FloatRect& rect) 843 { 844 paintCurrentFrameInContext(context, rect); 845 } 846 847 void MediaPlayerPrivateRemote::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& rect) 848 { 849 if (context.paintingDisabled()) 850 return; 851 852 auto nativeImage = nativeImageForCurrentTime(); 853 if (!nativeImage) 854 return; 855 856 FloatRect imageRect { FloatPoint::zero(), nativeImage->size() }; 857 context.drawNativeImage(*nativeImage, imageRect.size(), rect, imageRect); 849 858 } 850 859 … … 855 864 return false; 856 865 } 857 #endif 858 866 #elif !PLATFORM(COCOA) 867 RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime() 868 { 869 notImplemented(); 870 return false; 871 } 872 #endif 873 874 #if !PLATFORM(COCOA) 859 875 RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime() 860 876 { … … 862 878 return nullptr; 863 879 } 880 #endif 864 881 865 882 bool MediaPlayerPrivateRemote::hasAvailableVideoFrame() const -
trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h
r273213 r273568 284 284 #if !USE(AVFOUNDATION) 285 285 bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final; 286 #else 287 RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final; 286 288 #endif 287 289 RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final; -
trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm
r268521 r273568 30 30 31 31 #import "RemoteAudioSourceProvider.h" 32 #import "RemoteMediaPlayerProxyMessages.h" 33 #import "WebCoreArgumentCoders.h" 34 #import <WebCore/ColorSpaceCG.h> 35 #import <WebCore/IOSurface.h> 32 36 #import <WebCore/VideoLayerManagerObjC.h> 33 37 #import <pal/spi/cocoa/QuartzCoreSPI.h> 38 #import <wtf/MachSendRight.h> 34 39 35 40 namespace WebKit { … … 58 63 #endif 59 64 65 RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime() 66 { 67 Optional<MachSendRight> sendRight; 68 if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::NativeImageForCurrentTime(), Messages::RemoteMediaPlayerProxy::NativeImageForCurrentTime::Reply(sendRight), m_id)) 69 return nullptr; 70 71 if (!sendRight) 72 return nullptr; 73 74 auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), sRGBColorSpaceRef()); 75 if (!surface) 76 return nullptr; 77 78 auto platformImage = WebCore::IOSurface::sinkIntoImage(WTFMove(surface)); 79 if (!platformImage) 80 return nullptr; 81 82 return NativeImage::create(WTFMove(platformImage)); 83 } 84 85 RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime() 86 { 87 Optional<MachSendRight> sendRight; 88 if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTime(), Messages::RemoteMediaPlayerProxy::NativeImageForCurrentTime::Reply(sendRight), m_id)) 89 return nullptr; 90 91 if (!sendRight) 92 return nullptr; 93 94 auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), nullptr); 95 if (!surface) 96 return nullptr; 97 98 return surface->createPixelBuffer(); 99 } 100 60 101 } // namespace WebKit 61 102
Note:
See TracChangeset
for help on using the changeset viewer.