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/base/win/dpi.h" | 5 #include "ui/base/win/dpi.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/win/scoped_hdc.h" | 9 #include "base/win/scoped_hdc.h" |
10 #include "ui/base/layout.h" | 10 #include "ui/base/layout.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 float GetDeviceScaleFactor() { | 97 float GetDeviceScaleFactor() { |
98 static const float device_scale_factor = GetDeviceScaleFactorImpl(); | 98 static const float device_scale_factor = GetDeviceScaleFactorImpl(); |
99 return device_scale_factor; | 99 return device_scale_factor; |
100 } | 100 } |
101 | 101 |
102 gfx::Point ScreenToDIPPoint(const gfx::Point& pixel_point) { | 102 gfx::Point ScreenToDIPPoint(const gfx::Point& pixel_point) { |
103 return gfx::ToFlooredPoint( | 103 return gfx::ToFlooredPoint( |
104 gfx::ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor())); | 104 gfx::ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor())); |
105 } | 105 } |
106 | 106 |
| 107 gfx::Point DIPToScreenPoint(const gfx::Point& dip_point) { |
| 108 return gfx::ToFlooredPoint( |
| 109 gfx::ScalePoint(dip_point, GetDeviceScaleFactor())); |
| 110 } |
| 111 |
107 gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) { | 112 gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) { |
108 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | 113 // TODO(kevers): Switch to non-deprecated method for float to int conversions. |
109 return gfx::ToFlooredRectDeprecated( | 114 return gfx::ToFlooredRectDeprecated( |
110 gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactor())); | 115 gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactor())); |
111 } | 116 } |
112 | 117 |
113 gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) { | 118 gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) { |
114 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | 119 // TODO(kevers): Switch to non-deprecated method for float to int conversions. |
115 return gfx::ToFlooredRectDeprecated( | 120 return gfx::ToFlooredRectDeprecated( |
116 gfx::ScaleRect(dip_bounds, GetDeviceScaleFactor())); | 121 gfx::ScaleRect(dip_bounds, GetDeviceScaleFactor())); |
(...skipping 29 matching lines...) Expand all Loading... |
146 } | 151 } |
147 } | 152 } |
148 } | 153 } |
149 } | 154 } |
150 return scale; | 155 return scale; |
151 } | 156 } |
152 | 157 |
153 } // namespace win | 158 } // namespace win |
154 | 159 |
155 } // namespace ui | 160 } // namespace ui |
OLD | NEW |