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_GFX_DISPLAY_H_ | 5 #ifndef UI_GFX_DISPLAY_H_ |
6 #define UI_GFX_DISPLAY_H_ | 6 #define UI_GFX_DISPLAY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 // Note: The screen and display currently uses pixel coordinate | 15 // Note: The screen and display currently uses pixel coordinate |
16 // system. For platforms that support DIP (density independent pixel), | 16 // system. For platforms that support DIP (density independent pixel), |
17 // |bounds()| and |work_area| will return values in DIP coordinate | 17 // |bounds()| and |work_area| will return values in DIP coordinate |
18 // system, not in backing pixels. | 18 // system, not in backing pixels. |
19 class UI_EXPORT Display { | 19 class UI_EXPORT Display { |
20 public: | 20 public: |
21 // Creates a display with kInvalidDisplayID as default. | 21 // Creates a display with kInvalidDisplayID as default. |
22 Display(); | 22 Display(); |
23 explicit Display(int64 id); | 23 explicit Display(int64 id); |
24 Display(int64 id, const Rect& bounds); | 24 Display(int64 id, const Rect& bounds); |
25 ~Display(); | 25 ~Display(); |
26 | 26 |
27 // Returns the forced device scale factor, which is given by | 27 // Returns the forced device scale factor, which is given by |
28 // "--force-device-scale-factor". | 28 // "--force-device-scale-factor". |
29 static float GetForcedDeviceScaleFactor(); | 29 static float GetForcedDeviceScaleFactor(); |
| 30 static bool HasForceDeviceScaleFactor(); |
30 | 31 |
31 // Returns 64-bit persistent ID for the specified manufacturer's ID and | 32 // Returns 64-bit persistent ID for the specified manufacturer's ID and |
32 // serial#. | 33 // serial#. |
33 static int64 GetID(uint16 manufacturer_id, uint32 serial_number); | 34 static int64 GetID(uint16 manufacturer_id, uint32 serial_number); |
34 | 35 |
35 // Sets/Gets unique identifier associated with the display. | 36 // Sets/Gets unique identifier associated with the display. |
36 // -1 means invalid display and it doesn't not exit. | 37 // -1 means invalid display and it doesn't not exit. |
37 int64 id() const { return id_; } | 38 int64 id() const { return id_; } |
38 void set_id(int64 id) { id_ = id; } | 39 void set_id(int64 id) { id_ = id; } |
39 | 40 |
(...skipping 30 matching lines...) Expand all Loading... |
70 // between old bounds and work area. | 71 // between old bounds and work area. |
71 void SetSize(const gfx::Size& size_in_pixel); | 72 void SetSize(const gfx::Size& size_in_pixel); |
72 | 73 |
73 // Computes and updates the display's work are using | 74 // Computes and updates the display's work are using |
74 // |work_area_insets| and the bounds. | 75 // |work_area_insets| and the bounds. |
75 void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets); | 76 void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets); |
76 | 77 |
77 // Returns the display's size in pixel coordinates. | 78 // Returns the display's size in pixel coordinates. |
78 gfx::Size GetSizeInPixel() const; | 79 gfx::Size GetSizeInPixel() const; |
79 | 80 |
80 #if defined(USE_AURA) | 81 #if defined(USE_AURA) || defined(OS_WIN) |
81 // TODO(oshima|skuhne): Eliminate the use of bounds_in_pixel in events_x.cc | 82 // TODO(oshima|skuhne): Eliminate the use of bounds_in_pixel in events_x.cc |
82 // and remove bounds_in_pixel from gfx::Display. | 83 // and remove bounds_in_pixel from gfx::Display. |
83 // Returns the display's bounds in pixel coordinates. | 84 // Returns the display's bounds in pixel coordinates. |
84 const Rect& bounds_in_pixel() const { return bounds_in_pixel_; } | 85 const Rect& bounds_in_pixel() const { return bounds_in_pixel_; } |
85 #endif | 86 #endif |
86 | 87 |
87 // Returns a string representation of the display; | 88 // Returns a string representation of the display; |
88 std::string ToString() const; | 89 std::string ToString() const; |
89 | 90 |
90 // True if the display contains valid display id. | 91 // True if the display contains valid display id. |
91 bool is_valid() const { return id_ != kInvalidDisplayID; } | 92 bool is_valid() const { return id_ != kInvalidDisplayID; } |
92 | 93 |
93 static const int64 kInvalidDisplayID; | 94 static const int64 kInvalidDisplayID; |
94 | 95 |
95 private: | 96 private: |
96 int64 id_; | 97 int64 id_; |
97 Rect bounds_; | 98 Rect bounds_; |
98 Rect work_area_; | 99 Rect work_area_; |
99 #if defined(USE_AURA) | 100 #if defined(USE_AURA) || defined(OS_WIN) |
100 Rect bounds_in_pixel_; | 101 Rect bounds_in_pixel_; |
101 #endif | 102 #endif |
102 float device_scale_factor_; | 103 float device_scale_factor_; |
103 }; | 104 }; |
104 | 105 |
105 } // namespace gfx | 106 } // namespace gfx |
106 | 107 |
107 #endif // UI_GFX_DISPLAY_H_ | 108 #endif // UI_GFX_DISPLAY_H_ |
OLD | NEW |