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

Side by Side Diff: chrome/renderer/media/video_renderer_impl.cc

Issue 42647: Fix a bug in VideoRendererImpl in scaling (Closed)
Patch Set: Created 11 years, 9 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
« no previous file with comments | « no previous file | 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) 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 #include "chrome/renderer/media/video_renderer_impl.h" 5 #include "chrome/renderer/media/video_renderer_impl.h"
6 #include "media/base/yuv_convert.h" 6 #include "media/base/yuv_convert.h"
7 7
8 VideoRendererImpl::VideoRendererImpl(WebMediaPlayerDelegateImpl* delegate) 8 VideoRendererImpl::VideoRendererImpl(WebMediaPlayerDelegateImpl* delegate)
9 : delegate_(delegate), 9 : delegate_(delegate),
10 last_converted_frame_(NULL) { 10 last_converted_frame_(NULL) {
(...skipping 24 matching lines...) Expand all
35 GetCurrentFrame(&video_frame); 35 GetCurrentFrame(&video_frame);
36 if (video_frame.get()) { 36 if (video_frame.get()) {
37 CopyToCurrentFrame(video_frame); 37 CopyToCurrentFrame(video_frame);
38 video_frame = NULL; 38 video_frame = NULL;
39 } 39 }
40 SkMatrix matrix; 40 SkMatrix matrix;
41 matrix.setTranslate(static_cast<SkScalar>(dest_rect.x()), 41 matrix.setTranslate(static_cast<SkScalar>(dest_rect.x()),
42 static_cast<SkScalar>(dest_rect.y())); 42 static_cast<SkScalar>(dest_rect.y()));
43 if (dest_rect.width() != video_size_.width() || 43 if (dest_rect.width() != video_size_.width() ||
44 dest_rect.height() != video_size_.height()) { 44 dest_rect.height() != video_size_.height()) {
45 matrix.preScale( 45 matrix.preScale(SkIntToScalar(dest_rect.width()) /
46 static_cast<SkScalar>(dest_rect.width() / video_size_.width()), 46 SkIntToScalar(video_size_.width()),
47 static_cast<SkScalar>(dest_rect.height() / video_size_.height())); 47 SkIntToScalar(dest_rect.height()) /
48 SkIntToScalar(video_size_.height()));
48 } 49 }
49 canvas->drawBitmapMatrix(bitmap_, matrix, NULL); 50 canvas->drawBitmapMatrix(bitmap_, matrix, NULL);
50 } 51 }
51 52
52 void VideoRendererImpl::CopyToCurrentFrame(media::VideoFrame* video_frame) { 53 void VideoRendererImpl::CopyToCurrentFrame(media::VideoFrame* video_frame) {
53 base::TimeDelta timestamp = video_frame->GetTimestamp(); 54 base::TimeDelta timestamp = video_frame->GetTimestamp();
54 if (video_frame != last_converted_frame_ || 55 if (video_frame != last_converted_frame_ ||
55 timestamp != last_converted_timestamp_) { 56 timestamp != last_converted_timestamp_) {
56 last_converted_frame_ = video_frame; 57 last_converted_frame_ = video_frame;
57 last_converted_timestamp_ = timestamp; 58 last_converted_timestamp_ = timestamp;
(...skipping 14 matching lines...) Expand all
72 frame_in.strides[media::VideoSurface::kYPlane], 73 frame_in.strides[media::VideoSurface::kYPlane],
73 frame_in.strides[media::VideoSurface::kUPlane], 74 frame_in.strides[media::VideoSurface::kUPlane],
74 bitmap_.rowBytes()); 75 bitmap_.rowBytes());
75 bitmap_.unlockPixels(); 76 bitmap_.unlockPixels();
76 video_frame->Unlock(); 77 video_frame->Unlock();
77 } else { 78 } else {
78 NOTREACHED(); 79 NOTREACHED();
79 } 80 }
80 } 81 }
81 } 82 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698