Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ui/gfx/rect_conversions.h" | 5 #include "ui/gfx/rect_conversions.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/gfx/safe_integer_conversions.h" | 10 #include "ui/gfx/safe_integer_conversions.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 | 13 |
| 14 Rect ToSizedRect(const RectF& rect) { | |
|
kevers
2013/04/19 20:31:42
This logic is identical to ToFlooredRectDeprecated
| |
| 15 int min_x = ToFlooredInt(rect.origin().x()); | |
| 16 int min_y = ToFlooredInt(rect.origin().y()); | |
| 17 int width = ToFlooredInt(rect.size().width()); | |
| 18 int height = ToFlooredInt(rect.size().height()); | |
| 19 return Rect(min_x, min_y, width, height); | |
| 20 } | |
| 21 | |
| 14 Rect ToEnclosingRect(const RectF& rect) { | 22 Rect ToEnclosingRect(const RectF& rect) { |
| 15 int min_x = ToFlooredInt(rect.x()); | 23 int min_x = ToFlooredInt(rect.x()); |
| 16 int min_y = ToFlooredInt(rect.y()); | 24 int min_y = ToFlooredInt(rect.y()); |
| 17 float max_x = rect.right(); | 25 float max_x = rect.right(); |
| 18 float max_y = rect.bottom(); | 26 float max_y = rect.bottom(); |
| 19 int width = std::max(ToCeiledInt(max_x) - min_x, 0); | 27 int width = std::max(ToCeiledInt(max_x) - min_x, 0); |
| 20 int height = std::max(ToCeiledInt(max_y) - min_y, 0); | 28 int height = std::max(ToCeiledInt(max_y) - min_y, 0); |
| 21 return Rect(min_x, min_y, width, height); | 29 return Rect(min_x, min_y, width, height); |
| 22 } | 30 } |
| 23 | 31 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 54 | 62 |
| 55 Rect ToFlooredRectDeprecated(const RectF& rect) { | 63 Rect ToFlooredRectDeprecated(const RectF& rect) { |
| 56 return Rect(ToFlooredInt(rect.x()), | 64 return Rect(ToFlooredInt(rect.x()), |
| 57 ToFlooredInt(rect.y()), | 65 ToFlooredInt(rect.y()), |
| 58 ToFlooredInt(rect.width()), | 66 ToFlooredInt(rect.width()), |
| 59 ToFlooredInt(rect.height())); | 67 ToFlooredInt(rect.height())); |
| 60 } | 68 } |
| 61 | 69 |
| 62 } // namespace gfx | 70 } // namespace gfx |
| 63 | 71 |
| OLD | NEW |