views: Fix ConvertPointFromPixel for fractional scaling (fixes issue #3312)

This commit is contained in:
Joshua Marler 2022-04-14 22:30:32 +00:00 committed by Marshall Greenblatt
parent 09a0606927
commit 0692cb0e80
2 changed files with 4 additions and 4 deletions

View File

@ -217,12 +217,12 @@ display::Display GetDisplayMatchingBounds(const gfx::Rect& bounds,
return display::Screen::GetScreen()->GetDisplayMatching(find_bounds); return display::Screen::GetScreen()->GetDisplayMatching(find_bounds);
} }
void ConvertPointFromPixels(gfx::Point* point, int device_scale_factor) { void ConvertPointFromPixels(gfx::Point* point, float device_scale_factor) {
*point = gfx::ToFlooredPoint( *point = gfx::ToFlooredPoint(
gfx::ScalePoint(gfx::PointF(*point), 1.0f / device_scale_factor)); gfx::ScalePoint(gfx::PointF(*point), 1.0f / device_scale_factor));
} }
void ConvertPointToPixels(gfx::Point* point, int device_scale_factor) { void ConvertPointToPixels(gfx::Point* point, float device_scale_factor) {
*point = gfx::ToFlooredPoint( *point = gfx::ToFlooredPoint(
gfx::ScalePoint(gfx::PointF(*point), device_scale_factor)); gfx::ScalePoint(gfx::PointF(*point), device_scale_factor));
} }

View File

@ -84,11 +84,11 @@ display::Display GetDisplayMatchingBounds(const gfx::Rect& bounds,
// Convert |point| from pixel coordinates to density independent pixels (DIP) // Convert |point| from pixel coordinates to density independent pixels (DIP)
// using |device_scale_factor|. // using |device_scale_factor|.
void ConvertPointFromPixels(gfx::Point* point, int device_scale_factor); void ConvertPointFromPixels(gfx::Point* point, float device_scale_factor);
// Convert |point| to pixel coordinates from density independent pixels (DIP) // Convert |point| to pixel coordinates from density independent pixels (DIP)
// using |device_scale_factor|. // using |device_scale_factor|.
void ConvertPointToPixels(gfx::Point* point, int device_scale_factor); void ConvertPointToPixels(gfx::Point* point, float device_scale_factor);
// Convert |point| from |view| to screen coordinates. If |output_pixel_coords| // Convert |point| from |view| to screen coordinates. If |output_pixel_coords|
// is true then |point| will be output in pixel coordinates instead of density // is true then |point| will be output in pixel coordinates instead of density