Changeset 273213 in webkit


Ignore:
Timestamp:
Feb 20, 2021 6:05:38 PM (3 years ago)
Author:
Peng Liu
Message:

Video elements do not work as sources for TexImage2D calls in GPU Process
https://bugs.webkit.org/show_bug.cgi?id=218184

Reviewed by Jer Noble.

Source/WebCore:

Add a function GraphicsContextGL::copyTextureFromMedia() which can be used by the graphics
context to copy video texture from a video element (player).

This patch also replaces MediaPlayer::copyVideoTextureToPlatformTexture() with
MediaPlayer::pixelBufferForCurrentTime() on Cocoa ports. The motivation is that
RemoteGraphicsContextGL::copyTextureFromMedia() will run in a background thread
("RemoteGraphicsContextGL work queue") and it is difficult to make
MediaPlayer::copyVideoTextureToPlatformTexture() thread-safe. In addition, we cannot
simply run it on the main thread because it uses graphic context internally. Adding a
function MediaPlayer::pixelBufferForCurrentTime() solves the problem.

Manually tested.
We need to enable both "GPU Process: Media" and "GPU Process: WebGL" to test the feature.

  • html/HTMLVideoElement.cpp:

(WebCore::HTMLVideoElement::copyVideoTextureToPlatformTexture): Deleted.

  • html/HTMLVideoElement.h:
  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::texImageSourceHelper):

  • platform/graphics/GraphicsContextGL.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):
(WebCore::MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture): Deleted.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::copyVideoTextureToPlatformTexture): Deleted.

  • platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:

(WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):

  • platform/graphics/opengl/GraphicsContextGLOpenGL.h:

Source/WebKit:

Add an IPC message RemoteGraphicsContextGL::CopyTextureFromMedia to implement
RemoteGraphicsContextGLProxy::copyTextureFromMedia() in the Web process.

  • GPUProcess/graphics/RemoteGraphicsContextGL.cpp:

(WebKit::RemoteGraphicsContextGL::copyTextureFromMedia):

  • GPUProcess/graphics/RemoteGraphicsContextGL.h:

We should use m_gpuConnectionToWebProcess in the main thread only.

  • GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:

(WebKit::RemoteGraphicsContextGLProxy::copyTextureFromMedia):

  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
  • WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
  • WebProcess/GPU/media/MediaPlayerPrivateRemote.h:

