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/geometry/rect.h" | 5 #include "ui/gfx/geometry/rect.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
11 #elif defined(OS_IOS) | 11 #elif defined(OS_IOS) |
12 #include <CoreGraphics/CoreGraphics.h> | 12 #include <CoreGraphics/CoreGraphics.h> |
13 #elif defined(OS_MACOSX) | 13 #elif defined(OS_MACOSX) |
14 #include <ApplicationServices/ApplicationServices.h> | 14 #include <ApplicationServices/ApplicationServices.h> |
15 #endif | 15 #endif |
16 | 16 |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "ui/gfx/geometry/insets.h" | 19 #include "ui/gfx/geometry/insets.h" |
| 20 #include "ui/gfx/geometry/rect_conversions.h" |
20 | 21 |
21 namespace gfx { | 22 namespace gfx { |
22 | 23 |
23 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
24 Rect::Rect(const RECT& r) | 25 Rect::Rect(const RECT& r) |
25 : origin_(r.left, r.top), | 26 : origin_(r.left, r.top), |
26 size_(std::abs(r.right - r.left), std::abs(r.bottom - r.top)) { | 27 size_(std::abs(r.right - r.left), std::abs(r.bottom - r.top)) { |
27 } | 28 } |
28 #elif defined(OS_MACOSX) | 29 #elif defined(OS_MACOSX) |
29 Rect::Rect(const CGRect& r) | 30 Rect::Rect(const CGRect& r) |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 276 } |
276 | 277 |
277 Rect BoundingRect(const Point& p1, const Point& p2) { | 278 Rect BoundingRect(const Point& p1, const Point& p2) { |
278 int rx = std::min(p1.x(), p2.x()); | 279 int rx = std::min(p1.x(), p2.x()); |
279 int ry = std::min(p1.y(), p2.y()); | 280 int ry = std::min(p1.y(), p2.y()); |
280 int rr = std::max(p1.x(), p2.x()); | 281 int rr = std::max(p1.x(), p2.x()); |
281 int rb = std::max(p1.y(), p2.y()); | 282 int rb = std::max(p1.y(), p2.y()); |
282 return Rect(rx, ry, rr - rx, rb - ry); | 283 return Rect(rx, ry, rr - rx, rb - ry); |
283 } | 284 } |
284 | 285 |
| 286 Rect SafelyScaleToEnclosingRect(const Rect& rect, float scale) { |
| 287 return ToEnclosingRect(ScaleRect(rect, scale)); |
| 288 } |
| 289 |
285 } // namespace gfx | 290 } // namespace gfx |
OLD | NEW |