OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "ui/display/win/dpi.h" | 5 #include "ui/display/win/dpi.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/win/scoped_hdc.h" | 9 #include "base/win/scoped_hdc.h" |
10 #include "ui/display/display.h" | 10 #include "ui/display/display.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 void SetDefaultDeviceScaleFactor(float scale) { | 46 void SetDefaultDeviceScaleFactor(float scale) { |
47 DCHECK_NE(0.f, scale); | 47 DCHECK_NE(0.f, scale); |
48 g_device_scale_factor = scale; | 48 g_device_scale_factor = scale; |
49 } | 49 } |
50 | 50 |
51 float GetDPIScale() { | 51 float GetDPIScale() { |
52 if (display::Display::HasForceDeviceScaleFactor()) | 52 if (display::Display::HasForceDeviceScaleFactor()) |
53 return display::Display::GetForcedDeviceScaleFactor(); | 53 return display::Display::GetForcedDeviceScaleFactor(); |
54 float dpi_scale = GetUnforcedDeviceScaleFactor(); | 54 return GetUnforcedDeviceScaleFactor(); |
55 return (dpi_scale <= 1.25f) ? 1.f : dpi_scale; | |
56 } | 55 } |
57 | 56 |
58 int GetDPIFromScalingFactor(float device_scaling_factor) { | 57 int GetDPIFromScalingFactor(float device_scaling_factor) { |
59 return kDefaultDPI * device_scaling_factor; | 58 return kDefaultDPI * device_scaling_factor; |
60 } | 59 } |
61 | 60 |
62 float GetScalingFactorFromDPI(int dpi) { | 61 float GetScalingFactorFromDPI(int dpi) { |
63 return static_cast<float>(dpi) / kDefaultDPI; | 62 return static_cast<float>(dpi) / kDefaultDPI; |
64 } | 63 } |
65 | 64 |
66 int GetSystemMetricsInDIP(int metric) { | 65 int GetSystemMetricsInDIP(int metric) { |
67 // The system metrics always reflect the system DPI, not whatever scale we've | 66 // The system metrics always reflect the system DPI, not whatever scale we've |
68 // forced or decided to use. | 67 // forced or decided to use. |
69 return static_cast<int>( | 68 return static_cast<int>( |
70 std::round(GetSystemMetrics(metric) / GetUnforcedDeviceScaleFactor())); | 69 std::round(GetSystemMetrics(metric) / GetUnforcedDeviceScaleFactor())); |
71 } | 70 } |
72 | 71 |
73 } // namespace win | 72 } // namespace win |
74 } // namespace display | 73 } // namespace display |
OLD | NEW |