summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-07-22 15:37:06 +0100
committerBen Murdoch <benm@google.com>2010-07-27 10:20:25 +0100
commit967717af5423377c967781471ee106e2bb4e11c8 (patch)
tree1e701dc0a12f7f07cce1df4a7681717de77a211b /WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
parentdcc30a9fca45f634b1d3a12b276d3a0ccce99fc3 (diff)
downloadexternal_webkit-967717af5423377c967781471ee106e2bb4e11c8.zip
external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.gz
external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.bz2
Merge WebKit at r63859 : Initial merge by git.
Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62
Diffstat (limited to 'WebKit/chromium/src/WebMediaPlayerClientImpl.cpp')
-rw-r--r--WebKit/chromium/src/WebMediaPlayerClientImpl.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
index 03051c3..2b0c9a7 100644
--- a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
+++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
@@ -14,7 +14,13 @@
#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"
@@ -22,12 +28,14 @@
#include "WebFrameImpl.h"
#include "WebKit.h"
#include "WebKitClient.h"
+#include "WebMediaElement.h"
#include "WebMediaPlayer.h"
#include "WebMimeRegistry.h"
#include "WebRect.h"
#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 +53,7 @@ static WebMediaPlayer* createWebMediaPlayer(
WebMediaPlayerClient* client, Frame* frame)
{
WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
+
if (!webFrame->client())
return 0;
return webFrame->client()->createMediaPlayer(webFrame, client);
@@ -71,6 +80,17 @@ void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar)
}
}
+WebMediaPlayerClientImpl* WebMediaPlayerClientImpl::fromMediaElement(const WebMediaElement* element)
+{
+ PlatformMedia pm = element->constUnwrap<HTMLMediaElement>()->platformMedia();
+ return static_cast<WebMediaPlayerClientImpl*>(pm.media.chromiumMediaPlayer);
+}
+
+WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const
+{
+ return m_webMediaPlayer.get();
+}
+
// WebMediaPlayerClient --------------------------------------------------------
void WebMediaPlayerClientImpl::networkStateChanged()
@@ -146,6 +166,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 +178,22 @@ void WebMediaPlayerClientImpl::cancelLoad()
m_webMediaPlayer->cancelLoad();
}
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* WebMediaPlayerClientImpl::platformLayer() const
+{
+ ASSERT(m_supportsAcceleratedCompositing);
+ return m_videoLayer.get();
+}
+#endif
+
+PlatformMedia WebMediaPlayerClientImpl::platformMedia() const
+{
+ PlatformMedia pm;
+ pm.type = PlatformMedia::ChromiumMediaPlayerType;
+ pm.media.chromiumMediaPlayer = const_cast<WebMediaPlayerClientImpl*>(this);
+ return pm;
+}
+
void WebMediaPlayerClientImpl::play()
{
if (m_webMediaPlayer.get())
@@ -360,6 +397,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 +416,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 +462,10 @@ MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& t
WebMediaPlayerClientImpl::WebMediaPlayerClientImpl()
: m_mediaPlayer(0)
+#if USE(ACCELERATED_COMPOSITING)
+ , m_videoLayer(0)
+ , m_supportsAcceleratedCompositing(false)
+#endif
{
}