Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit d35025f

Browse files
[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: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@206369 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f8c1d1b commit d35025f

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

Source/WebCore/ChangeLog

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2016-09-26 Olivier Blin <[email protected]>
2+
3+
[GStreamer] Support flipY for GPU-to-GPU copy of video textures to WebGL
4+
https://bugs.webkit.org/show_bug.cgi?id=162491
5+
6+
Reviewed by Philippe Normand.
7+
8+
GPU-GPU copy of video textures to WebGL has been added for
9+
GStreamer in bug 159928. It did not handle textures with inverted
10+
Y, and thus copy to such textures was not accelerated.
11+
12+
This occurs with THREE.js which defaults to flipY for textures.
13+
It can be tested on http://flimshaw.github.io/Valiant360/
14+
15+
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
16+
(WebCore::MediaPlayerPrivateGStreamerBase::paintToCairoSurface):
17+
(WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
18+
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
19+
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
20+
121
2016-09-25 Antti Koivisto <[email protected]>
222

323
AuthorStyleSheets shouldn't trigger synchronous style resolutions

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ GLContext* MediaPlayerPrivateGStreamerBase::prepareContextForCairoPaint(GstVideo
716716
}
717717

718718
// This should be called with the sample mutex locked.
719-
bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(cairo_surface_t* outputSurface, cairo_device_t* device, GstVideoInfo& videoInfo, const IntSize& size, const IntSize& rotatedSize)
719+
bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(cairo_surface_t* outputSurface, cairo_device_t* device, GstVideoInfo& videoInfo, const IntSize& size, const IntSize& rotatedSize, bool flipY)
720720
{
721721
GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
722722
GstVideoFrame videoFrame;
@@ -749,6 +749,12 @@ bool MediaPlayerPrivateGStreamerBase::paintToCairoSurface(cairo_surface_t* outpu
749749
ASSERT_NOT_REACHED();
750750
break;
751751
}
752+
753+
if (flipY) {
754+
cairo_scale(cr.get(), 1.0f, -1.0f);
755+
cairo_translate(cr.get(), 0.0f, -size.height());
756+
}
757+
752758
cairo_set_source_surface(cr.get(), surface.get(), 0, 0);
753759
cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE);
754760
cairo_paint(cr.get());
@@ -767,7 +773,7 @@ bool MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture(Graphics
767773
if (m_usingFallbackVideoSink)
768774
return false;
769775

770-
if (flipY || premultiplyAlpha)
776+
if (premultiplyAlpha)
771777
return false;
772778

773779
GstVideoInfo videoInfo;
@@ -787,7 +793,7 @@ bool MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture(Graphics
787793
context->getTexParameteriv(outputTarget, GL_TEXTURE_MAG_FILTER, &magFilter);
788794

789795
RefPtr<cairo_surface_t> outputSurface = adoptRef(cairo_gl_surface_create_for_texture(glContext->cairoDevice(), CAIRO_CONTENT_COLOR_ALPHA, outputTexture, rotatedSize.width(), rotatedSize.height()));
790-
if (!paintToCairoSurface(outputSurface.get(), glContext->cairoDevice(), videoInfo, size, rotatedSize))
796+
if (!paintToCairoSurface(outputSurface.get(), glContext->cairoDevice(), videoInfo, size, rotatedSize, flipY))
791797
return false;
792798

793799
context->bindTexture(outputTarget, outputTexture);
@@ -811,7 +817,7 @@ NativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime()
811817
return nullptr;
812818

813819
RefPtr<cairo_surface_t> rotatedSurface = adoptRef(cairo_gl_surface_create(context->cairoDevice(), CAIRO_CONTENT_COLOR_ALPHA, rotatedSize.width(), rotatedSize.height()));
814-
if (!paintToCairoSurface(rotatedSurface.get(), context->cairoDevice(), videoInfo, size, rotatedSize))
820+
if (!paintToCairoSurface(rotatedSurface.get(), context->cairoDevice(), videoInfo, size, rotatedSize, false))
815821
return nullptr;
816822

817823
return rotatedSurface;

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface
133133
GstElement* createGLAppSink();
134134
GstElement* createVideoSinkGL();
135135
GLContext* prepareContextForCairoPaint(GstVideoInfo&, IntSize&, IntSize&);
136-
bool paintToCairoSurface(cairo_surface_t*, cairo_device_t*, GstVideoInfo&, const IntSize&, const IntSize&);
136+
bool paintToCairoSurface(cairo_surface_t*, cairo_device_t*, GstVideoInfo&, const IntSize&, const IntSize&, bool);
137137
#endif
138138

139139
void setStreamVolumeElement(GstStreamVolume*);

0 commit comments

Comments
 (0)