Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: webkit/glue/media/video_renderer_impl.h

Issue 147225: Refactoring to introduce refcount to WebMediaPlayerImpl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/api/src/WebMediaPlayerClientImpl.cpp ('k') | webkit/glue/media/video_renderer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 // 4 //
5 // The video renderer implementation to be use by the media pipeline. It lives 5 // The video renderer implementation to be use by the media pipeline. It lives
6 // inside video renderer thread and also WebKit's main thread. We need to be 6 // inside video renderer thread and also WebKit's main thread. We need to be
7 // extra careful about members shared by two different threads, especially 7 // extra careful about members shared by two different threads, especially
8 // video frame buffers. 8 // video frame buffers.
9 // 9 //
10 // Methods called from WebKit's main thread: 10 // Methods called from WebKit's main thread:
11 // Paint() 11 // Paint()
12 // SetRect() 12 // SetRect()
13 13
14 #ifndef WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ 14 #ifndef WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_
15 #define WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ 15 #define WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_
16 16
17 #include "base/gfx/platform_canvas.h" 17 #include "base/gfx/platform_canvas.h"
18 #include "base/gfx/rect.h" 18 #include "base/gfx/rect.h"
19 #include "base/gfx/size.h" 19 #include "base/gfx/size.h"
20 #include "media/base/buffers.h" 20 #include "media/base/buffers.h"
21 #include "media/base/factory.h" 21 #include "media/base/factory.h"
22 #include "media/base/filters.h" 22 #include "media/base/filters.h"
23 #include "media/filters/video_renderer_base.h" 23 #include "media/filters/video_renderer_base.h"
24 #include "webkit/api/public/WebMediaPlayer.h" 24 #include "webkit/api/public/WebMediaPlayer.h"
25 #include "webkit/glue/webmediaplayer_impl.h"
25 26
26 namespace webkit_glue { 27 namespace webkit_glue {
27 28
28 class WebMediaPlayerImpl;
29
30 class VideoRendererImpl : public media::VideoRendererBase { 29 class VideoRendererImpl : public media::VideoRendererBase {
31 public: 30 public:
32 // Methods for painting called by the WebMediaPlayerDelegateImpl 31 // Methods for painting called by the WebMediaPlayerImpl::Proxy
33 32
34 // This method is called with the same rect as the Paint method and could 33 // This method is called with the same rect as the Paint method and could
35 // be used by future implementations to implement an improved color space + 34 // be used by future implementations to implement an improved color space +
36 // scale code on a separate thread. Since we always do the stretch on the 35 // scale code on a separate thread. Since we always do the stretch on the
37 // same thread as the Paint method, we just ignore the call for now. 36 // same thread as the Paint method, we just ignore the call for now.
38 virtual void SetRect(const gfx::Rect& rect); 37 virtual void SetRect(const gfx::Rect& rect);
39 38
40 // Paint the current front frame on the |canvas| stretching it to fit the 39 // Paint the current front frame on the |canvas| stretching it to fit the
41 // |dest_rect| 40 // |dest_rect|
42 virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); 41 virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
43 42
44 // Static method for creating factory for this object. 43 // Static method for creating factory for this object.
45 static media::FilterFactory* CreateFactory(WebMediaPlayerImpl* delegate) { 44 static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy) {
46 return new media::FilterFactoryImpl1<VideoRendererImpl, 45 return new media::FilterFactoryImpl1<VideoRendererImpl,
47 WebMediaPlayerImpl*>(delegate); 46 WebMediaPlayerImpl::Proxy*>(proxy);
48 } 47 }
49 48
50 // FilterFactoryImpl1 implementation. 49 // FilterFactoryImpl1 implementation.
51 static bool IsMediaFormatSupported(const media::MediaFormat& media_format); 50 static bool IsMediaFormatSupported(const media::MediaFormat& media_format);
52 51
53 protected: 52 protected:
54 // Method called by VideoRendererBase during initialization. 53 // Method called by VideoRendererBase during initialization.
55 virtual bool OnInitialize(media::VideoDecoder* decoder); 54 virtual bool OnInitialize(media::VideoDecoder* decoder);
56 55
57 // Method called by the VideoRendererBase when stopping. 56 // Method called by the VideoRendererBase when stopping.
58 virtual void OnStop(); 57 virtual void OnStop();
59 58
60 // Method called by the VideoRendererBase when a frame is available. 59 // Method called by the VideoRendererBase when a frame is available.
61 virtual void OnFrameAvailable(); 60 virtual void OnFrameAvailable();
62 61
63 private: 62 private:
64 // Only the filter factories can create instances. 63 // Only the filter factories can create instances.
65 friend class media::FilterFactoryImpl1<VideoRendererImpl, 64 friend class media::FilterFactoryImpl1<VideoRendererImpl,
66 WebMediaPlayerImpl*>; 65 WebMediaPlayerImpl::Proxy*>;
67 explicit VideoRendererImpl(WebMediaPlayerImpl* delegate); 66 explicit VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy);
68 virtual ~VideoRendererImpl() {} 67 virtual ~VideoRendererImpl() {}
69 68
70 // Determine the conditions to perform fast paint. Returns true if we can do 69 // Determine the conditions to perform fast paint. Returns true if we can do
71 // fast paint otherwise false. 70 // fast paint otherwise false.
72 bool CanFastPaint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); 71 bool CanFastPaint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
73 72
74 // Slow paint does a YUV => RGB, and scaled blit in two separate operations. 73 // Slow paint does a YUV => RGB, and scaled blit in two separate operations.
75 void SlowPaint(media::VideoFrame* video_frame, 74 void SlowPaint(media::VideoFrame* video_frame,
76 skia::PlatformCanvas* canvas, 75 skia::PlatformCanvas* canvas,
77 const gfx::Rect& dest_rect); 76 const gfx::Rect& dest_rect);
78 77
79 // Fast paint does YUV => RGB, scaling, blitting all in one step into the 78 // Fast paint does YUV => RGB, scaling, blitting all in one step into the
80 // canvas. It's not always safe and appropriate to perform fast paint. 79 // canvas. It's not always safe and appropriate to perform fast paint.
81 // CanFastPaint() is used to determine the conditions. 80 // CanFastPaint() is used to determine the conditions.
82 void FastPaint(media::VideoFrame* video_frame, 81 void FastPaint(media::VideoFrame* video_frame,
83 skia::PlatformCanvas* canvas, 82 skia::PlatformCanvas* canvas,
84 const gfx::Rect& dest_rect); 83 const gfx::Rect& dest_rect);
85 84
86 void TransformToSkIRect(const SkMatrix& matrix, const gfx::Rect& src_rect, 85 void TransformToSkIRect(const SkMatrix& matrix, const gfx::Rect& src_rect,
87 SkIRect* dest_rect); 86 SkIRect* dest_rect);
88 87
89 // Pointer to our parent object that is called to request repaints. 88 // Pointer to our parent object that is called to request repaints.
90 WebMediaPlayerImpl* delegate_; 89 scoped_refptr<WebMediaPlayerImpl::Proxy> proxy_;
91 90
92 // An RGB bitmap used to convert the video frames. 91 // An RGB bitmap used to convert the video frames.
93 SkBitmap bitmap_; 92 SkBitmap bitmap_;
94 93
95 // These two members are used to determine if the |bitmap_| contains 94 // These two members are used to determine if the |bitmap_| contains
96 // an already converted image of the current frame. IMPORTANT NOTE: The 95 // an already converted image of the current frame. IMPORTANT NOTE: The
97 // value of |last_converted_frame_| must only be used for comparison purposes, 96 // value of |last_converted_frame_| must only be used for comparison purposes,
98 // and it should be assumed that the value of the pointer is INVALID unless 97 // and it should be assumed that the value of the pointer is INVALID unless
99 // it matches the pointer returned from GetCurrentFrame(). Even then, just 98 // it matches the pointer returned from GetCurrentFrame(). Even then, just
100 // to make sure, we compare the timestamp to be sure the bits in the 99 // to make sure, we compare the timestamp to be sure the bits in the
101 // |current_frame_bitmap_| are valid. 100 // |current_frame_bitmap_| are valid.
102 media::VideoFrame* last_converted_frame_; 101 media::VideoFrame* last_converted_frame_;
103 base::TimeDelta last_converted_timestamp_; 102 base::TimeDelta last_converted_timestamp_;
104 103
105 // The size of the video. 104 // The size of the video.
106 gfx::Size video_size_; 105 gfx::Size video_size_;
107 106
108 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 107 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
109 }; 108 };
110 109
111 } // namespace webkit_glue 110 } // namespace webkit_glue
112 111
113 #endif // WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ 112 #endif // WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/api/src/WebMediaPlayerClientImpl.cpp ('k') | webkit/glue/media/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698