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

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

Issue 7493030: Split WebMediaPlayerImpl::Proxy into its own class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fixes Created 9 years, 4 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 | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 //
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
7 // extra careful about members shared by two different threads, especially
8 // video frame buffers.
9 4
10 #ifndef WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ 5 #ifndef WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_
11 #define WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ 6 #define WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_
12 7
13 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
14 #include "media/base/filters.h" 9 #include "media/base/filters.h"
15 #include "media/filters/video_renderer_base.h" 10 #include "media/filters/video_renderer_base.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "webkit/glue/media/web_video_renderer.h" 14 #include "webkit/glue/media/web_video_renderer.h"
20 #include "webkit/glue/webmediaplayer_impl.h"
21 15
22 namespace webkit_glue { 16 namespace webkit_glue {
23 17
18 // The video renderer implementation to be use by the media pipeline. It lives
19 // inside video renderer thread and also WebKit's main thread. We need to be
20 // extra careful about members shared by two different threads, especially
21 // video frame buffers.
24 class VideoRendererImpl : public WebVideoRenderer { 22 class VideoRendererImpl : public WebVideoRenderer {
25 public: 23 public:
26 explicit VideoRendererImpl(bool pts_logging); 24 explicit VideoRendererImpl(bool pts_logging);
27 virtual ~VideoRendererImpl(); 25 virtual ~VideoRendererImpl();
28 26
29 // WebVideoRenderer implementation. 27 // WebVideoRenderer implementation.
30 virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy); 28 virtual void SetWebMediaPlayerProxy(WebMediaPlayerProxy* proxy) OVERRIDE;
31 virtual void SetRect(const gfx::Rect& rect); 29 virtual void SetRect(const gfx::Rect& rect) OVERRIDE;
32 virtual void Paint(SkCanvas* canvas, const gfx::Rect& dest_rect); 30 virtual void Paint(SkCanvas* canvas, const gfx::Rect& dest_rect) OVERRIDE;
33 virtual void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out); 31 virtual void GetCurrentFrame(
34 virtual void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame); 32 scoped_refptr<media::VideoFrame>* frame_out) OVERRIDE;
33 virtual void PutCurrentFrame(
34 scoped_refptr<media::VideoFrame> frame) OVERRIDE;
35 35
36 protected: 36 protected:
37 // Method called by VideoRendererBase during initialization. 37 // VideoRendererBase implementation.
38 virtual bool OnInitialize(media::VideoDecoder* decoder); 38 virtual bool OnInitialize(media::VideoDecoder* decoder) OVERRIDE;
39 39 virtual void OnStop(media::FilterCallback* callback) OVERRIDE;
40 // Method called by the VideoRendererBase when stopping. 40 virtual void OnFrameAvailable() OVERRIDE;
41 virtual void OnStop(media::FilterCallback* callback);
42
43 // Method called by the VideoRendererBase when a frame is available.
44 virtual void OnFrameAvailable();
45 41
46 private: 42 private:
47 // Determine the conditions to perform fast paint. Returns true if we can do 43 // Determine the conditions to perform fast paint. Returns true if we can do
48 // fast paint otherwise false. 44 // fast paint otherwise false.
49 bool CanFastPaint(SkCanvas* canvas, const gfx::Rect& dest_rect); 45 bool CanFastPaint(SkCanvas* canvas, const gfx::Rect& dest_rect);
50 46
51 // Slow paint does a YUV => RGB, and scaled blit in two separate operations. 47 // Slow paint does a YUV => RGB, and scaled blit in two separate operations.
52 void SlowPaint(media::VideoFrame* video_frame, 48 void SlowPaint(media::VideoFrame* video_frame,
53 SkCanvas* canvas, 49 SkCanvas* canvas,
54 const gfx::Rect& dest_rect); 50 const gfx::Rect& dest_rect);
55 51
56 // Fast paint does YUV => RGB, scaling, blitting all in one step into the 52 // Fast paint does YUV => RGB, scaling, blitting all in one step into the
57 // canvas. It's not always safe and appropriate to perform fast paint. 53 // canvas. It's not always safe and appropriate to perform fast paint.
58 // CanFastPaint() is used to determine the conditions. 54 // CanFastPaint() is used to determine the conditions.
59 void FastPaint(media::VideoFrame* video_frame, 55 void FastPaint(media::VideoFrame* video_frame,
60 SkCanvas* canvas, 56 SkCanvas* canvas,
61 const gfx::Rect& dest_rect); 57 const gfx::Rect& dest_rect);
62 58
63 void TransformToSkIRect(const SkMatrix& matrix, const gfx::Rect& src_rect,
64 SkIRect* dest_rect);
65
66 // Pointer to our parent object that is called to request repaints. 59 // Pointer to our parent object that is called to request repaints.
67 scoped_refptr<WebMediaPlayerImpl::Proxy> proxy_; 60 scoped_refptr<WebMediaPlayerProxy> proxy_;
68 61
69 // An RGB bitmap used to convert the video frames. 62 // An RGB bitmap used to convert the video frames.
70 SkBitmap bitmap_; 63 SkBitmap bitmap_;
71 64
72 // These two members are used to determine if the |bitmap_| contains 65 // These two members are used to determine if the |bitmap_| contains
73 // an already converted image of the current frame. IMPORTANT NOTE: The 66 // an already converted image of the current frame. IMPORTANT NOTE: The
74 // value of |last_converted_frame_| must only be used for comparison purposes, 67 // value of |last_converted_frame_| must only be used for comparison purposes,
75 // and it should be assumed that the value of the pointer is INVALID unless 68 // and it should be assumed that the value of the pointer is INVALID unless
76 // it matches the pointer returned from GetCurrentFrame(). Even then, just 69 // it matches the pointer returned from GetCurrentFrame(). Even then, just
77 // to make sure, we compare the timestamp to be sure the bits in the 70 // to make sure, we compare the timestamp to be sure the bits in the
78 // |current_frame_bitmap_| are valid. 71 // |current_frame_bitmap_| are valid.
79 media::VideoFrame* last_converted_frame_; 72 media::VideoFrame* last_converted_frame_;
80 base::TimeDelta last_converted_timestamp_; 73 base::TimeDelta last_converted_timestamp_;
81 74
82 // The size of the video. 75 // The size of the video.
83 gfx::Size video_size_; 76 gfx::Size video_size_;
84 77
85 // Whether we're logging video presentation timestamps (PTS). 78 // Whether we're logging video presentation timestamps (PTS).
86 bool pts_logging_; 79 bool pts_logging_;
87 80
88 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 81 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
89 }; 82 };
90 83
91 } // namespace webkit_glue 84 } // namespace webkit_glue
92 85
93 #endif // WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_ 86 #endif // WEBKIT_GLUE_MEDIA_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/media/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698