blob: fc49a56cfe2f85a61167e8abaac2b7eff672431e [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/geometry/size.h"
#include "base/strings/stringprintf.h"
namespace gfx {
int Size::GetArea() const {
return 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();
}
std::string Size::ToString() const {
return base::StringPrintf("%dx%d", width(), height());
}
} // namespace gfx