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

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

Issue 7792041: roll skia to 2193 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | « DEPS ('k') | no next file » | 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 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
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.
131 SkDevice* device = canvas->getDevice(); 118 SkDevice* device = canvas->getDevice();
119 const SkBitmap::Config config = device->config();
132 120
133 // Get the boundary of the device. 121 if (config == SkBitmap::kARGB_8888_Config && device->isOpaque()) {
134 SkIRect device_rect;
135 device->getBounds(&device_rect);
136
137 // Get the pixel config of the device.
138 const SkBitmap::Config config = device->config();
139 // Get the total clip rect associated with the canvas.
140 const SkRegion& total_clip = canvas->getTotalClip();
141
142 SkIRect dest_irect;
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; 122 return true;
148 } 123 }
149 } 124 }
150 125
151 return false; 126 return false;
152 } 127 }
153 128
154 void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, 129 void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame,
155 SkCanvas* canvas, 130 SkCanvas* canvas,
156 const gfx::Rect& dest_rect) { 131 const gfx::Rect& dest_rect) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 video_frame->stride(media::VideoFrame::kUPlane), 271 video_frame->stride(media::VideoFrame::kUPlane),
297 bitmap.rowBytes(), 272 bitmap.rowBytes(),
298 yuv_type, 273 yuv_type,
299 media::ROTATE_0, 274 media::ROTATE_0,
300 media::FILTER_BILINEAR); 275 media::FILTER_BILINEAR);
301 bitmap.unlockPixels(); 276 bitmap.unlockPixels();
302 } 277 }
303 } 278 }
304 279
305 } // namespace webkit_glue 280 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698