namespace gfx {
-template class SizeBase<Size, int>;
-
-#if defined(OS_MACOSX)
-Size::Size(const CGSize& s)
- : SizeBase<Size, int>(s.width, s.height) {
+#if defined(OS_WIN)
+SIZE Size::ToSIZE() const {
+ SIZE s;
+ s.cx = width();
+ s.cy = height();
+ return s;
}
+#endif
+#if defined(OS_MACOSX)
Size& Size::operator=(const CGSize& s) {
set_width(s.width);
set_height(s.height);
}
#endif
-#if defined(OS_WIN)
-SIZE Size::ToSIZE() const {
- SIZE s;
- s.cx = width();
- s.cy = height();
- return s;
+int Size::GetArea() const {
+ return width() * height();
}
-#elif defined(OS_MACOSX)
-CGSize Size::ToCGSize() const {
- return CGSizeMake(width(), height());
+
+void Size::Enlarge(int grow_width, int grow_height) {
+ SetSize(width() + grow_width, height() + grow_height);
+}
+
+void Size::SetToMin(const Size& other) {
+ width_ = width() <= other.width() ? width() : other.width();
+ height_ = height() <= other.height() ? height() : other.height();
+}
+
+void Size::SetToMax(const Size& other) {
+ width_ = width() >= other.width() ? width() : other.width();
+ height_ = height() >= other.height() ? height() : other.height();
}
-#endif
std::string Size::ToString() const {
return base::StringPrintf("%dx%d", width(), height());