Changeset 50798 in webkit


Ignore:
Timestamp:
Nov 11, 2009 3:24:56 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-11 Benjamin Otte <otte@gnome.org>

Reviewed by Jan Alonzo.

[GTK] Black artifacts in youtube.com/html5

Paint the video to the given size. It's the job of the callers to keep
track of aspect ratio. RenderVideo.cpp does it for the <video>
element.
https://bugs.webkit.org/show_bug.cgi?id=30925

  • platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivate::paint):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50797 r50798  
     12009-11-11  Benjamin Otte  <otte@gnome.org>
     2
     3        Reviewed by Jan Alonzo.
     4
     5        [GTK] Black artifacts in youtube.com/html5
     6
     7        Paint the video to the given size. It's the job of the callers to keep
     8        track of aspect ratio. RenderVideo.cpp does it for the <video>
     9        element.
     10        https://bugs.webkit.org/show_bug.cgi?id=30925
     11
     12        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
     13        (WebCore::MediaPlayerPrivate::paint):
     14
    1152009-11-11  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
    216
  • trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp

    r50736 r50798  
    687687
    688688    int width = 0, height = 0;
    689     int pixelAspectRatioNumerator = 0;
    690     int pixelAspectRatioDenominator = 0;
    691     double doublePixelAspectRatioNumerator = 0;
    692     double doublePixelAspectRatioDenominator = 0;
    693     double displayWidth;
    694     double displayHeight;
    695     double scale, gapHeight, gapWidth;
     689    GstCaps *caps = gst_buffer_get_caps(m_buffer);
    696690    GstVideoFormat format;
    697691
    698     GstCaps* caps = gst_buffer_get_caps(m_buffer);
    699 
    700     if (G_UNLIKELY(!gst_video_format_parse_caps(caps, &format, &width, &height)
    701                    || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator, &pixelAspectRatioDenominator))) {
     692    if (!gst_video_format_parse_caps(caps, &format, &width, &height)) {
    702693      gst_caps_unref(caps);
    703694      return;
    704695    }
    705 
    706     displayWidth = width;
    707     displayHeight = height;
    708     doublePixelAspectRatioNumerator = pixelAspectRatioNumerator;
    709     doublePixelAspectRatioDenominator = pixelAspectRatioDenominator;
    710696
    711697    cairo_format_t cairoFormat;
     
    722708
    723709    cairo_save(cr);
    724     cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
    725 
    726     // Calculate the display width/height from the storage width/height and the pixel aspect ratio
    727     displayWidth *= doublePixelAspectRatioNumerator / doublePixelAspectRatioDenominator;
    728     displayHeight *= doublePixelAspectRatioDenominator / doublePixelAspectRatioNumerator;
    729 
    730     // Calculate the largest scale factor that would fill the target surface
    731     scale = std::min(rect.width() / displayWidth, rect.height() / displayHeight);
    732     // And calculate the new display width/height
    733     displayWidth *= scale;
    734     displayHeight *= scale;
    735 
    736     // Calculate gap between border an picture on every side
    737     gapWidth = (rect.width() - displayWidth) / 2.0;
    738     gapHeight = (rect.height() - displayHeight) / 2.0;
    739 
    740     // Paint the rectangle on the context and draw the buffer inside the rectangle
    741 
    742     // Go to the new origin and center the video frame.
    743     cairo_translate(cr, rect.x() + gapWidth, rect.y() + gapHeight);
    744     cairo_rectangle(cr, 0, 0, rect.width(), rect.height());
    745     // Scale the video frame according to the pixel aspect ratio.
    746     cairo_scale(cr, doublePixelAspectRatioNumerator / doublePixelAspectRatioDenominator,
    747                 doublePixelAspectRatioDenominator / doublePixelAspectRatioNumerator);
    748     // Scale the video frame to fill the target surface as good as possible.
    749     cairo_scale(cr, scale, scale);
     710
     711    // translate and scale the context to correct size
     712    cairo_translate(cr, rect.x(), rect.y());
     713    cairo_scale(cr, static_cast<double>(rect.width()) / width, static_cast<double>(rect.height()) / height);
     714
    750715    // And paint it.
    751716    cairo_set_source_surface(cr, src, 0, 0);
     717    cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_PAD);
     718    cairo_rectangle(cr, 0, 0, width, height);
    752719    cairo_fill(cr);
    753720    cairo_restore(cr);
Note: See TracChangeset for help on using the changeset viewer.