Update about_credits.html by re-running license.py
[chromium-blink-merge.git] / gfx / size.cc
blob6e5528efdccc3141a2f8a5e106b42576d4e78f39
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "gfx/size.h"
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #elif defined(OS_MACOSX)
10 #include <CoreGraphics/CGGeometry.h>
11 #endif
13 #include <ostream>
15 #include "base/logging.h"
17 namespace gfx {
19 Size::Size(int width, int height) {
20 set_width(width);
21 set_height(height);
24 #if defined(OS_MACOSX)
25 Size::Size(const CGSize& s) {
26 set_width(s.width);
27 set_height(s.height);
30 Size& Size::operator=(const CGSize& s) {
31 set_width(s.width);
32 set_height(s.height);
33 return *this;
35 #endif
37 #if defined(OS_WIN)
38 SIZE Size::ToSIZE() const {
39 SIZE s;
40 s.cx = width_;
41 s.cy = height_;
42 return s;
44 #elif defined(OS_MACOSX)
45 CGSize Size::ToCGSize() const {
46 return CGSizeMake(width_, height_);
48 #endif
50 void Size::set_width(int width) {
51 if (width < 0) {
52 NOTREACHED() << "negative width:" << width;
53 width = 0;
55 width_ = width;
58 void Size::set_height(int height) {
59 if (height < 0) {
60 NOTREACHED() << "negative height:" << height;
61 height = 0;
63 height_ = height;
66 std::ostream& operator<<(std::ostream& out, const gfx::Size& s) {
67 return out << s.width() << "x" << s.height();
70 } // namespace gfx