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
3 // found in the LICENSE file.
5 #include "content/browser/renderer_host/dip_util.h"
7 #include "content/public/browser/render_widget_host_view.h"
8 #include "ui/base/layout.h"
9 #include "ui/gfx/display.h"
10 #include "ui/gfx/geometry/dip_util.h"
11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/point_conversions.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/rect_conversions.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/geometry/size_conversions.h"
17 #include "ui/gfx/screen.h"
21 float GetScaleFactorForView(const RenderWidgetHostView
* view
) {
22 return ui::GetScaleFactorForNativeView(view
? view
->GetNativeView() : NULL
);
25 gfx::Point
ConvertViewPointToDIP(const RenderWidgetHostView
* view
,
26 const gfx::Point
& point_in_pixel
) {
27 return gfx::ConvertPointToDIP(GetScaleFactorForView(view
), point_in_pixel
);
30 gfx::Size
ConvertViewSizeToPixel(const RenderWidgetHostView
* view
,
31 const gfx::Size
& size_in_dip
) {
32 return gfx::ConvertSizeToPixel(GetScaleFactorForView(view
), size_in_dip
);
35 gfx::Rect
ConvertViewRectToPixel(const RenderWidgetHostView
* view
,
36 const gfx::Rect
& rect_in_dip
) {
37 return gfx::ConvertRectToPixel(GetScaleFactorForView(view
), rect_in_dip
);
40 } // namespace content