2010-07-19 Victoria Kirst <vrk@google.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jul 2010 06:28:51 +0000 (06:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jul 2010 06:28:51 +0000 (06:28 +0000)
        Reviewed by David Levin.

        Added a simple implementation of VideoLayerChromium. Uses the
        LayerChromium::updateTextureRect() to send video frames to the
        GPU.
        https://bugs.webkit.org/show_bug.cgi?id=42234

        * WebCore.gypi: Added include for VideoLayerChromium.
        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
        (WebCore::GraphicsLayerChromium::setContentsToMedia): Implemented
        setContentsToMedia, though it does not seem to trigger a repaint
        correctly.
        * platform/graphics/chromium/GraphicsLayerChromium.h:
        * platform/graphics/chromium/VideoLayerChromium.cpp: Added.
        (WebCore::VideoLayerChromium::create):
        (WebCore::VideoLayerChromium::VideoLayerChromium):
        (WebCore::VideoLayerChromium::updateTextureContents):
        * platform/graphics/chromium/VideoLayerChromium.h: Added.
        (WebCore::VideoLayerChromium::drawsContent):
2010-07-19  Victoria Kirst  <vrk@google.com>

        Reviewed by David Levin.

        Updated WebMediaPlayer to support accelerated rendering and to
        create and return a VideoChromiumLayer as its platform layer.
        https://bugs.webkit.org/show_bug.cgi?id=42234

        * src/WebMediaPlayerClientImpl.cpp:
        (WebKit::WebMediaPlayerClientImpl::platformLayer):
        (WebKit::WebMediaPlayerClientImpl::create):
        * src/WebMediaPlayerClientImpl.h:
        (WebKit::WebMediaPlayerClientImpl::supportsAcceleratedRendering):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63723 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.gypi
WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
WebCore/platform/graphics/chromium/VideoLayerChromium.cpp [new file with mode: 0644]
WebCore/platform/graphics/chromium/VideoLayerChromium.h [new file with mode: 0644]
WebKit/chromium/ChangeLog
WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
WebKit/chromium/src/WebMediaPlayerClientImpl.h

index d20857e..34aeeb6 100644 (file)
@@ -1,3 +1,25 @@
+2010-07-19  Victoria Kirst  <vrk@google.com>
+
+        Reviewed by David Levin.
+
+        Added a simple implementation of VideoLayerChromium. Uses the
+        LayerChromium::updateTextureRect() to send video frames to the
+        GPU.
+        https://bugs.webkit.org/show_bug.cgi?id=42234
+
+        * WebCore.gypi: Added include for VideoLayerChromium.
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::setContentsToMedia): Implemented
+        setContentsToMedia, though it does not seem to trigger a repaint
+        correctly.
+        * platform/graphics/chromium/GraphicsLayerChromium.h:
+        * platform/graphics/chromium/VideoLayerChromium.cpp: Added.
+        (WebCore::VideoLayerChromium::create):
+        (WebCore::VideoLayerChromium::VideoLayerChromium):
+        (WebCore::VideoLayerChromium::updateTextureContents):
+        * platform/graphics/chromium/VideoLayerChromium.h: Added.
+        (WebCore::VideoLayerChromium::drawsContent):
+
 2010-07-19  Dirk Schulze  <krit@webkit.org>
 
         Reviewed by Nikolas Zimmermann.
index d2d3f55..7aa5d60 100644 (file)
             'platform/graphics/chromium/UniscribeHelper.h',
             'platform/graphics/chromium/UniscribeHelperTextRun.cpp',
             'platform/graphics/chromium/UniscribeHelperTextRun.h',
+            'platform/graphics/chromium/VideoLayerChromium.cpp',
+            'platform/graphics/chromium/VideoLayerChromium.h',
             'platform/graphics/chromium/WebGLLayerChromium.cpp',
             'platform/graphics/chromium/WebGLLayerChromium.h',
             'platform/graphics/filters/FEBlend.cpp',
index 9b65346..a01a17f 100644 (file)
@@ -363,9 +363,30 @@ void GraphicsLayerChromium::setContentsToWebGL(PlatformLayer* platformLayer)
 }
 #endif
 
