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" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 Rect DIPToScreenRect(const Rect& dip_bounds) { | 87 Rect DIPToScreenRect(const Rect& dip_bounds) { |
88 // See comment in ScreenToDIPRect for why we calculate size like this. | 88 // See comment in ScreenToDIPRect for why we calculate size like this. |
89 return Rect(DIPToScreenPoint(dip_bounds.origin()), | 89 return Rect(DIPToScreenPoint(dip_bounds.origin()), |
90 DIPToScreenSize(dip_bounds.size())); | 90 DIPToScreenSize(dip_bounds.size())); |
91 } | 91 } |
92 | 92 |
93 Size ScreenToDIPSize(const Size& size_in_pixels) { | 93 Size ScreenToDIPSize(const Size& size_in_pixels) { |
94 // Always ceil sizes. Otherwise we may be leaving off part of the bounds. | 94 // Always ceil sizes. Otherwise we may be leaving off part of the bounds. |
95 return ToCeiledSize(ScaleSize(size_in_pixels, 1.0f / GetDPIScale())); | 95 return ScaleToCeiledSize(size_in_pixels, 1.0f / GetDPIScale()); |
96 } | 96 } |
97 | 97 |
98 Size DIPToScreenSize(const Size& dip_size) { | 98 Size DIPToScreenSize(const Size& dip_size) { |
99 // 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. |
100 return ToCeiledSize(ScaleSize(dip_size, GetDPIScale())); | 100 return ScaleToCeiledSize(dip_size, GetDPIScale()); |
101 } | 101 } |
102 | 102 |
103 int GetSystemMetricsInDIP(int metric) { | 103 int GetSystemMetricsInDIP(int metric) { |
104 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); | 104 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); |
105 } | 105 } |
106 | 106 |
107 } // namespace win | 107 } // namespace win |
108 } // namespace gfx | 108 } // namespace gfx |
OLD | NEW |