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

Unified Diff: ui/views/mus/screen_mus.cc

Issue 1903003002: mus/views: Fix creating gfx::Display in high-dpi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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/views/mus/BUILD.gn ('k') | ui/views/mus/screen_mus_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/screen_mus.cc
diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc
index d22499cc4b5e2dc03ee3801f10704399d576a39f..faa31ad3463dc1ac9b46a703fc11236c1faf2e7b 100644
--- a/ui/views/mus/screen_mus.cc
+++ b/ui/views/mus/screen_mus.cc
@@ -17,9 +17,19 @@ namespace mojo {
template <>
struct TypeConverter<gfx::Display, mus::mojom::DisplayPtr> {
static gfx::Display Convert(const mus::mojom::DisplayPtr& input) {
- gfx::Display result(input->id, input->bounds.To<gfx::Rect>());
- result.set_work_area(input->work_area.To<gfx::Rect>());
+ gfx::Display result(input->id);
+ gfx::Rect pixel_bounds = input->bounds.To<gfx::Rect>();
+ gfx::Rect pixel_work_area = input->work_area.To<gfx::Rect>();
+ float pixel_ratio = input->device_pixel_ratio;
+
+ gfx::Rect dip_bounds =
+ gfx::ScaleToEnclosingRect(pixel_bounds, 1.f / pixel_ratio);
+ gfx::Rect dip_work_area =
+ gfx::ScaleToEnclosingRect(pixel_work_area, 1.f / pixel_ratio);
+ result.set_bounds(dip_bounds);
+ result.set_work_area(dip_work_area);
result.set_device_scale_factor(input->device_pixel_ratio);
+
switch (input->rotation) {
case mus::mojom::Rotation::VALUE_0:
result.set_rotation(gfx::Display::ROTATE_0);
« no previous file with comments | « ui/views/mus/BUILD.gn ('k') | ui/views/mus/screen_mus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698