dip_util.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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.
4
5#ifndef UI_COMPOSITOR_DIP_UTIL_H_
6#define UI_COMPOSITOR_DIP_UTIL_H_
7
8#include "ui/compositor/compositor_export.h"
9#include "base/basictypes.h"
10#include "ui/gfx/point_f.h"
11
12namespace gfx {
13class Point;
14class Size;
15class Rect;
16}  // namespace gfx
17
18namespace ui {
19class Layer;
20
21COMPOSITOR_EXPORT float GetDeviceScaleFactor(const Layer* layer);
22
23// Utility functions that convert point/size/rect between
24// DIP and pixel coordinates system.
25COMPOSITOR_EXPORT gfx::Point ConvertPointToDIP(
26    const Layer* layer,
27    const gfx::Point& point_in_pixel);
28COMPOSITOR_EXPORT gfx::PointF ConvertPointToDIP(
29    const Layer* layer,
30    const gfx::PointF& point_in_pixel);
31COMPOSITOR_EXPORT gfx::Size ConvertSizeToDIP(
32    const Layer* layer,
33    const gfx::Size& size_in_pixel);
34COMPOSITOR_EXPORT gfx::Rect ConvertRectToDIP(
35    const Layer* layer,
36    const gfx::Rect& rect_in_pixel);
37COMPOSITOR_EXPORT gfx::Point ConvertPointToPixel(
38    const Layer* layer,
39    const gfx::Point& point_in_dip);
40COMPOSITOR_EXPORT gfx::Size ConvertSizeToPixel(
41    const Layer* layer,
42    const gfx::Size& size_in_dip);
43COMPOSITOR_EXPORT gfx::Rect ConvertRectToPixel(
44    const Layer* layer,
45    const gfx::Rect& rect_in_dip);
46
47}  // namespace ui
48
49#endif  // UI_COMPOSITOR_DIP_UTIL_H_
50