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 "content/browser/renderer_host/dip_util.h" | 5 #include "content/browser/renderer_host/dip_util.h" |
6 | 6 |
7 #include "content/public/browser/render_widget_host_view.h" | 7 #include "content/public/browser/render_widget_host_view.h" |
8 #include "ui/gfx/display.h" | 8 #include "ui/gfx/display.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 #include "ui/gfx/point_conversions.h" | 10 #include "ui/gfx/point_conversions.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 gfx::Point ConvertPointToDIP(const RenderWidgetHostView* view, | 30 gfx::Point ConvertPointToDIP(const RenderWidgetHostView* view, |
31 const gfx::Point& point_in_pixel) { | 31 const gfx::Point& point_in_pixel) { |
32 return gfx::ToFlooredPoint( | 32 return gfx::ToFlooredPoint( |
33 gfx::ScalePoint(point_in_pixel, 1.0f / GetScaleForView(view))); | 33 gfx::ScalePoint(point_in_pixel, 1.0f / GetScaleForView(view))); |
34 } | 34 } |
35 | 35 |
36 gfx::Size ConvertSizeToDIP(const RenderWidgetHostView* view, | 36 gfx::Size ConvertSizeToDIP(const RenderWidgetHostView* view, |
37 const gfx::Size& size_in_pixel) { | 37 const gfx::Size& size_in_pixel) { |
38 return gfx::ToFlooredSize( | 38 return gfx::ToFlooredSize( |
39 size_in_pixel.Scale(1.0f / GetScaleForView(view))); | 39 gfx::ScaleSize(size_in_pixel, 1.0f / GetScaleForView(view))); |
40 } | 40 } |
41 | 41 |
42 gfx::Rect ConvertRectToDIP(const RenderWidgetHostView* view, | 42 gfx::Rect ConvertRectToDIP(const RenderWidgetHostView* view, |
43 const gfx::Rect& rect_in_pixel) { | 43 const gfx::Rect& rect_in_pixel) { |
44 float scale = 1.0f / GetScaleForView(view); | 44 float scale = 1.0f / GetScaleForView(view); |
45 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_pixel, scale)); | 45 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_pixel, scale)); |
46 } | 46 } |
47 | 47 |
48 gfx::Point ConvertPointToPixel(const RenderWidgetHostView* view, | 48 gfx::Point ConvertPointToPixel(const RenderWidgetHostView* view, |
49 const gfx::Point& point_in_dip) { | 49 const gfx::Point& point_in_dip) { |
50 return gfx::ToFlooredPoint( | 50 return gfx::ToFlooredPoint( |
51 gfx::ScalePoint(point_in_dip, GetScaleForView(view))); | 51 gfx::ScalePoint(point_in_dip, GetScaleForView(view))); |
52 } | 52 } |
53 | 53 |
54 gfx::Size ConvertSizeToPixel(const RenderWidgetHostView* view, | 54 gfx::Size ConvertSizeToPixel(const RenderWidgetHostView* view, |
55 const gfx::Size& size_in_dip) { | 55 const gfx::Size& size_in_dip) { |
56 return gfx::ToFlooredSize(size_in_dip.Scale(GetScaleForView(view))); | 56 return gfx::ToFlooredSize( |
| 57 gfx::ScaleSize(size_in_dip, GetScaleForView(view))); |
57 } | 58 } |
58 | 59 |
59 gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view, | 60 gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view, |
60 const gfx::Rect& rect_in_dip) { | 61 const gfx::Rect& rect_in_dip) { |
61 float scale = GetScaleForView(view); | 62 float scale = GetScaleForView(view); |
62 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_dip, scale)); | 63 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_dip, scale)); |
63 } | 64 } |
64 | 65 |
65 } // namespace content | 66 } // namespace content |
OLD | NEW |