Changeset 152711 in webkit


Ignore:
Timestamp:
Jul 16, 2013 3:16:46 AM (11 years ago)
Author:
commit-queue@webkit.org
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 <vjaquez@igalia.com> 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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152710 r152711  
     12013-07-16  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [texmap][GStreamer] upload onto the texture only the buffer to be painted
     4        https://bugs.webkit.org/show_bug.cgi?id=118471
     5
     6        Reviewed by Philippe Normand.
     7
     8        Right now all the buffers are uploaded onto the texture. With this
     9        logic pose situations where buffers that will not be painted are
     10        uploaded.
     11
     12        This patch uploads only the buffers that are going to be shown.
     13
     14        With this approach, the buffers may arrive before a GraphicsLayer is
     15        set, so we should be more cautious with GraphicsLayerTextureMapper's
     16        client.
     17
     18        No new tests, covered by existing tests.
     19
     20        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     21        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
     22        (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture):
     23        (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
     24        (WebCore::MediaPlayerPrivateGStreamerBase::paint):
     25        (WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper):
     26        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     27        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
     28        (WebCore::GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper):
     29        (WebCore::GraphicsLayerTextureMapper::setContentsToMedia):
     30
    1312013-07-16  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
    232
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r151733 r152711  
    116116    , m_volumeSignalHandler(0)
    117117    , m_muteSignalHandler(0)
    118 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    119     , m_texture(0)
    120 #endif
    121118{
    122119#if GLIB_CHECK_VERSION(2, 31, 0)
     
    326323
    327324#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    328 void MediaPlayerPrivateGStreamerBase::updateTexture(GstBuffer* buffer)
    329 {
    330     if (!m_texture)
    331         return;
    332 
    333     if (!client())
    334         return;
     325PassRefPtr<BitmapTexture> MediaPlayerPrivateGStreamerBase::updateTexture(TextureMapper* textureMapper)
     326{
     327    g_mutex_lock(m_bufferMutex);
     328    if (!m_buffer) {
     329        g_mutex_unlock(m_bufferMutex);
     330        return 0;
     331    }
    335332
    336333    const void* srcData = 0;
     
    338335    GRefPtr<GstCaps> caps = currentVideoSinkCaps();
    339336#else
    340     GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(buffer);
    341 #endif
    342     if (!caps)
    343         return;
     337    GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(m_buffer);
     338#endif
     339    if (!caps) {
     340        g_mutex_unlock(m_bufferMutex);
     341        return 0;
     342    }
    344343
    345344    IntSize size;
    346345    GstVideoFormat format;
    347346    int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
    348     if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
    349         return;
    350 
    351     if (m_texture->size() != size)
    352         m_texture->reset(size);
     347    if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
     348        g_mutex_unlock(m_bufferMutex);
     349        return 0;
     350    }
     351
     352    RefPtr<BitmapTexture> texture = textureMapper->acquireTextureFromPool(size);
    353353
    354354#if GST_CHECK_VERSION(1, 1, 0)
    355355    GstVideoGLTextureUploadMeta* meta;
    356     if ((meta = gst_buffer_get_video_gl_texture_upload_meta(buffer))) {
     356    if ((meta = gst_buffer_get_video_gl_texture_upload_meta(m_buffer))) {
    357357        if (meta->n_textures == 1) { // BRGx & BGRA formats use only one texture.
    358             const BitmapTextureGL* textureGL = static_cast<const BitmapTextureGL*>(m_texture.get());
     358            const BitmapTextureGL* textureGL = static_cast<const BitmapTextureGL*>(texture.get());
    359359            guint ids[4] = { textureGL->id(), 0, 0, 0 };
    360360
    361361            if (gst_video_gl_texture_upload_meta_upload(meta, ids)) {
    362                 client()->setPlatformLayerNeedsDisplay();
    363                 return;
     362                g_mutex_unlock(m_bufferMutex);
     363                return texture;
    364364            }
    365365        }
     
    369369#ifdef GST_API_VERSION_1
    370370    GstMapInfo srcInfo;
    371     gst_buffer_map(buffer, &srcInfo, GST_MAP_READ);
     371    gst_buffer_map(m_buffer, &srcInfo, GST_MAP_READ);
    372372    srcData = srcInfo.data;
    373373#else
    374     srcData = GST_BUFFER_DATA(buffer);
    375 #endif
    376 
    377     m_texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), stride, BitmapTexture::UpdateCannotModifyOriginalImageData);
     374    srcData = GST_BUFFER_DATA(m_buffer);
     375#endif
     376
     377    texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), stride, BitmapTexture::UpdateCannotModifyOriginalImageData);
    378378
    379379#ifdef GST_API_VERSION_1
    380     gst_buffer_unmap(buffer, &srcInfo);
    381 #endif
    382 
    383     client()->setPlatformLayerNeedsDisplay();
     380    gst_buffer_unmap(m_buffer, &srcInfo);
     381#endif
     382
     383    g_mutex_unlock(m_bufferMutex);
     384    return texture;
    384385}
    385386#endif
     
    389390    g_return_if_fail(GST_IS_BUFFER(buffer));
    390391
     392    g_mutex_lock(m_bufferMutex);
     393    gst_buffer_replace(&m_buffer, buffer);
     394    g_mutex_unlock(m_bufferMutex);
     395
    391396#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    392     if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
    393         updateTexture(buffer);
    394     else
    395 #endif
    396     {
    397         g_mutex_lock(m_bufferMutex);
    398         gst_buffer_replace(&m_buffer, buffer);
    399         g_mutex_unlock(m_bufferMutex);
    400         m_player->repaint();
    401     }
     397    if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player) && client()) {
     398        client()->setPlatformLayerNeedsDisplay();
     399        return;
     400    }
     401#endif
     402
     403    m_player->repaint();
    402404}
    403405
     
    410412{
    411413#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    412     if (m_texture)
     414    if (client())
    413415        return;
    414416#endif
     
    456458        return;
    457459
    458     if (!m_texture) {
    459         m_texture = textureMapper->acquireTextureFromPool(naturalSize());
    460         return;
    461     }
    462 
    463     textureMapper->drawTexture(*m_texture.get(), targetRect, matrix, opacity);
     460    RefPtr<BitmapTexture> texture = updateTexture(textureMapper);
     461    if (texture)
     462        textureMapper->drawTexture(*texture.get(), targetRect, matrix, opacity);
    464463}
    465464#endif
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r151728 r152711  
    138138    mutable IntSize m_videoSize;
    139139#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    140     void updateTexture(GstBuffer*);
    141     RefPtr<BitmapTexture> m_texture;
     140    PassRefPtr<BitmapTexture> updateTexture(TextureMapper*);
    142141#endif
    143142};
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r149813 r152711  
    7878GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper()
    7979{
     80    if (m_contentsLayer)
     81        m_contentsLayer->setClient(0);
     82
    8083    willBeDestroyed();
    8184}
     
    385388    GraphicsLayer::setContentsToMedia(media);
    386389    notifyChange(ContentChange);
     390
     391    if (m_contentsLayer)
     392        m_contentsLayer->setClient(0);
     393
    387394    m_contentsLayer = media;
    388395
    389     m_contentsLayer->setClient(this);
     396    if (m_contentsLayer)
     397        m_contentsLayer->setClient(this);
    390398}
    391399
Note: See TracChangeset for help on using the changeset viewer.