<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#c17">Comment # 17</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:olivier.blin&#64;softathome.com" title="Olivier Blin &lt;olivier.blin&#64;softathome.com&gt;"> <span class="fn">Olivier Blin</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=159928#c15">comment #15</a>)
<span class="quote">&gt; 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>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <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>
&gt; 
&gt; &gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:700
&gt; &gt; +bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(RefPtr&lt;cairo_surface_t&gt; outputSurface, cairo_device_t* device, GstVideoInfo* videoInfo)
&gt; 
&gt; I don't think you need to pass the smart pointer to this function, and in
&gt; that case I would pass a reference instead of a copy, but I think you can
&gt; simply pass the pointer.</span >

Right, I have also simplified the callers, the WebGL case does not need a smart pointer at all.

<span class="quote">&gt; &gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:702
&gt; &gt; +    // m_sampleMutex should be locked by the caller
&gt; 
&gt; I would move this comment before the function, saying something like: //
&gt; This should be called with the sample mutex locked.
&gt; 
&gt; &gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:710
&gt; &gt; -    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
&gt; &gt; +    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(videoInfo), GST_VIDEO_INFO_HEIGHT(videoInfo));
&gt; 
&gt; Both callers do this, maybe you could pass this as a const reference.</span >

Ok

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

Ok

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

See Miguel's answer.

<span class="quote">&gt; &gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:813
&gt; &gt; +    GstVideoInfo videoInfo;
&gt; &gt; +    WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
&gt; &gt; +    if (!getSampleVideoInfo(m_sample.get(), videoInfo))
&gt; &gt; +        return nullptr;
&gt; &gt; +
&gt; &gt; +    GLContext* context = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
&gt; &gt; +    context-&gt;makeContextCurrent();
&gt; &gt; +    cairo_device_t* device = context-&gt;cairoDevice();
&gt; &gt; +
&gt; &gt; +    // Thread-awareness is a huge performance hit on non-Intel drivers.
&gt; &gt; +    cairo_gl_device_set_thread_aware(device, FALSE);
&gt; &gt; +
&gt; &gt; +    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
&gt; &gt; +    IntSize rotatedSize = m_videoSourceOrientation.usesWidthAsHeight() ? size.transposedSize() : size;
&gt; 
&gt; All this is mostly duplicated code, could we move it to a helper function?
&gt; maybe a function that prepares the context and returns the GLContext as
&gt; return value, and video info, and sizes as output parameters</span >

I am not sure it is worth it, it is not much more readable after being extracted, but I will do so in the next patch proposal.
Also, the cairo_device needs to be kept around as well.

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

Yes, moved it to together with other protected methods.

Thanks for your feedback!</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>