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

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

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make DisplayWin Standalone Created 4 years, 11 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/gfx/screen_win_unittest.cc ('k') | ui/gfx/win/dpi.cc » ('j') | 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 #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/geometry/point.h" 8 #include "ui/gfx/geometry/point.h"
9 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/size.h" 10 #include "ui/gfx/geometry/size.h"
11 #include "ui/gfx/gfx_export.h" 11 #include "ui/gfx/gfx_export.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 14
15 // Sets the device scale factor that will be used unless overridden on the 15 // Sets the device scale factor that will be used unless overridden on the
16 // command line by --force-device-scale-factor. If this is not called, and that 16 // command line by --force-device-scale-factor. If this is not called, and that
17 // flag is not used, the scale factor used by the DIP conversion functions below 17 // flag is not used, the scale factor used by the DIP conversion functions below
18 // will be that returned by GetDPIScale(). 18 // will be that returned by GetDPIScale().
19 GFX_EXPORT void SetDefaultDeviceScaleFactor(float scale); 19 GFX_EXPORT void SetDefaultDeviceScaleFactor(float scale);
20 20
21 GFX_EXPORT Size GetDPI(); 21 GFX_EXPORT int GetDPIFromScalingFactor(float device_scaling_factor);
22 22
23 // Gets the scale factor of the display. For example, if the display DPI is 23 // Gets the scale factor of the display. For example, if the display DPI is
24 // 96 then the scale factor is 1.0. This clamps scale factors <= 1.25 to 1.0 to 24 // 96 then the scale factor is 1.0. This clamps scale factors <= 1.25 to 1.0 to
25 // maintain previous (non-DPI-aware) behavior where only the font size was 25 // maintain previous (non-DPI-aware) behavior where only the font size was
26 // boosted. 26 // boosted.
27 GFX_EXPORT float GetDPIScale(); 27 GFX_EXPORT float GetDPIScale();
28 28
29 namespace win { 29 namespace win {
30 30
31 GFX_EXPORT Point ScreenToDIPPoint(const Point& pixel_point);
32
33 GFX_EXPORT Point DIPToScreenPoint(const Point& dip_point);
34
35 // WARNING: there is no right way to scale sizes and rects. The implementation
36 // of these strives to maintain a constant size by scaling the size independent
37 // of the origin. An alternative is to get the enclosing rect, which is the
38 // right way for some situations. Understand which you need before blindly
39 // assuming this is the right way.
40 GFX_EXPORT Rect ScreenToDIPRect(const Rect& pixel_bounds);
41 GFX_EXPORT Rect DIPToScreenRect(const Rect& dip_bounds);
42 GFX_EXPORT Size ScreenToDIPSize(const Size& size_in_pixels);
43 GFX_EXPORT Size DIPToScreenSize(const Size& dip_size);
44
45 // Win32's GetSystemMetrics uses pixel measures. This function calls 31 // Win32's GetSystemMetrics uses pixel measures. This function calls
46 // GetSystemMetrics for the given |metric|, then converts the result to DIP. 32 // GetSystemMetrics for the given |metric|, then converts the result to DIP.
47 GFX_EXPORT int GetSystemMetricsInDIP(int metric); 33 GFX_EXPORT int GetSystemMetricsInDIP(int metric);
48 34
49 } // namespace win 35 } // namespace win
50 } // namespace gfx 36 } // namespace gfx
51 37
52 #endif // UI_GFX_DPI_WIN_H_ 38 #endif // UI_GFX_DPI_WIN_H_
OLDNEW
« no previous file with comments | « ui/gfx/screen_win_unittest.cc ('k') | ui/gfx/win/dpi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698