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. |
| 22 Display(); |
| 23 explicit Display(int64 id); |
| 24 Display(int64 id, const Rect& bounds); |
| 25 ~Display(); |
| 26 |
21 // Returns the forced device scale factor, which is given by | 27 // Returns the forced device scale factor, which is given by |
22 // "--force-device-scale-factor". | 28 // "--force-device-scale-factor". |
23 static float GetForcedDeviceScaleFactor(); | 29 static float GetForcedDeviceScaleFactor(); |
24 | 30 |
25 // Creates a display with invalid id(-1) as default. | 31 // Returns 64-bit persistent ID for the specified manufacturer's ID and |
26 Display(); | 32 // serial#. |
27 explicit Display(int id); | 33 static int64 GetID(uint16 manufacturer_id, uint32 serial_number); |
28 Display(int id, const Rect& bounds); | |
29 ~Display(); | |
30 | 34 |
31 // Sets/Gets unique identifier associated with the display. | 35 // Sets/Gets unique identifier associated with the display. |
32 // -1 means invalid display and it doesn't not exit. | 36 // -1 means invalid display and it doesn't not exit. |
33 int id() const { return id_; } | 37 int64 id() const { return id_; } |
34 void set_id(int id) { id_ = id; } | 38 void set_id(int64 id) { id_ = id; } |
35 | 39 |
36 // Gets/Sets the display's bounds in gfx::Screen's coordinates. | 40 // Gets/Sets the display's bounds in gfx::Screen's coordinates. |
37 const Rect& bounds() const { return bounds_; } | 41 const Rect& bounds() const { return bounds_; } |
38 void set_bounds(const Rect& bounds) { bounds_ = bounds; } | 42 void set_bounds(const Rect& bounds) { bounds_ = bounds; } |
39 | 43 |
40 // Gets/Sets the display's work area in gfx::Screen's coordinates. | 44 // Gets/Sets the display's work area in gfx::Screen's coordinates. |
41 const Rect& work_area() const { return work_area_; } | 45 const Rect& work_area() const { return work_area_; } |
42 void set_work_area(const Rect& work_area) { work_area_ = work_area; } | 46 void set_work_area(const Rect& work_area) { work_area_ = work_area; } |
43 | 47 |
44 // Output device's pixel scale factor. This specifies how much the | 48 // Output device's pixel scale factor. This specifies how much the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #if defined(USE_AURA) | 80 #if defined(USE_AURA) |
77 // TODO(oshima|skuhne): Eliminate the use of bounds_in_pixel in events_x.cc | 81 // TODO(oshima|skuhne): Eliminate the use of bounds_in_pixel in events_x.cc |
78 // and remove bounds_in_pixel from gfx::Display. | 82 // and remove bounds_in_pixel from gfx::Display. |
79 // Returns the display's bounds in pixel coordinates. | 83 // Returns the display's bounds in pixel coordinates. |
80 const Rect& bounds_in_pixel() const { return bounds_in_pixel_; } | 84 const Rect& bounds_in_pixel() const { return bounds_in_pixel_; } |
81 #endif | 85 #endif |
82 | 86 |
83 // Returns a string representation of the display; | 87 // Returns a string representation of the display; |
84 std::string ToString() const; | 88 std::string ToString() const; |
85 | 89 |
| 90 static const int64 kInvalidDisplayID; |
| 91 |
86 private: | 92 private: |
87 int id_; | 93 int64 id_; |
88 Rect bounds_; | 94 Rect bounds_; |
89 Rect work_area_; | 95 Rect work_area_; |
90 #if defined(USE_AURA) | 96 #if defined(USE_AURA) |
91 Rect bounds_in_pixel_; | 97 Rect bounds_in_pixel_; |
92 #endif | 98 #endif |
93 float device_scale_factor_; | 99 float device_scale_factor_; |
94 }; | 100 }; |
95 | 101 |
96 } // namespace gfx | 102 } // namespace gfx |
97 | 103 |
98 #endif // UI_GFX_DISPLAY_H_ | 104 #endif // UI_GFX_DISPLAY_H_ |
OLD | NEW |