⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273800 in webkit


Ignore:
Timestamp:
Mar 2, 2021, 7:09:13 PM (6 years ago)
Author:
Alan Coon
Message:

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

Location:
branches/safari-612.1.5-branch/Source
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.1.5-branch/Source/WebCore/ChangeLog

    r273799 r273800  
     12021-03-02  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r273568. rdar://problem/74952680
     4
     5    [GPUP] Allow painting of GPUP hosted video from the WebContent process
     6    https://bugs.webkit.org/show_bug.cgi?id=222461
     7   
     8    Reviewed by Eric Carlson.
     9   
     10    Source/WebCore:
     11   
     12    - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<>
     13      rather than just a raw pointer.
     14   
     15    - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer
     16      and to reconstitute a CVPixelBuffer from an IOSurface.
     17   
     18    * platform/cocoa/CoreVideoSoftLink.cpp:
     19    * platform/cocoa/CoreVideoSoftLink.h:
     20    * platform/graphics/MediaPlayer.cpp:
     21    (WebCore::MediaPlayer::pixelBufferForCurrentTime):
     22    * platform/graphics/MediaPlayer.h:
     23    * platform/graphics/MediaPlayerPrivate.h:
     24    (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
     25    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     26    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     27    (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
     28    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     29    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     30    (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
     31    * platform/graphics/cocoa/IOSurface.h:
     32    * platform/graphics/cocoa/IOSurface.mm:
     33    (WebCore::IOSurface::createFromPixelBuffer):
     34    (WebCore::IOSurface::createPixelBuffer):
     35    * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
     36    (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
     37   
     38    Source/WebKit:
     39   
     40    Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime().
     41    Use those methods to implement paintCurrentFrameInContext().
     42   
     43    * GPUProcess/media/RemoteMediaPlayerProxy.h:
     44    * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
     45    * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
     46    (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
     47    (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime):
     48    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
     49    (WebKit::MediaPlayerPrivateRemote::paint):
     50    (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext):
     51    (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
     52    * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
     53    * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
     54    (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
     55    (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
     56   
     57   
     58    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     59
     60    2021-02-26  Jer Noble  <jer.noble@apple.com>
     61
     62            [GPUP] Allow painting of GPUP hosted video from the WebContent process
     63            https://bugs.webkit.org/show_bug.cgi?id=222461
     64
     65            Reviewed by Eric Carlson.
     66
     67            - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<>
     68              rather than just a raw pointer.
     69
     70            - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer
     71              and to reconstitute a CVPixelBuffer from an IOSurface.
     72
     73            * platform/cocoa/CoreVideoSoftLink.cpp:
     74            * platform/cocoa/CoreVideoSoftLink.h:
     75            * platform/graphics/MediaPlayer.cpp:
     76            (WebCore::MediaPlayer::pixelBufferForCurrentTime):
     77            * platform/graphics/MediaPlayer.h:
     78            * platform/graphics/MediaPlayerPrivate.h:
     79            (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
     80            * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     81            * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     82            (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
     83            * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     84            * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     85            (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
     86            * platform/graphics/cocoa/IOSurface.h:
     87            * platform/graphics/cocoa/IOSurface.mm:
     88            (WebCore::IOSurface::createFromPixelBuffer):
     89            (WebCore::IOSurface::createPixelBuffer):
     90            * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
     91            (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
     92
    1932021-03-02  Alan Coon  <alancoon@apple.com>
    294
  • branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp

    r269371 r273800  
    4747SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferPoolCreatePixelBuffer, CVReturn, (CFAllocatorRef allocator, CVPixelBufferPoolRef pixelBufferPool, CVPixelBufferRef* pixelBufferOut), (allocator, pixelBufferPool, pixelBufferOut))
    4848SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetIOSurface, IOSurfaceRef, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
     49SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVImageBufferGetColorSpace, CGColorSpaceRef, (CVImageBufferRef pixelBuffer), (pixelBuffer))
     50
    4951SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(WebCore, CoreVideo, kCVPixelBufferPixelFormatTypeKey, CFStringRef, WEBCORE_EXPORT)
    5052SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferCGBitmapContextCompatibilityKey, CFStringRef)
  • branches/safari-612.1.5-branch/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h

    r265073 r273800  
    6363SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferPoolGetPixelBufferAttributes, CFDictionaryRef, (CVPixelBufferPoolRef pool), (pool))
    6464#define CVPixelBufferPoolGetPixelBufferAttributes softLink_CoreVideo_CVPixelBufferPoolGetPixelBufferAttributes
     65SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVImageBufferGetColorSpace, CGColorSpaceRef, (CVImageBufferRef pixelBuffer), (pixelBuffer))
     66#define CVImageBufferGetColorSpace softLink_CoreVideo_CVImageBufferGetColorSpace
    6567
    6668SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferPixelFormatTypeKey, CFStringRef)
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r273213 r273800  
    10161016#else
    10171017
    1018 CVPixelBufferRef MediaPlayer::pixelBufferForCurrentTime()
     1018RetainPtr<CVPixelBufferRef> MediaPlayer::pixelBufferForCurrentTime()
    10191019{
    10201020    return m_private->pixelBufferForCurrentTime();
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayer.h

    r273213 r273800  
    445445    bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
    446446#else
    447     CVPixelBufferRef pixelBufferForCurrentTime();
     447    RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime();
    448448#endif
    449449
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r273213 r273800  
    165165    virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; }
    166166#else
    167     virtual CVPixelBufferRef pixelBufferForCurrentTime() { return nullptr; }
     167    virtual RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() { return nullptr; }
    168168#endif
    169169    virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; }
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r273213 r273800  
    255255    void waitForVideoOutputMediaDataWillChange();
    256256
    257     CVPixelBufferRef pixelBufferForCurrentTime() final;
     257    RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
    258258
    259259#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r273213 r273800  
    23892389}
    23902390
    2391 CVPixelBufferRef MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()
     2391RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()
    23922392{
    23932393    updateLastPixelBuffer();
    … …  
    23952395        return nullptr;
    23962396
    2397     return m_lastPixelBuffer.get();
     2397    return m_lastPixelBuffer;
    23982398}
    23992399
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r273213 r273800  
    222222    void paint(GraphicsContext&, const FloatRect&) override;
    223223    void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
    224     CVPixelBufferRef pixelBufferForCurrentTime() final;
     224    RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
    225225
    226226    bool supportsAcceleratedRendering() const override;
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r273213 r273800  
    624624}
    625625
    626 CVPixelBufferRef MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()
     626RetainPtr<CVPixelBufferRef> MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()
    627627{
    628628    // We have been asked to paint into a WebGL canvas, so take that as a signal to create
    … …  
    639639    }
    640640
    641     return m_lastPixelBuffer.get();
     641    return m_lastPixelBuffer;
    642642}
    643643
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h

    r271673 r273800  
    3535#define HAVE_IOSURFACE_RGB10 1
    3636#endif
     37
     38using CVPixelBufferRef = struct __CVBuffer*;
    3739
    3840namespace WTF {
    … …  
    105107    static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, CGColorSpaceRef);
    106108    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef);
     109    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromPixelBuffer(CVPixelBufferRef);
    107110   
    108111#if USE(IOSURFACE_CANVAS_BACKING_STORE)
    … …  
    123126    WEBCORE_EXPORT RetainPtr<CGImageRef> createImage();
    124127    WEBCORE_EXPORT static RetainPtr<CGImageRef> sinkIntoImage(std::unique_ptr<IOSurface>);
     128    WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> createPixelBuffer();
    125129
    126130#ifdef __OBJC__
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm

    r272616 r273800  
    4141#import <wtf/text/TextStream.h>
    4242
     43#import <WebCore/CoreVideoSoftLink.h>
     44
    4345namespace WebCore {
    4446
    … …  
    101103    CGContextFlush(surfaceContext);
    102104    return surface;
     105}
     106
     107std::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);
    103121}
    104122
    … …  
    281299}
    282300
     301RetainPtr<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
    283311void IOSurface::setContextSize(IntSize contextSize)
    284312{
  • branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp

    r273213 r273800  
    272272    UNUSED_VARIABLE(premultiplyAlpha);
    273273    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));
    275275#else
    276276    return player.copyVideoTextureToPlatformTexture(this, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY);
  • branches/safari-612.1.5-branch/Source/WebKit/ChangeLog

    r273790 r273800  
     12021-03-02  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r273568. rdar://problem/74952680
     4
     5    [GPUP] Allow painting of GPUP hosted video from the WebContent process
     6    https://bugs.webkit.org/show_bug.cgi?id=222461
     7   
     8    Reviewed by Eric Carlson.
     9   
     10    Source/WebCore:
     11   
     12    - Change the return type of pixelBufferForCurrentTime() to return a RetainPtr<>
     13      rather than just a raw pointer.
     14   
     15    - Add utility methods on IOSurface to retrieve an IOSurface from a CVPixelBuffer
     16      and to reconstitute a CVPixelBuffer from an IOSurface.
     17   
     18    * platform/cocoa/CoreVideoSoftLink.cpp:
     19    * platform/cocoa/CoreVideoSoftLink.h:
     20    * platform/graphics/MediaPlayer.cpp:
     21    (WebCore::MediaPlayer::pixelBufferForCurrentTime):
     22    * platform/graphics/MediaPlayer.h:
     23    * platform/graphics/MediaPlayerPrivate.h:
     24    (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
     25    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     26    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     27    (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
     28    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     29    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     30    (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
     31    * platform/graphics/cocoa/IOSurface.h:
     32    * platform/graphics/cocoa/IOSurface.mm:
     33    (WebCore::IOSurface::createFromPixelBuffer):
     34    (WebCore::IOSurface::createPixelBuffer):
     35    * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
     36    (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
     37   
     38    Source/WebKit:
     39   
     40    Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime().
     41    Use those methods to implement paintCurrentFrameInContext().
     42   
     43    * GPUProcess/media/RemoteMediaPlayerProxy.h:
     44    * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
     45    * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
     46    (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
     47    (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime):
     48    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
     49    (WebKit::MediaPlayerPrivateRemote::paint):
     50    (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext):
     51    (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
     52    * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
     53    * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
     54    (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
     55    (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
     56   
     57   
     58    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     59
     60    2021-02-26  Jer Noble  <jer.noble@apple.com>
     61
     62            [GPUP] Allow painting of GPUP hosted video from the WebContent process
     63            https://bugs.webkit.org/show_bug.cgi?id=222461
     64
     65            Reviewed by Eric Carlson.
     66
     67            Add Cocoa implementations for nativeImageForCurrentTime() and pixelBufferForCurrentTime().
     68            Use those methods to implement paintCurrentFrameInContext().
     69
     70            * GPUProcess/media/RemoteMediaPlayerProxy.h:
     71            * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
     72            * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
     73            (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
     74            (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime):
     75            * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
     76            (WebKit::MediaPlayerPrivateRemote::paint):
     77            (WebKit::MediaPlayerPrivateRemote::paintCurrentFrameInContext):
     78            (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
     79            * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
     80            * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
     81            (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
     82            (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
     83
    1842021-03-02  Alan Coon  <alancoon@apple.com>
    285
  • branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h

    r272600 r273800  
    287287    void setShouldEnableAudioSourceProvider(bool);
    288288
     289#if PLATFORM(COCOA)
     290    void nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
     291    void pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
     292#endif
     293
    289294#if !RELEASE_LOG_DISABLED
    290295    const Logger& mediaPlayerLogger() final { return m_logger; }
  • branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in

    r272600 r273800  
    127127    SetShouldEnableAudioSourceProvider(bool shouldEnable)
    128128#endif
     129
     130#if PLATFORM(COCOA)
     131    NativeImageForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous
     132    PixelBufferForCurrentTime() -> (Optional<MachSendRight> sendRight) Synchronous
     133#endif
    129134}
    130135
  • branches/safari-612.1.5-branch/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm

    r272414 r273800  
    3232#import "MediaPlayerPrivateRemoteMessages.h"
    3333#import <QuartzCore/QuartzCore.h>
     34#import <WebCore/IOSurface.h>
    3435#import <WebCore/IntSize.h>
    3536#import <wtf/MachSendRight.h>
    … …  
    7778}
    7879
     80void 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
     108void 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
    79134} // namespace WebKit
    80135
  • branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp

    r273213 r273800  
    4343#include <JavaScriptCore/GenericTypedArrayViewInlines.h>
    4444#include <JavaScriptCore/TypedArrayType.h>
     45#include <WebCore/GraphicsContext.h>
    4546#include <WebCore/MediaPlayer.h>
    4647#include <WebCore/NotImplemented.h>
    … …  
    839840#endif
    840841
    841 void MediaPlayerPrivateRemote::paint(GraphicsContext&, const FloatRect&)
    842 {
    843     notImplemented();
    844 }
    845 
    846 void MediaPlayerPrivateRemote::paintCurrentFrameInContext(GraphicsContext&, const FloatRect&)
    847 {
    848     notImplemented();
     842void MediaPlayerPrivateRemote::paint(GraphicsContext& context, const FloatRect& rect)
     843{
     844    paintCurrentFrameInContext(context, rect);
     845}
     846
     847void 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);
    849858}
    850859
    … …  
    855864    return false;
    856865}
    857 #endif
    858 
     866#elif !PLATFORM(COCOA)
     867RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime()
     868{
     869    notImplemented();
     870    return false;
     871}
     872#endif
     873
     874#if !PLATFORM(COCOA)
    859875RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime()
    860876{
    … …  
    862878    return nullptr;
    863879}
     880#endif
    864881
    865882bool MediaPlayerPrivateRemote::hasAvailableVideoFrame() const
  • branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h

    r273213 r273800  
    284284#if !USE(AVFOUNDATION)
    285285    bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final;
     286#else
     287    RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
    286288#endif
    287289    RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final;
  • branches/safari-612.1.5-branch/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm

    r268521 r273800  
    3030
    3131#import "RemoteAudioSourceProvider.h"
     32#import "RemoteMediaPlayerProxyMessages.h"
     33#import "WebCoreArgumentCoders.h"
     34#import <WebCore/ColorSpaceCG.h>
     35#import <WebCore/IOSurface.h>
    3236#import <WebCore/VideoLayerManagerObjC.h>
    3337#import <pal/spi/cocoa/QuartzCoreSPI.h>
     38#import <wtf/MachSendRight.h>
    3439
    3540namespace WebKit {
    … …  
    5863#endif
    5964
     65RefPtr<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
     85RetainPtr<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
    60101} // namespace WebKit
    61102
Note: See TracChangeset for help on using the changeset viewer.