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

Side by Side Diff: ui/display/win/screen_win.cc

Issue 2176183005: Allow Forced Scale Factor with Per-Monitor DPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 17 matching lines...) Expand all
28 namespace display { 28 namespace display {
29 namespace win { 29 namespace win {
30 namespace { 30 namespace {
31 31
32 // TODO(robliao): http://crbug.com/615514 Remove when ScreenWin usage is 32 // TODO(robliao): http://crbug.com/615514 Remove when ScreenWin usage is
33 // resolved with Desktop Aura and WindowTreeHost. 33 // resolved with Desktop Aura and WindowTreeHost.
34 ScreenWin* g_screen_win_instance = nullptr; 34 ScreenWin* g_screen_win_instance = nullptr;
35 35
36 float GetMonitorScaleFactor(HMONITOR monitor) { 36 float GetMonitorScaleFactor(HMONITOR monitor) {
37 DCHECK(monitor); 37 DCHECK(monitor);
38 if (display::Display::HasForceDeviceScaleFactor())
39 return display::Display::GetForcedDeviceScaleFactor();
40
38 if (base::win::IsProcessPerMonitorDpiAware()) { 41 if (base::win::IsProcessPerMonitorDpiAware()) {
39 static auto get_dpi_for_monitor_func = [](){ 42 static auto get_dpi_for_monitor_func = [](){
40 using GetDpiForMonitorPtr = decltype(::GetDpiForMonitor)*; 43 using GetDpiForMonitorPtr = decltype(::GetDpiForMonitor)*;
41 HMODULE shcore_dll = ::LoadLibrary(L"shcore.dll"); 44 HMODULE shcore_dll = ::LoadLibrary(L"shcore.dll");
42 if (shcore_dll) { 45 if (shcore_dll) {
43 return reinterpret_cast<GetDpiForMonitorPtr>( 46 return reinterpret_cast<GetDpiForMonitorPtr>(
44 ::GetProcAddress(shcore_dll, "GetDpiForMonitor")); 47 ::GetProcAddress(shcore_dll, "GetDpiForMonitor"));
45 } 48 }
46 return static_cast<GetDpiForMonitorPtr>(nullptr); 49 return static_cast<GetDpiForMonitorPtr>(nullptr);
47 }(); 50 }();
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), 565 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(),
563 reported_scale) == unique_scale_factors.end()) { 566 reported_scale) == unique_scale_factors.end()) {
564 unique_scale_factors.push_back(reported_scale); 567 unique_scale_factors.push_back(reported_scale);
565 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); 568 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale);
566 } 569 }
567 } 570 }
568 } 571 }
569 572
570 } // namespace win 573 } // namespace win
571 } // namespace display 574 } // namespace display
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698