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 #ifndef UI_COMPOSITOR_DIP_UTIL_H_ | 5 #ifndef UI_COMPOSITOR_DIP_UTIL_H_ |
6 #define UI_COMPOSITOR_DIP_UTIL_H_ | 6 #define UI_COMPOSITOR_DIP_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ui/compositor/compositor_export.h" | 9 #include "ui/compositor/compositor_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 class Point; | 13 class Point; |
14 class Size; | 14 class Size; |
15 class Rect; | 15 class Rect; |
16 } // namespace gfx | 16 } // namespace gfx |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 namespace test { | |
20 | |
21 // A scoped object allows you to temporarily enable DIP | |
22 // in the unit tests. | |
23 class COMPOSITOR_EXPORT ScopedDIPEnablerForTest { | |
24 public: | |
25 ScopedDIPEnablerForTest(); | |
26 ~ScopedDIPEnablerForTest(); | |
27 | |
28 private: | |
29 DISALLOW_COPY_AND_ASSIGN(ScopedDIPEnablerForTest); | |
30 }; | |
31 | |
32 } // namespace test | |
33 | |
34 class Layer; | 19 class Layer; |
35 | 20 |
36 // True if DIP is enabled. | |
37 COMPOSITOR_EXPORT bool IsDIPEnabled(); | |
38 | |
39 COMPOSITOR_EXPORT float GetDeviceScaleFactor(const Layer* layer); | 21 COMPOSITOR_EXPORT float GetDeviceScaleFactor(const Layer* layer); |
40 | 22 |
41 // Utility functions that convert point/size/rect between | 23 // Utility functions that convert point/size/rect between |
42 // DIP and pixel coordinates system. | 24 // DIP and pixel coordinates system. |
43 COMPOSITOR_EXPORT gfx::Point ConvertPointToDIP( | 25 COMPOSITOR_EXPORT gfx::Point ConvertPointToDIP( |
44 const Layer* layer, | 26 const Layer* layer, |
45 const gfx::Point& point_in_pixel); | 27 const gfx::Point& point_in_pixel); |
46 COMPOSITOR_EXPORT gfx::Size ConvertSizeToDIP( | 28 COMPOSITOR_EXPORT gfx::Size ConvertSizeToDIP( |
47 const Layer* layer, | 29 const Layer* layer, |
48 const gfx::Size& size_in_pixel); | 30 const gfx::Size& size_in_pixel); |
49 COMPOSITOR_EXPORT gfx::Rect ConvertRectToDIP( | 31 COMPOSITOR_EXPORT gfx::Rect ConvertRectToDIP( |
50 const Layer* layer, | 32 const Layer* layer, |
51 const gfx::Rect& rect_in_pixel); | 33 const gfx::Rect& rect_in_pixel); |
52 COMPOSITOR_EXPORT gfx::Point ConvertPointToPixel( | 34 COMPOSITOR_EXPORT gfx::Point ConvertPointToPixel( |
53 const Layer* layer, | 35 const Layer* layer, |
54 const gfx::Point& point_in_dip); | 36 const gfx::Point& point_in_dip); |
55 COMPOSITOR_EXPORT gfx::Size ConvertSizeToPixel( | 37 COMPOSITOR_EXPORT gfx::Size ConvertSizeToPixel( |
56 const Layer* layer, | 38 const Layer* layer, |
57 const gfx::Size& size_in_dip); | 39 const gfx::Size& size_in_dip); |
58 COMPOSITOR_EXPORT gfx::Rect ConvertRectToPixel( | 40 COMPOSITOR_EXPORT gfx::Rect ConvertRectToPixel( |
59 const Layer* layer, | 41 const Layer* layer, |
60 const gfx::Rect& rect_in_dip); | 42 const gfx::Rect& rect_in_dip); |
61 | 43 |
62 } // namespace ui | 44 } // namespace ui |
63 | 45 |
64 #endif // UI_COMPOSITOR_DIP_UTIL_H_ | 46 #endif // UI_COMPOSITOR_DIP_UTIL_H_ |
OLD | NEW |