Title: [150890] trunk/Source/WebCore
Revision
150890
Author
[email protected]
Date
2013-05-29 06:24:51 -0700 (Wed, 29 May 2013)

Log Message

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

Patch by Víctor Manuel Jáquez Leal <[email protected]> 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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150889 => 150890)


--- trunk/Source/WebCore/ChangeLog	2013-05-29 13:19:34 UTC (rev 150889)
+++ trunk/Source/WebCore/ChangeLog	2013-05-29 13:24:51 UTC (rev 150890)
@@ -1,3 +1,38 @@
+2013-05-29  Víctor Manuel Jáquez Leal  <[email protected]>
+
+        [texmap][GStreamer][GTK] Composited Video support
+        https://bugs.webkit.org/show_bug.cgi?id=86410
+
+        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
+
 2013-05-29  Peter Gal  <[email protected]>
 
         [Qt] Missing files from build after r150853

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (150889 => 150890)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2013-05-29 13:19:34 UTC (rev 150889)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2013-05-29 13:24:51 UTC (rev 150890)
@@ -111,6 +111,9 @@
     , m_repaintHandler(0)
     , m_volumeSignalHandler(0)
     , m_muteSignalHandler(0)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+    , m_texture(0)
+#endif
 {
 }
 
@@ -297,11 +300,54 @@
     m_muteTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateMuteChangeTimeoutCallback), this);
 }
 
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+void MediaPlayerPrivateGStreamerBase::updateTexture(GstBuffer* buffer)
+{
+    if (!m_texture)
+        return;
+
+    if (!client())
+        return;
+
+    const void* srcData = 0;
+    IntSize size = naturalSize();
+
+    if (m_texture->size() != size)
+        m_texture->reset(size);
+
+#ifdef GST_API_VERSION_1
+    GstMapInfo srcInfo;
+    gst_buffer_map(buffer, &srcInfo, GST_MAP_READ);
+    srcData = srcInfo.data;
+#else
+    srcData = GST_BUFFER_DATA(buffer);
+#endif
+
+    // @TODO: support cropping
+    m_texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), size.width() * 4, BitmapTexture::UpdateCannotModifyOriginalImageData);
+
+#ifdef GST_API_VERSION_1
+    gst_buffer_unmap(buffer, &srcInfo);
+#endif
+
+    client()->setPlatformLayerNeedsDisplay();
+}
+#endif
+
 void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstBuffer* buffer)
 {
     g_return_if_fail(GST_IS_BUFFER(buffer));
-    gst_buffer_replace(&m_buffer, buffer);
-    m_player->repaint();
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+    if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
+        updateTexture(buffer);
+    else
+#endif
+    {
+        gst_buffer_replace(&m_buffer, buffer);
+        m_player->repaint();
+    }
 }
 
 void MediaPlayerPrivateGStreamerBase::setSize(const IntSize& size)
@@ -311,6 +357,11 @@
 
 void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const IntRect& rect)
 {
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+    if (m_texture)
+        return;
+#endif
+
     if (context->paintingDisabled())
         return;
 
@@ -332,6 +383,21 @@
         rect, gstImage->rect(), CompositeCopy, DoNotRespectImageOrientation, false);
 }
 
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+    if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode)
+        return;
+
+    if (!m_texture) {
+        m_texture = textureMapper->acquireTextureFromPool(naturalSize());
+        return;
+    }
+
+    textureMapper->drawTexture(*m_texture.get(), targetRect, matrix, opacity);
+}
+#endif
+
 #if USE(NATIVE_FULLSCREEN_VIDEO)
 void MediaPlayerPrivateGStreamerBase::enterFullscreen()
 {

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (150889 => 150890)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h	2013-05-29 13:19:34 UTC (rev 150889)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h	2013-05-29 13:24:51 UTC (rev 150890)
@@ -29,6 +29,10 @@
 
 #include <wtf/Forward.h>
 
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+#include "TextureMapperPlatformLayer.h"
+#endif
+
 typedef struct _GstBuffer GstBuffer;
 typedef struct _GstElement GstElement;
 typedef struct _GstMessage GstMessage;
@@ -43,7 +47,11 @@
 class IntRect;
 class GStreamerGWorld;
 
-class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface {
+class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+    , public TextureMapperPlatformLayer
+#endif
+{
 
 public:
     ~MediaPlayerPrivateGStreamerBase();
@@ -93,6 +101,12 @@
     unsigned audioDecodedByteCount() const;
     unsigned videoDecodedByteCount() const;
 
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+    virtual PlatformLayer* platformLayer() const { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); }
+    virtual bool supportsAcceleratedRendering() const { return true; }
+    virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
+#endif
+
 protected:
     MediaPlayerPrivateGStreamerBase(MediaPlayer*);
     GstElement* createVideoSink(GstElement* pipeline);
@@ -119,6 +133,10 @@
     unsigned long m_muteSignalHandler;
     GRefPtr<GstPad> m_videoSinkPad;
     mutable IntSize m_videoSize;
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+    void updateTexture(GstBuffer*);
+    RefPtr<BitmapTexture> m_texture;
+#endif
 };
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to