| OLD | NEW |
| 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" |
| 17 #include "ui/gfx/geometry/point_f.h" |
| 16 | 18 |
| 17 namespace gfx { | 19 namespace gfx { |
| 18 | 20 |
| 19 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 20 Point::Point(DWORD point) { | 22 Point::Point(DWORD point) { |
| 21 POINTS points = MAKEPOINTS(point); | 23 POINTS points = MAKEPOINTS(point); |
| 22 x_ = points.x; | 24 x_ = points.x; |
| 23 y_ = points.y; | 25 y_ = points.y; |
| 24 } | 26 } |
| 25 | 27 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 | 58 |
| 57 void Point::SetToMax(const Point& other) { | 59 void Point::SetToMax(const Point& other) { |
| 58 x_ = x_ >= other.x_ ? x_ : other.x_; | 60 x_ = x_ >= other.x_ ? x_ : other.x_; |
| 59 y_ = y_ >= other.y_ ? y_ : other.y_; | 61 y_ = y_ >= other.y_ ? y_ : other.y_; |
| 60 } | 62 } |
| 61 | 63 |
| 62 std::string Point::ToString() const { | 64 std::string Point::ToString() const { |
| 63 return base::StringPrintf("%d,%d", x(), y()); | 65 return base::StringPrintf("%d,%d", x(), y()); |
| 64 } | 66 } |
| 65 | 67 |
| 68 Point ScaleToCeiledPoint(const Point& point, float x_scale, float y_scale) { |
| 69 if (x_scale == 1.f && y_scale == 1.f) |
| 70 return point; |
| 71 return ToCeiledPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale)); |
| 72 } |
| 73 |
| 74 Point ScaleToCeiledPoint(const Point& point, float scale) { |
| 75 if (scale == 1.f) |
| 76 return point; |
| 77 return ToCeiledPoint(ScalePoint(gfx::PointF(point), scale, scale)); |
| 78 } |
| 79 |
| 80 Point ScaleToFlooredPoint(const Point& point, float x_scale, float y_scale) { |
| 81 if (x_scale == 1.f && y_scale == 1.f) |
| 82 return point; |
| 83 return ToFlooredPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale)); |
| 84 } |
| 85 |
| 86 Point ScaleToFlooredPoint(const Point& point, float scale) { |
| 87 if (scale == 1.f) |
| 88 return point; |
| 89 return ToFlooredPoint(ScalePoint(gfx::PointF(point), scale, scale)); |
| 90 } |
| 91 |
| 92 Point ScaleToRoundedPoint(const Point& point, float x_scale, float y_scale) { |
| 93 if (x_scale == 1.f && y_scale == 1.f) |
| 94 return point; |
| 95 return ToRoundedPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale)); |
| 96 } |
| 97 |
| 98 Point ScaleToRoundedPoint(const Point& point, float scale) { |
| 99 if (scale == 1.f) |
| 100 return point; |
| 101 return ToRoundedPoint(ScalePoint(gfx::PointF(point), scale, scale)); |
| 102 } |
| 103 |
| 66 } // namespace gfx | 104 } // namespace gfx |
| OLD | NEW |