Tools:

  • Scripts/generate-gpup-webgl:
Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r273211 r273213  
     12021-02-20  Peng Liu  <peng.liu6@apple.com>
     2
     3        Video elements do not work as sources for TexImage2D calls in GPU Process
     4        https://bugs.webkit.org/show_bug.cgi?id=218184
     5
     6        Reviewed by Jer Noble.
     7
     8        Add a function `GraphicsContextGL::copyTextureFromMedia()` which can be used by the graphics
     9        context to copy video texture from a video element (player).
     10       
     11        This patch also replaces `MediaPlayer::copyVideoTextureToPlatformTexture()` with
     12        `MediaPlayer::pixelBufferForCurrentTime()` on Cocoa ports. The motivation is that
     13        `RemoteGraphicsContextGL::copyTextureFromMedia()` will run in a background thread
     14        ("RemoteGraphicsContextGL work queue") and it is difficult to make
     15        `MediaPlayer::copyVideoTextureToPlatformTexture()` thread-safe. In addition, we cannot
     16        simply run it on the main thread because it uses graphic context internally. Adding a
     17        function `MediaPlayer::pixelBufferForCurrentTime()` solves the problem.
     18
     19        Manually tested.
     20        We need to enable both "GPU Process: Media" and "GPU Process: WebGL" to test the feature.
     21
     22        * html/HTMLVideoElement.cpp:
     23        (WebCore::HTMLVideoElement::copyVideoTextureToPlatformTexture): Deleted.
     24        * html/HTMLVideoElement.h:
     25
     26        * html/canvas/WebGLRenderingContextBase.cpp:
     27        (WebCore::WebGLRenderingContextBase::texImageSourceHelper):
     28        * platform/graphics/GraphicsContextGL.h:
     29
     30        * platform/graphics/MediaPlayer.cpp:
     31        (WebCore::MediaPlayer::pixelBufferForCurrentTime):
     32        * platform/graphics/MediaPlayer.h:
     33        * platform/graphics/MediaPlayerPrivate.h:
     34        (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime):
     35        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     36        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     37        (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime):
     38        (WebCore::MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture): Deleted.
     39        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     40        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     41        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime):
     42        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::copyVideoTextureToPlatformTexture): Deleted.
     43
     44        * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
     45        (WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia):
     46        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
     47
    1482021-02-20  Sam Weinig  <weinig@apple.com>
    249
  • trunk/Source/WebCore/html/HTMLVideoElement.cpp

    r272475 r273213  
    301301}
    302302
    303 bool HTMLVideoElement::copyVideoTextureToPlatformTexture(GraphicsContextGL* context, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
    304 {
    305     if (!player())
    306         return false;
    307     return player()->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY);
    308 }
    309 
    310303bool HTMLVideoElement::hasAvailableVideoFrame() const
    311304{
  • trunk/Source/WebCore/html/HTMLVideoElement.h

    r269850 r273213  
    7777
    7878    RefPtr<NativeImage> nativeImageForCurrentTime();
    79 
    80     // Used by WebGL to do GPU-GPU textures copy if possible.
    81     // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h.
    82     bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
    8379
    8480    WEBCORE_EXPORT bool shouldDisplayPosterImage() const;
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r273138 r273213  
    48824882            && type == GraphicsContextGL::UNSIGNED_BYTE
    48834883            && !level) {
    4884             if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
     4884            if (video->player() && m_context->copyTextureFromMedia(*video->player(), texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
    48854885#if !USE(ANGLE)
    48864886                texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type);
  • trunk/Source/WebCore/platform/graphics/GraphicsContextGL.h

    r273080 r273213  
    3333#include "IntRect.h"
    3434#include "IntSize.h"
     35#include "MediaPlayer.h"
    3536#include "PlatformLayer.h"
    3637#include <wtf/HashSet.h>
     
    13071308    virtual GraphicsContextGLCV* asCV() = 0;
    13081309#endif
    1309 
     1310    virtual bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) = 0;
    13101311
    13111312    IntSize getInternalFramebufferSize() const { return IntSize(m_currentWidth, m_currentHeight); }
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r272750 r273213  
    10071007}
    10081008
     1009#if !USE(AVFOUNDATION)
     1010
    10091011bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContextGL* context, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
    10101012{
    10111013    return m_private->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY);
    10121014}
     1015
     1016#else
     1017
     1018CVPixelBufferRef MediaPlayer::pixelBufferForCurrentTime()
     1019{
     1020    return m_private->pixelBufferForCurrentTime();
     1021}
     1022
     1023#endif
    10131024
    10141025RefPtr<NativeImage> MediaPlayer::nativeImageForCurrentTime()
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r272414 r273213  
    6363OBJC_CLASS NSArray;
    6464
     65#if ENABLE(WEBGL) && USE(AVFOUNDATION)
     66typedef struct __CVBuffer* CVPixelBufferRef;
     67#endif
     68
    6569namespace WebCore {
    6670
     
    438442    // The destination texture may need to be resized to to the dimensions of the source texture or re-defined to the required internalFormat.
    439443    // The current restrictions require that format shoud be RGB or RGBA, type should be UNSIGNED_BYTE and level should be 0. It may be lifted in the future.
    440 
     444#if !USE(AVFOUNDATION)
    441445    bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
     446#else
     447    CVPixelBufferRef pixelBufferForCurrentTime();
     448#endif
    442449
    443450    RefPtr<NativeImage> nativeImageForCurrentTime();
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r271219 r273213  
    162162
    163163    virtual void paintCurrentFrameInContext(GraphicsContext& c, const FloatRect& r) { paint(c, r); }
     164#if !USE(AVFOUNDATION)
    164165    virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; }
     166#else
     167    virtual CVPixelBufferRef pixelBufferForCurrentTime() { return nullptr; }
     168#endif
    165169    virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; }
    166170
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r271219 r273213  
    255255    void waitForVideoOutputMediaDataWillChange();
    256256
    257     bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
     257    CVPixelBufferRef pixelBufferForCurrentTime() final;
    258258
    259259#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r273128 r273213  
    23892389}
    23902390
    2391 bool MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture(GraphicsContextGL* context, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
    2392 {
    2393     ASSERT(context);
    2394 
     2391CVPixelBufferRef MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()
     2392{
    23952393    updateLastPixelBuffer();
    23962394    if (!m_lastPixelBuffer)
    2397         return false;
    2398 
    2399     auto contextCV = context->asCV();
    2400     if (!contextCV)
    2401         return false;
    2402     UNUSED_VARIABLE(premultiplyAlpha);
    2403     ASSERT_UNUSED(outputTarget, outputTarget == GraphicsContextGL::TEXTURE_2D);
    2404     return contextCV->copyPixelBufferToTexture(m_lastPixelBuffer.get(), outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));
     2395        return nullptr;
     2396
     2397    return m_lastPixelBuffer.get();
    24052398}
    24062399
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r269907 r273213  
    222222    void paint(GraphicsContext&, const FloatRect&) override;
    223223    void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
    224     bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) override;
     224    CVPixelBufferRef pixelBufferForCurrentTime() final;
    225225
    226226    bool supportsAcceleratedRendering() const override;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r271530 r273213  
    624624}
    625625
    626 bool MediaPlayerPrivateMediaSourceAVFObjC::copyVideoTextureToPlatformTexture(GraphicsContextGL* context, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
     626CVPixelBufferRef MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()
    627627{
    628628    // We have been asked to paint into a WebGL canvas, so take that as a signal to create
     
    634634    }
    635635
    636     ASSERT(context);
    637 
    638636    if (updateLastPixelBuffer()) {
    639637        if (!m_lastPixelBuffer)
    640             return false;
    641     }
    642     auto contextCV = context->asCV();
    643     if (!contextCV)
    644         return false;
    645     UNUSED_VARIABLE(premultiplyAlpha);
    646     ASSERT_UNUSED(outputTarget, outputTarget == GraphicsContextGL::TEXTURE_2D);
    647     return contextCV->copyPixelBufferToTexture(m_lastPixelBuffer.get(), outputTexture, level, internalFormat, format, type, GraphicsContextGLCV::FlipY(flipY));
     638            return nullptr;
     639    }
     640
     641    return m_lastPixelBuffer.get();
    648642}
    649643
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp

    r273080 r273213  
    3434#include "ImageBuffer.h"
    3535#include "ImageData.h"
     36#include "MediaPlayerPrivate.h"
    3637#include <wtf/UniqueArray.h>
     38
     39#if USE(AVFOUNDATION)
     40#include "GraphicsContextGLCV.h"
     41#endif
    3742
    3843namespace WebCore {
     
    254259#endif
    255260
     261bool GraphicsContextGLOpenGL::copyTextureFromMedia(MediaPlayer& player, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
     262{
     263#if USE(AVFOUNDATION)
     264    auto pixelBuffer = player.pixelBufferForCurrentTime();
     265    if (!pixelBuffer)
     266        return false;
     267
     268    auto contextCV = asCV();
     269    if (!contextCV)
     270        return false;
     271
     272    UNUSED_VARIABLE(premultiplyAlpha);
     273    ASSERT_UNUSED(outputTarget, outputTarget == GraphicsContextGL::TEXTURE_2D);
     274    return contextCV->copyPixelBufferToTexture(pixelBuffer, outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));
     275#else
     276    return player.copyVideoTextureToPlatformTexture(this, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY);
     277#endif
     278}
     279
    256280} // namespace WebCore
    257281
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h

    r273080 r273213  
    8787class ImageBuffer;
    8888class ImageData;
     89class MediaPlayer;
    8990#if USE(TEXTURE_MAPPER)
    9091class TextureMapperGCGLPlatformLayer;
     
    466467    RefPtr<ImageData> readCompositedResultsForPainting();
    467468
     469    bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
     470
    468471#if USE(OPENGL) && ENABLE(WEBGL2)
    469472    void primitiveRestartIndex(GCGLuint);
  • trunk/Source/WebKit/ChangeLog

    r273212 r273213  
     12021-02-20  Peng Liu  <peng.liu6@apple.com>
     2
     3        Video elements do not work as sources for TexImage2D calls in GPU Process
     4        https://bugs.webkit.org/show_bug.cgi?id=218184
     5
     6        Reviewed by Jer Noble.
     7
     8        Add an IPC message `RemoteGraphicsContextGL::CopyTextureFromMedia` to implement
     9        `RemoteGraphicsContextGLProxy::copyTextureFromMedia()` in the Web process.
     10
     11        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
     12        (WebKit::RemoteGraphicsContextGL::copyTextureFromMedia):
     13        * GPUProcess/graphics/RemoteGraphicsContextGL.h:
     14        We should use `m_gpuConnectionToWebProcess` in the main thread only.
     15
     16        * GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
     17
     18        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
     19        (WebKit::RemoteGraphicsContextGLProxy::copyTextureFromMedia):
     20        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
     21
     22        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
     23        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
     24
    1252021-02-20  Youenn Fablet  <youenn@apple.com>
    226
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp

    r273204 r273213  
    3535#include <WebCore/GraphicsContextGLOpenGL.h>
    3636#include <WebCore/NotImplemented.h>
     37#include <wtf/MainThread.h>
    3738#include <wtf/NeverDestroyed.h>
     39
     40#if USE(AVFOUNDATION)
     41#include <WebCore/GraphicsContextGLCV.h>
     42#endif
    3843
    3944namespace WebKit {
     
    5964
    6065RemoteGraphicsContextGL::RemoteGraphicsContextGL(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream)
    61     : m_streamConnection(IPC::StreamServerConnection<RemoteGraphicsContextGL>::create(gpuConnectionToWebProcess.connection(), WTFMove(stream), remoteGraphicsContextGLStreamWorkQueue()))
     66    : m_gpuConnectionToWebProcess(makeWeakPtr(gpuConnectionToWebProcess))
     67    , m_streamConnection(IPC::StreamServerConnection<RemoteGraphicsContextGL>::create(gpuConnectionToWebProcess.connection(), WTFMove(stream), remoteGraphicsContextGLStreamWorkQueue()))
    6268    , m_graphicsContextGLIdentifier(graphicsContextGLIdentifier)
    6369    , m_renderingBackend(makeRef(renderingBackend))
     
    202208}
    203209
     210void RemoteGraphicsContextGL::copyTextureFromMedia(WebCore::MediaPlayerIdentifier mediaPlayerIdentifier, uint32_t texture, uint32_t target, int32_t level, uint32_t internalFormat, uint32_t format, uint32_t type, bool premultiplyAlpha, bool flipY, CompletionHandler<void(bool)>&& completionHandler)
     211{
     212#if USE(AVFOUNDATION)
     213    UNUSED_VARIABLE(premultiplyAlpha);
     214    ASSERT_UNUSED(target, target == GraphicsContextGL::TEXTURE_2D);
     215
     216    RetainPtr<CVPixelBufferRef> pixelBuffer;
     217    auto getPixelBuffer = [&] {
     218        if (!m_gpuConnectionToWebProcess)
     219            return;
     220
     221        if (auto mediaPlayer = m_gpuConnectionToWebProcess->remoteMediaPlayerManagerProxy().mediaPlayer(mediaPlayerIdentifier))
     222            pixelBuffer = mediaPlayer->pixelBufferForCurrentTime();
     223    };
     224
     225    if (isMainThread())
     226        getPixelBuffer();
     227    else
     228        callOnMainThreadAndWait(WTFMove(getPixelBuffer));
     229
     230    if (!pixelBuffer) {
     231        completionHandler(false);
     232        return;
     233    }
     234
     235    auto contextCV = m_context->asCV();
     236    if (!contextCV) {
     237        completionHandler(false);
     238        return;
     239    }
     240
     241    completionHandler(contextCV->copyPixelBufferToTexture(pixelBuffer.get(), texture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY)));
     242#else
     243    UNUSED_VARIABLE(mediaPlayerIdentifier);
     244    UNUSED_VARIABLE(texture);
     245    UNUSED_VARIABLE(target);
     246    UNUSED_VARIABLE(level);
     247    UNUSED_VARIABLE(internalFormat);
     248    UNUSED_VARIABLE(format);
     249    UNUSED_VARIABLE(type);
     250    UNUSED_VARIABLE(premultiplyAlpha);
     251    UNUSED_VARIABLE(flipY);
     252
     253    notImplemented();
     254    completionHandler(false);
     255#endif
     256}
     257
    204258} // namespace WebKit
    205259
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h

    r273204 r273213  
    9292    void paintRenderingResultsToCanvas(WebCore::RenderingResourceIdentifier, CompletionHandler<void()>&&);
    9393    void paintCompositedResultsToCanvas(WebCore::RenderingResourceIdentifier, CompletionHandler<void()>&&);
     94    void copyTextureFromMedia(WebCore::MediaPlayerIdentifier, uint32_t texture, uint32_t target, int32_t level, uint32_t internalFormat, uint32_t format, uint32_t type, bool premultiplyAlpha, bool flipY, CompletionHandler<void(bool)>&&);
    9495
    9596#include "RemoteGraphicsContextGLFunctionsGenerated.h" // NOLINT
     
    9798    void paintImageDataToImageBuffer(RefPtr<WebCore::ImageData>&&, WebCore::RenderingResourceIdentifier, CompletionHandler<void()>&&);
    9899
     100    WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess;
    99101    RefPtr<IPC::StreamServerConnection<RemoteGraphicsContextGL>> m_streamConnection;
    100102    RefPtr<WebCore::GraphicsContextGLOpenGL> m_context;
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in

    r273204 r273213  
    3737    void SynthesizeGLError(uint32_t error)
    3838    void GetError() -> (uint32_t returnValue) Synchronous
    39     void PaintRenderingResultsToCanvas(WebCore::RenderingResourceIdentifier identifier) -> () Synchronous
    40     void PaintCompositedResultsToCanvas(WebCore::RenderingResourceIdentifier identifier) -> () Synchronous
    41 
     39    void PaintRenderingResultsToCanvas(WebCore::RenderingResourceIdentifier imageBuffer) -> () Synchronous
     40    void PaintCompositedResultsToCanvas(WebCore::RenderingResourceIdentifier imageBuffer) -> () Synchronous
     41    void CopyTextureFromMedia(WebCore::MediaPlayerIdentifier identifier, uint32_t texture, uint32_t target, int32_t level, uint32_t internalFormat, uint32_t format, uint32_t type, bool premultiplyAlpha, bool flipY) -> (bool success) Synchronous
    4242
    4343    void SetFailNextGPUStatusCheck()
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp

    r273204 r273213  
    165165}
    166166
     167bool RemoteGraphicsContextGLProxy::copyTextureFromMedia(MediaPlayer& mediaPlayer, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
     168{
     169    bool result = false;
     170    auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::CopyTextureFromMedia(mediaPlayer.identifier(), texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY), Messages::RemoteGraphicsContextGL::CopyTextureFromMedia::Reply(result));
     171    if (!sendResult) {
     172        markContextLost();
     173        return false;
     174    }
     175
     176    return result;
     177}
     178
    167179void RemoteGraphicsContextGLProxy::synthesizeGLError(GCGLenum error)
    168180{
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h

    r273204 r273213  
    7070    void synthesizeGLError(GCGLenum error) final;
    7171    GCGLenum getError() final;
     72
     73    bool copyTextureFromMedia(WebCore::MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
    7274
    7375    // Functions with a generated implementation. This list is used by generate-gpup-webgl script.
  • trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp

    r272908 r273213  
    849849}
    850850
     851#if !USE(AVFOUNDATION)
    851852bool MediaPlayerPrivateRemote::copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool)
    852853{
     
    854855    return false;
    855856}
     857#endif
    856858
    857859RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime()
  • trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h

    r271219 r273213  
    282282    void paint(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
    283283    void paintCurrentFrameInContext(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
     284#if !USE(AVFOUNDATION)
    284285    bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final;
     286#endif
    285287    RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final;
    286288
  • trunk/Tools/ChangeLog

    r273209 r273213  
     12021-02-20  Peng Liu  <peng.liu6@apple.com>
     2
     3        Video elements do not work as sources for TexImage2D calls in GPU Process
     4        https://bugs.webkit.org/show_bug.cgi?id=218184
     5
     6        Reviewed by Jer Noble.
     7
     8        * Scripts/generate-gpup-webgl:
     9
    1102021-02-20  Jiewen Tan  <jiewen_tan@apple.com>
    211
  • trunk/Tools/Scripts/generate-gpup-webgl

    r273204 r273213  
    104104    void PaintRenderingResultsToCanvas(WebCore::RenderingResourceIdentifier imageBuffer) -> () Synchronous
    105105    void PaintCompositedResultsToCanvas(WebCore::RenderingResourceIdentifier imageBuffer) -> () Synchronous
    106 
     106    void CopyTextureFromMedia(WebCore::MediaPlayerIdentifier identifier, uint32_t texture, uint32_t target, int32_t level, uint32_t internalFormat, uint32_t format, uint32_t type, bool premultiplyAlpha, bool flipY) -> (bool success) Synchronous
    107107{}
    108108}}
    109109
    110110#endif
    111 
    112111"""
    113112)
Note: See TracChangeset for help on using the changeset viewer.