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

Side by Side Diff: ui/gfx/win/screen_win_display.cc

Issue 1679393002: Multiple DPI Tracking for ScreenWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback EXCEPT rect_util Rename Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/win/screen_win_display.h ('k') | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/win/screen_win_display.h" 5 #include "ui/gfx/win/screen_win_display.h"
6 6
7 #include "ui/gfx/geometry/insets.h"
7 #include "ui/gfx/win/display_info.h" 8 #include "ui/gfx/win/display_info.h"
8 #include "ui/gfx/win/dpi.h" 9 #include "ui/gfx/win/dpi.h"
10 #include "ui/gfx/win/rect_util.h"
9 11
10 namespace { 12 namespace {
11 13
12 gfx::Display CreateDisplayFromDisplayInfo( 14 gfx::Display CreateDisplayFromDisplayInfo(
13 const gfx::win::DisplayInfo& display_info) { 15 const gfx::win::DisplayInfo& display_info) {
14 gfx::Display display(display_info.id()); 16 gfx::Display display(display_info.id());
15 gfx::Rect dip_screen_bounds( 17 float scale_factor = display_info.device_scale_factor();
16 gfx::win::ScreenToDIPRect(display_info.screen_rect())); 18 display.set_device_scale_factor(scale_factor);
17 display.set_bounds(dip_screen_bounds);
18 display.set_work_area( 19 display.set_work_area(
19 gfx::win::ScreenToDIPRect(display_info.screen_work_rect())); 20 gfx::ScaleToEnclosingRect(display_info.screen_work_rect(),
20 display.SetScaleAndBounds(display_info.device_scale_factor(), 21 1.0f / scale_factor));
21 display_info.screen_rect()); 22 display.set_bounds(gfx::ScaleToEnclosingRect(display_info.screen_rect(),
23 1.0f / scale_factor));
22 display.set_rotation(display_info.rotation()); 24 display.set_rotation(display_info.rotation());
23 return display; 25 return display;
24 } 26 }
27
28 gfx::Display CreateDisplayWithReferenceFromDisplayInfo(
29 const gfx::win::ScreenWinDisplay& reference,
30 const gfx::win::DisplayInfo& display_info) {
31 gfx::Display display(display_info.id());
32 float scale_factor = display_info.device_scale_factor();
33 display.set_device_scale_factor(scale_factor);
34 const gfx::Insets pixel_insets =
35 display_info.screen_rect().InsetsFrom(display_info.screen_work_rect());
36 const gfx::Insets scaled_insets = pixel_insets.Scale(1.0f / scale_factor,
37 1.0f / scale_factor);
38 const gfx::Rect scaled_bounds =
39 gfx::win::ScaleAndPositionRect(reference.display().bounds(),
40 reference.pixel_bounds(),
41 display_info.screen_rect(),
42 scale_factor);
43 display.set_bounds(scaled_bounds);
44 gfx::Rect scaled_work_area(scaled_bounds);
45 scaled_work_area.Inset(scaled_insets);
46 display.set_work_area(scaled_work_area);
47 display.set_rotation(display_info.rotation());
48 return display;
49 }
25 50
26 } // namespace 51 } // namespace
27 52
28 namespace gfx { 53 namespace gfx {
29 namespace win { 54 namespace win {
30 55
31 ScreenWinDisplay::ScreenWinDisplay() = default; 56 ScreenWinDisplay::ScreenWinDisplay() = default;
32 57
33 ScreenWinDisplay::ScreenWinDisplay(const DisplayInfo& display_info) 58 ScreenWinDisplay::ScreenWinDisplay(const DisplayInfo& display_info)
34 : display_(CreateDisplayFromDisplayInfo(display_info)), 59 : display_(CreateDisplayFromDisplayInfo(display_info)),
35 pixel_bounds_(display_info.screen_rect()) {} 60 pixel_bounds_(display_info.screen_rect()) {}
36 61
62 ScreenWinDisplay::ScreenWinDisplay(const ScreenWinDisplay& reference,
63 const DisplayInfo& display_info)
64 : display_(CreateDisplayWithReferenceFromDisplayInfo(reference,
65 display_info)),
66 pixel_bounds_(display_info.screen_rect()) {}
67
37 } // namespace win 68 } // namespace win
38 } // namespace gfx 69 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/win/screen_win_display.h ('k') | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698