| 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 #include "ui/gfx/win/dpi.h" | 5 #include "ui/gfx/win/dpi.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include "base/win/scoped_hdc.h" | 8 #include "base/win/scoped_hdc.h" |
| 9 #include "ui/gfx/display.h" | 9 #include "ui/gfx/display.h" |
| 10 #include "ui/gfx/geometry/point_conversions.h" | 10 #include "ui/gfx/geometry/point_conversions.h" |
| 11 #include "ui/gfx/geometry/rect_conversions.h" | 11 #include "ui/gfx/geometry/rect_conversions.h" |
| 12 #include "ui/gfx/geometry/size_conversions.h" | 12 #include "ui/gfx/geometry/size_conversions.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 int kDefaultDPIX = 96; | 16 int kDefaultDPI = 96; |
| 17 int kDefaultDPIY = 96; | |
| 18 | |
| 19 bool force_highdpi_for_testing = false; | |
| 20 | 17 |
| 21 float g_device_scale_factor = 0.0f; | 18 float g_device_scale_factor = 0.0f; |
| 22 | 19 |
| 23 float GetUnforcedDeviceScaleFactor() { | 20 float GetUnforcedDeviceScaleFactor() { |
| 24 // If the global device scale factor is initialized use it. This is to ensure | 21 // If the global device scale factor is initialized use it. This is to ensure |
| 25 // we use the same scale factor across all callsites. | 22 // we use the same scale factor across all callsites. |
| 26 if (g_device_scale_factor) | 23 if (g_device_scale_factor) |
| 27 return g_device_scale_factor; | 24 return g_device_scale_factor; |
| 28 return static_cast<float>(gfx::GetDPI().width()) / | 25 return static_cast<float>(gfx::GetDPI().width()) / |
| 29 static_cast<float>(kDefaultDPIX); | 26 static_cast<float>(kDefaultDPI); |
| 30 } | 27 } |
| 31 | 28 |
| 32 } // namespace | 29 } // namespace |
| 33 | 30 |
| 34 namespace gfx { | 31 namespace gfx { |
| 35 | 32 |
| 36 void InitDeviceScaleFactor(float scale) { | 33 void InitDeviceScaleFactor(float scale) { |
| 37 DCHECK_NE(0.0f, scale); | 34 DCHECK_NE(0.0f, scale); |
| 38 g_device_scale_factor = scale; | 35 g_device_scale_factor = scale; |
| 39 } | 36 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // Always ceil sizes. Otherwise we may be leaving off part of the bounds. | 99 // Always ceil sizes. Otherwise we may be leaving off part of the bounds. |
| 103 return ToCeiledSize(ScaleSize(dip_size, GetDPIScale())); | 100 return ToCeiledSize(ScaleSize(dip_size, GetDPIScale())); |
| 104 } | 101 } |
| 105 | 102 |
| 106 int GetSystemMetricsInDIP(int metric) { | 103 int GetSystemMetricsInDIP(int metric) { |
| 107 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); | 104 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); |
| 108 } | 105 } |
| 109 | 106 |
| 110 } // namespace win | 107 } // namespace win |
| 111 } // namespace gfx | 108 } // namespace gfx |
| OLD | NEW |