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

Unified Diff: remoting/base/util.cc

Issue 8954003: Revised sub-rectangle scaling for use in Chromoting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace bounds-check on loop with a DCHECK. Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: remoting/base/util.cc
diff --git a/remoting/base/util.cc b/remoting/base/util.cc
index e960f09fbd21dc0867afaf9e76a09b919f0e8110..0bda6b169230f5e430ab589d729b4cabb9971592 100644
--- a/remoting/base/util.cc
+++ b/remoting/base/util.cc
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "remoting/base/util.h"
+
+#include <math.h>
+
#include "base/logging.h"
#include "base/stringprintf.h"
#include "base/time.h"
#include "media/base/video_frame.h"
#include "media/base/yuv_convert.h"
-#include "remoting/base/util.h"
using media::VideoFrame;
@@ -74,41 +77,6 @@ void ConvertYUVToRGB32WithRect(const uint8* y_plane,
media::YV12);
}
-void ScaleYUVToRGB32WithRect(const uint8* y_plane,
- const uint8* u_plane,
- const uint8* v_plane,
- uint8* rgb_plane,
- const SkIRect& source_rect,
- const SkIRect& dest_rect,
- int y_stride,
- int uv_stride,
- int rgb_stride) {
- int rgb_offset = CalculateRGBOffset(dest_rect.fLeft,
- dest_rect.fTop,
- rgb_stride);
- int y_offset = CalculateYOffset(source_rect.fLeft,
- source_rect.fTop,
- y_stride);
- int uv_offset = CalculateUVOffset(source_rect.fLeft,
- source_rect.fTop,
- uv_stride);
-
- media::ScaleYUVToRGB32(y_plane + y_offset,
- u_plane + uv_offset,
- v_plane + uv_offset,
- rgb_plane + rgb_offset,
- source_rect.width(),
- source_rect.height(),
- dest_rect.width(),
- dest_rect.height(),
- y_stride,
- uv_stride,
- rgb_stride,
- media::YV12,
- media::ROTATE_0,
- media::FILTER_NONE);
-}
-
void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
uint8* y_plane,
uint8* u_plane,
@@ -150,12 +118,11 @@ SkIRect AlignRect(const SkIRect& rect) {
SkIRect ScaleRect(const SkIRect& rect,
double horizontal_ratio,
double vertical_ratio) {
- int x = rect.fLeft * horizontal_ratio;
- int y = rect.fTop * vertical_ratio;
- int w = rect.fRight * horizontal_ratio - x;
- int h = rect.fBottom * vertical_ratio - y;
-
- return SkIRect::MakeXYWH(x, y, w, h);
+ int left = floor(rect.left() * horizontal_ratio);
+ int top = floor(rect.top() * vertical_ratio);
+ int right = ceil(rect.right() * horizontal_ratio);
+ int bottom = ceil(rect.bottom() * vertical_ratio);
+ return SkIRect::MakeLTRB(left, top, right, bottom);
}
void CopyRect(const uint8* src_plane,

Powered by Google App Engine
This is Rietveld 408576698