-void GraphicsLayerChromium::setContentsToVideo(PlatformLayer* videoLayer)
+void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
 {
-    // FIXME: Implement
+    bool childrenChanged = false;
+    if (layer) {
+        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForVideo) {
+            setupContentsLayer(layer);
+            m_contentsLayer = layer;
+            m_contentsLayerPurpose = ContentsLayerForVideo;
+            childrenChanged = true;
+        }
+        layer->setOwner(this);
+        layer->setNeedsDisplay();
+        updateContentsRect();
+    } else {
+        if (m_contentsLayer) {
+            childrenChanged = true;
+  
+            // The old contents layer will be removed via updateSublayerList.
+            m_contentsLayer = 0;
+        }
+    }
+  
+    if (childrenChanged)
+        updateSublayerList();
 }
 
 void GraphicsLayerChromium::setGeometryOrientation(CompositingCoordinatesOrientation orientation)
index ccd02eb..cd5e479 100644 (file)
@@ -85,7 +85,7 @@ public:
     virtual void setContentsRect(const IntRect&);
 
     virtual void setContentsToImage(Image*);
-    virtual void setContentsToVideo(PlatformLayer*);
+    virtual void setContentsToMedia(PlatformLayer*);
     virtual void setContentsToWebGL(PlatformLayer*);
 
     virtual PlatformLayer* platformLayer() const;
