diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 17:31:49 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 17:31:49 +0000 |
commit | 8931c41ae5392aab1c70f9c9b4e4c64061fdd9af (patch) | |
tree | be0d4f804f0e5964ffbd093b26d8c3fe96f443c3 /webkit/glue/media | |
parent | 7de37fb6af07c84deee63f6a1baec91e0290c830 (diff) | |
download | chromium_src-8931c41ae5392aab1c70f9c9b4e4c64061fdd9af.zip chromium_src-8931c41ae5392aab1c70f9c9b4e4c64061fdd9af.tar.gz chromium_src-8931c41ae5392aab1c70f9c9b4e4c64061fdd9af.tar.bz2 |
Refactoring to introduce refcount to WebMediaPlayerImpl
WebMediaPlayerImpl interacts with multiple threads that it
becomes necessary to make it refcounted so we can post task
on different threads' message loop.
Review URL: http://codereview.chromium.org/147225
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20038 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r-- | webkit/glue/media/video_renderer_impl.cc | 14 | ||||
-rw-r--r-- | webkit/glue/media/video_renderer_impl.h | 15 |
2 files changed, 15 insertions, 14 deletions
diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc index 9137fb3..a7dc980 100644 --- a/webkit/glue/media/video_renderer_impl.cc +++ b/webkit/glue/media/video_renderer_impl.cc @@ -9,12 +9,12 @@ namespace webkit_glue { -VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl* delegate) - : delegate_(delegate), + VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy) + : proxy_(proxy), last_converted_frame_(NULL) { // TODO(hclam): decide whether to do the following line in this thread or // in the render thread. - delegate_->SetVideoRenderer(this); + proxy->SetVideoRenderer(this); } // static @@ -25,7 +25,6 @@ bool VideoRendererImpl::IsMediaFormatSupported( return ParseMediaFormat(media_format, &width, &height); } - bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) { int width = 0; int height = 0; @@ -44,11 +43,14 @@ bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) { } void VideoRendererImpl::OnStop() { - delegate_->SetVideoRenderer(NULL); + DCHECK(proxy_); + proxy_->SetVideoRenderer(NULL); + proxy_ = NULL; } void VideoRendererImpl::OnFrameAvailable() { - delegate_->PostRepaintTask(); + DCHECK(proxy_); + proxy_->Repaint(); } void VideoRendererImpl::SetRect(const gfx::Rect& rect) { diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h index ee251a5..d57223e 100644 --- a/webkit/glue/media/video_renderer_impl.h +++ b/webkit/glue/media/video_renderer_impl.h @@ -22,14 +22,13 @@ #include "media/base/filters.h" #include "media/filters/video_renderer_base.h" #include "webkit/api/public/WebMediaPlayer.h" +#include "webkit/glue/webmediaplayer_impl.h" namespace webkit_glue { -class WebMediaPlayerImpl; - class VideoRendererImpl : public media::VideoRendererBase { public: - // Methods for painting called by the WebMediaPlayerDelegateImpl + // 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 + @@ -42,9 +41,9 @@ class VideoRendererImpl : public media::VideoRendererBase { virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); // Static method for creating factory for this object. - static media::FilterFactory* CreateFactory(WebMediaPlayerImpl* delegate) { + static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy) { return new media::FilterFactoryImpl1<VideoRendererImpl, - WebMediaPlayerImpl*>(delegate); + WebMediaPlayerImpl::Proxy*>(proxy); } // FilterFactoryImpl1 implementation. @@ -63,8 +62,8 @@ class VideoRendererImpl : public media::VideoRendererBase { private: // Only the filter factories can create instances. friend class media::FilterFactoryImpl1<VideoRendererImpl, - WebMediaPlayerImpl*>; - explicit VideoRendererImpl(WebMediaPlayerImpl* delegate); + WebMediaPlayerImpl::Proxy*>; + explicit VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy); virtual ~VideoRendererImpl() {} // Determine the conditions to perform fast paint. Returns true if we can do @@ -87,7 +86,7 @@ class VideoRendererImpl : public media::VideoRendererBase { SkIRect* dest_rect); // Pointer to our parent object that is called to request repaints. - WebMediaPlayerImpl* delegate_; + scoped_refptr<WebMediaPlayerImpl::Proxy> proxy_; // An RGB bitmap used to convert the video frames. SkBitmap bitmap_; |