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

Side by Side Diff: remoting/base/util.cc

Issue 9331003: Improving the decoder pipeline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/base/util.h" 5 #include "remoting/base/util.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 int x = RoundToTwosMultiple(rect.left()); 212 int x = RoundToTwosMultiple(rect.left());
213 int y = RoundToTwosMultiple(rect.top()); 213 int y = RoundToTwosMultiple(rect.top());
214 int right = RoundToTwosMultiple(rect.right() + 1); 214 int right = RoundToTwosMultiple(rect.right() + 1);
215 int bottom = RoundToTwosMultiple(rect.bottom() + 1); 215 int bottom = RoundToTwosMultiple(rect.bottom() + 1);
216 return SkIRect::MakeLTRB(x, y, right, bottom); 216 return SkIRect::MakeLTRB(x, y, right, bottom);
217 } 217 }
218 218
219 SkIRect ScaleRect(const SkIRect& rect, 219 SkIRect ScaleRect(const SkIRect& rect,
220 const SkISize& in_size, 220 const SkISize& in_size,
221 const SkISize& out_size) { 221 const SkISize& out_size) {
222 int left = (rect.left() * out_size.width()) / in_size.width(); 222 // Use floating point to up/down scale more accurately.
223 int top = (rect.top() * out_size.height()) / in_size.height(); 223 float scale_x = static_cast<float>(out_size.width()) / in_size.width();
224 int right = (rect.right() * out_size.width() + out_size.width() - 1) / 224 float scale_y = static_cast<float>(out_size.height()) / in_size.height();
225 in_size.width(); 225
226 int bottom = (rect.bottom() * out_size.height() + out_size.height() - 1) / 226 int left = static_cast<int>(floor(scale_x * rect.left()));
227 in_size.height(); 227 int top = static_cast<int>(floor(scale_y * rect.top()));
228 int right = static_cast<int>(ceil(scale_x * rect.right()));
229 int bottom = static_cast<int>(ceil(scale_y * rect.bottom()));
228 return SkIRect::MakeLTRB(left, top, right, bottom); 230 return SkIRect::MakeLTRB(left, top, right, bottom);
229 } 231 }
230 232
231 void CopyRect(const uint8* src_plane, 233 void CopyRect(const uint8* src_plane,
232 int src_plane_stride, 234 int src_plane_stride,
233 uint8* dest_plane, 235 uint8* dest_plane,
234 int dest_plane_stride, 236 int dest_plane_stride,
235 int bytes_per_pixel, 237 int bytes_per_pixel,
236 const SkIRect& rect) { 238 const SkIRect& rect) {
237 // Get the address of the starting point. 239 // Get the address of the starting point.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // Copy bits. 274 // Copy bits.
273 CopyRect(source_buffer + source_offset, 275 CopyRect(source_buffer + source_offset,
274 source_stride, 276 source_stride,
275 dest_buffer + dest_offset, 277 dest_buffer + dest_offset,
276 dest_stride, 278 dest_stride,
277 GetBytesPerPixel(media::VideoFrame::RGB32), 279 GetBytesPerPixel(media::VideoFrame::RGB32),
278 SkIRect::MakeWH(dest_rect.width(), dest_rect.height())); 280 SkIRect::MakeWH(dest_rect.width(), dest_rect.height()));
279 } 281 }
280 282
281 } // namespace remoting 283 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698