<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194528] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194528">194528</a></dd>
<dt>Author</dt> <dd>philn@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-04 03:15:07 -0800 (Mon, 04 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GStreamer] A video element isn't drawn onto the canvas.
https://bugs.webkit.org/show_bug.cgi?id=132671

Reviewed by Michael Catanzaro.

When both cairo-gl and gst-gl are available the texture coming
from glimagesink can be used to create a cairo-gl surface that can
be used for video rendering within a canvas element.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawImage): Use NativeImage
drawing if both cairo-gl and gst-gl are available.
* platform/graphics/GraphicsContext.h: Implement drawNativeImage
for Cairo GraphicsContext.
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawNativeImage): Ditto.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
Implement nativeImageForCurrentTime(), this method is used by the
canvas rendering context.
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiescpp">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiesh">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/ChangeLog        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-01-04  Philippe Normand  &lt;pnormand@igalia.com&gt;
+
+        [GStreamer] A video element isn't drawn onto the canvas.
+        https://bugs.webkit.org/show_bug.cgi?id=132671
+
+        Reviewed by Michael Catanzaro.
+
+        When both cairo-gl and gst-gl are available the texture coming
+        from glimagesink can be used to create a cairo-gl surface that can
+        be used for video rendering within a canvas element.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawImage): Use NativeImage
+        drawing if both cairo-gl and gst-gl are available.
+        * platform/graphics/GraphicsContext.h: Implement drawNativeImage
+        for Cairo GraphicsContext.
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawNativeImage): Ditto.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        Implement nativeImageForCurrentTime(), this method is used by the
+        canvas rendering context.
+        (WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+
</ins><span class="cx"> 2016-01-03  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Fix -Wpessimizing-move warnings after switch to WTFMove
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -1597,7 +1597,7 @@
</span><span class="cx"> 
</span><span class="cx">     checkOrigin(video);
</span><span class="cx"> 
</span><del>-#if USE(CG)
</del><ins>+#if USE(CG) || (ENABLE(ACCELERATED_2D_CANVAS) &amp;&amp; USE(GSTREAMER_GL) &amp;&amp; USE(CAIRO))
</ins><span class="cx">     if (PassNativeImagePtr image = video-&gt;nativeImageForCurrentTime()) {
</span><span class="cx">         c-&gt;drawNativeImage(image, FloatSize(video-&gt;videoWidth(), video-&gt;videoHeight()), dstRect, srcRect);
</span><span class="cx">         if (rectContainsCanvas(dstRect))
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -249,13 +249,15 @@
</span><span class="cx"> 
</span><span class="cx">     const GraphicsContextState&amp; state() const { return m_state; }
</span><span class="cx"> 
</span><ins>+#if USE(CG) || USE(CAIRO)
+    WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize&amp; selfSize, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
+#endif
+
</ins><span class="cx"> #if USE(CG)
</span><span class="cx">     void applyStrokePattern();
</span><span class="cx">     void applyFillPattern();
</span><span class="cx">     void drawPath(const Path&amp;);
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize&amp; selfSize, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
-
</del><span class="cx">     void clipToNativeImage(PassNativeImagePtr, const FloatRect&amp; destRect, const FloatSize&amp; bufferSize);
</span><span class="cx">     
</span><span class="cx">     WEBCORE_EXPORT void setIsCALayerContext(bool);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -252,6 +252,38 @@
</span><span class="cx">     cairo_restore(cr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize&amp; imageSize, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
+{
+    UNUSED_PARAM(imageSize);
+
+    NativeImagePtr image = imagePtr;
+
+    platformContext()-&gt;save();
+
+    // Set the compositing operation.
+    if (op == CompositeSourceOver &amp;&amp; blendMode == BlendModeNormal)
+        setCompositeOperation(CompositeCopy);
+    else
+        setCompositeOperation(op, blendMode);
+
+    FloatRect dst = destRect;
+
+    if (orientation != DefaultImageOrientation) {
+        // ImageOrientation expects the origin to be at (0, 0).
+        translate(dst.x(), dst.y());
+        dst.setLocation(FloatPoint());
+        concatCTM(orientation.transformFromDefault(dst.size()));
+        if (orientation.usesWidthAsHeight()) {
+            // The destination rectangle will have its width and height already reversed for the orientation of
+            // the image, as it was needed for page layout, so we need to reverse it back here.
+            dst = FloatRect(dst.x(), dst.y(), dst.height(), dst.width());
+        }
+    }
+
+    platformContext()-&gt;drawSurfaceToContext(image.get(), dst, srcRect, *this);
+    platformContext()-&gt;restore();
+}
+
</ins><span class="cx"> // This is only used to draw borders, so we should not draw shadows.
</span><span class="cx"> void GraphicsContext::drawLine(const FloatPoint&amp; point1, const FloatPoint&amp; point2)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;gst/audio/audio-info.h&gt;
</span><span class="cx"> #include &lt;gst/gst.h&gt;
</span><del>-#include &lt;gst/video/video-info.h&gt;
</del><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/glib/GUniquePtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -73,6 +72,22 @@
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><ins>+
+bool getSampleVideoInfo(GstSample* sample, GstVideoInfo&amp; videoInfo)
+{
+    if (!GST_IS_SAMPLE(sample))
+        return false;
+
+    GstCaps* caps = gst_sample_get_caps(sample);
+    if (!caps)
+        return false;
+
+    gst_video_info_init(&amp;videoInfo);
+    if (!gst_video_info_from_caps(&amp;videoInfo, caps))
+        return false;
+
+    return true;
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> GstBuffer* createGstBuffer(GstBuffer* buffer)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;gst/gst.h&gt;
</span><span class="cx"> #include &lt;gst/video/video-format.h&gt;
</span><ins>+#include &lt;gst/video/video-info.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #define LOG_MEDIA_MESSAGE(...) do { \
</span><span class="cx">     GST_DEBUG(__VA_ARGS__); \
</span><span class="lines">@@ -65,6 +66,7 @@
</span><span class="cx"> GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, const gchar* name, GstPad* target);
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx"> bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&amp;, GstVideoFormat&amp;, int&amp; pixelAspectRatioNumerator, int&amp; pixelAspectRatioDenominator, int&amp; stride);
</span><ins>+bool getSampleVideoInfo(GstSample*, GstVideoInfo&amp;);
</ins><span class="cx"> #endif
</span><span class="cx"> GstBuffer* createGstBuffer(GstBuffer*);
</span><span class="cx"> GstBuffer* createGstBufferForData(const char* data, int length);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -87,6 +87,10 @@
</span><span class="cx"> #endif
</span><span class="cx"> #endif // USE(GSTREAMER_GL)
</span><span class="cx"> 
</span><ins>+#if USE(CAIRO) &amp;&amp; ENABLE(ACCELERATED_2D_CANVAS)
+#include &lt;cairo-gl.h&gt;
+#endif
+
</ins><span class="cx"> GST_DEBUG_CATEGORY(webkit_media_player_debug);
</span><span class="cx"> #define GST_CAT_DEFAULT webkit_media_player_debug
</span><span class="cx"> 
</span><span class="lines">@@ -111,9 +115,7 @@
</span><span class="cx">     explicit GstVideoFrameHolder(GstSample* sample)
</span><span class="cx">     {
</span><span class="cx">         GstVideoInfo videoInfo;
</span><del>-        gst_video_info_init(&amp;videoInfo);
-        GstCaps* caps = gst_sample_get_caps(sample);
-        if (UNLIKELY(!gst_video_info_from_caps(&amp;videoInfo, caps)))
</del><ins>+        if (UNLIKELY(!getSampleVideoInfo(sample, videoInfo)))
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         m_size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
</span><span class="lines">@@ -497,13 +499,8 @@
</span><span class="cx">     layerBuffer-&gt;setUnmanagedBufferDataHolder(WTFMove(frameHolder));
</span><span class="cx">     m_platformLayerProxy-&gt;pushNextBuffer(WTFMove(layerBuffer));
</span><span class="cx"> #else
</span><del>-    GstCaps* caps = gst_sample_get_caps(m_sample.get());
-    if (UNLIKELY(!caps))
-        return;
-
</del><span class="cx">     GstVideoInfo videoInfo;
</span><del>-    gst_video_info_init(&amp;videoInfo);
-    if (UNLIKELY(!gst_video_info_from_caps(&amp;videoInfo, caps)))
</del><ins>+    if (UNLIKELY(!getSampleVideoInfo(m_sample.get(), videoInfo)))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
</span><span class="lines">@@ -636,16 +633,8 @@
</span><span class="cx">         {
</span><span class="cx">             WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
</span><span class="cx"> 
</span><del>-            if (!m_sample)
-                return;
-
-            GstCaps* caps = gst_sample_get_caps(m_sample.get());
-            if (UNLIKELY(!caps))
-                return;
-
</del><span class="cx">             GstVideoInfo videoInfo;
</span><del>-            gst_video_info_init(&amp;videoInfo);
-            if (UNLIKELY(!gst_video_info_from_caps(&amp;videoInfo, caps)))
</del><ins>+            if (UNLIKELY(!getSampleVideoInfo(m_sample.get(), videoInfo)))
</ins><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">             IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
</span><span class="lines">@@ -657,16 +646,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if USE(GSTREAMER_GL)
</span><del>-    if (!GST_IS_SAMPLE(m_sample.get()))
-        return;
-
-    GstCaps* caps = gst_sample_get_caps(m_sample.get());
-    if (!caps)
-        return;
-
</del><span class="cx">     GstVideoInfo videoInfo;
</span><del>-    gst_video_info_init(&amp;videoInfo);
-    if (!gst_video_info_from_caps(&amp;videoInfo, caps))
</del><ins>+    if (!getSampleVideoInfo(m_sample.get(), videoInfo))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
</span><span class="lines">@@ -685,6 +666,43 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+PassNativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime()
+{
+#if !USE(CAIRO) || !ENABLE(ACCELERATED_2D_CANVAS)
+    return nullptr;
+#endif
+
+    if (m_usingFallbackVideoSink)
+        return nullptr;
+
+    WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
+
+    GstVideoInfo videoInfo;
+    if (!getSampleVideoInfo(m_sample.get(), videoInfo))
+        return nullptr;
+
+    GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
+    GstVideoFrame videoFrame;
+    if (!gst_video_frame_map(&amp;videoFrame, &amp;videoInfo, buffer, static_cast&lt;GstMapFlags&gt;(GST_MAP_READ | GST_MAP_GL)))
+        return nullptr;
+
+    GLContext* context = GLContext::sharingContext();
+    context-&gt;makeContextCurrent();
+    cairo_device_t* device = context-&gt;cairoDevice();
+
+    // Thread-awareness is a huge performance hit on non-Intel drivers.
+    cairo_gl_device_set_thread_aware(device, FALSE);
+
+    unsigned textureID = *reinterpret_cast&lt;unsigned*&gt;(videoFrame.data[0]);
+    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
+    cairo_surface_t* surface = cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, textureID, size.width(), size.height());
+    gst_video_frame_unmap(&amp;videoFrame);
+
+    return adoptRef(surface);
+}
+#endif
+
</ins><span class="cx"> bool MediaPlayerPrivateGStreamerBase::supportsFullscreen() const
</span><span class="cx"> {
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (194527 => 194528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h        2016-01-04 05:20:20 UTC (rev 194527)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h        2016-01-04 11:15:07 UTC (rev 194528)
</span><span class="lines">@@ -118,6 +118,10 @@
</span><span class="cx">     virtual bool supportsAcceleratedRendering() const override { return true; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+    virtual PassNativeImagePtr nativeImageForCurrentTime();
+#endif
+
</ins><span class="cx"> protected:
</span><span class="cx">     MediaPlayerPrivateGStreamerBase(MediaPlayer*);
</span><span class="cx">     virtual GstElement* createVideoSink();
</span></span></pre>
</div>
</div>

</body>
</html>