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 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const gfx::Size& size_in_pixel() const { return size_in_pixel_; } | 86 const gfx::Size& size_in_pixel() const { return size_in_pixel_; } |
87 | 87 |
88 // The overscan insets for the display in DIP. | 88 // The overscan insets for the display in DIP. |
89 const gfx::Insets& overscan_insets_in_dip() const { | 89 const gfx::Insets& overscan_insets_in_dip() const { |
90 return overscan_insets_in_dip_; | 90 return overscan_insets_in_dip_; |
91 } | 91 } |
92 | 92 |
93 float ui_scale() const { return ui_scale_; } | 93 float ui_scale() const { return ui_scale_; } |
94 void set_ui_scale(float scale) { ui_scale_ = scale; } | 94 void set_ui_scale(float scale) { ui_scale_ = scale; } |
95 | 95 |
96 // Copy the display info except for two fields that can be modified by a user | 96 // Copy the display info except for fields that can be modified by a user |
97 // (|has_custom_overscan_insets_| and |custom_overscan_insets_in_dip_|). | 97 // (|has_custom_overscan_insets_| and |custom_overscan_insets_in_dip_|, |
98 void CopyFromNative(const DisplayInfo& native_info); | 98 // |rotation_| and |ui_scale_|). |rotation_| and |ui_scale_| are copied |
| 99 // when the |another_info| isn't native one. |
| 100 void Copy(const DisplayInfo& another_info); |
99 | 101 |
100 // Update the |bounds_in_pixel_| and |size_in_pixel_| using | 102 // Update the |bounds_in_pixel_| and |size_in_pixel_| using |
101 // given |bounds_in_pixel|. | 103 // given |bounds_in_pixel|. |
102 void SetBounds(const gfx::Rect& bounds_in_pixel); | 104 void SetBounds(const gfx::Rect& bounds_in_pixel); |
103 | 105 |
104 // Update the |bounds_in_pixel| according to the current overscan | 106 // Update the |bounds_in_pixel| according to the current overscan |
105 // and rotation settings. | 107 // and rotation settings. |
106 // 1) If this has custom overscan insets | 108 // 1) If this has custom overscan insets |
107 // (i.e. |has_custom_overscan_insets_| is true), it simply applies | 109 // (i.e. |has_custom_overscan_insets_| is true), it simply applies |
108 // the existing |overscan_insets_in_dip_|. | 110 // the existing |overscan_insets_in_dip_|. |
109 // 2) If this doesn't have custom overscan insets but the display claims | 111 // 2) If this doesn't have custom overscan insets but the display claims |
110 // that it has overscan (|has_overscan_| is true), then updates | 112 // that it has overscan (|has_overscan_| is true), then updates |
111 // |overscan_insets_in_dip_| to default value (5% of the display size) | 113 // |overscan_insets_in_dip_| to default value (5% of the display size) |
112 // and apply the insets. | 114 // and apply the insets. |
113 // 3) Otherwise, clear the overscan insets. | 115 // 3) Otherwise, clear the overscan insets. |
114 void UpdateDisplaySize(); | 116 void UpdateDisplaySize(); |
115 | 117 |
116 // Sets/Clears the overscan insets. | 118 // Sets/Clears the overscan insets. |
117 void SetOverscanInsets(bool custom, | 119 void SetOverscanInsets(bool custom, |
118 const gfx::Insets& insets_in_dip); | 120 const gfx::Insets& insets_in_dip); |
119 gfx::Insets GetOverscanInsetsInPixel() const; | 121 gfx::Insets GetOverscanInsetsInPixel() const; |
| 122 |
120 void clear_has_custom_overscan_insets() { | 123 void clear_has_custom_overscan_insets() { |
121 has_custom_overscan_insets_ = false; | 124 has_custom_overscan_insets_ = false; |
122 } | 125 } |
| 126 bool has_custom_overscan_insets() const { |
| 127 return has_custom_overscan_insets_; |
| 128 } |
| 129 |
| 130 void set_native(bool native) { native_ = native; } |
| 131 bool native() const { return native_; } |
123 | 132 |
124 // Returns a string representation of the DisplayInfo; | 133 // Returns a string representation of the DisplayInfo; |
125 std::string ToString() const; | 134 std::string ToString() const; |
126 | 135 |
127 private: | 136 private: |
128 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); | 137 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); |
129 // Set the overscan flag. Used for test. | 138 // Set the overscan flag. Used for test. |
130 void set_has_overscan_for_test(bool has_overscan) { | 139 void set_has_overscan_for_test(bool has_overscan) { |
131 has_overscan_ = has_overscan; | 140 has_overscan_ = has_overscan; |
132 } | 141 } |
133 | 142 |
134 int64 id_; | 143 int64 id_; |
135 std::string name_; | 144 std::string name_; |
136 bool has_overscan_; | 145 bool has_overscan_; |
137 gfx::Display::Rotation rotation_; | 146 gfx::Display::Rotation rotation_; |
138 float device_scale_factor_; | 147 float device_scale_factor_; |
139 gfx::Rect bounds_in_pixel_; | 148 gfx::Rect bounds_in_pixel_; |
140 // The size of the display in use. The size can be different from the size | 149 // The size of the display in use. The size can be different from the size |
141 // of |bounds_in_pixel_| if the display has overscan insets and/or rotation. | 150 // of |bounds_in_pixel_| if the display has overscan insets and/or rotation. |
142 gfx::Size size_in_pixel_; | 151 gfx::Size size_in_pixel_; |
143 gfx::Insets overscan_insets_in_dip_; | 152 gfx::Insets overscan_insets_in_dip_; |
144 | 153 |
145 // True if the |overscan_insets_in_dip| is specified by a user. This | 154 // True if the |overscan_insets_in_dip| is specified by a user. This |
146 // is used not to override the insets by native insets. | 155 // is used not to override the insets by native insets. |
147 bool has_custom_overscan_insets_; | 156 bool has_custom_overscan_insets_; |
148 | 157 |
149 // UI scale of the display. | 158 // UI scale of the display. |
150 float ui_scale_; | 159 float ui_scale_; |
| 160 |
| 161 // True if this comes from native platform (DisplayChangeObserverX11). |
| 162 bool native_; |
151 }; | 163 }; |
152 | 164 |
153 } // namespace internal | 165 } // namespace internal |
154 } // namespace ash | 166 } // namespace ash |
155 | 167 |
156 #endif // ASH_DISPLAY_DISPLAY_INFO_H_ | 168 #endif // ASH_DISPLAY_DISPLAY_INFO_H_ |
OLD | NEW |