Title: [152711] trunk/Source/WebCore
Revision
152711
Author
[email protected]
Date
2013-07-16 03:16:46 -0700 (Tue, 16 Jul 2013)

Log Message

[texmap][GStreamer] upload onto the texture only the buffer to be painted
https://bugs.webkit.org/show_bug.cgi?id=118471

Patch by Víctor Manuel Jáquez Leal <[email protected]> on 2013-07-16
Reviewed by Philippe Normand.

Right now all the buffers are uploaded onto the texture. With this
logic pose situations where buffers that will not be painted are
uploaded.

This patch uploads only the buffers that are going to be shown.

With this approach, the buffers may arrive before a GraphicsLayer is
set, so we should be more cautious with GraphicsLayerTextureMapper's
client.

No new tests, covered by existing tests.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::updateTexture):
(WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
(WebCore::MediaPlayerPrivateGStreamerBase::paint):
(WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper):
(WebCore::GraphicsLayerTextureMapper::setContentsToMedia):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152710 => 152711)


--- trunk/Source/WebCore/ChangeLog	2013-07-16 09:50:24 UTC (rev 152710)
+++ trunk/Source/WebCore/ChangeLog	2013-07-16 10:16:46 UTC (rev 152711)
@@ -1,5 +1,35 @@
 2013-07-16  Víctor Manuel Jáquez Leal  <[email protected]>
 
+        [texmap][GStreamer] upload onto the texture only the buffer to be painted
+        https://bugs.webkit.org/show_bug.cgi?id=118471
+
+        Reviewed by Philippe Normand.
+
+        Right now all the buffers are uploaded onto the texture. With this
+        logic pose situations where buffers that will not be painted are
+        uploaded.
+
+        This patch uploads only the buffers that are going to be shown.
+
+        With this approach, the buffers may arrive before a GraphicsLayer is
+        set, so we should be more cautious with GraphicsLayerTextureMapper's
+        client.
+
+        No new tests, covered by existing tests.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture):
+        (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
+        (WebCore::MediaPlayerPrivateGStreamerBase::paint):
+        (WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper):
+        (WebCore::GraphicsLayerTextureMapper::setContentsToMedia):
+
+2013-07-16  Víctor Manuel Jáquez Leal  <[email protected]>
+
         [GStreamer] verify and log the received caps in the video sink
         https://bugs.webkit.org/show_bug.cgi?id=118559
 

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2013-07-16 09:50:24 UTC (rev 152710)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2013-07-16 10:16:46 UTC (rev 152711)
@@ -115,9 +115,6 @@
     , m_repaintHandler(0)
     , m_volumeSignalHandler(0)
     , m_muteSignalHandler(0)
-#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
-    , m_texture(0)
-#endif
 {
 #if GLIB_CHECK_VERSION(2, 31, 0)
     m_bufferMutex = WTF::fastNew<GMutex>();
@@ -325,42 +322,45 @@
 
 
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
-void MediaPlayerPrivateGStreamerBase::updateTexture(GstBuffer* buffer)
+PassRefPtr<BitmapTexture> MediaPlayerPrivateGStreamerBase::updateTexture(TextureMapper* textureMapper)
 {
-    if (!m_texture)
-        return;
+    g_mutex_lock(m_bufferMutex);
+    if (!m_buffer) {
+        g_mutex_unlock(m_bufferMutex);
+        return 0;
+    }
 
-    if (!client())
-        return;
-
     const void* srcData = 0;
 #ifdef GST_API_VERSION_1
     GRefPtr<GstCaps> caps = currentVideoSinkCaps();
 #else
-    GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(buffer);
+    GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(m_buffer);
 #endif
-    if (!caps)
-        return;
+    if (!caps) {
+        g_mutex_unlock(m_bufferMutex);
+        return 0;
+    }
 
     IntSize size;
     GstVideoFormat format;
     int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
-    if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
-        return;
+    if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
+        g_mutex_unlock(m_bufferMutex);
+        return 0;
+    }
 
-    if (m_texture->size() != size)
-        m_texture->reset(size);
+    RefPtr<BitmapTexture> texture = textureMapper->acquireTextureFromPool(size);
 
 #if GST_CHECK_VERSION(1, 1, 0)
     GstVideoGLTextureUploadMeta* meta;
-    if ((meta = gst_buffer_get_video_gl_texture_upload_meta(buffer))) {
+    if ((meta = gst_buffer_get_video_gl_texture_upload_meta(m_buffer))) {
         if (meta->n_textures == 1) { // BRGx & BGRA formats use only one texture.
-            const BitmapTextureGL* textureGL = static_cast<const BitmapTextureGL*>(m_texture.get());
+            const BitmapTextureGL* textureGL = static_cast<const BitmapTextureGL*>(texture.get());
             guint ids[4] = { textureGL->id(), 0, 0, 0 };
 
             if (gst_video_gl_texture_upload_meta_upload(meta, ids)) {
-                client()->setPlatformLayerNeedsDisplay();
-                return;
+                g_mutex_unlock(m_bufferMutex);
+                return texture;
             }
         }
     }
@@ -368,19 +368,20 @@
 
 #ifdef GST_API_VERSION_1
     GstMapInfo srcInfo;
-    gst_buffer_map(buffer, &srcInfo, GST_MAP_READ);
+    gst_buffer_map(m_buffer, &srcInfo, GST_MAP_READ);
     srcData = srcInfo.data;
 #else
-    srcData = GST_BUFFER_DATA(buffer);
+    srcData = GST_BUFFER_DATA(m_buffer);
 #endif
 
-    m_texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), stride, BitmapTexture::UpdateCannotModifyOriginalImageData);
+    texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), stride, BitmapTexture::UpdateCannotModifyOriginalImageData);
 
 #ifdef GST_API_VERSION_1
