| Index: ui/gfx/geometry/dip_util.cc
|
| diff --git a/ui/gfx/geometry/dip_util.cc b/ui/gfx/geometry/dip_util.cc
|
| index c1efdf5e414f25e444796d104d1e1ceaf3971a96..1a6b5d9176abdda3c0d3a0a0a720a8c7f593dbc0 100644
|
| --- a/ui/gfx/geometry/dip_util.cc
|
| +++ b/ui/gfx/geometry/dip_util.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "ui/gfx/geometry/dip_util.h"
|
|
|
| +#include "ui/gfx/geometry/insets.h"
|
| #include "ui/gfx/geometry/point.h"
|
| #include "ui/gfx/geometry/point_conversions.h"
|
| #include "ui/gfx/geometry/point_f.h"
|
| @@ -14,28 +15,54 @@
|
|
|
| namespace gfx {
|
|
|
| +Insets ConvertInsetsToDIP(float scale_factor,
|
| + const gfx::Insets& insets_in_pixel) {
|
| + if (scale_factor == 1.f)
|
| + return insets_in_pixel;
|
| + return insets_in_pixel.Scale(1.f / scale_factor);
|
| +}
|
| +
|
| Point ConvertPointToDIP(float scale_factor, const Point& point_in_pixel) {
|
| - return ScaleToFlooredPoint(point_in_pixel, 1.0f / scale_factor);
|
| + if (scale_factor == 1.f)
|
| + return point_in_pixel;
|
| + return ScaleToFlooredPoint(point_in_pixel, 1.f / scale_factor);
|
| }
|
|
|
| PointF ConvertPointToDIP(float scale_factor, const PointF& point_in_pixel) {
|
| - return ScalePoint(point_in_pixel, 1.0f / scale_factor);
|
| + if (scale_factor == 1.f)
|
| + return point_in_pixel;
|
| + return ScalePoint(point_in_pixel, 1.f / scale_factor);
|
| }
|
|
|
| Size ConvertSizeToDIP(float scale_factor, const Size& size_in_pixel) {
|
| - return ScaleToFlooredSize(size_in_pixel, 1.0f / scale_factor);
|
| + if (scale_factor == 1.f)
|
| + return size_in_pixel;
|
| + return ScaleToFlooredSize(size_in_pixel, 1.f / scale_factor);
|
| }
|
|
|
| Rect ConvertRectToDIP(float scale_factor, const Rect& rect_in_pixel) {
|
| + if (scale_factor == 1.f)
|
| + return rect_in_pixel;
|
| return ToFlooredRectDeprecated(
|
| - ScaleRect(RectF(rect_in_pixel), 1.0f / scale_factor));
|
| + ScaleRect(RectF(rect_in_pixel), 1.f / scale_factor));
|
| +}
|
| +
|
| +Insets ConvertInsetsToPixel(float scale_factor,
|
| + const gfx::Insets& insets_in_dip) {
|
| + if (scale_factor == 1.f)
|
| + return insets_in_dip;
|
| + return insets_in_dip.Scale(scale_factor);
|
| }
|
|
|
| Point ConvertPointToPixel(float scale_factor, const Point& point_in_dip) {
|
| + if (scale_factor == 1.f)
|
| + return point_in_dip;
|
| return ScaleToFlooredPoint(point_in_dip, scale_factor);
|
| }
|
|
|
| Size ConvertSizeToPixel(float scale_factor, const Size& size_in_dip) {
|
| + if (scale_factor == 1.f)
|
| + return size_in_dip;
|
| return ScaleToFlooredSize(size_in_dip, scale_factor);
|
| }
|
|
|
| @@ -45,6 +72,8 @@ Rect ConvertRectToPixel(float scale_factor, const Rect& rect_in_dip) {
|
| // coordinate. To do otherwise (such as flooring the size) potentially
|
| // results in rounding down and not drawing all the pixels that are
|
| // touched.
|
| + if (scale_factor == 1.f)
|
| + return rect_in_dip;
|
| return ToEnclosingRect(
|
| RectF(ScalePoint(gfx::PointF(rect_in_dip.origin()), scale_factor),
|
| ScaleSize(gfx::SizeF(rect_in_dip.size()), scale_factor)));
|
|
|