Changeset 150014 in webkit


Ignore:
Timestamp:
May 13, 2013 8:14:46 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[texmap][GStreamer] 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-13
Reviewed by Philippe Normand.

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.

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

    r150013 r150014  
     12013-05-13  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [texmap][GStreamer] Composited Video support
     4        https://bugs.webkit.org/show_bug.cgi?id=86410
     5
     6        Reviewed by Philippe Normand.
     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        No new tests, already covered by existing tests.
     15
     16        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     17        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
     18        (WebCore):
     19        (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): update the
     20        texture content with the new received video buffer.
     21        (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): choose to
     22        use the accelerated compositing or the normal code path
     23        (WebCore::MediaPlayerPrivateGStreamerBase::paint): if accelerated
     24        compositing is used this method is halted.
     25        (WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper): get
     26        a texture from the pool and draws it if it is already available.
     27        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     28        (MediaPlayerPrivateGStreamerBase):
     29        (WebCore::MediaPlayerPrivateGStreamerBase::platformLayer): returns itself
     30        (WebCore::MediaPlayerPrivateGStreamerBase::supportsAcceleratedRendering):
     31        returns true
     32
    1332013-05-13  Andreas Kling  <akling@apple.com>
    234
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r149543 r150014  
    112112    , m_volumeSignalHandler(0)
    113113    , m_muteSignalHandler(0)
     114#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
     115    , m_texture(0)
     116#endif
    114117{
    115118}
     
    298301}
    299302
     303
     304#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
     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)
     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)
     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)
     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

    r142406 r150014  
    3030#include <wtf/Forward.h>
    3131
     32#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
     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)
     52    , public TextureMapperPlatformLayer
     53#endif
     54{
    4755
    4856public:
     
    94102    unsigned videoDecodedByteCount() const;
    95103
     104#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
     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)
     137    void updateTexture(GstBuffer*);
     138    RefPtr<BitmapTexture> m_texture;
     139#endif
    122140};
    123141}
Note: See TracChangeset for help on using the changeset viewer.