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/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 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | |
|
kevers
2013/06/03 17:28:50
Misleading comment. ToFlooredPoint is not depreca
girard
2013/06/03 22:31:55
Done.
| |
| 98 return gfx::ToFlooredPoint( | |
| 99 gfx::ScalePoint(dip_point, GetDeviceScaleFactor())); | |
| 100 } | |
| 101 | |
| 96 gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) { | 102 gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) { |
| 97 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | 103 // TODO(kevers): Switch to non-deprecated method for float to int conversions. |
| 98 return gfx::ToFlooredRectDeprecated( | 104 return gfx::ToFlooredRectDeprecated( |
| 99 gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactor())); | 105 gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactor())); |
| 100 } | 106 } |
| 101 | 107 |
| 102 gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) { | 108 gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) { |
| 103 // TODO(kevers): Switch to non-deprecated method for float to int conversions. | 109 // TODO(kevers): Switch to non-deprecated method for float to int conversions. |
| 104 return gfx::ToFlooredRectDeprecated( | 110 return gfx::ToFlooredRectDeprecated( |
| 105 gfx::ScaleRect(dip_bounds, GetDeviceScaleFactor())); | 111 gfx::ScaleRect(dip_bounds, GetDeviceScaleFactor())); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 135 } | 141 } |
| 136 } | 142 } |
| 137 } | 143 } |
| 138 } | 144 } |
| 139 return scale; | 145 return scale; |
| 140 } | 146 } |
| 141 | 147 |
| 142 } // namespace win | 148 } // namespace win |
| 143 | 149 |
| 144 } // namespace ui | 150 } // namespace ui |
| OLD | NEW |