Title: [206369] trunk/Source/WebCore
Revision
206369
Author
[email protected]
Date
2016-09-26 03:20:48 -0700 (Mon, 26 Sep 2016)

Log Message

[GStreamer] Support flipY for GPU-to-GPU copy of video textures to WebGL
https://bugs.webkit.org/show_bug.cgi?id=162491

Patch by Olivier Blin <[email protected]> on 2016-09-26
Reviewed by Philippe Normand.

GPU-GPU copy of video textures to WebGL has been added for
GStreamer in bug 159928. It did not handle textures with inverted
Y, and thus copy to such textures was not accelerated.

This occurs with THREE.js which defaults to flipY for textures.
It can be tested on http://flimshaw.github.io/Valiant360/

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::paintToCairoSurface):
(WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206368 => 206369)


--- trunk/Source/WebCore/ChangeLog	2016-09-26 07:26:59 UTC (rev 206368)
+++ trunk/Source/WebCore/ChangeLog	2016-09-26 10:20:48 UTC (rev 206369)
@@ -1,3 +1,23 @@
+2016-09-26  Olivier Blin  <[email protected]>
+
+        [GStreamer] Support flipY for GPU-to-GPU copy of video textures to WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=162491
+
+        Reviewed by Philippe Normand.
+
+        GPU-GPU copy of video textures to WebGL has been added for
+        GStreamer in bug 159928. It did not handle textures with inverted
+        Y, and thus copy to such textures was not accelerated.
+
+        This occurs with THREE.js which defaults to flipY for textures.
+        It can be tested on http://flimshaw.github.io/Valiant360/
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::paintToCairoSurface):
+        (WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
+        (WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+
 2016-09-25  Antti Koivisto  <[email protected]>
 
         AuthorStyleSheets shouldn't trigger synchronous style resolutions

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (206368 => 206369)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2016-09-26 07:26:59 UTC (rev 206368)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2016-09-26 10:20:48 UTC (rev 206369)
@@ -716,7 +716,7 @@
 }
 
 // This should be called with the sample mutex locked.
-bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(cairo_surface_t* outputSurface, cairo_device_t* device, GstVideoInfo& videoInfo, const IntSize& size, const IntSize& rotatedSize)
+bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(cairo_surface_t* outputSurface, cairo_device_t* device, GstVideoInfo& videoInfo, const IntSize& size, const IntSize& rotatedSize, bool flipY)
 {
     GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
     GstVideoFrame videoFrame;
@@ -749,6 +749,12 @@
         ASSERT_NOT_REACHED();
         break;
     }
+
+    if (flipY) {
+        cairo_scale(cr.get(), 1.0f, -1.0f);
+        cairo_translate(cr.get(), 0.0f, -size.height());
+    }
+
     cairo_set_source_surface(cr.get(), surface.get(), 0, 0);
     cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE);
     cairo_paint(cr.get());
@@ -767,7 +773,7 @@
     if (m_usingFallbackVideoSink)
         return false;
 
-    if (flipY || premultiplyAlpha)
+    if (premultiplyAlpha)
         return false;
 
     GstVideoInfo videoInfo;
@@ -787,7 +793,7 @@
     context->getTexParameteriv(outputTarget, GL_TEXTURE_MAG_FILTER, &magFilter);
 
     RefPtr<cairo_surface_t> outputSurface = adoptRef(cairo_gl_surface_create_for_texture(glContext->cairoDevice(), CAIRO_CONTENT_COLOR_ALPHA, outputTexture, rotatedSize.width(), rotatedSize.height()));
-    if (!paintToCairoSurface(outputSurface.get(), glContext->cairoDevice(), videoInfo, size, rotatedSize))
+    if (!paintToCairoSurface(outputSurface.get(), glContext->cairoDevice(), videoInfo, size, rotatedSize, flipY))
         return false;
 
     context->bindTexture(outputTarget, outputTexture);
@@ -811,7 +817,7 @@
         return nullptr;
 
     RefPtr<cairo_surface_t> rotatedSurface = adoptRef(cairo_gl_surface_create(context->cairoDevice(), CAIRO_CONTENT_COLOR_ALPHA, rotatedSize.width(), rotatedSize.height()));
-    if (!paintToCairoSurface(rotatedSurface.get(), context->cairoDevice(), videoInfo, size, rotatedSize))
+    if (!paintToCairoSurface(rotatedSurface.get(), context->cairoDevice(), videoInfo, size, rotatedSize, false))
         return nullptr;
 
     return rotatedSurface;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (206368 => 206369)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h	2016-09-26 07:26:59 UTC (rev 206368)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h	2016-09-26 10:20:48 UTC (rev 206369)
@@ -133,7 +133,7 @@
     GstElement* createGLAppSink();
     GstElement* createVideoSinkGL();
     GLContext* prepareContextForCairoPaint(GstVideoInfo&, IntSize&, IntSize&);
-    bool paintToCairoSurface(cairo_surface_t*, cairo_device_t*, GstVideoInfo&, const IntSize&, const IntSize&);
+    bool paintToCairoSurface(cairo_surface_t*, cairo_device_t*, GstVideoInfo&, const IntSize&, const IntSize&, bool);
 #endif
 
     void setStreamVolumeElement(GstStreamVolume*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to