Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / ui / gfx / geometry / point.cc
blobcf8919e2573332295b35e211f83ea35ad78a6e67
1 // Copyright (c) 2012 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 "ui/gfx/geometry/point.h"
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #elif defined(OS_IOS)
10 #include <CoreGraphics/CoreGraphics.h>
11 #elif defined(OS_MACOSX)
12 #include <ApplicationServices/ApplicationServices.h>
13 #endif
15 #include "base/strings/stringprintf.h"
17 namespace gfx {
19 #if defined(OS_WIN)
20 Point::Point(DWORD point) {
21 POINTS points = MAKEPOINTS(point);
22 x_ = points.x;
23 y_ = points.y;
26 Point::Point(const POINT& point) : x_(point.x), y_(point.y) {
29 Point& Point::operator=(const POINT& point) {
30 x_ = point.x;
31 y_ = point.y;
32 return *this;
34 #elif defined(OS_MACOSX)
35 Point::Point(const CGPoint& point) : x_(point.x), y_(point.y) {
37 #endif
39 #if defined(OS_WIN)
40 POINT Point::ToPOINT() const {
41 POINT p;
42 p.x = x();
43 p.y = y();
44 return p;
46 #elif defined(OS_MACOSX)
47 CGPoint Point::ToCGPoint() const {
48 return CGPointMake(x(), y());
50 #endif
52 void Point::SetToMin(const Point& other) {
53 x_ = x_ <= other.x_ ? x_ : other.x_;
54 y_ = y_ <= other.y_ ? y_ : other.y_;
57 void Point::SetToMax(const Point& other) {
58 x_ = x_ >= other.x_ ? x_ : other.x_;
59 y_ = y_ >= other.y_ ? y_ : other.y_;
62 std::string Point::ToString() const {
63 return base::StringPrintf("%d,%d", x(), y());
66 } // namespace gfx