WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Rebase of the proposed patches (without gst surfaces)
0001-WIP-texmap-GStreamer-Composited-Video-support.patch (text/plain), 12.24 KB, created by
Víctor M. Jáquez L.
on 2013-02-07 03:39:01 PST
(
hide
)
Description:
Rebase of the proposed patches (without gst surfaces)
Filename:
MIME Type:
Creator:
Víctor M. Jáquez L.
Created:
2013-02-07 03:39:01 PST
Size:
12.24 KB
patch
obsolete
>From 3d6b72e931b45b49d16a0fe68472850c03ff982b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= > <vjaquez@igalia.com> >Date: Thu, 7 Feb 2013 06:09:30 -0500 >Subject: [PATCH] WIP: [texmap][GStreamer] Composited Video support > >https://bugs.webkit.org/show_bug.cgi?id=86410 >--- > Source/WebCore/html/HTMLMediaElement.cpp | 2 + > .../gstreamer/MediaPlayerPrivateGStreamer.cpp | 72 ++++++++++++++++++++++ > .../gstreamer/MediaPlayerPrivateGStreamer.h | 65 ++++++++++++++++++- > .../graphics/texmap/GraphicsLayerTextureMapper.h | 1 + > .../graphics/texmap/TextureMapperShaderProgram.h | 8 ++- > Source/WebCore/rendering/RenderLayerBacking.cpp | 16 ++++- > 6 files changed, 158 insertions(+), 6 deletions(-) > >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 5fb484c..a001ca7 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -397,6 +397,8 @@ void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr > if (!value.isNull()) { > clearMediaPlayer(MediaResource); > scheduleLoad(MediaResource); >+ if (renderer()) >+ renderer()->updateFromElement(); > } > } else if (name == controlsAttr) > configureMediaControls(); >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >index 1616f91..b1c0d0d 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >@@ -1625,6 +1625,11 @@ void MediaPlayerPrivateGStreamer::triggerRepaint(GstBuffer* buffer) > > void MediaPlayerPrivateGStreamer::paint(GraphicsContext* context, const IntRect& rect) > { >+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) >+ if (m_texture) >+ return; >+#endif >+ > if (context->paintingDisabled()) > return; > >@@ -1839,6 +1844,73 @@ void MediaPlayerPrivateGStreamer::setDownloadBuffering() > } > } > >+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) >+void MediaPlayerPrivateGStreamer::acceleratedRenderingStateChanged() { >+} >+ >+PlatformLayer* MediaPlayerPrivateGStreamer::platformLayer() const { >+ return const_cast<MediaPlayerPrivateGStreamer*>(this); >+} >+ >+bool MediaPlayerPrivateGStreamer::supportsAcceleratedRendering() const { >+ return true; >+} >+ >+void MediaPlayerPrivateGStreamer::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask) { >+ if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) >+ return; >+ >+ if (m_buffer) { >+ IntSize size = naturalSize(); >+ >+ m_texture = textureMapper->acquireTextureFromPool(size); >+ RefPtr<BitmapTexture> source = textureMapper->acquireTextureFromPool(size); >+ >+#ifdef GST_API_VERSION_1 >+ GstMapInfo sourceInfo; >+ gst_buffer_map(m_buffer, &sourceInfo, GST_MAP_READ); >+ source->updateContents(sourceInfo.data, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0,0), size.width() * 4, BitmapTexture::UpdateCannotModifyOriginalImageData); >+ gst_buffer_unmap(m_buffer, &sourceInfo); >+#else >+ source->updateContents(GST_BUFFER_DATA(m_buffer), WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0,0), size.width() * 4); >+#endif >+ >+ TextureMapperGL* textureMapperGL = static_cast<TextureMapperGL*>(textureMapper); >+ textureMapperGL->bindSurface(m_texture.get()); >+ >+ GraphicsContext3D* context3D = textureMapperGL->graphicsContext3D(); >+ if (!m_program) { >+ m_program = TextureMapperShaderProgramBlue::create(context3D); >+ } >+ context3D->enableVertexAttribArray(m_program->vertexLocation()); >+ context3D->enableVertexAttribArray(m_program->texCoordLocation()); >+ context3D->useProgram(m_program->programID()); >+ >+ context3D->activeTexture(GraphicsContext3D::TEXTURE0); >+ context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, static_cast<const BitmapTextureGL*>(source.get())->id()); >+ context3D->uniform1i(m_program->maskLocation(), 0); >+ >+ const GC3Dfloat targetVertices[] = {-1, -1, 1, -1, 1, 1, -1, 1}; >+ context3D->vertexAttribPointer(m_program->vertexLocation(), 2, GraphicsContext3D::FLOAT, true, 0, GC3Dintptr(targetVertices)); >+ const GC3Dfloat sourceVertices[] = {0, 0, 1, 0, 1, 1, 0, 1}; >+ context3D->vertexAttribPointer(m_program->texCoordLocation(), 2, GraphicsContext3D::FLOAT, true, 0, GC3Dintptr(sourceVertices)); >+ >+ context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4); >+ context3D->disableVertexAttribArray(m_program->vertexLocation()); >+ context3D->disableVertexAttribArray(m_program->texCoordLocation()); >+ textureMapperGL->bindSurface(NULL); >+ >+ gst_buffer_unref(m_buffer); >+ m_buffer = 0; >+ } >+ >+ if (m_texture) { >+ textureMapper->drawTexture(*m_texture.get(), targetRect, matrix, opacity, mask); >+ } >+ >+} >+#endif >+ > void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload) > { > m_originalPreloadWasAutoAndWasOverridden = m_preload != preload && m_preload == MediaPlayer::Auto; >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >index fd37d83..91d5d4fd 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >@@ -28,6 +28,14 @@ > #include "MediaPlayerPrivate.h" > #include "Timer.h" > >+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) >+#include "TextureMapperGL.h" >+#include "TextureMapperShaderProgram.h" >+#include "TextureMapperPlatformLayer.h" >+#include "GraphicsTypes3D.h" >+#include "GraphicsContext3D.h" >+#endif >+ > #include <glib.h> > #include <gst/gst.h> > #include <wtf/Forward.h> >@@ -46,7 +54,49 @@ class IntRect; > class GStreamerGWorld; > class MediaPlayerPrivateGStreamer; > >-class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { >+#define STRINGIFY(...) #__VA_ARGS__ >+ >+static const char* vertexShaderSourceBlue = >+ STRINGIFY( >+ attribute vec4 a_vertex; >+ attribute vec4 a_texCoord; >+ varying highp vec2 v_sourceTexCoord; >+ void main(void) >+ { >+ v_sourceTexCoord = vec2(a_texCoord.x, a_texCoord.y); >+ gl_Position = a_vertex; >+ } >+ ); >+ >+static const char* fragmentShaderSourceBlue = >+ STRINGIFY( >+ precision mediump float; >+ uniform sampler2D s_source; >+ varying highp vec2 v_sourceTexCoord; >+ void main(void) >+ { >+ gl_FragColor = texture2D(s_source, v_sourceTexCoord); >+ } >+ ); >+ >+class TextureMapperShaderProgramBlue : public TextureMapperShaderProgram { >+public: >+ static PassRefPtr<TextureMapperShaderProgramBlue> create(PassRefPtr<GraphicsContext3D> context) { >+ return adoptRef(new TextureMapperShaderProgramBlue(context)); >+ } >+ >+ TEXMAP_DECLARE_ATTRIBUTE(texCoord) >+ TEXMAP_DECLARE_SAMPLER(source) >+ >+private: >+ TextureMapperShaderProgramBlue(PassRefPtr<GraphicsContext3D> context) : TextureMapperShaderProgram (context, vertexShaderSourceBlue, fragmentShaderSourceBlue) { } >+}; >+ >+class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface >+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) >+ , public TextureMapperPlatformLayer >+#endif >+{ > > public: > ~MediaPlayerPrivateGStreamer(); >@@ -141,6 +191,14 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { > > static KURL convertPlaybinURL(const gchar* uri); > >+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) >+ virtual void acceleratedRenderingStateChanged(); >+ // Const-casting here is safe, since all of TextureMapperPlatformLayer's functions are const. >+ virtual PlatformLayer* platformLayer() const; >+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask); >+ virtual bool supportsAcceleratedRendering() const; >+#endif >+ > private: > MediaPlayerPrivateGStreamer(MediaPlayer*); > >@@ -224,6 +282,11 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { > KURL m_url; > bool m_originalPreloadWasAutoAndWasOverridden; > bool m_preservesPitch; >+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) >+ RefPtr<GraphicsContext3D> m_context; >+ RefPtr<BitmapTexture> m_texture; >+ RefPtr<TextureMapperShaderProgramBlue> m_program; >+#endif > }; > } > >diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h >index 694b5a3..a6fbc37 100644 >--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h >+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h >@@ -66,6 +66,7 @@ public: > virtual void setShowDebugBorder(bool) OVERRIDE; > virtual void setDebugBorder(const Color&, float width) OVERRIDE; > virtual void setShowRepaintCounter(bool) OVERRIDE; >+ virtual bool hasContentsLayer() const { return m_contentsLayer; } > virtual void flushCompositingState(const FloatRect&); > virtual void flushCompositingStateForThisLayerOnly(); > virtual void setName(const String& name); >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h >index 037e7d6..414e923 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h >@@ -85,14 +85,16 @@ public: > > void setMatrix(GC3Duint, const TransformationMatrix&); > >-private: > TextureMapperShaderProgram(PassRefPtr<GraphicsContext3D>, const String& vertexShaderSource, const String& fragmentShaderSource); >- Platform3DObject m_vertexShader; >- Platform3DObject m_fragmentShader; > >+protected: > enum VariableType { UniformVariable, AttribVariable }; > GC3Duint getLocation(const AtomicString&, VariableType); > >+private: >+ Platform3DObject m_vertexShader; >+ Platform3DObject m_fragmentShader; >+ > RefPtr<GraphicsContext3D> m_context; > Platform3DObject m_id; > HashMap<AtomicString, GC3Duint> m_variables; >diff --git a/Source/WebCore/rendering/RenderLayerBacking.cpp b/Source/WebCore/rendering/RenderLayerBacking.cpp >index 7267baa..8dee45e 100644 >--- a/Source/WebCore/rendering/RenderLayerBacking.cpp >+++ b/Source/WebCore/rendering/RenderLayerBacking.cpp >@@ -79,6 +79,17 @@ using namespace HTMLNames; > static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*); > static IntRect clipBox(RenderBox* renderer); > >+static inline bool isAcceleratedVideo(RenderObject* renderer) >+{ >+#if ENABLE(VIDEO) >+ if (renderer->isVideo()) { >+ return toRenderVideo(renderer)->supportsAcceleratedRendering(); >+ } >+#else >+ UNUSED_PARAM(renderer); >+#endif >+ return false; >+} > static inline bool isAcceleratedCanvas(RenderObject* renderer) > { > #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS) >@@ -1710,8 +1721,9 @@ void RenderLayerBacking::setContentsNeedDisplay() > { > ASSERT(!paintsIntoCompositedAncestor()); > >- if (m_graphicsLayer && m_graphicsLayer->drawsContent()) >+ if (m_graphicsLayer && (m_graphicsLayer->drawsContent() || m_graphicsLayer->hasContentsLayer())) { > m_graphicsLayer->setNeedsDisplay(); >+ } > > if (m_foregroundLayer && m_foregroundLayer->drawsContent()) > m_foregroundLayer->setNeedsDisplay(); >@@ -1731,7 +1743,7 @@ void RenderLayerBacking::setContentsNeedDisplayInRect(const IntRect& r) > { > ASSERT(!paintsIntoCompositedAncestor()); > >- if (m_graphicsLayer && m_graphicsLayer->drawsContent()) { >+ if (m_graphicsLayer && (m_graphicsLayer->drawsContent() || m_graphicsLayer->hasContentsLayer())) { > IntRect layerDirtyRect = r; > layerDirtyRect.move(-m_graphicsLayer->offsetFromRenderer()); > m_graphicsLayer->setNeedsDisplayInRect(layerDirtyRect); >-- >1.7.11.7 >
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 86410
:
143452
|
149515
|
149522
|
168253
|
168470
|
172019
|
172745
|
174322
|
177424
|
187046
|
189741
|
191247
|
194084
|
194877
|
198493
|
200421
|
200423
|
201553
|
201564
|
203145
|
203151