diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 18:50:11 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 18:50:11 +0000 |
commit | 8400e0328996ef46e390903b6c378549f7b13aa3 (patch) | |
tree | 351883f0cdc05aca6f61c0ca0cf9bb945d0b807d /webkit | |
parent | 7386be50a212a569840f8da41be445cb00e90beb (diff) | |
download | chromium_src-8400e0328996ef46e390903b6c378549f7b13aa3.zip chromium_src-8400e0328996ef46e390903b6c378549f7b13aa3.tar.gz chromium_src-8400e0328996ef46e390903b6c378549f7b13aa3.tar.bz2 |
Initial work for cross-process video rendering using layers.
Introduces VideoLayer, which is similar to BackingStore except handles YUV surfaces and conversion to RGB.
BUG=33329
TEST=N/A
Review URL: http://codereview.chromium.org/597066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/media/video_renderer_impl.cc | 7 | ||||
-rw-r--r-- | webkit/glue/media/video_renderer_impl.h | 37 | ||||
-rw-r--r-- | webkit/glue/media/web_video_renderer.h | 39 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 15 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.h | 54 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 4 | ||||
-rw-r--r-- | webkit/webkit.gyp | 1 |
7 files changed, 122 insertions, 35 deletions
diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc index a7dc980..ba06d1c 100644 --- a/webkit/glue/media/video_renderer_impl.cc +++ b/webkit/glue/media/video_renderer_impl.cc @@ -18,6 +18,13 @@ namespace webkit_glue { } // static +media::FilterFactory* VideoRendererImpl::CreateFactory( + WebMediaPlayerImpl::Proxy* proxy) { + return new media::FilterFactoryImpl1<VideoRendererImpl, + WebMediaPlayerImpl::Proxy*>(proxy); +} + +// static bool VideoRendererImpl::IsMediaFormatSupported( const media::MediaFormat& media_format) { int width = 0; diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h index b0fde12..4bc7210 100644 --- a/webkit/glue/media/video_renderer_impl.h +++ b/webkit/glue/media/video_renderer_impl.h @@ -6,10 +6,6 @@ // inside video renderer thread and also WebKit's main thread. We need to be // extra careful about members shared by two different threads, especially // video frame buffers. -// -// Methods called from WebKit's main thread: -// Paint() -// SetRect() #ifndef WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ #define WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ @@ -17,38 +13,41 @@ #include "base/gfx/rect.h" #include "base/gfx/size.h" #include "media/base/buffers.h" -#include "media/base/factory.h" #include "media/base/filters.h" #include "media/filters/video_renderer_base.h" #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayer.h" +#include "webkit/glue/media/web_video_renderer.h" #include "webkit/glue/webmediaplayer_impl.h" namespace webkit_glue { -class VideoRendererImpl : public media::VideoRendererBase { +class VideoRendererImpl : public WebVideoRenderer { public: - // Methods for painting called by the WebMediaPlayerImpl::Proxy - - // This method is called with the same rect as the Paint method and could - // be used by future implementations to implement an improved color space + - // scale code on a separate thread. Since we always do the stretch on the - // same thread as the Paint method, we just ignore the call for now. + // WebVideoRenderer implementation. virtual void SetRect(const gfx::Rect& rect); - - // Paint the current front frame on the |canvas| stretching it to fit the - // |dest_rect| virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); // Static method for creating factory for this object. - static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy) { - return new media::FilterFactoryImpl1<VideoRendererImpl, - WebMediaPlayerImpl::Proxy*>(proxy); - } + static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy); // FilterFactoryImpl1 implementation. static bool IsMediaFormatSupported(const media::MediaFormat& media_format); + // TODO(scherkus): remove this mega-hack, see http://crbug.com/28207 + class FactoryFactory : public webkit_glue::WebVideoRendererFactoryFactory { + public: + FactoryFactory() : webkit_glue::WebVideoRendererFactoryFactory() {} + + virtual media::FilterFactory* CreateFactory( + webkit_glue::WebMediaPlayerImpl::Proxy* proxy) { + return VideoRendererImpl::CreateFactory(proxy); + } + + private: + DISALLOW_COPY_AND_ASSIGN(FactoryFactory); + }; + protected: // Method called by VideoRendererBase during initialization. virtual bool OnInitialize(media::VideoDecoder* decoder); diff --git a/webkit/glue/media/web_video_renderer.h b/webkit/glue/media/web_video_renderer.h new file mode 100644 index 0000000..8bafb1a --- /dev/null +++ b/webkit/glue/media/web_video_renderer.h @@ -0,0 +1,39 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#ifndef WEBKIT_GLUE_MEDIA_WEB_VIDEO_RENDERER_H_ +#define WEBKIT_GLUE_MEDIA_WEB_VIDEO_RENDERER_H_ + +#include "media/filters/video_renderer_base.h" + +namespace webkit_glue { + +// A specialized version of a VideoRenderer designed to be used inside WebKit. +class WebVideoRenderer : public media::VideoRendererBase { + public: + WebVideoRenderer() : media::VideoRendererBase() {} + virtual ~WebVideoRenderer() {} + + // This method is called with the same rect as the Paint() method and could + // be used by future implementations to implement an improved color space + + // scale code on a separate thread. Since we always do the stretch on the + // same thread as the Paint method, we just ignore the call for now. + // + // Method called on the render thread. + virtual void SetRect(const gfx::Rect& rect) = 0; + + // Paint the current front frame on the |canvas| stretching it to fit the + // |dest_rect|. + // + // Method called on the render thread. + virtual void Paint(skia::PlatformCanvas* canvas, + const gfx::Rect& dest_rect) = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(WebVideoRenderer); +}; + +} // namespace webkit_glue + +#endif // WEBKIT_GLUE_MEDIA_WEB_VIDEO_RENDERER_H_ diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index da4339a..8dd46b5 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,6 +18,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "webkit/glue/media/video_renderer_impl.h" +#include "webkit/glue/media/web_video_renderer.h" using WebKit::WebCanvas; using WebKit::WebRect; @@ -80,7 +81,7 @@ void WebMediaPlayerImpl::Proxy::Repaint() { } void WebMediaPlayerImpl::Proxy::SetVideoRenderer( - VideoRendererImpl* video_renderer) { + WebVideoRenderer* video_renderer) { video_renderer_ = video_renderer; } @@ -181,7 +182,9 @@ void WebMediaPlayerImpl::Proxy::NetworkEventTask() { // WebMediaPlayerImpl implementation WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, - media::FilterFactoryCollection* factory) + media::FilterFactoryCollection* factory, + WebVideoRendererFactoryFactory* + video_renderer_factory) : network_state_(WebKit::WebMediaPlayer::Empty), ready_state_(WebKit::WebMediaPlayer::HaveNothing), main_loop_(NULL), @@ -194,6 +197,10 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, DCHECK(!main_loop_); main_loop_ = MessageLoop::current(); + // Make sure this gets deleted. + scoped_ptr<WebVideoRendererFactoryFactory> + scoped_video_renderer_factory(video_renderer_factory); + // Create the pipeline and its thread. if (!pipeline_thread_.Start()) { NOTREACHED() << "Could not start PipelineThread"; @@ -225,7 +232,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, } filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory()); filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory()); - filter_factory_->AddFactory(VideoRendererImpl::CreateFactory(proxy_)); + filter_factory_->AddFactory(video_renderer_factory->CreateFactory(proxy_)); } WebMediaPlayerImpl::~WebMediaPlayerImpl() { diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h index 7e2d8b2..b44cc62 100644 --- a/webkit/glue/webmediaplayer_impl.h +++ b/webkit/glue/webmediaplayer_impl.h @@ -1,7 +1,7 @@ -// Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. -// +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. // It contains PipelineImpl which is the actual media player pipeline, it glues // the media player pipeline, data source, audio renderer and renderer. @@ -14,7 +14,7 @@ // media::PipelineImpl // The media playback pipeline. // -// VideoRendererImpl +// WebVideoRenderer // Video renderer object. // // WebMediaPlayerImpl::Proxy @@ -29,7 +29,7 @@ // WebMediaPlayerImpl ------> PipelineImpl // | ^ | r // | | v -// | | VideoRendererImpl +// | | WebVideoRenderer // | | ^ r // | | | // | r | r | @@ -39,7 +39,7 @@ // v // WebMediaPlayerClient // -// Notice that Proxy and VideoRendererImpl are referencing each other. This +// Notice that Proxy and WebVideoRenderer are referencing each other. This // interdependency has to be treated carefully. // // Other issues: @@ -60,6 +60,7 @@ #include "base/lock.h" #include "base/message_loop.h" #include "base/ref_counted.h" +#include "ipc/ipc_message.h" #include "media/base/filters.h" #include "media/base/pipeline_impl.h" #include "skia/ext/platform_canvas.h" @@ -74,7 +75,8 @@ class FilterFactoryCollection; namespace webkit_glue { -class VideoRendererImpl; +class WebVideoRenderer; +class WebVideoRendererFactoryFactory; class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, public MessageLoop::DestructionObserver { @@ -94,7 +96,7 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // Public methods called from the video renderer. void Repaint(); - void SetVideoRenderer(VideoRendererImpl* video_renderer); + void SetVideoRenderer(WebVideoRenderer* video_renderer); // Public methods called from WebMediaPlayerImpl. void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); @@ -109,6 +111,9 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, void PipelineErrorCallback(); void NetworkEventCallback(); + // Returns the message loop used by the proxy. + MessageLoop* message_loop() { return render_loop_; } + private: friend class base::RefCountedThreadSafe<Proxy>; @@ -135,7 +140,7 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // The render message loop where WebKit lives. MessageLoop* render_loop_; WebMediaPlayerImpl* webmediaplayer_; - scoped_refptr<VideoRendererImpl> video_renderer_; + scoped_refptr<WebVideoRenderer> video_renderer_; Lock lock_; int outstanding_repaints_; @@ -161,8 +166,12 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // audio renderer is a fake audio device that plays silence. Provider of the // |factory| can override the default filters by adding extra filters to // |factory| before calling this method. + // + // |video_renderer_factory| is used to construct a factory that should create + // a subclass of WebVideoRenderer. Is deleted by WebMediaPlayerImpl. WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, - media::FilterFactoryCollection* factory); + media::FilterFactoryCollection* factory, + WebVideoRendererFactoryFactory* video_renderer_factory); virtual ~WebMediaPlayerImpl(); virtual void load(const WebKit::WebURL& url); @@ -295,6 +304,29 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); }; +// TODO(scherkus): WebMediaPlayerImpl creates and injects its Proxy into a +// video renderer factory, so we need to (unfortunately) have a factory of a +// factory so we can receive the proxy pointer without violating the +// separation of renderer code from webkit glue code. This is part of a +// longer-term plan to rethink our FilterFactory strategy (refer to +// http://crbug.com/28207). +// +// Either that or we rethink this Proxy business as a short-term solution. +class WebVideoRendererFactoryFactory { + public: + WebVideoRendererFactoryFactory() {} + virtual ~WebVideoRendererFactoryFactory() {} + + // Creates a FilterFactory which should be capable of creating a + // WebVideoRenderer subclass. + virtual media::FilterFactory* CreateFactory( + WebMediaPlayerImpl::Proxy* proxy) = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(WebVideoRendererFactoryFactory); +}; + + } // namespace webkit_glue #endif // WEBKIT_GLUE_WEBMEDIAPLAYER_IMPL_H_ diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 4c5db40..1cff673 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -44,6 +44,7 @@ #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" #include "webkit/glue/media/simple_data_source.h" +#include "webkit/glue/media/video_renderer_impl.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webplugin_impl.h" #include "webkit/glue/webpreferences.h" @@ -667,7 +668,8 @@ WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( bridge_factory); factory->AddFactory(buffered_data_source_factory); factory->AddFactory(simple_data_source_factory); - return new webkit_glue::WebMediaPlayerImpl(client, factory); + return new webkit_glue::WebMediaPlayerImpl( + client, factory, new webkit_glue::VideoRendererImpl::FactoryFactory()); } bool TestWebViewDelegate::allowPlugins(WebFrame* frame, diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 4c1f9a1..fce94944 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -240,6 +240,7 @@ 'glue/media/simple_data_source.h', 'glue/media/video_renderer_impl.cc', 'glue/media/video_renderer_impl.h', + 'glue/media/web_video_renderer.h', 'glue/plugins/coregraphics_private_symbols_mac.h', 'glue/plugins/nphostapi.h', 'glue/plugins/fake_plugin_window_tracker_mac.h', |