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. |
Wez
2012/02/17 23:42:17
Given that the results are still integer, how is t
alexeypa (please no reviews)
2012/02/21 23:00:44
Up-scaling didn't work properly in all cases with
Wez
2012/02/23 00:11:09
Do remember in what way it was broken? I'd prefer
alexeypa (please no reviews)
2012/02/23 17:10:33
Sorry, I don't remember. I do remember that I hit
Wez
2012/02/23 22:59:26
OK; there's no intrinsic reason why doing the inte
alexeypa (please no reviews)
2012/02/23 23:59:14
OK, here is the bug I was talking about. Say in_si
Wez
2012/02/24 00:12:30
Correct. :)
alexeypa (please no reviews)
2012/02/24 16:46:56
I don't think anything can be called a performance
Wez
2012/02/24 18:02:04
Sorry, I should have pointed out that my comments
|
+ 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); |
} |