WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-222461-20210225232147.patch (text/plain), 22.96 KB, created by
Jer Noble
on 2021-02-25 23:21:48 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2021-02-25 23:21:48 PST
Size:
22.96 KB
patch
obsolete
>Subversion Revision: 273507 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 59a775bf3f5bfe6d019adb8c17a3ea6771634870..cc77b267beacd20ef248b994c18ffa0a492a64f5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2021-02-25 Jer Noble <jer.noble@apple.com> >+ >+ [GPUP] Allow painting of GPUP hosted video from the WebContent process >+ https://bugs.webkit.org/show_bug.cgi?id=222461 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ - 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/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-02-23 Darin Adler <darin@apple.com> > > Streamline ImageData size calculations and handle out-of-memory >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f5cff6acd377ccff3d644b733892daaee2ed8f81..abc3dbaec3d7869f0bb2f77b4c6c10ddaf06d215 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2021-02-25 Jer Noble <jer.noble@apple.com> >+ >+ [GPUP] Allow painting of GPUP hosted video from the WebContent process >+ https://bugs.webkit.org/show_bug.cgi?id=222461 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime(). >+ Use those methods to implement paintCurrentFrameInContext(). >+ >+ * GPUProcess/media/RemoteMediaPlayerProxy.cpp: >+ (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime): >+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime): >+ * GPUProcess/media/RemoteMediaPlayerProxy.h: >+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in: >+ * 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-02-25 Eric Carlson <eric.carlson@apple.com> > > [GPUP] Some media-capabilities tests fail when media in GPU Process is enabled >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp >index 4b0acc7dc10a03fae109f52369b6960ab158f015..c6e598c9dbdd05fa5c0893f3319a7b73d3afb56c 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.cpp >+++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp >@@ -1015,7 +1015,7 @@ bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContextGL* context, > > #else > >-CVPixelBufferRef MediaPlayer::pixelBufferForCurrentTime() >+RetainPtr<CVPixelBufferRef> MediaPlayer::pixelBufferForCurrentTime() > { > return m_private->pixelBufferForCurrentTime(); > } >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h >index 4db9d7258633f1bd4c0f69b622e7ab0322fc2089..f811326d25fb1aa2a0992793536e8902d58f2759 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.h >+++ b/Source/WebCore/platform/graphics/MediaPlayer.h >@@ -444,7 +444,7 @@ public: > #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(); >diff --git a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >index c6a7cc388f2f34a3f44123e2f25d5379799aa286..bdd9906ad66578f8c0257ee44eadf24d59584d71 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >+++ b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >@@ -164,7 +164,7 @@ public: > #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; } > >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >index 1451acc39d877d98f7aa968467dfbe72600db8f9..97873faaed7df60b6fc257cfcfd0b29e95271c3f 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >@@ -254,7 +254,7 @@ private: > RefPtr<NativeImage> nativeImageForCurrentTime() final; > void waitForVideoOutputMediaDataWillChange(); > >- CVPixelBufferRef pixelBufferForCurrentTime() final; >+ RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final; > > #if ENABLE(LEGACY_ENCRYPTED_MEDIA) > void keyAdded() final; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >index 4215f9b12f371de6075aea71f1bfdf9b377f2747..5761c099b1f194fa1f0d803c695d042fbe4483a9 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >@@ -2391,13 +2391,13 @@ void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& c > > } > >-CVPixelBufferRef MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime() >+RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime() > { > updateLastPixelBuffer(); > if (!m_lastPixelBuffer) > return nullptr; > >- return m_lastPixelBuffer.get(); >+ return m_lastPixelBuffer; > } > > RefPtr<NativeImage> MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime() >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >index 7ac532f0f99bf34616ada7fa622b7186ddd5d7a6..55a4d58f8d80f6994b3f4299e99b51b526385f23 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >@@ -221,7 +221,7 @@ private: > 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. >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >index 34054b7baa49667271bc32edbc65f59097738bb6..28bdc3cb40b27b7d4896cc004d152adf7c92b489 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >@@ -623,7 +623,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext(GraphicsCo > 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 @@ CVPixelBufferRef MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime > return nullptr; > } > >- return m_lastPixelBuffer.get(); >+ return m_lastPixelBuffer; > } > > bool MediaPlayerPrivateMediaSourceAVFObjC::hasAvailableVideoFrame() const >diff --git a/Source/WebCore/platform/graphics/cocoa/IOSurface.h b/Source/WebCore/platform/graphics/cocoa/IOSurface.h >index 2c474e117ad72f51230e6084203d30431f1b6376..c506e04fb719ab8712e2d0299f6e5fb0bd166ae5 100644 >--- a/Source/WebCore/platform/graphics/cocoa/IOSurface.h >+++ b/Source/WebCore/platform/graphics/cocoa/IOSurface.h >@@ -35,6 +35,8 @@ > #define HAVE_IOSURFACE_RGB10 1 > #endif > >+using CVPixelBufferRef = struct __CVBuffer*; >+ > namespace WTF { > class MachSendRight; > class TextStream; >@@ -104,6 +106,7 @@ public: > 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 @@ public: > // 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(); } >diff --git a/Source/WebCore/platform/graphics/cocoa/IOSurface.mm b/Source/WebCore/platform/graphics/cocoa/IOSurface.mm >index cf7cb6e53cd49836cb493aacbe16bb05e4374b68..548a2e6eac6ad9fa8c8323f96b1ee5e762e23a65 100644 >--- a/Source/WebCore/platform/graphics/cocoa/IOSurface.mm >+++ b/Source/WebCore/platform/graphics/cocoa/IOSurface.mm >@@ -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 @@ std::unique_ptr<IOSurface> IOSurface::createFromImage(CGImageRef image) > 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 @@ RetainPtr<CGImageRef> IOSurface::sinkIntoImage(std::unique_ptr<IOSurface> surfac > 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) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp >index af991b175e95d6c846bba6ed945db5231d7cd58c..cbd6591193251dd17d1fb04d5c04afeb97b39eff 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp >@@ -271,7 +271,7 @@ bool GraphicsContextGLOpenGL::copyTextureFromMedia(MediaPlayer& player, Platform > > 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 >diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp b/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp >index b4d1eaf2cdb19b082f2ee0cb26cdd07e7251d1a9..391a4d4ed957b1843542829bfb88209da1b175ae 100644 >--- a/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp >+++ b/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp >@@ -48,6 +48,7 @@ > #include "TextTrackPrivateRemoteConfiguration.h" > #include "TrackPrivateRemoteConfiguration.h" > #include "WebCoreArgumentCoders.h" >+#include <WebCore/IOSurface.h> > #include <WebCore/LayoutRect.h> > #include <WebCore/MediaPlayer.h> > #include <WebCore/MediaPlayerPrivate.h> >@@ -1010,6 +1011,60 @@ void RemoteMediaPlayerProxy::setShouldEnableAudioSourceProvider(bool shouldEnabl > #endif > } > >+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 = 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 = IOSurface::createFromPixelBuffer(pixelBuffer.get()); >+ if (!surface) { >+ completionHandler(WTF::nullopt); >+ return; >+ } >+ >+ completionHandler(surface->createSendRight()); >+#endif >+} >+ > } // namespace WebKit > > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h b/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h >index 62c550c4a8702c055bdb6a5715b8efcd07ce4ad0..e70ca1d61c33c694a69fdbe8a1e54f4397854258 100644 >--- a/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h >+++ b/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h >@@ -286,6 +286,9 @@ private: > void createAudioSourceProvider(); > void setShouldEnableAudioSourceProvider(bool); > >+ void nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&); >+ void pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&); >+ > #if !RELEASE_LOG_DISABLED > const Logger& mediaPlayerLogger() final { return m_logger; } > const void* mediaPlayerLogIdentifier() { return reinterpret_cast<const void*>(m_configuration.logIdentifier); } >diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in b/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in >index 8367ec3fb328a85f94af33c32d7b1e0235be42b5..ca6e8a1f88b48673927832706477af2d62f9b415 100644 >--- a/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in >+++ b/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in >@@ -126,6 +126,9 @@ messages -> RemoteMediaPlayerProxy NotRefCounted { > CreateAudioSourceProvider() > SetShouldEnableAudioSourceProvider(bool shouldEnable) > #endif >+ >+ NativeImageForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous >+ PixelBufferForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous > } > > #endif >diff --git a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp >index 8cb461825cc6419581b37dda1c4669362257c9c8..2adeacce0d1456f9305ff038a7a7cf6bc41732f3 100644 >--- a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp >+++ b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp >@@ -42,6 +42,7 @@ > #include "WebProcess.h" > #include <JavaScriptCore/GenericTypedArrayViewInlines.h> > #include <JavaScriptCore/TypedArrayType.h> >+#include <WebCore/GraphicsContext.h> > #include <WebCore/MediaPlayer.h> > #include <WebCore/NotImplemented.h> > #include <WebCore/PlatformLayer.h> >@@ -838,14 +839,22 @@ void MediaPlayerPrivateRemote::setVideoInlineSizeFenced(const IntSize& size, con > } > #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 @@ bool MediaPlayerPrivateRemote::copyVideoTextureToPlatformTexture(WebCore::Graphi > 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 > { >diff --git a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h >index f28ea932fcc153d8b7033df110222595c1d5d877..c99521975a1d763d109551d847fa6d48abd4c9bf 100644 >--- a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h >+++ b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h >@@ -283,6 +283,8 @@ private: > 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; > >diff --git a/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm b/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm >index 4f3de773c1236f330f540a9c8d64100cfb05bbc0..7a7fd6c1791c43f651df22eee1108347a1fe1d8f 100644 >--- a/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm >+++ b/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm >@@ -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 @@ PlatformLayerContainer MediaPlayerPrivateRemote::createVideoFullscreenLayer() > } > #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)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 222461
:
421616
|
421618
|
421619