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.
5 #ifndef UI_GFX_DPI_WIN_H_
6 #define UI_GFX_DPI_WIN_H_
8 #include "ui/gfx/gfx_export.h"
9 #include "ui/gfx/point.h"
10 #include "ui/gfx/rect.h"
11 #include "ui/gfx/size.h"
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
20 GFX_EXPORT
void InitDeviceScaleFactor(float scale
);
22 GFX_EXPORT Size
GetDPI();
24 // Gets the scale factor of the display. For example, if the display DPI is
25 // 96 then the scale factor is 1.0.
26 GFX_EXPORT
float GetDPIScale();
28 // Tests to see if the command line flag "--high-dpi-support" is set.
29 GFX_EXPORT
bool IsHighDPIEnabled();
31 GFX_EXPORT
bool IsInHighDPIMode();
33 GFX_EXPORT
void EnableHighDPISupport();
35 GFX_EXPORT
void ForceHighDPISupportForTesting(float scale
);
37 // TODO(kevers|girard): Move above methods into win namespace.
41 GFX_EXPORT
float GetDeviceScaleFactor();
43 GFX_EXPORT Point
ScreenToDIPPoint(const Point
& pixel_point
);
45 GFX_EXPORT Point
DIPToScreenPoint(const Point
& dip_point
);
47 GFX_EXPORT Rect
ScreenToDIPRect(const Rect
& pixel_bounds
);
49 GFX_EXPORT Rect
DIPToScreenRect(const Rect
& dip_bounds
);
51 GFX_EXPORT Size
ScreenToDIPSize(const Size
& size_in_pixels
);
53 GFX_EXPORT Size
DIPToScreenSize(const Size
& dip_size
);
55 // Win32's GetSystemMetrics uses pixel measures. This function calls
56 // GetSystemMetrics for the given |metric|, then converts the result to DIP.
57 GFX_EXPORT
int GetSystemMetricsInDIP(int metric
);
59 // Returns true if the global device scale factor has been explicitly set for
61 GFX_EXPORT
bool IsDeviceScaleFactorSet();
63 GFX_EXPORT
extern const wchar_t kRegistryProfilePath
[];
64 GFX_EXPORT
extern const wchar_t kHighDPISupportW
[];
69 #endif // UI_GFX_DPI_WIN_H_