diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-14 23:30:59 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-14 23:30:59 +0000 |
commit | e0fc2f1f81f13440af3bb4cf5e56a031f91fc163 (patch) | |
tree | c84d3625eac633ea78d68688ecd74e2d0a158334 /base | |
parent | 98af9aca7168f061bfaae5cd4f4eb3f7de4e70e7 (diff) | |
download | chromium_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 'base')
-rw-r--r-- | base/base.gyp | 1 | ||||
-rw-r--r-- | base/base.gypi | 6 | ||||
-rw-r--r-- | base/gfx/point.cc | 56 | ||||
-rw-r--r-- | base/gfx/rect.cc | 238 | ||||
-rw-r--r-- | base/gfx/rect_unittest.cc | 314 | ||||
-rw-r--r-- | base/gfx/size.cc | 70 |
6 files changed, 0 insertions, 685 deletions
diff --git a/base/base.gyp b/base/base.gyp index 30d746d..1a40a29 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -71,7 +71,6 @@ 'file_util_unittest.cc', 'file_version_info_unittest.cc', 'file_watcher_unittest.cc', - 'gfx/rect_unittest.cc', 'gmock_unittest.cc', 'histogram_unittest.cc', 'hmac_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index 1fbb537..a251641 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -519,12 +519,6 @@ 'field_trial.h', 'file_descriptor_shuffle.cc', 'file_descriptor_shuffle.h', - 'gfx/point.cc', - 'gfx/point.h', - 'gfx/rect.cc', - 'gfx/rect.h', - 'gfx/size.cc', - 'gfx/size.h', 'hmac.h', 'hmac_mac.cc', 'hmac_nss.cc', diff --git a/base/gfx/point.cc b/base/gfx/point.cc deleted file mode 100644 index 05b7596..0000000 --- a/base/gfx/point.cc +++ /dev/null @@ -1,56 +0,0 @@ -// 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 "base/gfx/point.h" - -#if defined(OS_WIN) -#include <windows.h> -#endif - -#include <iostream> - -namespace gfx { - -Point::Point() : x_(0), y_(0) { -} - -Point::Point(int x, int y) : x_(x), y_(y) { -} - -#if defined(OS_WIN) -Point::Point(DWORD point) { - POINTS points = MAKEPOINTS(point); - x_ = points.x; - y_ = points.y; -} - -Point::Point(const POINT& point) : x_(point.x), y_(point.y) { -} - -Point& Point::operator=(const POINT& point) { - x_ = point.x; - y_ = point.y; - return *this; -} - -POINT Point::ToPOINT() const { - POINT p; - p.x = x_; - p.y = y_; - return p; -} -#elif defined(OS_MACOSX) -Point::Point(const CGPoint& point) : x_(point.x), y_(point.y) { -} - -CGPoint Point::ToCGPoint() const { - return CGPointMake(x_, y_); -} -#endif - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Point& p) { - return out << p.x() << "," << p.y(); -} diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc deleted file mode 100644 index a3c6712..0000000 --- a/base/gfx/rect.cc +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) 2010 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 "base/gfx/rect.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_MACOSX) -#include <CoreGraphics/CGGeometry.h> -#elif defined(OS_POSIX) -#include <gdk/gdk.h> -#endif - -#include <iostream> - -#include "base/logging.h" - -namespace { - -void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { - if (*origin < dst_origin) { - *origin = dst_origin; - *size = std::min(dst_size, *size); - } else { - *size = std::min(dst_size, *size); - *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; - } -} - -} // namespace - -namespace gfx { - -Rect::Rect() { -} - -Rect::Rect(int width, int height) { - set_width(width); - set_height(height); -} - -Rect::Rect(int x, int y, int width, int height) - : origin_(x, y) { - set_width(width); - set_height(height); -} - -Rect::Rect(const gfx::Point& origin, const gfx::Size& size) - : origin_(origin), size_(size) { -} - -#if defined(OS_WIN) -Rect::Rect(const RECT& r) - : origin_(r.left, r.top) { - set_width(r.right - r.left); - set_height(r.bottom - r.top); -} - -Rect& Rect::operator=(const RECT& r) { - origin_.SetPoint(r.left, r.top); - set_width(r.right - r.left); - set_height(r.bottom - r.top); - return *this; -} -#elif defined(OS_MACOSX) -Rect::Rect(const CGRect& r) - : origin_(r.origin.x, r.origin.y) { - set_width(r.size.width); - set_height(r.size.height); -} - -Rect& Rect::operator=(const CGRect& r) { - origin_.SetPoint(r.origin.x, r.origin.y); - set_width(r.size.width); - set_height(r.size.height); - return *this; -} -#elif defined(OS_POSIX) -Rect::Rect(const GdkRectangle& r) - : origin_(r.x, r.y) { - set_width(r.width); - set_height(r.height); -} - -Rect& Rect::operator=(const GdkRectangle& r) { - origin_.SetPoint(r.x, r.y); - set_width(r.width); - set_height(r.height); - return *this; -} -#endif - -void Rect::set_width(int width) { - size_.set_width(width); -} -void Rect::set_height(int height) { - size_.set_height(height); -} - -void Rect::SetRect(int x, int y, int width, int height) { - origin_.SetPoint(x, y); - set_width(width); - set_height(height); -} - -void Rect::Inset(int left, int top, int right, int bottom) { - Offset(left, top); - set_width(std::max(width() - left - right, 0)); - set_height(std::max(height() - top - bottom, 0)); -} - -void Rect::Offset(int horizontal, int vertical) { - origin_.Offset(horizontal, vertical); -} - -bool Rect::operator==(const Rect& other) const { - return origin_ == other.origin_ && size_ == other.size_; -} - -#if defined(OS_WIN) -RECT Rect::ToRECT() const { - RECT r; - r.left = x(); - r.right = right(); - r.top = y(); - r.bottom = bottom(); - return r; -} -#elif defined(OS_MACOSX) -CGRect Rect::ToCGRect() const { - return CGRectMake(x(), y(), width(), height()); -} -#elif defined(OS_POSIX) -GdkRectangle Rect::ToGdkRectangle() const { - GdkRectangle r = {x(), y(), width(), height()}; - return r; -} -#endif - -bool Rect::Contains(int point_x, int point_y) const { - return (point_x >= x()) && (point_x < right()) && - (point_y >= y()) && (point_y < bottom()); -} - -bool Rect::Contains(const Rect& rect) const { - return (rect.x() >= x() && rect.right() <= right() && - rect.y() >= y() && rect.bottom() <= bottom()); -} - -bool Rect::Intersects(const Rect& rect) const { - return !(rect.x() >= right() || rect.right() <= x() || - rect.y() >= bottom() || rect.bottom() <= y()); -} - -Rect Rect::Intersect(const Rect& rect) const { - int rx = std::max(x(), rect.x()); - int ry = std::max(y(), rect.y()); - int rr = std::min(right(), rect.right()); - int rb = std::min(bottom(), rect.bottom()); - - if (rx >= rr || ry >= rb) - rx = ry = rr = rb = 0; // non-intersecting - - return Rect(rx, ry, rr - rx, rb - ry); -} - -Rect Rect::Union(const Rect& rect) const { - // special case empty rects... - if (IsEmpty()) - return rect; - if (rect.IsEmpty()) - return *this; - - int rx = std::min(x(), rect.x()); - int ry = std::min(y(), rect.y()); - int rr = std::max(right(), rect.right()); - int rb = std::max(bottom(), rect.bottom()); - - return Rect(rx, ry, rr - rx, rb - ry); -} - -Rect Rect::Subtract(const Rect& rect) const { - // boundary cases: - if (!Intersects(rect)) - return *this; - if (rect.Contains(*this)) - return Rect(); - - int rx = x(); - int ry = y(); - int rr = right(); - int rb = bottom(); - - if (rect.y() <= y() && rect.bottom() >= bottom()) { - // complete intersection in the y-direction - if (rect.x() <= x()) { - rx = rect.right(); - } else { - rr = rect.x(); - } - } else if (rect.x() <= x() && rect.right() >= right()) { - // complete intersection in the x-direction - if (rect.y() <= y()) { - ry = rect.bottom(); - } else { - rb = rect.y(); - } - } - return Rect(rx, ry, rr - rx, rb - ry); -} - -Rect Rect::AdjustToFit(const Rect& rect) const { - int new_x = x(); - int new_y = y(); - int new_width = width(); - int new_height = height(); - AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); - AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); - return Rect(new_x, new_y, new_width, new_height); -} - -Point Rect::CenterPoint() const { - return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2); -} - -bool Rect::SharesEdgeWith(const gfx::Rect& rect) const { - return (y() == rect.y() && height() == rect.height() && - (x() == rect.right() || right() == rect.x())) || - (x() == rect.x() && width() == rect.width() && - (y() == rect.bottom() || bottom() == rect.y())); -} - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { - return out << r.origin() << " " << r.size(); -} diff --git a/base/gfx/rect_unittest.cc b/base/gfx/rect_unittest.cc deleted file mode 100644 index 3562883..0000000 --- a/base/gfx/rect_unittest.cc +++ /dev/null @@ -1,314 +0,0 @@ -// 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 "base/basictypes.h" -#include "base/gfx/rect.h" -#include "testing/gtest/include/gtest/gtest.h" - -typedef testing::Test RectTest; - -TEST(RectTest, Contains) { - static const struct ContainsCase { - int rect_x; - int rect_y; - int rect_width; - int rect_height; - int point_x; - int point_y; - bool contained; - } contains_cases[] = { - {0, 0, 10, 10, 0, 0, true}, - {0, 0, 10, 10, 5, 5, true}, - {0, 0, 10, 10, 9, 9, true}, - {0, 0, 10, 10, 5, 10, false}, - {0, 0, 10, 10, 10, 5, false}, - {0, 0, 10, 10, -1, -1, false}, - {0, 0, 10, 10, 50, 50, false}, - #ifdef NDEBUG - {0, 0, -10, -10, 0, 0, false}, - #endif // NDEBUG - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(contains_cases); ++i) { - const ContainsCase& value = contains_cases[i]; - gfx::Rect rect(value.rect_x, value.rect_y, - value.rect_width, value.rect_height); - EXPECT_EQ(value.contained, rect.Contains(value.point_x, value.point_y)); - } -} - -TEST(RectTest, Intersects) { - static const struct { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - bool intersects; - } tests[] = { - { 0, 0, 0, 0, 0, 0, 0, 0, false }, - { 0, 0, 10, 10, 0, 0, 10, 10, true }, - { 0, 0, 10, 10, 10, 10, 10, 10, false }, - { 10, 10, 10, 10, 0, 0, 10, 10, false }, - { 10, 10, 10, 10, 5, 5, 10, 10, true }, - { 10, 10, 10, 10, 15, 15, 10, 10, true }, - { 10, 10, 10, 10, 20, 15, 10, 10, false }, - { 10, 10, 10, 10, 21, 15, 10, 10, false } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - EXPECT_EQ(tests[i].intersects, r1.Intersects(r2)); - } -} - -TEST(RectTest, Intersect) { - static const struct { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - int x3; // rect 3: the union of rects 1 and 2 - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 0, 0, // zeros - 0, 0, 0, 0, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, // equal - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 0, 0, 4, 4, // neighboring - 4, 4, 4, 4, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, // overlapping corners - 2, 2, 4, 4, - 2, 2, 2, 2 }, - { 0, 0, 4, 4, // T junction - 3, 1, 4, 2, - 3, 1, 1, 2 }, - { 3, 0, 2, 2, // gap - 0, 0, 2, 2, - 0, 0, 0, 0 } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect ir = r1.Intersect(r2); - EXPECT_EQ(r3.x(), ir.x()); - EXPECT_EQ(r3.y(), ir.y()); - EXPECT_EQ(r3.width(), ir.width()); - EXPECT_EQ(r3.height(), ir.height()); - } -} - -TEST(RectTest, Union) { - static const struct Test { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - int x3; // rect 3: the union of rects 1 and 2 - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 0, 0, 4, 4, - 4, 4, 4, 4, - 0, 0, 8, 8 }, - { 0, 0, 4, 4, - 0, 5, 4, 4, - 0, 0, 4, 9 }, - { 0, 0, 2, 2, - 3, 3, 2, 2, - 0, 0, 5, 5 }, - { 3, 3, 2, 2, // reverse r1 and r2 from previous test - 0, 0, 2, 2, - 0, 0, 5, 5 }, - { 0, 0, 0, 0, // union with empty rect - 2, 2, 2, 2, - 2, 2, 2, 2 } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect u = r1.Union(r2); - EXPECT_EQ(r3.x(), u.x()); - EXPECT_EQ(r3.y(), u.y()); - EXPECT_EQ(r3.width(), u.width()); - EXPECT_EQ(r3.height(), u.height()); - } -} - -TEST(RectTest, Equals) { - ASSERT_TRUE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 0, 0, 0))); - ASSERT_TRUE(gfx::Rect(1, 2, 3, 4).Equals(gfx::Rect(1, 2, 3, 4))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 0, 0, 1))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 0, 1, 0))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 1, 0, 0))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(1, 0, 0, 0))); -} - -TEST(RectTest, AdjustToFit) { - static const struct Test { - int x1; // source - int y1; - int w1; - int h1; - int x2; // target - int y2; - int w2; - int h2; - int x3; // rect 3: results of invoking AdjustToFit - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 2, 2, - 0, 0, 2, 2, - 0, 0, 2, 2 }, - { 2, 2, 3, 3, - 0, 0, 4, 4, - 1, 1, 3, 3 }, - { -1, -1, 5, 5, - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 2, 2, 4, 4, - 0, 0, 3, 3, - 0, 0, 3, 3 }, - { 2, 2, 1, 1, - 0, 0, 3, 3, - 2, 2, 1, 1 } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect u(r1.AdjustToFit(r2)); - EXPECT_EQ(r3.x(), u.x()); - EXPECT_EQ(r3.y(), u.y()); - EXPECT_EQ(r3.width(), u.width()); - EXPECT_EQ(r3.height(), u.height()); - } -} - -TEST(RectTest, Subtract) { - // Matching - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 10, 20, 20)).Equals( - gfx::Rect(0, 0, 0, 0))); - - // Contains - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 30, 30)).Equals( - gfx::Rect(0, 0, 0, 0))); - - // No intersection - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(30, 30, 20, 20)).Equals( - gfx::Rect(10, 10, 20, 20))); - - // Not a complete intersection in either direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(15, 15, 20, 20)).Equals( - gfx::Rect(10, 10, 20, 20))); - - // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 15, 20, 20)).Equals( - gfx::Rect(10, 10, 20, 5))); - - // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 15, 30, 20)).Equals( - gfx::Rect(10, 10, 20, 5))); - - // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 30, 20)).Equals( - gfx::Rect(10, 25, 20, 5))); - - // Complete intersection in the y-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 10, 10, 30)).Equals( - gfx::Rect(20, 10, 10, 20))); - - // Complete intersection in the y-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 20, 30)).Equals( - gfx::Rect(25, 10, 5, 20))); -} - -TEST(RectTest, IsEmpty) { - EXPECT_TRUE(gfx::Rect(0, 0, 0, 0).IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 0, 0).size().IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 10, 0).IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 10, 0).size().IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 0, 10).IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 0, 10).size().IsEmpty()); - EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).IsEmpty()); - EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).size().IsEmpty()); -} - -TEST(RectTest, SharesEdgeWith) { - gfx::Rect r(2, 3, 4, 5); - - // Must be non-overlapping - EXPECT_FALSE(r.SharesEdgeWith(r)); - - gfx::Rect just_above(2, 1, 4, 2); - gfx::Rect just_below(2, 8, 4, 2); - gfx::Rect just_left(0, 3, 2, 5); - gfx::Rect just_right(6, 3, 2, 5); - - EXPECT_TRUE(r.SharesEdgeWith(just_above)); - EXPECT_TRUE(r.SharesEdgeWith(just_below)); - EXPECT_TRUE(r.SharesEdgeWith(just_left)); - EXPECT_TRUE(r.SharesEdgeWith(just_right)); - - // Wrong placement - gfx::Rect same_height_no_edge(0, 0, 1, 5); - gfx::Rect same_width_no_edge(0, 0, 4, 1); - - EXPECT_FALSE(r.SharesEdgeWith(same_height_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(same_width_no_edge)); - - gfx::Rect just_above_no_edge(2, 1, 5, 2); // too wide - gfx::Rect just_below_no_edge(2, 8, 3, 2); // too narrow - gfx::Rect just_left_no_edge(0, 3, 2, 6); // too tall - gfx::Rect just_right_no_edge(6, 3, 2, 4); // too short - - EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge)); -} diff --git a/base/gfx/size.cc b/base/gfx/size.cc deleted file mode 100644 index 91f39c0..0000000 --- a/base/gfx/size.cc +++ /dev/null @@ -1,70 +0,0 @@ -// 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 "base/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(); -} |