Changeset 49439 in webkit


Ignore:
Timestamp:
Oct 12, 2009 7:34:39 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-10-12 Sebastian Dröge <sebastian.droege@collabora.co.uk>

Reviewed by Gustavo Noronha.

https://bugs.webkit.org/show_bug.cgi?id=29998

Scale video to completely fill the target surface while
keeping the aspect ratio. This fixes displaying of the
YouTube HTML5 sample website.

  • platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: Scale video to completely fill the target surface, keep the aspect ratio and center it.
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49438 r49439  
     12009-10-12  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=29998
     6       
     7        Scale video to completely fill the target surface while
     8        keeping the aspect ratio. This fixes displaying of the
     9        YouTube HTML5 sample website.
     10
     11        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
     12        Scale video to completely fill the target surface, keep
     13        the aspect ratio and center it.
     14
    1152009-10-12  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
    216
  • trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp

    r49438 r49439  
    657657    double doublePixelAspectRatioNumerator = 0;
    658658    double doublePixelAspectRatioDenominator = 0;
     659    double displayWidth;
     660    double displayHeight;
     661    double scale, gapHeight, gapWidth;
     662
    659663    GstCaps *caps = gst_buffer_get_caps(m_buffer);
    660664
     
    665669    }
    666670
     671    displayWidth = width;
     672    displayHeight = height;
    667673    doublePixelAspectRatioNumerator = pixelAspectRatioNumerator;
    668674    doublePixelAspectRatioDenominator = pixelAspectRatioDenominator;
     
    677683    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
    678684
     685    displayWidth *= doublePixelAspectRatioNumerator / doublePixelAspectRatioDenominator;
     686    displayHeight *= doublePixelAspectRatioDenominator / doublePixelAspectRatioNumerator;
     687
     688    scale = MIN (rect.width () / displayWidth, rect.height () / displayHeight);
     689    displayWidth *= scale;
     690    displayHeight *= scale;
     691
     692    // Calculate gap between border an picture
     693    gapWidth = (rect.width() - displayWidth) / 2.0;
     694    gapHeight = (rect.height() - displayHeight) / 2.0;
     695
    679696    // paint the rectangle on the context and draw the surface inside.
    680     cairo_translate(cr, rect.x(), rect.y());
     697    cairo_translate(cr, rect.x() + gapWidth, rect.y() + gapHeight);
    681698    cairo_rectangle(cr, 0, 0, rect.width(), rect.height());
    682699    cairo_scale(cr, doublePixelAspectRatioNumerator / doublePixelAspectRatioDenominator,
    683700                doublePixelAspectRatioDenominator / doublePixelAspectRatioNumerator);
     701    cairo_scale(cr, scale, scale);
    684702    cairo_set_source_surface(cr, src, 0, 0);
    685703    cairo_fill(cr);
Note: See TracChangeset for help on using the changeset viewer.