summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/dip_util.cc
blob: 225d17bcb44f8733049a79adc6c1ca29ba51de89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/renderer_host/dip_util.h"

#include "content/public/browser/render_widget_host_view.h"
#include "ui/base/layout.h"
#include "ui/gfx/display.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/screen.h"

namespace content {

float GetScaleFactorForView(const RenderWidgetHostView* view) {
  return ui::GetScaleFactorForNativeView(view ? view->GetNativeView() : NULL);
}

gfx::Point ConvertViewPointToDIP(const RenderWidgetHostView* view,
                                 const gfx::Point& point_in_pixel) {
  return gfx::ConvertPointToDIP(GetScaleFactorForView(view), point_in_pixel);
}

gfx::Size ConvertViewSizeToPixel(const RenderWidgetHostView* view,
                                 const gfx::Size& size_in_dip) {
  return gfx::ConvertSizeToPixel(GetScaleFactorForView(view), size_in_dip);
}

gfx::Rect ConvertViewRectToPixel(const RenderWidgetHostView* view,
                                 const gfx::Rect& rect_in_dip) {
  return gfx::ConvertRectToPixel(GetScaleFactorForView(view), rect_in_dip);
}

}  // namespace content