| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/display/win/screen_win.h" | 5 #include "ui/display/win/screen_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellscalingapi.h> | 8 #include <shellscalingapi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/win/win_util.h" | 16 #include "base/win/win_util.h" |
| 17 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 18 #include "ui/display/display_layout.h" | 18 #include "ui/display/display_layout.h" |
| 19 #include "ui/display/display_layout_builder.h" | 19 #include "ui/display/display_layout_builder.h" |
| 20 #include "ui/display/win/display_info.h" | 20 #include "ui/display/win/display_info.h" |
| 21 #include "ui/display/win/dpi.h" | 21 #include "ui/display/win/dpi.h" |
| 22 #include "ui/display/win/scaling_util.h" | 22 #include "ui/display/win/scaling_util.h" |
| 23 #include "ui/display/win/screen_win_display.h" | 23 #include "ui/display/win/screen_win_display.h" |
| 24 #include "ui/gfx/geometry/point.h" | 24 #include "ui/gfx/geometry/point.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
| 27 #include "ui/gfx/geometry/vector2d.h" | 27 #include "ui/gfx/geometry/vector2d.h" |
| 28 #include "ui/gfx/icc_profile.h" |
| 28 | 29 |
| 29 namespace display { | 30 namespace display { |
| 30 namespace win { | 31 namespace win { |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // TODO(robliao): http://crbug.com/615514 Remove when ScreenWin usage is | 34 // TODO(robliao): http://crbug.com/615514 Remove when ScreenWin usage is |
| 34 // resolved with Desktop Aura and WindowTreeHost. | 35 // resolved with Desktop Aura and WindowTreeHost. |
| 35 ScreenWin* g_screen_win_instance = nullptr; | 36 ScreenWin* g_screen_win_instance = nullptr; |
| 36 | 37 |
| 37 float GetMonitorScaleFactor(HMONITOR monitor) { | 38 float GetMonitorScaleFactor(HMONITOR monitor) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) { | 83 Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) { |
| 83 Display display(display_info.id()); | 84 Display display(display_info.id()); |
| 84 float scale_factor = display_info.device_scale_factor(); | 85 float scale_factor = display_info.device_scale_factor(); |
| 85 display.set_device_scale_factor(scale_factor); | 86 display.set_device_scale_factor(scale_factor); |
| 86 display.set_work_area( | 87 display.set_work_area( |
| 87 gfx::ScaleToEnclosingRect(display_info.screen_work_rect(), | 88 gfx::ScaleToEnclosingRect(display_info.screen_work_rect(), |
| 88 1.0f / scale_factor)); | 89 1.0f / scale_factor)); |
| 89 display.set_bounds(gfx::ScaleToEnclosingRect(display_info.screen_rect(), | 90 display.set_bounds(gfx::ScaleToEnclosingRect(display_info.screen_rect(), |
| 90 1.0f / scale_factor)); | 91 1.0f / scale_factor)); |
| 91 display.set_rotation(display_info.rotation()); | 92 display.set_rotation(display_info.rotation()); |
| 93 |
| 94 // TODO(ccameron): Populate this based on this specific display. |
| 95 // http://crbug.com/735613 |
| 96 display.set_color_space(gfx::ICCProfile::FromBestMonitor().GetColorSpace()); |
| 97 |
| 92 return display; | 98 return display; |
| 93 } | 99 } |
| 94 | 100 |
| 95 // Windows historically has had a hard time handling displays of DPIs higher | 101 // Windows historically has had a hard time handling displays of DPIs higher |
| 96 // than 96. Handling multiple DPI displays means we have to deal with Windows' | 102 // than 96. Handling multiple DPI displays means we have to deal with Windows' |
| 97 // monitor physical coordinates and map into Chrome's DIP coordinates. | 103 // monitor physical coordinates and map into Chrome's DIP coordinates. |
| 98 // | 104 // |
| 99 // To do this, DisplayInfosToScreenWinDisplays reasons over monitors as a tree | 105 // To do this, DisplayInfosToScreenWinDisplays reasons over monitors as a tree |
| 100 // using the primary monitor as the root. All monitors touching this root are | 106 // using the primary monitor as the root. All monitors touching this root are |
| 101 // considered a children. | 107 // considered a children. |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000); | 599 std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000); |
| 594 if (!base::ContainsValue(unique_scale_factors, reported_scale)) { | 600 if (!base::ContainsValue(unique_scale_factors, reported_scale)) { |
| 595 unique_scale_factors.push_back(reported_scale); | 601 unique_scale_factors.push_back(reported_scale); |
| 596 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); | 602 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); |
| 597 } | 603 } |
| 598 } | 604 } |
| 599 } | 605 } |
| 600 | 606 |
| 601 } // namespace win | 607 } // namespace win |
| 602 } // namespace display | 608 } // namespace display |
| OLD | NEW |