-    gst_buffer_unmap(buffer, &srcInfo);
+    gst_buffer_unmap(m_buffer, &srcInfo);
 #endif
 
-    client()->setPlatformLayerNeedsDisplay();
+    g_mutex_unlock(m_bufferMutex);
+    return texture;
 }
 #endif
 
@@ -388,17 +389,18 @@
 {
     g_return_if_fail(GST_IS_BUFFER(buffer));
 
+    g_mutex_lock(m_bufferMutex);
+    gst_buffer_replace(&m_buffer, buffer);
+    g_mutex_unlock(m_bufferMutex);
+
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
-    if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
-        updateTexture(buffer);
-    else
-#endif
-    {
-        g_mutex_lock(m_bufferMutex);
-        gst_buffer_replace(&m_buffer, buffer);
-        g_mutex_unlock(m_bufferMutex);
-        m_player->repaint();
+    if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player) && client()) {
+        client()->setPlatformLayerNeedsDisplay();
+        return;
     }
+#endif
+
+    m_player->repaint();
 }
 
 void MediaPlayerPrivateGStreamerBase::setSize(const IntSize& size)
@@ -409,7 +411,7 @@
 void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const IntRect& rect)
 {
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
-    if (m_texture)
+    if (client())
         return;
 #endif
 
@@ -455,12 +457,9 @@
     if (!m_player->visible())
         return;
 
-    if (!m_texture) {
-        m_texture = textureMapper->acquireTextureFromPool(naturalSize());
-        return;
-    }
-
-    textureMapper->drawTexture(*m_texture.get(), targetRect, matrix, opacity);
+    RefPtr<BitmapTexture> texture = updateTexture(textureMapper);
+    if (texture)
+        textureMapper->drawTexture(*texture.get(), targetRect, matrix, opacity);
 }
 #endif
 

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h	2013-07-16 09:50:24 UTC (rev 152710)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h	2013-07-16 10:16:46 UTC (rev 152711)
@@ -137,8 +137,7 @@
     unsigned long m_muteSignalHandler;
     mutable IntSize m_videoSize;
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
-    void updateTexture(GstBuffer*);
-    RefPtr<BitmapTexture> m_texture;
+    PassRefPtr<BitmapTexture> updateTexture(TextureMapper*);
 #endif
 };
 }

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (152710 => 152711)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2013-07-16 09:50:24 UTC (rev 152710)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2013-07-16 10:16:46 UTC (rev 152711)
@@ -77,6 +77,9 @@
 
 GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper()
 {
+    if (m_contentsLayer)
+        m_contentsLayer->setClient(0);
+
     willBeDestroyed();
 }
 
@@ -384,9 +387,14 @@
 
     GraphicsLayer::setContentsToMedia(media);
     notifyChange(ContentChange);
+
+    if (m_contentsLayer)
+        m_contentsLayer->setClient(0);
+
     m_contentsLayer = media;
 
-    m_contentsLayer->setClient(this);
+    if (m_contentsLayer)
+        m_contentsLayer->setClient(this);
 }
 
 void GraphicsLayerTextureMapper::setShowDebugBorder(bool show)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to