summaryrefslogtreecommitdiffstats
path: root/gfx/size.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-14 23:30:59 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-14 23:30:59 +0000
commite0fc2f1f81f13440af3bb4cf5e56a031f91fc163 (patch)
treec84d3625eac633ea78d68688ecd74e2d0a158334 /gfx/size.cc
parent98af9aca7168f061bfaae5cd4f4eb3f7de4e70e7 (diff)
downloadchromium_src-e0fc2f1f81f13440af3bb4cf5e56a031f91fc163.zip
chromium_src-e0fc2f1f81f13440af3bb4cf5e56a031f91fc163.tar.gz
chromium_src-e0fc2f1f81f13440af3bb4cf5e56a031f91fc163.tar.bz2
Move base/gfx contents to gfx/
TBR=darin BUG=none TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/size.cc')
-rw-r--r--gfx/size.cc70
1 files changed, 70 insertions, 0 deletions
diff --git a/gfx/size.cc b/gfx/size.cc
new file mode 100644
index 0000000..d450f20
--- /dev/null
+++ b/gfx/size.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2006-2008 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 "gfx/size.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#elif defined(OS_MACOSX)
+#include <CoreGraphics/CGGeometry.h>
+#endif
+
+#include <iostream>
+
+#include "base/logging.h"
+
+namespace gfx {
+
+Size::Size(int width, int height) {
+ set_width(width);
+ set_height(height);
+}
+
+#if defined(OS_MACOSX)
+Size::Size(const CGSize& s) {
+ set_width(s.width);
+ set_height(s.height);
+}
+
+Size& Size::operator=(const CGSize& s) {
+ set_width(s.width);
+ set_height(s.height);
+ return *this;
+}
+#endif
+
+#if defined(OS_WIN)
+SIZE Size::ToSIZE() const {
+ SIZE s;
+ s.cx = width_;
+ s.cy = height_;
+ return s;
+}
+#elif defined(OS_MACOSX)
+CGSize Size::ToCGSize() const {
+ return CGSizeMake(width_, height_);
+}
+#endif
+
+void Size::set_width(int width) {
+ if (width < 0) {
+ NOTREACHED();
+ width = 0;
+ }
+ width_ = width;
+}
+
+void Size::set_height(int height) {
+ if (height < 0) {
+ NOTREACHED();
+ height = 0;
+ }
+ height_ = height;
+}
+
+} // namespace gfx
+
+std::ostream& operator<<(std::ostream& out, const gfx::Size& s) {
+ return out << s.width() << "x" << s.height();
+}