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 "base/logging.h" |
8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
11 #include "third_party/skia/include/core/SkDevice.h" | 11 #include "third_party/skia/include/core/SkDevice.h" |
12 #include "webkit/glue/webmediaplayer_proxy.h" | 12 #include "webkit/glue/webmediaplayer_proxy.h" |
13 | 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 } | |
25 | |
26 namespace webkit_glue { | 14 namespace webkit_glue { |
27 | 15 |
28 VideoRendererImpl::VideoRendererImpl(bool pts_logging) | 16 VideoRendererImpl::VideoRendererImpl(bool pts_logging) |
29 : last_converted_frame_(NULL), | 17 : last_converted_frame_(NULL), |
30 pts_logging_(pts_logging) { | 18 pts_logging_(pts_logging) { |
31 } | 19 } |
32 | 20 |
33 VideoRendererImpl::~VideoRendererImpl() {} | 21 VideoRendererImpl::~VideoRendererImpl() {} |
34 | 22 |
35 bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) { | 23 bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 108 |
121 const SkMatrix& total_matrix = canvas->getTotalMatrix(); | 109 const SkMatrix& total_matrix = canvas->getTotalMatrix(); |
122 // Perform the following checks here: | 110 // Perform the following checks here: |
123 // 1. Check for skewing factors of the transformation matrix. They should be | 111 // 1. Check for skewing factors of the transformation matrix. They should be |
124 // zero. | 112 // zero. |
125 // 2. Check for mirroring and flipping. Make sure they are greater than zero. | 113 // 2. Check for mirroring and flipping. Make sure they are greater than zero. |
126 if (SkScalarNearlyZero(total_matrix.getSkewX()) && | 114 if (SkScalarNearlyZero(total_matrix.getSkewX()) && |
127 SkScalarNearlyZero(total_matrix.getSkewY()) && | 115 SkScalarNearlyZero(total_matrix.getSkewY()) && |
128 total_matrix.getScaleX() > 0 && | 116 total_matrix.getScaleX() > 0 && |
129 total_matrix.getScaleY() > 0) { | 117 total_matrix.getScaleY() > 0) { |
130 // Get the properties of the SkDevice and the clip rect. | 118 // Get the properties of the SkDevice |
scherkus (not reviewing)
2011/08/30 17:21:38
I was going to nit about adding a period, but this
reed1
2011/08/30 17:42:16
Done.
| |
131 SkDevice* device = canvas->getDevice(); | 119 SkDevice* device = canvas->getDevice(); |
132 | 120 |
133 // Get the boundary of the device. | |
134 SkIRect device_rect; | |
135 device->getBounds(&device_rect); | |
136 | |
137 // Get the pixel config of the device. | 121 // Get the pixel config of the device. |
138 const SkBitmap::Config config = device->config(); | 122 const SkBitmap::Config config = device->config(); |
139 // Get the total clip rect associated with the canvas. | |
140 const SkRegion& total_clip = canvas->getTotalClip(); | |
141 | 123 |
142 SkIRect dest_irect; | 124 if (config == SkBitmap::kARGB_8888_Config && device->isOpaque()) { |
143 TransformToSkIRect(canvas->getTotalMatrix(), dest_rect, &dest_irect); | |
144 | |
145 if (config == SkBitmap::kARGB_8888_Config && device->isOpaque() && | |
146 device_rect.contains(total_clip.getBounds())) { | |
147 return true; | 125 return true; |
148 } | 126 } |
149 } | 127 } |
150 | 128 |
151 return false; | 129 return false; |
152 } | 130 } |
153 | 131 |
154 void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, | 132 void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, |
155 SkCanvas* canvas, | 133 SkCanvas* canvas, |
156 const gfx::Rect& dest_rect) { | 134 const gfx::Rect& dest_rect) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 video_frame->stride(media::VideoFrame::kUPlane), | 274 video_frame->stride(media::VideoFrame::kUPlane), |
297 bitmap.rowBytes(), | 275 bitmap.rowBytes(), |
298 yuv_type, | 276 yuv_type, |
299 media::ROTATE_0, | 277 media::ROTATE_0, |
300 media::FILTER_BILINEAR); | 278 media::FILTER_BILINEAR); |
301 bitmap.unlockPixels(); | 279 bitmap.unlockPixels(); |
302 } | 280 } |
303 } | 281 } |
304 | 282 |
305 } // namespace webkit_glue | 283 } // namespace webkit_glue |
OLD | NEW |