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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/point.cc
diff --git a/ui/gfx/geometry/point.cc b/ui/gfx/geometry/point.cc
index cf8919e2573332295b35e211f83ea35ad78a6e67..0893550e0690a039dd1fa26ccc1ef28a19221f11 100644
--- a/ui/gfx/geometry/point.cc
+++ b/ui/gfx/geometry/point.cc
@@ -13,6 +13,7 @@
#endif
#include "base/strings/stringprintf.h"
+#include "ui/gfx/geometry/point_conversions.h"
namespace gfx {
@@ -63,4 +64,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) {
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
+ 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
« 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