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

Unified 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 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 30691ea065531f9300883092de8dc55d5316b65b..d2ec9be23096121c92382c415af4ee7da95aa875 100644
--- a/remoting/base/util.cc
+++ b/remoting/base/util.cc
@@ -219,12 +219,14 @@ SkIRect AlignRect(const SkIRect& rect) {
SkIRect ScaleRect(const SkIRect& rect,
const SkISize& in_size,
const SkISize& out_size) {
- int left = (rect.left() * out_size.width()) / in_size.width();
- int top = (rect.top() * out_size.height()) / in_size.height();
- int right = (rect.right() * out_size.width() + out_size.width() - 1) /
- in_size.width();
- int bottom = (rect.bottom() * out_size.height() + out_size.height() - 1) /
- in_size.height();
+ // Use floating point to up/down scale more accurately.
+ float scale_x = static_cast<float>(out_size.width()) / in_size.width();
+ float scale_y = static_cast<float>(out_size.height()) / in_size.height();
+
+ int left = static_cast<int>(floor(scale_x * rect.left()));
+ int top = static_cast<int>(floor(scale_y * rect.top()));
+ int right = static_cast<int>(ceil(scale_x * rect.right()));
+ int bottom = static_cast<int>(ceil(scale_y * rect.bottom()));
return SkIRect::MakeLTRB(left, top, right, bottom);
}

Powered by Google App Engine
This is Rietveld 408576698