Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: ui/gfx/geometry/size.h

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/geometry/rect_f.h ('k') | ui/gfx/geometry/size.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef UI_GFX_GEOMETRY_SIZE_H_ 5 #ifndef UI_GFX_GEOMETRY_SIZE_H_
6 #define UI_GFX_GEOMETRY_SIZE_H_ 6 #define UI_GFX_GEOMETRY_SIZE_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "ui/gfx/geometry/size_f.h"
13 #include "ui/gfx/gfx_export.h" 12 #include "ui/gfx/gfx_export.h"
14 13
15 #if defined(OS_WIN) 14 #if defined(OS_WIN)
16 typedef struct tagSIZE SIZE; 15 typedef struct tagSIZE SIZE;
17 #elif defined(OS_MACOSX) 16 #elif defined(OS_MACOSX)
18 typedef struct CGSize CGSize; 17 typedef struct CGSize CGSize;
19 #endif 18 #endif
20 19
21 namespace gfx { 20 namespace gfx {
22 21
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 set_height(height); 54 set_height(height);
56 } 55 }
57 56
58 void Enlarge(int grow_width, int grow_height); 57 void Enlarge(int grow_width, int grow_height);
59 58
60 void SetToMin(const Size& other); 59 void SetToMin(const Size& other);
61 void SetToMax(const Size& other); 60 void SetToMax(const Size& other);
62 61
63 bool IsEmpty() const { return !width() || !height(); } 62 bool IsEmpty() const { return !width() || !height(); }
64 63
65 operator SizeF() const {
66 return SizeF(static_cast<float>(width()), static_cast<float>(height()));
67 }
68
69 std::string ToString() const; 64 std::string ToString() const;
70 65
71 private: 66 private:
72 int width_; 67 int width_;
73 int height_; 68 int height_;
74 }; 69 };
75 70
76 inline bool operator==(const Size& lhs, const Size& rhs) { 71 inline bool operator==(const Size& lhs, const Size& rhs) {
77 return lhs.width() == rhs.width() && lhs.height() == rhs.height(); 72 return lhs.width() == rhs.width() && lhs.height() == rhs.height();
78 } 73 }
79 74
80 inline bool operator!=(const Size& lhs, const Size& rhs) { 75 inline bool operator!=(const Size& lhs, const Size& rhs) {
81 return !(lhs == rhs); 76 return !(lhs == rhs);
82 } 77 }
83 78
84 // This is declared here for use in gtest-based unit tests but is defined in 79 // This is declared here for use in gtest-based unit tests but is defined in
85 // the gfx_test_support target. Depend on that to use this in your unit test. 80 // the gfx_test_support target. Depend on that to use this in your unit test.
86 // This should not be used in production code - call ToString() instead. 81 // This should not be used in production code - call ToString() instead.
87 void PrintTo(const Size& size, ::std::ostream* os); 82 void PrintTo(const Size& size, ::std::ostream* os);
88 83
84 // Helper methods to scale a gfx::Size to a new gfx::Size.
85 GFX_EXPORT Size ScaleToCeiledSize(const Size& size,
86 float x_scale,
87 float y_scale);
88 GFX_EXPORT Size ScaleToCeiledSize(const Size& size, float x_scale);
89 GFX_EXPORT Size ScaleToFlooredSize(const Size& size,
90 float x_scale,
91 float y_scale);
92 GFX_EXPORT Size ScaleToFlooredSize(const Size& size, float x_scale);
93 GFX_EXPORT Size ScaleToRoundedSize(const Size& size,
94 float x_scale,
95 float y_scale);
96 GFX_EXPORT Size ScaleToRoundedSize(const Size& size, float x_scale);
97
89 } // namespace gfx 98 } // namespace gfx
90 99
91 #endif // UI_GFX_GEOMETRY_SIZE_H_ 100 #endif // UI_GFX_GEOMETRY_SIZE_H_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/rect_f.h ('k') | ui/gfx/geometry/size.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698