OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gfx/rect_conversions.h" |
| 6 |
| 7 #include "ui/gfx/safe_floor_ceil.h" |
| 8 |
| 9 namespace gfx { |
| 10 |
| 11 Rect ToEnclosingRect(const RectF& rect) { |
| 12 int min_x = ToFlooredInt(rect.origin().x()); |
| 13 int min_y = ToFlooredInt(rect.origin().y()); |
| 14 float max_x = rect.origin().x() + rect.size().width(); |
| 15 float max_y = rect.origin().y() + rect.size().height(); |
| 16 int width = std::max(ToCeiledInt(max_x) - min_x, 0); |
| 17 int height = std::max(ToCeiledInt(max_y) - min_y, 0); |
| 18 return Rect(min_x, min_y, width, height); |
| 19 } |
| 20 |
| 21 Rect ToEnclosedRect(const RectF& rect) { |
| 22 int min_x = ToCeiledInt(rect.origin().x()); |
| 23 int min_y = ToCeiledInt(rect.origin().y()); |
| 24 float max_x = rect.origin().x() + rect.size().width(); |
| 25 float max_y = rect.origin().y() + rect.size().height(); |
| 26 int width = std::max(ToFlooredInt(max_x) - min_x, 0); |
| 27 int height = std::max(ToFlooredInt(max_y) - min_y, 0); |
| 28 return Rect(min_x, min_y, width, height); |
| 29 } |
| 30 |
| 31 } // namespace gfx |
| 32 |
OLD | NEW |