Changeset 150890 in webkit


Ignore:
Timestamp:
May 29, 2013 6:24:51 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[texmap][GStreamer][GTK] Composited Video support
https://bugs.webkit.org/show_bug.cgi?id=86410

Patch by Víctor Manuel Jáquez Leal <vjaquez@igalia.com> on 2013-05-29
Reviewed by Noam Rosenthal.

Enable the video accelerated compositing using the WebKit's
TextureMapper.

This patch does not use hardware accelerated video decoding. It
provides a generic path for system memory buffers.

This new functionality is only available when the coordinated graphics
system is not used.

No new tests, already covered by existing tests.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:

(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore):
(WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): update the
texture content with the new received video buffer.
(WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): choose to
use the accelerated compositing or the normal code path
(WebCore::MediaPlayerPrivateGStreamerBase::paint): if accelerated
compositing is used this method is halted.
(WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper): get
a texture from the pool and draws it if it is already available.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:

(MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::platformLayer): returns itself
(WebCore::MediaPlayerPrivateGStreamerBase::supportsAcceleratedRendering):
returns true

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150882 r150890  
     12013-05-29  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [texmap][GStreamer][GTK] Composited Video support
     4        https://bugs.webkit.org/show_bug.cgi?id=86410
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Enable the video accelerated compositing using the WebKit's
     9        TextureMapper.
     10
     11        This patch does not use hardware accelerated video decoding. It
     12        provides a generic path for system memory buffers.
     13
     14        This new functionality is only available when the coordinated graphics
     15        system is not used.
     16
     17        No new tests, already covered by existing tests.
     18
     19        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     20        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
     21        (WebCore):
     22        (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): update the
     23        texture content with the new received video buffer.
     24        (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): choose to
     25        use the accelerated compositing or the normal code path
     26        (WebCore::MediaPlayerPrivateGStreamerBase::paint): if accelerated
     27        compositing is used this method is halted.
     28        (WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper): get
     29        a texture from the pool and draws it if it is already available.
     30        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     31        (MediaPlayerPrivateGStreamerBase):
     32        (WebCore::MediaPlayerPrivateGStreamerBase::platformLayer): returns itself
     33        (WebCore::MediaPlayerPrivateGStreamerBase::supportsAcceleratedRendering):
     34        returns true
     35
    1362013-05-29  Peter Gal  <galpeter@inf.u-szeged.hu>
    237
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r150035 r150890  
    112112    , m_volumeSignalHandler(0)
    113113    , m_muteSignalHandler(0)
     114#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     115    , m_texture(0)
     116#endif
    114117{
    115118}
     
    298301}
    299302
     303
     304#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     305void MediaPlayerPrivateGStreamerBase::updateTexture(GstBuffer* buffer)
     306{
     307    if (!m_texture)
     308        return;
     309
     310    if (!client())
     311        return;
     312
     313    const void* srcData = 0;
     314    IntSize size = naturalSize();
     315
     316    if (m_texture->size() != size)
     317        m_texture->reset(size);
     318
     319#ifdef GST_API_VERSION_1
     320    GstMapInfo srcInfo;
     321    gst_buffer_map(buffer, &srcInfo, GST_MAP_READ);
     322    srcData = srcInfo.data;
     323#else
     324    srcData = GST_BUFFER_DATA(buffer);
     325#endif
     326
     327    // @TODO: support cropping
     328    m_texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), size.width() * 4, BitmapTexture::UpdateCannotModifyOriginalImageData);
     329
     330#ifdef GST_API_VERSION_1
     331    gst_buffer_unmap(buffer, &srcInfo);
     332#endif
     333
     334    client()->setPlatformLayerNeedsDisplay();
     335}
     336#endif
     337
    300338void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstBuffer* buffer)
    301339{
    302340    g_return_if_fail(GST_IS_BUFFER(buffer));
    303     gst_buffer_replace(&m_buffer, buffer);
    304     m_player->repaint();
     341
     342#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     343    if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
     344        updateTexture(buffer);
     345    else
     346#endif
     347    {
     348        gst_buffer_replace(&m_buffer, buffer);
     349        m_player->repaint();
     350    }
    305351}
    306352
     
    312358void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const IntRect& rect)
    313359{
     360#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     361    if (m_texture)
     362        return;
     363#endif
     364
    314365    if (context->paintingDisabled())
    315366        return;
     
    332383        rect, gstImage->rect(), CompositeCopy, DoNotRespectImageOrientation, false);
    333384}
     385
     386#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     387void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
     388{
     389    if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode)
     390        return;
     391
     392    if (!m_texture) {
     393        m_texture = textureMapper->acquireTextureFromPool(naturalSize());
     394        return;
     395    }
     396
     397    textureMapper->drawTexture(*m_texture.get(), targetRect, matrix, opacity);
     398}
     399#endif
    334400
    335401#if USE(NATIVE_FULLSCREEN_VIDEO)
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r150035 r150890  
    3030#include <wtf/Forward.h>
    3131
     32#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     33#include "TextureMapperPlatformLayer.h"
     34#endif
     35
    3236typedef struct _GstBuffer GstBuffer;
    3337typedef struct _GstElement GstElement;
     
    4448class GStreamerGWorld;
    4549
    46 class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface {
     50class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface
     51#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     52    , public TextureMapperPlatformLayer
     53#endif
     54{
    4755
    4856public:
     
    94102    unsigned videoDecodedByteCount() const;
    95103
     104#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     105    virtual PlatformLayer* platformLayer() const { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); }
     106    virtual bool supportsAcceleratedRendering() const { return true; }
     107    virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
     108#endif
     109
    96110protected:
    97111    MediaPlayerPrivateGStreamerBase(MediaPlayer*);
     
    120134    GRefPtr<GstPad> m_videoSinkPad;
    121135    mutable IntSize m_videoSize;
     136#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
     137    void updateTexture(GstBuffer*);
     138    RefPtr<BitmapTexture> m_texture;
     139#endif
    122140};
    123141}
Note: See TracChangeset for help on using the changeset viewer.