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

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

Issue 1417023002: Remove some implicit Point to PointF conversions, add helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-views: extrachange Created 5 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/image/image_skia_operations.cc » ('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 #elif defined(OS_IOS) 9 #elif defined(OS_IOS)
10 #include <CoreGraphics/CoreGraphics.h> 10 #include <CoreGraphics/CoreGraphics.h>
11 #elif defined(OS_MACOSX) 11 #elif defined(OS_MACOSX)
12 #include <ApplicationServices/ApplicationServices.h> 12 #include <ApplicationServices/ApplicationServices.h>
13 #endif 13 #endif
14 14
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "ui/gfx/geometry/point_conversions.h"
16 17
17 namespace gfx { 18 namespace gfx {
18 19
19 #if defined(OS_WIN) 20 #if defined(OS_WIN)
20 Point::Point(DWORD point) { 21 Point::Point(DWORD point) {
21 POINTS points = MAKEPOINTS(point); 22 POINTS points = MAKEPOINTS(point);
22 x_ = points.x; 23 x_ = points.x;
23 y_ = points.y; 24 y_ = points.y;
24 } 25 }
25 26
(...skipping 30 matching lines...) Expand all
56 57
57 void Point::SetToMax(const Point& other) { 58 void Point::SetToMax(const Point& other) {
58 x_ = x_ >= other.x_ ? x_ : other.x_; 59 x_ = x_ >= other.x_ ? x_ : other.x_;
59 y_ = y_ >= other.y_ ? y_ : other.y_; 60 y_ = y_ >= other.y_ ? y_ : other.y_;
60 } 61 }
61 62
62 std::string Point::ToString() const { 63 std::string Point::ToString() const {
63 return base::StringPrintf("%d,%d", x(), y()); 64 return base::StringPrintf("%d,%d", x(), y());
64 } 65 }
65 66
67 Point ScaleToCeiledPoint(const Point& point, float x_scale, float y_scale) {
68 if (x_scale == 1.f && y_scale == 1.f)
69 return point;
70 return ToCeiledPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale));
71 }
72
73 Point ScaleToCeiledPoint(const Point& point, float scale) {
sky 2015/10/21 16:45:00 WDYT of inlining the single float variants? For ex
danakj 2015/10/21 17:55:40 I would but they require the PointF definition the
74 if (scale == 1.f)
75 return point;
76 return ToCeiledPoint(ScalePoint(gfx::PointF(point), scale, scale));
77 }
78
79 Point ScaleToFlooredPoint(const Point& point, float x_scale, float y_scale) {
80 if (x_scale == 1.f && y_scale == 1.f)
81 return point;
82 return ToFlooredPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale));
83 }
84
85 Point ScaleToFlooredPoint(const Point& point, float scale) {
86 if (scale == 1.f)
87 return point;
88 return ToFlooredPoint(ScalePoint(gfx::PointF(point), scale, scale));
89 }
90
91 Point ScaleToRoundedPoint(const Point& point, float x_scale, float y_scale) {
92 if (x_scale == 1.f && y_scale == 1.f)
93 return point;
94 return ToRoundedPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale));
95 }
96
97 Point ScaleToRoundedPoint(const Point& point, float scale) {
98 if (scale == 1.f)
99 return point;
100 return ToRoundedPoint(ScalePoint(gfx::PointF(point), scale, scale));
101 }
102
66 } // namespace gfx 103 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/point.h ('k') | ui/gfx/image/image_skia_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698