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

Side by Side Diff: ui/base/win/dpi.cc

Issue 16196008: Add HiDPI flag for Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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/base/ui_base_switches.cc ('k') | 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/base/win/dpi.h" 5 #include "ui/base/win/dpi.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8 #include "base/command_line.h"
9 #include "base/win/scoped_hdc.h" 9 #include "base/win/scoped_hdc.h"
10 #include "ui/base/layout.h" 10 #include "ui/base/layout.h"
11 #include "base/win/registry.h" 11 #include "base/win/registry.h"
12 #include "ui/base/ui_base_switches.h"
12 #include "ui/gfx/display.h" 13 #include "ui/gfx/display.h"
13 #include "ui/gfx/point_conversions.h" 14 #include "ui/gfx/point_conversions.h"
14 #include "ui/gfx/rect_conversions.h" 15 #include "ui/gfx/rect_conversions.h"
15 #include "ui/gfx/size_conversions.h" 16 #include "ui/gfx/size_conversions.h"
16 17
17 namespace { 18 namespace {
18 19
19 int kDefaultDPIX = 96; 20 int kDefaultDPIX = 96;
20 int kDefaultDPIY = 96; 21 int kDefaultDPIY = 96;
21 22
23 bool IsHighDPIEnabled() {
24 // Default is disabled.
25 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kHighDPISupport)) {
26 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
27 switches::kHighDPISupport).compare("1") == 0;
28 }
29 return false;
30 }
31
22 float GetDeviceScaleFactorImpl() { 32 float GetDeviceScaleFactorImpl() {
23 #if defined(ENABLE_HIDPI) 33 #if defined(ENABLE_HIDPI)
24 float scale = gfx::Display::HasForceDeviceScaleFactor() ? 34 if (IsHighDPIEnabled()) {
25 gfx::Display::GetForcedDeviceScaleFactor() : ui::GetDPIScale(); 35 float scale = gfx::Display::HasForceDeviceScaleFactor() ?
26 // Quantize to nearest supported scale factor. 36 gfx::Display::GetForcedDeviceScaleFactor() : ui::GetDPIScale();
27 scale = ui::GetScaleFactorScale(ui::GetScaleFactorFromScale(scale)); 37 // Quantize to nearest supported scale factor.
28 return scale; 38 scale = ui::GetScaleFactorScale(ui::GetScaleFactorFromScale(scale));
29 #else 39 return scale;
40 }
41 #endif
30 return 1.0f; 42 return 1.0f;
31 #endif
32 } 43 }
33 44
34 BOOL IsProcessDPIAwareWrapper() { 45 BOOL IsProcessDPIAwareWrapper() {
35 typedef BOOL(WINAPI *IsProcessDPIAwarePtr)(VOID); 46 typedef BOOL(WINAPI *IsProcessDPIAwarePtr)(VOID);
36 IsProcessDPIAwarePtr is_process_dpi_aware_func = 47 IsProcessDPIAwarePtr is_process_dpi_aware_func =
37 reinterpret_cast<IsProcessDPIAwarePtr>( 48 reinterpret_cast<IsProcessDPIAwarePtr>(
38 GetProcAddress(GetModuleHandleA("user32.dll"), "IsProcessDPIAware")); 49 GetProcAddress(GetModuleHandleA("user32.dll"), "IsProcessDPIAware"));
39 if (is_process_dpi_aware_func) 50 if (is_process_dpi_aware_func)
40 return is_process_dpi_aware_func(); 51 return is_process_dpi_aware_func();
41 return FALSE; 52 return FALSE;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 146 }
136 } 147 }
137 } 148 }
138 } 149 }
139 return scale; 150 return scale;
140 } 151 }
141 152
142 } // namespace win 153 } // namespace win
143 154
144 } // namespace ui 155 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ui_base_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698