| 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);
|
| }
|
|
|
|
|