| 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/compositor/dip_util.h" | 5 #include "ui/compositor/dip_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "ui/base/ui_base_switches.h" | 8 #include "ui/base/ui_base_switches.h" |
| 9 #include "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
| 10 #include "ui/compositor/compositor_switches.h" | 10 #include "ui/compositor/compositor_switches.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 float GetDeviceScaleFactor(const Layer* layer) { | 22 float GetDeviceScaleFactor(const Layer* layer) { |
| 23 return layer->device_scale_factor(); | 23 return layer->device_scale_factor(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 gfx::Point ConvertPointToDIP(const Layer* layer, | 26 gfx::Point ConvertPointToDIP(const Layer* layer, |
| 27 const gfx::Point& point_in_pixel) { | 27 const gfx::Point& point_in_pixel) { |
| 28 return gfx::ToFlooredPoint( | 28 return gfx::ToFlooredPoint( |
| 29 gfx::ScalePoint(point_in_pixel, 1.0f / GetDeviceScaleFactor(layer))); | 29 gfx::ScalePoint(point_in_pixel, 1.0f / GetDeviceScaleFactor(layer))); |
| 30 } | 30 } |
| 31 | 31 |
| 32 gfx::PointF ConvertPointToDIP(const Layer* layer, |
| 33 const gfx::PointF& point_in_pixel) { |
| 34 return gfx::ScalePoint(point_in_pixel, 1.0f / GetDeviceScaleFactor(layer)); |
| 35 } |
| 36 |
| 32 gfx::Size ConvertSizeToDIP(const Layer* layer, | 37 gfx::Size ConvertSizeToDIP(const Layer* layer, |
| 33 const gfx::Size& size_in_pixel) { | 38 const gfx::Size& size_in_pixel) { |
| 34 return gfx::ToFlooredSize( | 39 return gfx::ToFlooredSize( |
| 35 gfx::ScaleSize(size_in_pixel, 1.0f / GetDeviceScaleFactor(layer))); | 40 gfx::ScaleSize(size_in_pixel, 1.0f / GetDeviceScaleFactor(layer))); |
| 36 } | 41 } |
| 37 | 42 |
| 38 gfx::Rect ConvertRectToDIP(const Layer* layer, | 43 gfx::Rect ConvertRectToDIP(const Layer* layer, |
| 39 const gfx::Rect& rect_in_pixel) { | 44 const gfx::Rect& rect_in_pixel) { |
| 40 float scale = 1.0f / GetDeviceScaleFactor(layer); | 45 float scale = 1.0f / GetDeviceScaleFactor(layer); |
| 41 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_pixel, scale)); | 46 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_pixel, scale)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 return gfx::ToFlooredSize( | 57 return gfx::ToFlooredSize( |
| 53 gfx::ScaleSize(size_in_dip, GetDeviceScaleFactor(layer))); | 58 gfx::ScaleSize(size_in_dip, GetDeviceScaleFactor(layer))); |
| 54 } | 59 } |
| 55 | 60 |
| 56 gfx::Rect ConvertRectToPixel(const Layer* layer, | 61 gfx::Rect ConvertRectToPixel(const Layer* layer, |
| 57 const gfx::Rect& rect_in_dip) { | 62 const gfx::Rect& rect_in_dip) { |
| 58 float scale = GetDeviceScaleFactor(layer); | 63 float scale = GetDeviceScaleFactor(layer); |
| 59 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_dip, scale)); | 64 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_dip, scale)); |
| 60 } | 65 } |
| 61 } // namespace ui | 66 } // namespace ui |
| OLD | NEW |