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 // Defines a simple integer rectangle class. The containment semantics | 5 // Defines a simple integer rectangle class. The containment semantics |
6 // are array-like; that is, the coordinate (x, y) is considered to be | 6 // are array-like; that is, the coordinate (x, y) is considered to be |
7 // contained by the rectangle, but the coordinate (x + width, y) is not. | 7 // contained by the rectangle, but the coordinate (x + width, y) is not. |
8 // The class will happily let you create malformed rectangles (that is, | 8 // The class will happily let you create malformed rectangles (that is, |
9 // rectangles with negative width and/or height), but there will be assertions | 9 // rectangles with negative width and/or height), but there will be assertions |
10 // in the operations (such as Contains()) to complain in this case. | 10 // in the operations (such as Contains()) to complain in this case. |
(...skipping 15 matching lines...) Expand all Loading... | |
26 typedef struct tagRECT RECT; | 26 typedef struct tagRECT RECT; |
27 #elif defined(OS_IOS) | 27 #elif defined(OS_IOS) |
28 #include <CoreGraphics/CoreGraphics.h> | 28 #include <CoreGraphics/CoreGraphics.h> |
29 #elif defined(OS_MACOSX) | 29 #elif defined(OS_MACOSX) |
30 #include <ApplicationServices/ApplicationServices.h> | 30 #include <ApplicationServices/ApplicationServices.h> |
31 #endif | 31 #endif |
32 | 32 |
33 namespace gfx { | 33 namespace gfx { |
34 | 34 |
35 class Insets; | 35 class Insets; |
36 | |
bbudge
2014/08/26 00:13:03
Why remove this line?
Derek Schuff
2014/08/26 00:32:31
leftover from experimental edits,fixed.
| |
37 class GFX_EXPORT Rect | 36 class GFX_EXPORT Rect |
38 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { | 37 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { |
39 public: | 38 public: |
40 Rect() : RectBase<Rect, Point, Size, Insets, Vector2d, int>(Point()) {} | 39 Rect() : RectBase<Rect, Point, Size, Insets, Vector2d, int>(Point()) {} |
41 | 40 |
42 Rect(int width, int height) | 41 Rect(int width, int height) |
43 : RectBase<Rect, Point, Size, Insets, Vector2d, int> | 42 : RectBase<Rect, Point, Size, Insets, Vector2d, int> |
44 (Size(width, height)) {} | 43 (Size(width, height)) {} |
45 | 44 |
46 Rect(int x, int y, int width, int height) | 45 Rect(int x, int y, int width, int height) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 int y = std::ceil(rect.y() * y_scale); | 123 int y = std::ceil(rect.y() * y_scale); |
125 int r = rect.width() == 0 ? x : std::floor(rect.right() * x_scale); | 124 int r = rect.width() == 0 ? x : std::floor(rect.right() * x_scale); |
126 int b = rect.height() == 0 ? y : std::floor(rect.bottom() * y_scale); | 125 int b = rect.height() == 0 ? y : std::floor(rect.bottom() * y_scale); |
127 return Rect(x, y, r - x, b - y); | 126 return Rect(x, y, r - x, b - y); |
128 } | 127 } |
129 | 128 |
130 inline Rect ScaleToEnclosedRect(const Rect& rect, float scale) { | 129 inline Rect ScaleToEnclosedRect(const Rect& rect, float scale) { |
131 return ScaleToEnclosedRect(rect, scale, scale); | 130 return ScaleToEnclosedRect(rect, scale, scale); |
132 } | 131 } |
133 | 132 |
134 #if !defined(COMPILER_MSVC) | 133 #if !defined(COMPILER_MSVC) && !defined(__native_client__) |
135 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; | 134 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; |
136 #endif | 135 #endif |
137 | 136 |
138 // This is declared here for use in gtest-based unit tests but is defined in | 137 // This is declared here for use in gtest-based unit tests but is defined in |
139 // the gfx_test_support target. Depend on that to use this in your unit test. | 138 // the gfx_test_support target. Depend on that to use this in your unit test. |
140 // This should not be used in production code - call ToString() instead. | 139 // This should not be used in production code - call ToString() instead. |
141 void PrintTo(const Rect& rect, ::std::ostream* os); | 140 void PrintTo(const Rect& rect, ::std::ostream* os); |
142 | 141 |
143 } // namespace gfx | 142 } // namespace gfx |
144 | 143 |
145 #endif // UI_GFX_GEOMETRY_RECT_H_ | 144 #endif // UI_GFX_GEOMETRY_RECT_H_ |
OLD | NEW |