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

Unified Diff: ui/gfx/geometry/point.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/geometry/point.cc
diff --git a/ui/gfx/geometry/point.cc b/ui/gfx/geometry/point.cc
index cf8919e2573332295b35e211f83ea35ad78a6e67..0f18afd0bc1e73a14cf01e30e8dfa78abdc58574 100644
--- a/ui/gfx/geometry/point.cc
+++ b/ui/gfx/geometry/point.cc
@@ -13,6 +13,8 @@
#endif
#include "base/strings/stringprintf.h"
+#include "ui/gfx/geometry/point_conversions.h"
+#include "ui/gfx/geometry/point_f.h"
namespace gfx {
@@ -63,4 +65,40 @@ std::string Point::ToString() const {
return base::StringPrintf("%d,%d", x(), y());
}
+Point ScaleToCeiledPoint(const Point& point, float x_scale, float y_scale) {
+ if (x_scale == 1.f && y_scale == 1.f)
+ return point;
+ return ToCeiledPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale));
+}
+
+Point ScaleToCeiledPoint(const Point& point, float scale) {
+ if (scale == 1.f)
+ return point;
+ return ToCeiledPoint(ScalePoint(gfx::PointF(point), scale, scale));
+}
+
+Point ScaleToFlooredPoint(const Point& point, float x_scale, float y_scale) {
+ if (x_scale == 1.f && y_scale == 1.f)
+ return point;
+ return ToFlooredPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale));
+}
+
+Point ScaleToFlooredPoint(const Point& point, float scale) {
+ if (scale == 1.f)
+ return point;
+ return ToFlooredPoint(ScalePoint(gfx::PointF(point), scale, scale));
+}
+
+Point ScaleToRoundedPoint(const Point& point, float x_scale, float y_scale) {
+ if (x_scale == 1.f && y_scale == 1.f)
+ return point;
+ return ToRoundedPoint(ScalePoint(gfx::PointF(point), x_scale, y_scale));
+}
+
+Point ScaleToRoundedPoint(const Point& point, float scale) {
+ if (scale == 1.f)
+ return point;
+ return ToRoundedPoint(ScalePoint(gfx::PointF(point), scale, scale));
+}
+
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698