diff --git a/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp b/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp
new file mode 100644 (file)
index 0000000..5ac0e57
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "VideoLayerChromium.h"
+
+namespace WebCore {
+
+PassRefPtr<VideoLayerChromium> VideoLayerChromium::create(GraphicsLayerChromium* owner)
+{
+    return adoptRef(new VideoLayerChromium(owner));
+}
+
+VideoLayerChromium::VideoLayerChromium(GraphicsLayerChromium* owner)
+    : LayerChromium(owner)
+{
+}
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/chromium/VideoLayerChromium.h b/WebCore/platform/graphics/chromium/VideoLayerChromium.h
new file mode 100644 (file)
index 0000000..1fa8009
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef VideoLayerChromium_h
+#define VideoLayerChromium_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerChromium.h"
+
+namespace WebCore {
+
+// A Layer that contains a Video element.
+class VideoLayerChromium : public LayerChromium {
+public:
+    static PassRefPtr<VideoLayerChromium> create(GraphicsLayerChromium* owner = 0);
+    virtual bool drawsContent() { return true; }
+
+private:
+    VideoLayerChromium(GraphicsLayerChromium* owner);
+};
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif
index 5039925..8a87a64 100644 (file)
@@ -1,3 +1,17 @@
+2010-07-19  Victoria Kirst  <vrk@google.com>
+
+        Reviewed by David Levin.
+
+        Updated WebMediaPlayer to support accelerated rendering and to
+        create and return a VideoChromiumLayer as its platform layer.
+        https://bugs.webkit.org/show_bug.cgi?id=42234
+
+        * src/WebMediaPlayerClientImpl.cpp:
+        (WebKit::WebMediaPlayerClientImpl::platformLayer):
+        (WebKit::WebMediaPlayerClientImpl::create):
+        * src/WebMediaPlayerClientImpl.h:
+        (WebKit::WebMediaPlayerClientImpl::supportsAcceleratedRendering):
+
 2010-07-19  Kenneth Russell  <kbr@google.com>
 
         Reviewed by Nate Chapin.
index 03051c3..de9cd14 100644 (file)
 #include "KURL.h"
 #include "MediaPlayer.h"
 #include "NotImplemented.h"
+#include "RenderView.h"
 #include "TimeRanges.h"
+#include "VideoLayerChromium.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "RenderLayerCompositor.h"
+#endif
 
 #include "WebCanvas.h"
 #include "WebCString.h"
@@ -28,6 +34,7 @@
 #include "WebSize.h"
 #include "WebString.h"
 #include "WebURL.h"
+#include "WebViewImpl.h"
 
 // WebCommon.h defines WEBKIT_USING_SKIA so this has to be included last.
 #if WEBKIT_USING_SKIA
@@ -45,6 +52,7 @@ static WebMediaPlayer* createWebMediaPlayer(
     WebMediaPlayerClient* client, Frame* frame)
 {
     WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
+
     if (!webFrame->client())
         return 0;
     return webFrame->client()->createMediaPlayer(webFrame, client);
@@ -146,6 +154,7 @@ void WebMediaPlayerClientImpl::load(const String& url)
 {
     Frame* frame = static_cast<HTMLMediaElement*>(
         m_mediaPlayer->mediaPlayerClient())->document()->frame();
+
     m_webMediaPlayer.set(createWebMediaPlayer(this, frame));
     if (m_webMediaPlayer.get())
         m_webMediaPlayer->load(KURL(ParsedURLString, url));
@@ -157,6 +166,14 @@ void WebMediaPlayerClientImpl::cancelLoad()
         m_webMediaPlayer->cancelLoad();
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+WebCore::PlatformLayer* WebMediaPlayerClientImpl::platformLayer() const
+{
+    ASSERT(m_supportsAcceleratedCompositing);
+    return m_videoLayer.get();
+}
+#endif
+
 void WebMediaPlayerClientImpl::play()
 {
     if (m_webMediaPlayer.get())
@@ -360,6 +377,13 @@ bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const
     return false;
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+bool WebMediaPlayerClientImpl::supportsAcceleratedRendering() const
+{
+    return m_supportsAcceleratedCompositing;
+}
+#endif
+
 MediaPlayer::MovieLoadType WebMediaPlayerClientImpl::movieLoadType() const
 {
     if (m_webMediaPlayer.get())
@@ -372,6 +396,22 @@ MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create(MediaPlayer* playe
 {
     WebMediaPlayerClientImpl* client = new WebMediaPlayerClientImpl();
     client->m_mediaPlayer = player;
+
+#if USE(ACCELERATED_COMPOSITING)
+    Frame* frame = static_cast<HTMLMediaElement*>(
+        client->m_mediaPlayer->mediaPlayerClient())->document()->frame();
+
+    // This does not actually check whether the hardware can support accelerated
+    // compositing, but only if the flag is set. However, this is checked lazily
+    // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there
+    // if necessary.
+    client->m_supportsAcceleratedCompositing =
+        frame->contentRenderer()->compositor()->hasAcceleratedCompositing();
+
+    if (client->m_supportsAcceleratedCompositing)
+        client->m_videoLayer = VideoLayerChromium::create(0);
+#endif
+
     return client;
 }
 
@@ -402,6 +442,10 @@ MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& t
 
 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl()
     : m_mediaPlayer(0)
+#if USE(ACCELERATED_COMPOSITING)
+    , m_videoLayer(0)
+    , m_supportsAcceleratedCompositing(false)
+#endif
 {
 }
 
index 57c93b7..ff03b5b 100644 (file)
@@ -66,6 +66,9 @@ public:
     // MediaPlayerPrivateInterface methods:
     virtual void load(const WebCore::String& url);
     virtual void cancelLoad();
+#if USE(ACCELERATED_COMPOSITING)
+    virtual WebCore::PlatformLayer* platformLayer() const;
+#endif
     virtual void play();
     virtual void pause();
     virtual bool supportsFullscreen() const;
@@ -94,6 +97,10 @@ public:
     virtual void setSize(const WebCore::IntSize&);
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
     virtual bool hasSingleSecurityOrigin() const;
+#if USE(ACCELERATED_COMPOSITING)
+    virtual bool supportsAcceleratedRendering() const;
+#endif
+
     virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const;
 
 private:
@@ -106,6 +113,10 @@ private:
 
     WebCore::MediaPlayer* m_mediaPlayer;
     OwnPtr<WebMediaPlayer> m_webMediaPlayer;
+#if USE(ACCELERATED_COMPOSITING)
+    RefPtr<WebCore::PlatformLayer> m_videoLayer;
+    bool m_supportsAcceleratedCompositing;
+#endif
     static bool m_isEnabled;
 };