summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/dip_util.h
blob: a7e1876ec797810254c6d56a944b649a39c29680 (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
41
42
43
// 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.

#ifndef CONTENT_BROWSER_RENDERER_HOST_DIP_UTIL_H_
#define CONTENT_BROWSER_RENDERER_HOST_DIP_UTIL_H_

#include "content/common/content_export.h"
#include "ui/base/layout.h"

namespace gfx {
class Point;
class Rect;
class Size;
}  // namespace gfx

namespace content {
class RenderWidgetHostView;

// Returns scale factor of the display nearest to |view|.
// Returns ui::SCALE_FACTOR_100P if the platform does not support DIP.
CONTENT_EXPORT ui::ScaleFactor GetScaleFactorForView(
    const RenderWidgetHostView* view);

// Utility functions that convert point/size/rect between DIP and pixel
// coordinate system.
CONTENT_EXPORT gfx::Point ConvertViewPointToDIP(
    const RenderWidgetHostView* view, const gfx::Point& point_in_pixel);
CONTENT_EXPORT gfx::Size ConvertViewSizeToPixel(
    const RenderWidgetHostView* view, const gfx::Size& size_in_dip);
CONTENT_EXPORT gfx::Rect ConvertViewRectToPixel(
    const RenderWidgetHostView* view, const gfx::Rect& rect_in_dip);

CONTENT_EXPORT gfx::Size ConvertSizeToDIP(
    float scale_factor, const gfx::Size& size_in_pixel);
CONTENT_EXPORT gfx::Rect ConvertRectToDIP(
    float scale_factor, const gfx::Rect& rect_in_pixel);
CONTENT_EXPORT gfx::Rect ConvertRectToPixel(
    float scale_factor, const gfx::Rect& rect_in_dip);

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_DIP_UTIL_H_