Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: ui/gfx/geometry/point.cc

Issue 642343003: gfx: De-templatize the gfx::Point and gfx::PointF classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: inlines-point: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/geometry/point.h ('k') | ui/gfx/geometry/point_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/geometry/point.h" 5 #include "ui/gfx/geometry/point.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 14
15 template class PointBase<Point, int, Vector2d>;
16
17 #if defined(OS_WIN) 15 #if defined(OS_WIN)
18 Point::Point(DWORD point) : PointBase<Point, int, Vector2d>(0, 0){ 16 Point::Point(DWORD point) {
19 POINTS points = MAKEPOINTS(point); 17 POINTS points = MAKEPOINTS(point);
20 set_x(points.x); 18 x_ = points.x;
21 set_y(points.y); 19 y_ = points.y;
22 } 20 }
23 21
24 Point::Point(const POINT& point) 22 Point::Point(const POINT& point) : x_(point.x), y_(point.y) {
25 : PointBase<Point, int, Vector2d>(point.x, point.y) {
26 } 23 }
27 24
28 Point& Point::operator=(const POINT& point) { 25 Point& Point::operator=(const POINT& point) {
29 set_x(point.x); 26 x_ = point.x;
30 set_y(point.y); 27 y_ = point.y;
31 return *this; 28 return *this;
32 } 29 }
33 30
34 POINT Point::ToPOINT() const { 31 POINT Point::ToPOINT() const {
35 POINT p; 32 POINT p;
36 p.x = x(); 33 p.x = x();
37 p.y = y(); 34 p.y = y();
38 return p; 35 return p;
39 } 36 }
40 #elif defined(OS_MACOSX) 37 #endif
41 Point::Point(const CGPoint& point) 38
42 : PointBase<Point, int, Vector2d>(point.x, point.y) { 39 void Point::SetToMin(const Point& other) {
40 x_ = x_ <= other.x_ ? x_ : other.x_;
41 y_ = y_ <= other.y_ ? y_ : other.y_;
43 } 42 }
44 43
45 CGPoint Point::ToCGPoint() const { 44 void Point::SetToMax(const Point& other) {
46 return CGPointMake(x(), y()); 45 x_ = x_ >= other.x_ ? x_ : other.x_;
46 y_ = y_ >= other.y_ ? y_ : other.y_;
47 } 47 }
48 #endif
49 48
50 std::string Point::ToString() const { 49 std::string Point::ToString() const {
51 return base::StringPrintf("%d,%d", x(), y()); 50 return base::StringPrintf("%d,%d", x(), y());
52 } 51 }
53 52
54 } // namespace gfx 53 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/point.h ('k') | ui/gfx/geometry/point_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698