Chromium Code Reviews| 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 kDefaultDPIX = 96; |
| 17 int kDefaultDPIY = 96; | 17 // int kDefaultDPIY = 96; |
|
Nico
2015/07/02 17:34:26
?
Matt Giuca
2015/07/03 03:46:29
Again, I didn't want to delete this information fr
| |
| 18 | |
| 19 bool force_highdpi_for_testing = false; | |
| 20 | 18 |
| 21 float g_device_scale_factor = 0.0f; | 19 float g_device_scale_factor = 0.0f; |
| 22 | 20 |
| 23 float GetUnforcedDeviceScaleFactor() { | 21 float GetUnforcedDeviceScaleFactor() { |
| 24 // If the global device scale factor is initialized use it. This is to ensure | 22 // If the global device scale factor is initialized use it. This is to ensure |
| 25 // we use the same scale factor across all callsites. | 23 // we use the same scale factor across all callsites. |
| 26 if (g_device_scale_factor) | 24 if (g_device_scale_factor) |
| 27 return g_device_scale_factor; | 25 return g_device_scale_factor; |
| 28 return static_cast<float>(gfx::GetDPI().width()) / | 26 return static_cast<float>(gfx::GetDPI().width()) / |
| 29 static_cast<float>(kDefaultDPIX); | 27 static_cast<float>(kDefaultDPIX); |
| (...skipping 72 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. | 100 // Always ceil sizes. Otherwise we may be leaving off part of the bounds. |
| 103 return ToCeiledSize(ScaleSize(dip_size, GetDPIScale())); | 101 return ToCeiledSize(ScaleSize(dip_size, GetDPIScale())); |
| 104 } | 102 } |
| 105 | 103 |
| 106 int GetSystemMetricsInDIP(int metric) { | 104 int GetSystemMetricsInDIP(int metric) { |
| 107 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); | 105 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); |
| 108 } | 106 } |
| 109 | 107 |
| 110 } // namespace win | 108 } // namespace win |
| 111 } // namespace gfx | 109 } // namespace gfx |
| OLD | NEW |