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 #ifndef UI_GFX_DPI_WIN_H_ | 5 #ifndef UI_GFX_DPI_WIN_H_ |
6 #define UI_GFX_DPI_WIN_H_ | 6 #define UI_GFX_DPI_WIN_H_ |
7 | 7 |
8 #include "ui/gfx/gfx_export.h" | 8 #include "ui/gfx/gfx_export.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 UI_EXPORT Size GetDPI(); | 15 // Initialization of the scale factor that should be applied for rendering |
| 16 // in this process. Must be called before attempts to call any of the getter |
| 17 // methods below in this file, e.g. in the early toolkit/resource bundle setup. |
| 18 // This can be called multiple times during various tests, but subsequent calls |
| 19 // have no effect. |
| 20 GFX_EXPORT void InitDeviceScaleFactor(float scale); |
| 21 |
| 22 GFX_EXPORT Size GetDPI(); |
16 | 23 |
17 // Gets the scale factor of the display. For example, if the display DPI is | 24 // Gets the scale factor of the display. For example, if the display DPI is |
18 // 96 then the scale factor is 1.0. | 25 // 96 then the scale factor is 1.0. |
19 UI_EXPORT float GetDPIScale(); | 26 GFX_EXPORT float GetDPIScale(); |
20 | 27 |
21 UI_EXPORT bool IsInHighDPIMode(); | 28 // Tests to see if the command line flag "--high-dpi-support" is set. |
| 29 GFX_EXPORT bool IsHighDPIEnabled(); |
22 | 30 |
23 UI_EXPORT void EnableHighDPISupport(); | 31 GFX_EXPORT bool IsInHighDPIMode(); |
| 32 |
| 33 GFX_EXPORT void EnableHighDPISupport(); |
24 | 34 |
25 // TODO(kevers|girard): Move above methods into win namespace. | 35 // TODO(kevers|girard): Move above methods into win namespace. |
26 | 36 |
27 namespace win { | 37 namespace win { |
28 | 38 |
29 UI_EXPORT float GetDeviceScaleFactor(); | 39 GFX_EXPORT float GetDeviceScaleFactor(); |
30 | 40 |
31 UI_EXPORT Point ScreenToDIPPoint(const Point& pixel_point); | 41 GFX_EXPORT Point ScreenToDIPPoint(const Point& pixel_point); |
32 | 42 |
33 UI_EXPORT Point DIPToScreenPoint(const Point& dip_point); | 43 GFX_EXPORT Point DIPToScreenPoint(const Point& dip_point); |
34 | 44 |
35 UI_EXPORT Rect ScreenToDIPRect(const Rect& pixel_bounds); | 45 GFX_EXPORT Rect ScreenToDIPRect(const Rect& pixel_bounds); |
36 | 46 |
37 UI_EXPORT Rect DIPToScreenRect(const Rect& dip_bounds); | 47 GFX_EXPORT Rect DIPToScreenRect(const Rect& dip_bounds); |
38 | 48 |
39 UI_EXPORT Size ScreenToDIPSize(const Size& size_in_pixels); | 49 GFX_EXPORT Size ScreenToDIPSize(const Size& size_in_pixels); |
40 | 50 |
41 UI_EXPORT Size DIPToScreenSize(const Size& dip_size); | 51 GFX_EXPORT Size DIPToScreenSize(const Size& dip_size); |
42 | 52 |
43 // Win32's GetSystemMetrics uses pixel measures. This function calls | 53 // Win32's GetSystemMetrics uses pixel measures. This function calls |
44 // GetSystemMetrics for the given |metric|, then converts the result to DIP. | 54 // GetSystemMetrics for the given |metric|, then converts the result to DIP. |
45 UI_EXPORT int GetSystemMetricsInDIP(int metric); | 55 GFX_EXPORT int GetSystemMetricsInDIP(int metric); |
46 | 56 |
47 // Sometimes the OS secretly scales apps that are not DPIAware. This is not | 57 // Sometimes the OS secretly scales apps that are not DPIAware. This is not |
48 // visible through standard OS calls like GetWindowPos(), or through | 58 // visible through standard OS calls like GetWindowPos(), or through |
49 // GetDPIScale(). | 59 // GetDPIScale(). |
50 // Returns the scale factor of the display, where 96 DPI is 1.0. | 60 // Returns the scale factor of the display, where 96 DPI is 1.0. |
51 // (Avoid this function... use GetDPIScale() instead.) | 61 // (Avoid this function... use GetDPIScale() instead.) |
52 // TODO(girard): Remove this once DPIAware is enabled - http://crbug.com/149881 | 62 // TODO(girard): Remove this once DPIAware is enabled - http://crbug.com/149881 |
53 UI_EXPORT double GetUndocumentedDPIScale(); | 63 GFX_EXPORT double GetUndocumentedDPIScale(); |
54 | 64 |
55 // Win7 and Win8 send touch events scaled according to the current DPI | 65 // Win7 and Win8 send touch events scaled according to the current DPI |
56 // scaling. Win8.1 corrects this, and sends touch events in DPI units. | 66 // scaling. Win8.1 corrects this, and sends touch events in DPI units. |
57 // This function returns the appropriate scaling factor for touch events. | 67 // This function returns the appropriate scaling factor for touch events. |
58 UI_EXPORT double GetUndocumentedDPITouchScale(); | 68 GFX_EXPORT double GetUndocumentedDPITouchScale(); |
59 | 69 |
60 } // namespace win | 70 } // namespace win |
61 } // namespace gfx | 71 } // namespace gfx |
62 | 72 |
63 #endif // UI_GFX_DPI_WIN_H_ | 73 #endif // UI_GFX_DPI_WIN_H_ |
OLD | NEW |