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

Unified Diff: ui/compositor/dip_util.cc

Issue 750173002: Move dip utils to gfx/geometry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missed android change Created 6 years, 1 month 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 | « content/browser/renderer_host/software_frame_manager.cc ('k') | ui/gfx/geometry/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/dip_util.cc
diff --git a/ui/compositor/dip_util.cc b/ui/compositor/dip_util.cc
index 4db8bcf29a0af466a24557ad1d04f0d8c460f482..ad85159c30ec42db56a98b963f3630ac3080c0c5 100644
--- a/ui/compositor/dip_util.cc
+++ b/ui/compositor/dip_util.cc
@@ -10,7 +10,7 @@
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/display.h"
-#include "ui/gfx/geometry/safe_integer_conversions.h"
+#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/point.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect.h"
@@ -30,50 +30,37 @@ float GetDeviceScaleFactor(const Layer* layer) {
gfx::Point ConvertPointToDIP(const Layer* layer,
const gfx::Point& point_in_pixel) {
- return gfx::ToFlooredPoint(
- gfx::ScalePoint(point_in_pixel, 1.0f / GetDeviceScaleFactor(layer)));
+ return gfx::ConvertPointToDIP(GetDeviceScaleFactor(layer), point_in_pixel);
}
gfx::PointF ConvertPointToDIP(const Layer* layer,
const gfx::PointF& point_in_pixel) {
- return gfx::ScalePoint(point_in_pixel, 1.0f / GetDeviceScaleFactor(layer));
+ return gfx::ConvertPointToDIP(GetDeviceScaleFactor(layer), point_in_pixel);
}
gfx::Size ConvertSizeToDIP(const Layer* layer,
const gfx::Size& size_in_pixel) {
- return gfx::ToFlooredSize(
- gfx::ScaleSize(size_in_pixel, 1.0f / GetDeviceScaleFactor(layer)));
+ return gfx::ConvertSizeToDIP(GetDeviceScaleFactor(layer), size_in_pixel);
}
gfx::Rect ConvertRectToDIP(const Layer* layer,
const gfx::Rect& rect_in_pixel) {
- float scale = 1.0f / GetDeviceScaleFactor(layer);
- return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_pixel, scale));
+ return gfx::ConvertRectToDIP(GetDeviceScaleFactor(layer), rect_in_pixel);
}
gfx::Point ConvertPointToPixel(const Layer* layer,
const gfx::Point& point_in_dip) {
- return gfx::ToFlooredPoint(
- gfx::ScalePoint(point_in_dip, GetDeviceScaleFactor(layer)));
+ return gfx::ConvertPointToPixel(GetDeviceScaleFactor(layer), point_in_dip);
}
gfx::Size ConvertSizeToPixel(const Layer* layer,
const gfx::Size& size_in_dip) {
- return gfx::ToFlooredSize(
- gfx::ScaleSize(size_in_dip, GetDeviceScaleFactor(layer)));
+ return gfx::ConvertSizeToPixel(GetDeviceScaleFactor(layer), size_in_dip);
}
gfx::Rect ConvertRectToPixel(const Layer* layer,
const gfx::Rect& rect_in_dip) {
- float scale = GetDeviceScaleFactor(layer);
- // Use ToEnclosingRect() to ensure we paint all the possible pixels
- // touched. ToEnclosingRect() floors the origin, and ceils the max
- // coordinate. To do otherwise (such as flooring the size) potentially
- // results in rounding down and not drawing all the pixels that are
- // touched.
- return gfx::ToEnclosingRect(
- gfx::RectF(gfx::ScalePoint(rect_in_dip.origin(), scale),
- gfx::ScaleSize(rect_in_dip.size(), scale)));
+ return gfx::ConvertRectToPixel(GetDeviceScaleFactor(layer), rect_in_dip);
}
#if DCHECK_IS_ON
« no previous file with comments | « content/browser/renderer_host/software_frame_manager.cc ('k') | ui/gfx/geometry/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698