OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 ASH_DISPLAY_DISPLAY_INFO_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_INFO_H_ |
6 #define ASH_DISPLAY_DISPLAY_INFO_H_ | 6 #define ASH_DISPLAY_DISPLAY_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ui/gfx/display.h" | 12 #include "ui/gfx/display.h" |
13 #include "ui/gfx/insets.h" | 13 #include "ui/gfx/insets.h" |
14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 // A struct that represents the display's resolution and | 19 // A struct that represents the display's mode info. |
20 // interlaced info. | 20 struct ASH_EXPORT DisplayMode { |
21 struct ASH_EXPORT Resolution { | 21 DisplayMode(); |
22 Resolution(const gfx::Size& size, bool interlaced); | 22 DisplayMode(const gfx::Size& size, |
| 23 float refresh_rate, |
| 24 bool interlaced, |
| 25 bool native); |
23 | 26 |
24 gfx::Size size; | 27 gfx::Size size; // Physical pixel size of the display. |
25 bool interlaced; | 28 float refresh_rate; // Refresh rate of the display, in Hz. |
| 29 bool interlaced; // True if mode is interlaced. |
| 30 bool native; // True if mode is native mode of the display. |
26 }; | 31 }; |
27 | 32 |
28 // DisplayInfo contains metadata for each display. This is used to | 33 // DisplayInfo contains metadata for each display. This is used to |
29 // create |gfx::Display| as well as to maintain extra infomation | 34 // create |gfx::Display| as well as to maintain extra infomation |
30 // to manage displays in ash environment. | 35 // to manage displays in ash environment. |
31 // This class is intentionally made copiable. | 36 // This class is intentionally made copiable. |
32 class ASH_EXPORT DisplayInfo { | 37 class ASH_EXPORT DisplayInfo { |
33 public: | 38 public: |
34 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display | 39 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display |
35 // whose size is 1440x800 at the location (100, 200) in host coordinates. | 40 // whose size is 1440x800 at the location (100, 200) in host coordinates. |
36 // The format is | 41 // The format is |
37 // | 42 // |
38 // [origin-]widthxheight[*device_scale_factor][#resolutions list] | 43 // [origin-]widthxheight[*device_scale_factor][#resolutions list] |
39 // [/<properties>][@ui-scale] | 44 // [/<properties>][@ui-scale] |
40 // | 45 // |
41 // where [] are optional: | 46 // where [] are optional: |
42 // - |origin| is given in x+y- format. | 47 // - |origin| is given in x+y- format. |
43 // - |device_scale_factor| is either 2 or 1 (or empty). | 48 // - |device_scale_factor| is either 2 or 1 (or empty). |
44 // - properties can combination of 'o', which adds default overscan insets | 49 // - properties can combination of 'o', which adds default overscan insets |
45 // (5%), and one rotation property where 'r' is 90 degree clock-wise | 50 // (5%), and one rotation property where 'r' is 90 degree clock-wise |
46 // (to the 'r'ight) 'u' is 180 degrees ('u'pside-down) and 'l' is | 51 // (to the 'r'ight) 'u' is 180 degrees ('u'pside-down) and 'l' is |
47 // 270 degrees (to the 'l'eft). | 52 // 270 degrees (to the 'l'eft). |
48 // - ui-scale is floating value, e.g. @1.5 or @1.25. | 53 // - ui-scale is floating value, e.g. @1.5 or @1.25. |
49 // - |resolution list| is the list of size that is given in | 54 // - |resolution list| is the list of size that is given in |
50 // |width x height| separated by '|'. | 55 // |width x height [% refresh_rate]| separated by '|'. |
51 // | 56 // |
52 // A couple of examples: | 57 // A couple of examples: |
53 // "100x100" | 58 // "100x100" |
54 // 100x100 window at 0,0 origin. 1x device scale factor. no overscan. | 59 // 100x100 window at 0,0 origin. 1x device scale factor. no overscan. |
55 // no rotation. 1.0 ui scale. | 60 // no rotation. 1.0 ui scale. |
56 // "5+5-300x200*2" | 61 // "5+5-300x200*2" |
57 // 300x200 window at 5,5 origin. 2x device scale factor. | 62 // 300x200 window at 5,5 origin. 2x device scale factor. |
58 // no overscan, no rotation. 1.0 ui scale. | 63 // no overscan, no rotation. 1.0 ui scale. |
59 // "300x200/ol" | 64 // "300x200/ol" |
60 // 300x200 window at 0,0 origin. 1x device scale factor. | 65 // 300x200 window at 0,0 origin. 1x device scale factor. |
61 // with 5% overscan. rotated to left (90 degree counter clockwise). | 66 // with 5% overscan. rotated to left (90 degree counter clockwise). |
62 // 1.0 ui scale. | 67 // 1.0 ui scale. |
63 // "10+20-300x200/u@1.5" | 68 // "10+20-300x200/u@1.5" |
64 // 300x200 window at 10,20 origin. 1x device scale factor. | 69 // 300x200 window at 10,20 origin. 1x device scale factor. |
65 // no overscan. flipped upside-down (180 degree) and 1.5 ui scale. | 70 // no overscan. flipped upside-down (180 degree) and 1.5 ui scale. |
66 // "200x100#300x200|200x100|100x100" | 71 // "200x100#300x200|200x100%59.0|100x100%60" |
67 // 200x100 window at 0,0 origin, with 3 possible resolutions, | 72 // 200x100 window at 0,0 origin, with 3 possible resolutions, |
68 // 300x200, 200x100 and 100x100. | 73 // 300x200, 200x100 at 59 Hz, and 100x100 at 60 Hz. |
69 static DisplayInfo CreateFromSpec(const std::string& spec); | 74 static DisplayInfo CreateFromSpec(const std::string& spec); |
70 | 75 |
71 // Creates a DisplayInfo from string spec using given |id|. | 76 // Creates a DisplayInfo from string spec using given |id|. |
72 static DisplayInfo CreateFromSpecWithID(const std::string& spec, | 77 static DisplayInfo CreateFromSpecWithID(const std::string& spec, |
73 int64 id); | 78 int64 id); |
74 | 79 |
75 DisplayInfo(); | 80 DisplayInfo(); |
76 DisplayInfo(int64 id, const std::string& name, bool has_overscan); | 81 DisplayInfo(int64 id, const std::string& name, bool has_overscan); |
77 ~DisplayInfo(); | 82 ~DisplayInfo(); |
78 | 83 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // and rotation settings. | 140 // and rotation settings. |
136 void UpdateDisplaySize(); | 141 void UpdateDisplaySize(); |
137 | 142 |
138 // Sets/Clears the overscan insets. | 143 // Sets/Clears the overscan insets. |
139 void SetOverscanInsets(const gfx::Insets& insets_in_dip); | 144 void SetOverscanInsets(const gfx::Insets& insets_in_dip); |
140 gfx::Insets GetOverscanInsetsInPixel() const; | 145 gfx::Insets GetOverscanInsetsInPixel() const; |
141 | 146 |
142 void set_native(bool native) { native_ = native; } | 147 void set_native(bool native) { native_ = native; } |
143 bool native() const { return native_; } | 148 bool native() const { return native_; } |
144 | 149 |
145 const std::vector<Resolution>& resolutions() const { | 150 const std::vector<DisplayMode>& display_modes() const { |
146 return resolutions_; | 151 return display_modes_; |
147 } | 152 } |
148 void set_resolutions(std::vector<Resolution>& resolution) { | 153 void set_display_modes(std::vector<DisplayMode>& display_modes) { |
149 resolutions_.swap(resolution); | 154 display_modes_.swap(display_modes); |
150 } | 155 } |
151 | 156 |
152 // Returns a string representation of the DisplayInfo | 157 // Returns a string representation of the DisplayInfo, excluding display |
153 // excluding resolutions. | 158 // modes. |
154 std::string ToString() const; | 159 std::string ToString() const; |
155 | 160 |
156 // Returns a string representation of the DisplayInfo | 161 // Returns a string representation of the DisplayInfo, including display |
157 // including resolutions. | 162 // modes. |
158 std::string ToFullString() const; | 163 std::string ToFullString() const; |
159 | 164 |
160 private: | 165 private: |
161 int64 id_; | 166 int64 id_; |
162 std::string name_; | 167 std::string name_; |
163 bool has_overscan_; | 168 bool has_overscan_; |
164 gfx::Display::Rotation rotation_; | 169 gfx::Display::Rotation rotation_; |
165 gfx::Display::TouchSupport touch_support_; | 170 gfx::Display::TouchSupport touch_support_; |
166 | 171 |
167 // This specifies the device's pixel density. (For example, a | 172 // This specifies the device's pixel density. (For example, a |
(...skipping 13 matching lines...) Expand all Loading... |
181 // shrink) the desktop over the native display resolution (useful in | 186 // shrink) the desktop over the native display resolution (useful in |
182 // HighDPI display). Note that this should not be confused with the | 187 // HighDPI display). Note that this should not be confused with the |
183 // device scale factor, which specifies the pixel density of the | 188 // device scale factor, which specifies the pixel density of the |
184 // display. The actuall scale value to be used depends on the device | 189 // display. The actuall scale value to be used depends on the device |
185 // scale factor. See |GetEffectiveScaleFactor()|. | 190 // scale factor. See |GetEffectiveScaleFactor()|. |
186 float configured_ui_scale_; | 191 float configured_ui_scale_; |
187 | 192 |
188 // True if this comes from native platform (DisplayChangeObserver). | 193 // True if this comes from native platform (DisplayChangeObserver). |
189 bool native_; | 194 bool native_; |
190 | 195 |
191 // The list of resolutions supported by this display. | 196 // The list of modes supported by this display. |
192 std::vector<Resolution> resolutions_; | 197 std::vector<DisplayMode> display_modes_; |
193 }; | 198 }; |
194 | 199 |
195 } // namespace internal | 200 } // namespace internal |
196 } // namespace ash | 201 } // namespace ash |
197 | 202 |
198 #endif // ASH_DISPLAY_DISPLAY_INFO_H_ | 203 #endif // ASH_DISPLAY_DISPLAY_INFO_H_ |
OLD | NEW |