OLD | NEW |
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 | 4 |
5 #include "webkit/glue/media/video_renderer_impl.h" | 5 #include "webkit/glue/media/video_renderer_impl.h" |
6 | 6 |
| 7 #include "base/logging.h" |
7 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
8 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
9 #include "webkit/glue/webmediaplayer_impl.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #include "third_party/skia/include/core/SkDevice.h" |
| 12 #include "webkit/glue/webmediaplayer_proxy.h" |
| 13 |
| 14 // Transform destination rect to local coordinates. |
| 15 static void TransformToSkIRect(const SkMatrix& matrix, |
| 16 const gfx::Rect& src_rect, |
| 17 SkIRect* dest_rect) { |
| 18 SkRect transformed_rect; |
| 19 SkRect skia_dest_rect; |
| 20 skia_dest_rect.iset(src_rect.x(), src_rect.y(), |
| 21 src_rect.right(), src_rect.bottom()); |
| 22 matrix.mapRect(&transformed_rect, skia_dest_rect); |
| 23 transformed_rect.round(dest_rect); |
| 24 } |
10 | 25 |
11 namespace webkit_glue { | 26 namespace webkit_glue { |
12 | 27 |
13 VideoRendererImpl::VideoRendererImpl(bool pts_logging) | 28 VideoRendererImpl::VideoRendererImpl(bool pts_logging) |
14 : last_converted_frame_(NULL), | 29 : last_converted_frame_(NULL), |
15 pts_logging_(pts_logging) { | 30 pts_logging_(pts_logging) { |
16 } | 31 } |
17 | 32 |
18 VideoRendererImpl::~VideoRendererImpl() {} | 33 VideoRendererImpl::~VideoRendererImpl() {} |
19 | 34 |
(...skipping 10 matching lines...) Expand all Loading... |
30 if (callback) { | 45 if (callback) { |
31 callback->Run(); | 46 callback->Run(); |
32 delete callback; | 47 delete callback; |
33 } | 48 } |
34 } | 49 } |
35 | 50 |
36 void VideoRendererImpl::OnFrameAvailable() { | 51 void VideoRendererImpl::OnFrameAvailable() { |
37 proxy_->Repaint(); | 52 proxy_->Repaint(); |
38 } | 53 } |
39 | 54 |
40 void VideoRendererImpl::SetWebMediaPlayerImplProxy( | 55 void VideoRendererImpl::SetWebMediaPlayerProxy(WebMediaPlayerProxy* proxy) { |
41 WebMediaPlayerImpl::Proxy* proxy) { | |
42 proxy_ = proxy; | 56 proxy_ = proxy; |
43 } | 57 } |
44 | 58 |
45 void VideoRendererImpl::SetRect(const gfx::Rect& rect) { | 59 void VideoRendererImpl::SetRect(const gfx::Rect& rect) {} |
46 } | |
47 | 60 |
48 // This method is always called on the renderer's thread. | 61 // This method is always called on the renderer's thread. |
49 void VideoRendererImpl::Paint(SkCanvas* canvas, | 62 void VideoRendererImpl::Paint(SkCanvas* canvas, |
50 const gfx::Rect& dest_rect) { | 63 const gfx::Rect& dest_rect) { |
51 scoped_refptr<media::VideoFrame> video_frame; | 64 scoped_refptr<media::VideoFrame> video_frame; |
52 GetCurrentFrame(&video_frame); | 65 GetCurrentFrame(&video_frame); |
53 if (!video_frame) { | 66 if (!video_frame) { |
54 SkPaint paint; | 67 SkPaint paint; |
55 paint.setColor(SK_ColorBLACK); | 68 paint.setColor(SK_ColorBLACK); |
56 canvas->drawRectCoords( | 69 canvas->drawRectCoords( |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 video_frame->stride(media::VideoFrame::kYPlane), | 305 video_frame->stride(media::VideoFrame::kYPlane), |
293 video_frame->stride(media::VideoFrame::kUPlane), | 306 video_frame->stride(media::VideoFrame::kUPlane), |
294 bitmap.rowBytes(), | 307 bitmap.rowBytes(), |
295 yuv_type, | 308 yuv_type, |
296 media::ROTATE_0, | 309 media::ROTATE_0, |
297 media::FILTER_BILINEAR); | 310 media::FILTER_BILINEAR); |
298 bitmap.unlockPixels(); | 311 bitmap.unlockPixels(); |
299 } | 312 } |
300 } | 313 } |
301 | 314 |
302 void VideoRendererImpl::TransformToSkIRect(const SkMatrix& matrix, | |
303 const gfx::Rect& src_rect, | |
304 SkIRect* dest_rect) { | |
305 // Transform destination rect to local coordinates. | |
306 SkRect transformed_rect; | |
307 SkRect skia_dest_rect; | |
308 skia_dest_rect.iset(src_rect.x(), src_rect.y(), | |
309 src_rect.right(), src_rect.bottom()); | |
310 matrix.mapRect(&transformed_rect, skia_dest_rect); | |
311 transformed_rect.round(dest_rect); | |
312 } | |
313 | |
314 } // namespace webkit_glue | 315 } // namespace webkit_glue |
OLD | NEW |