WebKit Bugzilla
Attachment 359874 Details for
Bug 193715
: [WPE] Implement GStreamer based holepunch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193715-20190123154348.patch (text/plain), 17.29 KB, created by
Miguel Gomez
on 2019-01-23 06:43:50 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Miguel Gomez
Created:
2019-01-23 06:43:50 PST
Size:
17.29 KB
patch
obsolete
>Subversion Revision: 240333 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e9e2b0d40e1f3ed2c36c8f4c4500f989b689ba27..79e045cd431e37ec20c535f0ebe32eb4709b4ffc 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,35 @@ >+2019-01-23 Miguel Gomez <magomez@igalia.com> >+ >+ [WPE] Implement GStreamer based holepunch >+ https://bugs.webkit.org/show_bug.cgi?id=193715 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement GStreamer based holepunch functionality. Instead of getting the video frames from the >+ video sink and drawing then, the player just draws a transparent rectangle on the position where >+ the video should be. A platform dependent video sink will be used to render the video frames on >+ a plane below the browser. >+ >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: >+ (WebCore::MediaPlayerPrivateGStreamerBase::naturalSize const): >+ (WebCore::MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded): >+ (WebCore::MediaPlayerPrivateGStreamerBase::createVideoSinkHolepunch): >+ (WebCore::MediaPlayerPrivateGStreamerBase::createVideoSink): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: >+ * platform/graphics/texmap/TextureMapper.h: >+ * platform/graphics/texmap/TextureMapperGL.cpp: >+ (WebCore::TextureMapperGL::drawSolidColor): >+ * platform/graphics/texmap/TextureMapperGL.h: >+ * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp: >+ (WebCore::setRectangleToVideoSink): >+ (WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper): >+ * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h: >+ (WebCore::TextureMapperPlatformLayerBuffer::setVideoSink): >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: >+ (WebCore::CoordinatedGraphicsLayer::setContentsToPlatformLayer): >+ * rendering/RenderVideo.cpp: >+ (WebCore::RenderVideo::videoBox const): >+ > 2019-01-23 Oriol Brufau <obrufau@igalia.com> > > [css-grid] Properly handle static positions of abspos inside grid items >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >index e130c20083d554f0ae1684acef86731c83060fb7..421815a06272f236e1c7311f2b83006dfc17b66b 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >@@ -129,6 +129,10 @@ > GST_DEBUG_CATEGORY(webkit_media_player_debug); > #define GST_CAT_DEFAULT webkit_media_player_debug > >+#if USE(GSTREAMER_HOLEPUNCH) >+#define HOLEPUNCH_DEFAULT_FRAME_WIDTH 1280 >+#define HOLEPUNCH_DEFAULT_FRAME_HEIGHT 720 >+#endif > > namespace WebCore { > using namespace std; >@@ -487,6 +491,13 @@ bool MediaPlayerPrivateGStreamerBase::ensureGstGLContext() > // Returns the size of the video > FloatSize MediaPlayerPrivateGStreamerBase::naturalSize() const > { >+#if USE(GSTREAMER_HOLEPUNCH) >+ // When using the holepuch we may not be able to get the video frames size, so we can't use >+ // it. But we need to report some non empty naturalSize so the GraphicsLayer for the player >+ // is properly created. >+ return FloatSize(HOLEPUNCH_DEFAULT_FRAME_WIDTH, HOLEPUNCH_DEFAULT_FRAME_HEIGHT); >+#endif >+ > if (!hasVideo()) > return FloatSize(); > >@@ -672,6 +683,13 @@ PlatformLayer* MediaPlayerPrivateGStreamerBase::platformLayer() const > #if USE(NICOSIA) > void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() > { >+#if USE(GSTREAMER_HOLEPUNCH) >+ auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy(); >+ LockHolder holder(proxy.lock()); >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(0, m_size, TextureMapperGL::ShouldNotBlend, GL_DONT_CARE); >+ layerBuffer->setVideoSink(m_videoSink.get()); >+ proxy.pushNextBuffer(WTFMove(layerBuffer)); >+#endif > } > #else > RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() const >@@ -681,6 +699,12 @@ RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() > > void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() > { >+#if USE(GSTREAMER_HOLEPUNCH) >+ LockHolder holder(m_platformLayerProxy.lock()); >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(0, m_size, TextureMapperGL::ShouldNotBlend, GL_DONT_CARE); >+ layerBuffer->setVideoSink(m_videoSink.get()); >+ m_platformLayerProxy().pushNextBuffer(WTFMove(layerBuffer)); >+#endif > } > #endif > >@@ -1078,10 +1102,42 @@ void MediaPlayerPrivateGStreamerBase::ensureGLVideoSinkContext() > } > #endif // USE(GSTREAMER_GL) > >+#if USE(GSTREAMER_HOLEPUNCH) >+GstElement* MediaPlayerPrivateGStreamerBase::createVideoSinkHolepunch() >+{ >+ // Here goes the platform-dependant code to create the videoSink. As a default >+ // we use a fakeSink so nothing is drawn to the page. >+ GstElement* videoSink = gst_element_factory_make("fakesink", nullptr); >+ >+ // Once the sink has been created, push a new buffer to the compositor with a reference to it. >+ auto proxyOperation = >+ [this, videoSink](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder holder(proxy.lock()); >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(0, m_size, TextureMapperGL::ShouldNotBlend, GL_DONT_CARE); >+ layerBuffer->setVideoSink(videoSink); >+ proxy.pushNextBuffer(WTFMove(layerBuffer)); >+ }; >+ >+#if USE(NICOSIA) >+ proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); >+#endif >+ >+ return videoSink; >+} >+#endif >+ > GstElement* MediaPlayerPrivateGStreamerBase::createVideoSink() > { > acceleratedRenderingStateChanged(); > >+#if USE(GSTREAMER_HOLEPUNCH) >+ m_videoSink = createVideoSinkHolepunch(); >+ return m_videoSink.get(); >+#endif >+ > #if USE(GSTREAMER_GL) > if (m_renderingCanBeAccelerated) > m_videoSink = createVideoSinkGL(); >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >index 76aa5ccfd8931f0c44095dfd0d70f4aa8f31e59c..e99f43702dc78d6060129aa77aa6067d08aaece4 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >@@ -173,6 +173,10 @@ protected: > MediaPlayerPrivateGStreamerBase(MediaPlayer*); > virtual GstElement* createVideoSink(); > >+#if USE(GSTREAMER_HOLEPUNCH) >+ GstElement* createVideoSinkHolepunch(); >+#endif >+ > #if USE(GSTREAMER_GL) > static GstFlowReturn newSampleCallback(GstElement*, MediaPlayerPrivateGStreamerBase*); > static GstFlowReturn newPrerollCallback(GstElement*, MediaPlayerPrivateGStreamerBase*); >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapper.h b/Source/WebCore/platform/graphics/texmap/TextureMapper.h >index 3556a95deea5d8adfe4f6654547cd0a4de0a0276..4216281ebc962bec05ac73bd2b9764f4b37874ef 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapper.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapper.h >@@ -70,7 +70,7 @@ public: > virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) = 0; > > virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, unsigned exposedEdges = AllEdges) = 0; >- virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) = 0; >+ virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&, bool blend = true) = 0; > virtual void clearColor(const Color&) = 0; > > // makes a surface the target for the following drawTexture calls. >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp >index ad68f2bd60f5c1d43e714ae2c77cdf613f9ac424..b6870c97f8baceb82984fe5e87e43c23cf8afc45 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp >@@ -504,13 +504,13 @@ void TextureMapperGL::drawTexture(GLuint texture, Flags flags, const IntSize& te > drawTexturedQuadWithProgram(program.get(), texture, flags, textureSize, targetRect, modelViewMatrix, opacity); > } > >-void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color) >+void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color, bool blend) > { > Flags flags = 0; > TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::SolidColor; > if (!matrix.mapQuad(rect).isRectilinear()) { > options |= TextureMapperShaderProgram::Antialiasing; >- flags |= ShouldBlend | ShouldAntialias; >+ flags |= ShouldAntialias | (blend ? ShouldBlend : 0); > } > > Ref<TextureMapperShaderProgram> program = data().getShaderProgram(options); >@@ -519,7 +519,7 @@ void TextureMapperGL::drawSolidColor(const FloatRect& rect, const Transformation > float r, g, b, a; > Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a); > glUniform4f(program->colorLocation(), r, g, b, a); >- if (a < 1) >+ if (a < 1 && blend) > flags |= ShouldBlend; > > draw(rect, matrix, program.get(), GL_TRIANGLE_FAN, flags); >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h >index e1e3905d33e72731e193d26efc3b1bccdee97363..286a0984e857a323745397206b9ce28d56539359 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h >@@ -53,7 +53,8 @@ public: > ShouldRotateTexture180 = 0x20, > ShouldRotateTexture270 = 0x40, > ShouldConvertTextureBGRAToRGBA = 0x80, >- ShouldConvertTextureARGBToRGBA = 0x100 >+ ShouldConvertTextureARGBToRGBA = 0x100, >+ ShouldNotBlend = 0x200 > }; > > typedef int Flags; >@@ -63,7 +64,7 @@ public: > void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) override; > void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, unsigned exposedEdges) override; > virtual void drawTexture(GLuint texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges = AllEdges); >- void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) override; >+ void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&, bool = true) override; > void clearColor(const Color&) override; > > void bindSurface(BitmapTexture* surface) override; >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp >index 8cc58d61d9b503797f072725e0c6d783de5d1de6..dde096800bb498c086248d24944b186bad23bcbc 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp >@@ -28,10 +28,21 @@ > > #if USE(COORDINATED_GRAPHICS_THREADED) > >+#include "FloatRect.h" > #include "NotImplemented.h" > > namespace WebCore { > >+#if USE(GSTREAMER_HOLEPUNCH) >+static void setRectangleToVideoSink(GstElement* videoSink, IntRect rect) >+{ >+ // Here goes the platform-dependant code to set to the videoSink the size >+ // and position of the video rendering window. Mark them unused as default. >+ UNUSED_PARAM(videoSink); >+ UNUSED_PARAM(rect); >+} >+#endif >+ > TextureMapperPlatformLayerBuffer::TextureMapperPlatformLayerBuffer(RefPtr<BitmapTexture>&& texture, TextureMapperGL::Flags flags) > : m_texture(WTFMove(texture)) > , m_textureID(0) >@@ -77,6 +88,15 @@ void TextureMapperPlatformLayerBuffer::paintToTextureMapper(TextureMapper& textu > return; > } > >+#if USE(GSTREAMER_HOLEPUNCH) >+ if (m_extraFlags & TextureMapperGL::ShouldNotBlend) { >+ ASSERT(m_videoSink && !m_texture); >+ texmapGL.drawSolidColor(targetRect, modelViewMatrix, Color(0, 0, 0, 0), false); >+ setRectangleToVideoSink(m_videoSink.get(), enclosingIntRect(modelViewMatrix.mapRect(targetRect))); >+ return; >+ } >+#endif >+ > ASSERT(m_textureID); > texmapGL.drawTexture(m_textureID, m_extraFlags, m_size, targetRect, modelViewMatrix, opacity); > } >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h >index 8b9455afef886b0c9adb1086104e77f8610b8dd9..6566ea232ae0ff6970d3e28973f8a1852ac2b327 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h >@@ -28,6 +28,7 @@ > #if USE(COORDINATED_GRAPHICS_THREADED) > > #include "BitmapTextureGL.h" >+#include "GRefPtrGStreamer.h" > #include "TextureMapperGLHeaders.h" > #include "TextureMapperPlatformLayer.h" > #include <wtf/MonotonicTime.h> >@@ -65,6 +66,10 @@ public: > > std::unique_ptr<TextureMapperPlatformLayerBuffer> clone(); > >+#if USE(GSTREAMER_HOLEPUNCH) >+ void setVideoSink(GstElement* videoSink) { m_videoSink = videoSink; } >+#endif >+ > private: > > RefPtr<BitmapTexture> m_texture; >@@ -76,6 +81,10 @@ private: > TextureMapperGL::Flags m_extraFlags; > bool m_hasManagedTexture; > std::unique_ptr<UnmanagedBufferDataHolder> m_unmanagedBufferDataHolder; >+ >+#if USE(GSTREAMER_HOLEPUNCH) >+ GRefPtr<GstElement> m_videoSink; >+#endif > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index 892f6b201344a46f94c0d8989321b2dd0b7682d4..3176ba102b0c1110bcde5fc4474a2d2c53ae5ea6 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -411,6 +411,8 @@ void CoordinatedGraphicsLayer::setContentsToPlatformLayer(PlatformLayer* platfor > if (m_nicosia.contentLayer != contentLayer) { > m_nicosia.contentLayer = contentLayer; > m_nicosia.delta.contentLayerChanged = true; >+ if (m_nicosia.contentLayer) >+ m_shouldUpdatePlatformLayer = true; > } > notifyFlushRequired(); > #else >diff --git a/Source/WebCore/rendering/RenderVideo.cpp b/Source/WebCore/rendering/RenderVideo.cpp >index 731cb63436c47862d4acbeda279baaa37250a7e1..2ecee419c5873366a1aaefebcc4dee3999a9a30d 100644 >--- a/Source/WebCore/rendering/RenderVideo.cpp >+++ b/Source/WebCore/rendering/RenderVideo.cpp >@@ -158,6 +158,13 @@ void RenderVideo::imageChanged(WrappedImagePtr newImage, const IntRect* rect) > > IntRect RenderVideo::videoBox() const > { >+#if PLATFORM(WPE) && USE(GSTREAMER_HOLEPUNCH) >+ // When using holepunch, skip all the intrinsic size calculations and just report the <video> >+ // element size. The external application or the custom sink will be in charge of scaling the video >+ // frames appropriately. >+ return snappedIntRect(contentBoxRect()); >+#endif >+ > LayoutSize intrinsicSize = this->intrinsicSize(); > > if (videoElement().shouldDisplayPosterImage()) >diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake >index 5f311b83c5ab98786f83b3ba50429374d0ab784d..fceafecbc01fb55a7be9dd8828f711b6fd96a6d3 100644 >--- a/Source/cmake/OptionsWPE.cmake >+++ b/Source/cmake/OptionsWPE.cmake >@@ -46,6 +46,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_RTC PRIVATE ${ENABLE_EXPERIMENTAL_FE > WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBLIC OFF) > WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON) > WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC OFF) >+WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepunch" PUBLIC OFF) > > # Private options specific to the WPE port. > WEBKIT_OPTION_DEFINE(USE_OPENVR "Whether to use OpenVR as WebVR backend." PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES}) >@@ -64,6 +65,8 @@ if (DEVELOPER_MODE) > WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON) > endif () > >+WEBKIT_OPTION_DEPEND(USE_GSTREAMER_HOLEPUNCH ENABLE_VIDEO) >+ > include(GStreamerDependencies) > > WEBKIT_OPTION_END() >diff --git a/ChangeLog b/ChangeLog >index 506fd3545b0fba8f614490a5bd2583b1ae221410..0c6df8a34ca08853d813e00bda59a19c0eb483a4 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-23 Miguel Gomez <magomez@igalia.com> >+ >+ [WPE] Implement GStreamer based holepunch >+ https://bugs.webkit.org/show_bug.cgi?id=193715 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add GSTREAMER_HOLEPUNCH option to the WPE port. >+ >+ * Source/cmake/OptionsWPE.cmake: >+ > 2019-01-18 Jer Noble <jer.noble@apple.com> > > SDK_VARIANT build destinations should be separate from non-SDK_VARIANT builds
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193715
:
359874
|
359884
|
360455
|
360459
|
361189
|
361294
|
361386