<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GStreamer] Support a direct GPU-to-GPU copy of video textures to WebGL"
   href="https://bugs.webkit.org/show_bug.cgi?id=159928#c15">Comment # 15</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GStreamer] Support a direct GPU-to-GPU copy of video textures to WebGL"
   href="https://bugs.webkit.org/show_bug.cgi?id=159928">bug 159928</a>
              from <span class="vcard"><a class="email" href="mailto:cgarcia&#64;igalia.com" title="Carlos Garcia Campos &lt;cgarcia&#64;igalia.com&gt;"> <span class="fn">Carlos Garcia Campos</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=289463&amp;action=diff" name="attach_289463" title="Patch">attachment 289463</a> <a href="attachment.cgi?id=289463&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=289463&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=289463&amp;action=review</a>

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:700
&gt; +bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(RefPtr&lt;cairo_surface_t&gt; outputSurface, cairo_device_t* device, GstVideoInfo* videoInfo)</span >

I don't think you need to pass the smart pointer to this function, and in that case I would pass a reference instead of a copy, but I think you can simply pass the pointer.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:702
&gt; +    // m_sampleMutex should be locked by the caller</span >

I would move this comment before the function, saying something like: // This should be called with the sample mutex locked.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:710
&gt; -    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
&gt; +    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(videoInfo), GST_VIDEO_INFO_HEIGHT(videoInfo));</span >

Both callers do this, maybe you could pass this as a const reference.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:713
&gt;      IntSize rotatedSize = m_videoSourceOrientation.usesWidthAsHeight() ? size.transposedSize() : size;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:773
&gt; +    GLContext* glContext = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
&gt; +    cairo_device_t* device = glContext-&gt;cairoDevice();
&gt; +
&gt; +    // Thread-awareness is a huge performance hit on non-Intel drivers.
&gt; +    cairo_gl_device_set_thread_aware(device, FALSE);
&gt; +
&gt; +    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
&gt; +    IntSize rotatedSize = m_videoSourceOrientation.usesWidthAsHeight() ? size.transposedSize() : size;
&gt; +</span >

Don't you need to make the context current in this case?

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:813
&gt; +    GstVideoInfo videoInfo;
&gt; +    WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
&gt; +    if (!getSampleVideoInfo(m_sample.get(), videoInfo))
&gt; +        return nullptr;
&gt; +
&gt; +    GLContext* context = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
&gt; +    context-&gt;makeContextCurrent();
&gt; +    cairo_device_t* device = context-&gt;cairoDevice();
&gt; +
&gt; +    // Thread-awareness is a huge performance hit on non-Intel drivers.
&gt; +    cairo_gl_device_set_thread_aware(device, FALSE);
&gt; +
&gt; +    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
&gt; +    IntSize rotatedSize = m_videoSourceOrientation.usesWidthAsHeight() ? size.transposedSize() : size;</span >

All this is mostly duplicated code, could we move it to a helper function? maybe a function that prepares the context and returns the GLContext as return value, and video info, and sizes as output parameters

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:119
&gt; +    bool paintToCairoSurface(RefPtr&lt;cairo_surface_t&gt; outputSurface, cairo_device_t*, GstVideoInfo*);</span >

This should be private.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>