Changeset 49019 in webkit


Ignore:
Timestamp:
Oct 2, 2009 4:14:58 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-10-02 Ben Murdoch <benm@google.com>

Reviewed by David Kilzer.

Stale database version persists through browser refresh (changeVersion doesn't work)
https://bugs.webkit.org/show_bug.cgi?id=27836

Scale the cairo surface of the video sink depending on the
pixel-aspect-ratio of the video buffer to paint. Also
destruct/re-create the surface when setSize() is called with a new
size.

  • platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivate::naturalSize): (WebCore::MediaPlayerPrivate::setSize): (WebCore::MediaPlayerPrivate::paint):
  • platform/graphics/gtk/VideoSinkGStreamer.cpp: (webkit_video_sink_idle_func):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49018 r49019  
    55        Stale database version persists through browser refresh (changeVersion doesn't work)
    66        https://bugs.webkit.org/show_bug.cgi?id=27836
     7
     8        Scale the cairo surface of the video sink depending on the
     9        pixel-aspect-ratio of the video buffer to paint. Also
     10        destruct/re-create the surface when setSize() is called with a new
     11        size.
     12
     13        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
     14        (WebCore::MediaPlayerPrivate::naturalSize):
     15        (WebCore::MediaPlayerPrivate::setSize):
     16        (WebCore::MediaPlayerPrivate::paint):
     17        * platform/graphics/gtk/VideoSinkGStreamer.cpp:
     18        (webkit_video_sink_idle_func):
     19
     202009-10-02  Philippe Normand  <pnormand@igalia.com>
     21
     22        Reviewed by Gustavo Noronha.
     23
     24        [GTK] missing support for anamorphic PAR video size
     25        https://bugs.webkit.org/show_bug.cgi?id=29717
    726
    827        Tests: storage/change-version-handle-reuse.html
  • trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp

    r48980 r49019  
    335335        return IntSize();
    336336
    337     int x = 0, y = 0;
     337    // TODO: handle possible clean aperture data. See
     338    // https://bugzilla.gnome.org/show_bug.cgi?id=596571
     339    // TODO: handle possible transformation matrix. See
     340    // https://bugzilla.gnome.org/show_bug.cgi?id=596326
     341    int width = 0, height = 0;
    338342    if (GstPad* pad = gst_element_get_static_pad(m_videoSink, "sink")) {
    339         gst_video_get_size(GST_PAD(pad), &x, &y);
     343        gst_video_get_size(GST_PAD(pad), &width, &height);
     344        GstCaps* caps = GST_PAD_CAPS(pad);
     345        gfloat pixelAspectRatio;
     346        gint pixelAspectRatioNumerator, pixelAspectRatioDenominator;
     347
     348        if (!gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
     349                                                     &pixelAspectRatioDenominator))
     350            pixelAspectRatioNumerator = pixelAspectRatioDenominator = 1;
     351
     352        pixelAspectRatio = (gfloat) pixelAspectRatioNumerator / (gfloat) pixelAspectRatioDenominator;
     353        width *= pixelAspectRatio;
     354        height /= pixelAspectRatio;
    340355        gst_object_unref(GST_OBJECT(pad));
    341356    }
    342357
    343     return IntSize(x, y);
     358    return IntSize(width, height);
    344359}
    345360
     
    625640void MediaPlayerPrivate::setSize(const IntSize& size)
    626641{
     642    // Destroy and re-create the cairo surface only if the size
     643    // changed.
     644    if (size != m_size) {
     645        if (m_surface)
     646            cairo_surface_destroy(m_surface);
     647        m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(),
     648                                               size.height());
     649        g_object_set(m_videoSink, "surface", m_surface, 0);
     650    }
     651
    627652    m_size = size;
     653
    628654}
    629655
     
    646672        return;
    647673
    648     //TODO: m_size vs rect?
    649674    cairo_t* cr = context->platformContext();
    650675
    651676    cairo_save(cr);
    652677    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
     678
     679    // paint the rectangle on the context and draw the surface inside.
    653680    cairo_translate(cr, rect.x(), rect.y());
    654681    cairo_rectangle(cr, 0, 0, rect.width(), rect.height());
  • trunk/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp

    r48979 r49019  
    112112    WebKitVideoSinkPrivate* priv = sink->priv;
    113113    GstBuffer* buffer;
     114    GstCaps* caps;
     115    GstVideoFormat* format;
     116    gint par_n, par_d;
     117    gfloat par;
     118    gint bwidth, bheight;
     119
    114120    if (!priv->async_queue)
    115121        return FALSE;
     
    119125        return FALSE;
    120126
    121     cairo_surface_t* src = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), CAIRO_FORMAT_RGB24, priv->width, priv->height, (4 * priv->width + 3) & ~3);
     127    caps = GST_BUFFER_CAPS(buffer);
     128    if (!gst_video_format_parse_caps(caps, format, &bwidth, &bheight)) {
     129        GST_ERROR_OBJECT(sink, "Unknown video format in buffer caps '%s'",
     130                         gst_caps_to_string(caps));
     131        return FALSE;
     132    }
     133
     134    if (!gst_video_parse_caps_pixel_aspect_ratio(caps, &par_n, &par_d))
     135        par_n = par_d = 1;
     136
     137    par = (gfloat) par_n / (gfloat) par_d;
     138
     139    // TODO: consider priv->rgb_ordering?
     140    cairo_surface_t* src = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer),
     141                                                               CAIRO_FORMAT_RGB24,
     142                                                               bwidth, bheight,
     143                                                               4 * bwidth);
    122144
    123145    // TODO: We copy the data twice right now. This could be easily improved.
    124146    cairo_t* cr = cairo_create(priv->surface);
     147    cairo_scale(cr, par, 1.0 / par);
    125148    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
    126149    cairo_set_source_surface(cr, src, 0, 0);
Note: See TracChangeset for help on using the changeset viewer.