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.h" | 5 #include "ui/gfx/rect.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #elif defined(TOOLKIT_GTK) | 9 #elif defined(TOOLKIT_GTK) |
10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "ui/gfx/insets.h" | 15 #include "ui/gfx/insets.h" |
16 #include "ui/gfx/rect_base_impl.h" | 16 #include "ui/gfx/rect_base_impl.h" |
| 17 #include "ui/gfx/rect_conversions.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 | 20 |
20 template class RectBase<Rect, Point, Size, Insets, int>; | 21 template class RectBase<Rect, Point, Size, Insets, int>; |
21 | 22 |
22 typedef class RectBase<Rect, Point, Size, Insets, int> RectBaseT; | 23 typedef class RectBase<Rect, Point, Size, Insets, int> RectBaseT; |
23 | 24 |
24 Rect::Rect() : RectBaseT(gfx::Point()) { | 25 Rect::Rect() : RectBaseT(gfx::Point()) { |
25 } | 26 } |
26 | 27 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 CGRect Rect::ToCGRect() const { | 100 CGRect Rect::ToCGRect() const { |
100 return CGRectMake(x(), y(), width(), height()); | 101 return CGRectMake(x(), y(), width(), height()); |
101 } | 102 } |
102 #elif defined(TOOLKIT_GTK) | 103 #elif defined(TOOLKIT_GTK) |
103 GdkRectangle Rect::ToGdkRectangle() const { | 104 GdkRectangle Rect::ToGdkRectangle() const { |
104 GdkRectangle r = {x(), y(), width(), height()}; | 105 GdkRectangle r = {x(), y(), width(), height()}; |
105 return r; | 106 return r; |
106 } | 107 } |
107 #endif | 108 #endif |
108 | 109 |
| 110 Rect ToRect(const RectF& rect) { |
| 111 return Rect(rect.origin().ToPoint(), rect.size().ToSize()); |
| 112 } |
| 113 |
| 114 Rect Rect::ScaleUnsafe(float scale) const { |
| 115 return ToRect(Scale(scale)); |
| 116 } |
| 117 |
| 118 Rect Rect::ScaleUnsafe(float x_scale, float y_scale) const { |
| 119 return ToRect(Scale(x_scale, y_scale)); |
| 120 } |
| 121 |
109 std::string Rect::ToString() const { | 122 std::string Rect::ToString() const { |
110 return base::StringPrintf("%s %s", | 123 return base::StringPrintf("%s %s", |
111 origin().ToString().c_str(), | 124 origin().ToString().c_str(), |
112 size().ToString().c_str()); | 125 size().ToString().c_str()); |
113 } | 126 } |
114 | 127 |
115 } // namespace gfx | 128 } // namespace gfx |
OLD | NEW |