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/monitor.h" | 8 #include "ui/gfx/display.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 #include "ui/gfx/screen.h" | 11 #include "ui/gfx/screen.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 float GetDIPScaleFactor(const RenderWidgetHostView* view) { | 16 float GetDIPScaleFactor(const RenderWidgetHostView* view) { |
17 // MacOS does not have an implementation of | 17 // MacOS does not have an implementation of |
18 // Screen::GetMonitorNearestWindow | 18 // Screen::GetMonitorNearestWindow |
19 // TODO(pkotwicz): Fix this. (crbug.com/129409). | 19 // TODO(pkotwicz): Fix this. (crbug.com/129409). |
20 #if !defined(OS_MACOSX) | 20 #if !defined(OS_MACOSX) |
21 if (gfx::Screen::IsDIPEnabled()) { | 21 if (gfx::Screen::IsDIPEnabled()) { |
22 gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow( | 22 gfx::Display display = gfx::Screen::GetMonitorNearestWindow( |
23 view ? view->GetNativeView() : NULL); | 23 view ? view->GetNativeView() : NULL); |
24 return monitor.device_scale_factor(); | 24 return display.device_scale_factor(); |
25 } | 25 } |
26 #endif | 26 #endif |
27 return 1.0f; | 27 return 1.0f; |
28 } | 28 } |
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 point_in_pixel.Scale(1.0f / GetDIPScaleFactor(view)); | 32 return point_in_pixel.Scale(1.0f / GetDIPScaleFactor(view)); |
33 } | 33 } |
34 | 34 |
(...skipping 20 matching lines...) Expand all Loading... |
55 } | 55 } |
56 | 56 |
57 gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view, | 57 gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view, |
58 const gfx::Rect& rect_in_dip) { | 58 const gfx::Rect& rect_in_dip) { |
59 float scale = GetDIPScaleFactor(view); | 59 float scale = GetDIPScaleFactor(view); |
60 return gfx::Rect(rect_in_dip.origin().Scale(scale), | 60 return gfx::Rect(rect_in_dip.origin().Scale(scale), |
61 rect_in_dip.size().Scale(scale)); | 61 rect_in_dip.size().Scale(scale)); |
62 } | 62 } |
63 | 63 |
64 } // namespace content | 64 } // namespace content |
OLD | NEW |