| 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 | 8 |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 float GetDeviceScaleFactor() { | 86 float GetDeviceScaleFactor() { |
| 87 static const float device_scale_factor = GetDeviceScaleFactorImpl(); | 87 static const float device_scale_factor = GetDeviceScaleFactorImpl(); |
| 88 return device_scale_factor; | 88 return device_scale_factor; |
| 89 } | 89 } |
| 90 | 90 |
| 91 gfx::Point ScreenToDIPPoint(const gfx::Point& pixel_point) { | 91 gfx::Point ScreenToDIPPoint(const gfx::Point& pixel_point) { |
| 92 return gfx::ToFlooredPoint( | 92 return gfx::ToFlooredPoint( |
| 93 gfx::ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor())); | 93 gfx::ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor())); |
| 94 } | 94 } |
| 95 | 95 |
| 96 gfx::Point DIPToScreenPoint(const gfx::Point& dip_point) { |
| 97 return gfx::ToFlooredPoint( |
| 98 gfx::ScalePoint(dip_point, GetDeviceScaleFactor())); |
| 99 } |
| 100 |
| 96 gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) { | 101 gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) { |
| 97 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | 102 // TODO(kevers): Switch to non-deprecated method for float to int conversions. |
| 98 return gfx::ToFlooredRectDeprecated( | 103 return gfx::ToFlooredRectDeprecated( |
| 99 gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactor())); | 104 gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactor())); |
| 100 } | 105 } |
| 101 | 106 |
| 102 gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) { | 107 gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) { |
| 103 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | 108 // TODO(kevers): Switch to non-deprecated method for float to int conversions. |
| 104 return gfx::ToFlooredRectDeprecated( | 109 return gfx::ToFlooredRectDeprecated( |
| 105 gfx::ScaleRect(dip_bounds, GetDeviceScaleFactor())); | 110 gfx::ScaleRect(dip_bounds, GetDeviceScaleFactor())); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 135 } | 140 } |
| 136 } | 141 } |
| 137 } | 142 } |
| 138 } | 143 } |
| 139 return scale; | 144 return scale; |
| 140 } | 145 } |
| 141 | 146 |
| 142 } // namespace win | 147 } // namespace win |
| 143 | 148 |
| 144 } // namespace ui | 149 } // namespace ui |
| OLD | NEW |