OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/base/scale.h" | |
6 | |
7 #include "base/basictypes.h" | |
8 | |
9 #if defined(OS_WIN) | |
10 #include "ui/base/win/dpi.h" | |
11 #include <Windows.h> | |
12 #endif // defined(OS_WIN) | |
13 | |
14 namespace { | |
15 | |
16 #if defined(OS_WIN) | |
17 | |
18 // TODO(joi): Pick this function up from somewhere central. | |
19 bool IsInMetroMode() { | |
sail
2012/04/18 16:44:14
I've added a new metro.h file in this CL:
http://c
Jói
2012/04/18 17:06:31
Updated my patch of your change and switched to us
| |
20 const char* kMetroModeEnvVar = "CHROME_METRO_DLL"; | |
21 char buffer[2]; | |
22 if (!::GetEnvironmentVariableA(kMetroModeEnvVar, buffer, arraysize(buffer))) | |
23 return false; | |
24 return buffer == std::string("1"); | |
25 } | |
26 | |
27 void GetScaleImplWin(bool* use_metro, bool* use_hidpi) { | |
28 #if defined(ENABLE_METRO) | |
29 *use_metro = IsInMetroMode(); | |
30 #endif // defined(ENABLE_METRO) | |
31 #if defined(ENABLE_HIDPI) | |
32 *use_hidpi = ui::GetDPIScale() > 1.5; | |
33 #endif // defined(ENABLE_HIDPI) | |
34 } | |
35 | |
36 #endif // defined(OS_WIN) | |
37 | |
38 } // namespace | |
39 | |
40 namespace ui { | |
41 | |
42 const DisplayScale GetThemeScale() { | |
43 #if defined(USE_ASH) | |
44 return DS_ASH; | |
45 #elif !defined(OS_WIN) | |
46 return DS_DESKTOP_100; | |
47 #else // On Windows. | |
48 bool use_metro = false; | |
49 bool use_hidpi = false; | |
50 GetScaleImplWin(&use_metro, &use_hidpi); | |
51 if (use_metro) { | |
52 // TODO(joi): Other Metro scales. | |
53 return DS_METRO_100; | |
54 } else if (use_hidpi) { | |
55 return DS_DESKTOP_200; | |
56 } else { | |
57 return DS_DESKTOP_100; | |
58 } | |
59 #endif // On Windows. | |
60 } | |
61 | |
62 const DisplayScale GetUIScale() { | |
63 #if defined(USE_ASH) | |
64 return DS_ASH; | |
65 #elif !defined(OS_WIN) | |
66 return DS_DESKTOP_100; | |
67 #else // On Windows. | |
68 bool use_metro = false; | |
69 bool use_hidpi = false; | |
70 GetScaleImplWin(&use_metro, &use_hidpi); | |
71 if (use_hidpi) { | |
72 return DS_DESKTOP_200; | |
73 } else { | |
74 return DS_DESKTOP_100; | |
75 } | |
76 #endif // On Windows. | |
77 } | |
78 | |
79 } // namespace ui | |
OLD | NEW |