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

Side by Side Diff: ui/gfx/dpi.h

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: constants Created 6 years, 1 month 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
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 #ifndef UI_GFX_DPI_WIN_H_ 5 #ifndef UI_GFX_DPI_H_
6 #define UI_GFX_DPI_WIN_H_ 6 #define UI_GFX_DPI_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 {
sky 2014/10/22 21:11:18 I have always found this file confusing. It's a mi
scottmg 2014/10/22 23:56:18 Yes, I find it very confusing too, since it seems
14 14
15 // Initialization of the scale factor that should be applied for rendering 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 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. 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 18 // This can be called multiple times during various tests, but subsequent calls
19 // have no effect. 19 // have no effect.
20 GFX_EXPORT void InitDeviceScaleFactor(float scale); 20 GFX_EXPORT void InitDeviceScaleFactor(float scale);
21 21
22 GFX_EXPORT float GetDeviceScaleFactor();
23
24 // Returns true if the global device scale factor has been explicitly set for
25 // the process.
26 GFX_EXPORT bool IsDeviceScaleFactorSet();
27
28 GFX_EXPORT void ForceHighDPISupportForTesting(float scale);
29
30 GFX_EXPORT bool IsInHighDPIMode();
sky 2014/10/22 21:11:18 Can this function be nuked and callers use GetDPI
31
22 GFX_EXPORT Size GetDPI(); 32 GFX_EXPORT Size GetDPI();
23 33
24 // Gets the scale factor of the display. For example, if the display DPI is 34 // Gets the scale factor of the display. For example, if the display DPI is
25 // 96 then the scale factor is 1.0. 35 // 96 then the scale factor is 1.0.
26 GFX_EXPORT float GetDPIScale(); 36 GFX_EXPORT float GetDPIScale();
27 37
28 // Tests to see if the command line flag "--high-dpi-support" is set.
29 GFX_EXPORT bool IsHighDPIEnabled();
30
31 GFX_EXPORT bool IsInHighDPIMode();
32
33 GFX_EXPORT void EnableHighDPISupport();
34
35 GFX_EXPORT void ForceHighDPISupportForTesting(float scale);
36
37 // TODO(kevers|girard): Move above methods into win namespace.
38
39 namespace win {
40
41 GFX_EXPORT float GetDeviceScaleFactor();
42
43 GFX_EXPORT Point ScreenToDIPPoint(const Point& pixel_point); 38 GFX_EXPORT Point ScreenToDIPPoint(const Point& pixel_point);
44 39
45 GFX_EXPORT Point DIPToScreenPoint(const Point& dip_point); 40 GFX_EXPORT Point DIPToScreenPoint(const Point& dip_point);
46 41
47 // WARNING: there is no right way to scale sizes and rects. The implementation 42 // WARNING: there is no right way to scale sizes and rects. The implementation
48 // of these strives to maintain a constant size by scaling the size independent 43 // of these strives to maintain a constant size by scaling the size independent
49 // of the origin. An alternative is to get the enclosing rect, which is the 44 // of the origin. An alternative is to get the enclosing rect, which is the
50 // right way for some situations. Understand which you need before blindly 45 // right way for some situations. Understand which you need before blindly
51 // assuming this is the right way. 46 // assuming this is the right way.
52 GFX_EXPORT Rect ScreenToDIPRect(const Rect& pixel_bounds); 47 GFX_EXPORT Rect ScreenToDIPRect(const Rect& pixel_bounds);
53 GFX_EXPORT Rect DIPToScreenRect(const Rect& dip_bounds); 48 GFX_EXPORT Rect DIPToScreenRect(const Rect& dip_bounds);
54 GFX_EXPORT Size ScreenToDIPSize(const Size& size_in_pixels); 49 GFX_EXPORT Size ScreenToDIPSize(const Size& size_in_pixels);
55 GFX_EXPORT Size DIPToScreenSize(const Size& dip_size); 50 GFX_EXPORT Size DIPToScreenSize(const Size& dip_size);
56 51
52 // Tests to see if the command line flag "--high-dpi-support" is set on Windows,
53 // always true on Linux.
54 GFX_EXPORT bool IsHighDPIEnabled();
sky 2014/10/22 21:11:18 Can this be nuked too?
55
56 #if defined(OS_WIN)
57 namespace win {
58
59 GFX_EXPORT void EnableHighDPISupport();
60
57 // Win32's GetSystemMetrics uses pixel measures. This function calls 61 // Win32's GetSystemMetrics uses pixel measures. This function calls
58 // GetSystemMetrics for the given |metric|, then converts the result to DIP. 62 // GetSystemMetrics for the given |metric|, then converts the result to DIP.
59 GFX_EXPORT int GetSystemMetricsInDIP(int metric); 63 GFX_EXPORT int GetSystemMetricsInDIP(int metric);
60 64
61 // Returns true if the global device scale factor has been explicitly set for 65 } // namespace win
62 // the process. 66 #endif // OS_WIN
63 GFX_EXPORT bool IsDeviceScaleFactorSet();
64 67
65 GFX_EXPORT extern const wchar_t kRegistryProfilePath[];
66 GFX_EXPORT extern const wchar_t kHighDPISupportW[];
67
68 } // namespace win
69 } // namespace gfx 68 } // namespace gfx
70 69
71 #endif // UI_GFX_DPI_WIN_H_ 70 #endif // UI_GFX_DPI_H_
OLDNEW
« no previous file with comments | « ui/gfx/canvas_paint_win.cc ('k') | ui/gfx/dpi.cc » ('j') | ui/gfx/dpi_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698