Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: ash/display/display_manager.h

Issue 2270553002: Move ash::DisplayInfo to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ASH_DISPLAY_DISPLAY_MANAGER_H_ 5 #ifndef ASH_DISPLAY_DISPLAY_MANAGER_H_
6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ 6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "ash/ash_export.h" 15 #include "ash/ash_export.h"
16 #include "ash/common/display/display_info.h"
17 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
18 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
19 #include "base/macros.h" 18 #include "base/macros.h"
20 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
22 #include "ui/display/display.h" 21 #include "ui/display/display.h"
23 #include "ui/display/manager/display_layout.h" 22 #include "ui/display/manager/display_layout.h"
23 #include "ui/display/manager/managed_display_info.h"
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 #include "ui/display/chromeos/display_configurator.h" 26 #include "ui/display/chromeos/display_configurator.h"
27 #endif 27 #endif
28 28
29 namespace aura { 29 namespace aura {
30 class Window; 30 class Window;
31 } 31 }
32 32
33 namespace chromeos { 33 namespace chromeos {
34 class DisplayNotificationsTest; 34 class DisplayNotificationsTest;
35 } 35 }
36 36
37 namespace display { 37 namespace display {
38 class DisplayLayoutStore; 38 class DisplayLayoutStore;
39 } 39 }
40 40
41 namespace gfx { 41 namespace gfx {
42 class Insets; 42 class Insets;
43 class Rect; 43 class Rect;
44 } 44 }
45 45
46 namespace ash { 46 namespace ash {
47 class AcceleratorControllerTest; 47 class AcceleratorControllerTest;
48 class MouseWarpController; 48 class MouseWarpController;
49 class ScreenAsh; 49 class ScreenAsh;
50 50
51 typedef std::vector<DisplayInfo> DisplayInfoList; 51 using DisplayInfoList = std::vector<display::ManagedDisplayInfo>;
52 52
53 namespace test { 53 namespace test {
54 class AshTestBase; 54 class AshTestBase;
55 class DisplayManagerTestApi; 55 class DisplayManagerTestApi;
56 class SystemGestureEventFilterTest; 56 class SystemGestureEventFilterTest;
57 } 57 }
58 58
59 // DisplayManager maintains the current display configurations, 59 // DisplayManager maintains the current display configurations,
60 // and notifies observers when configuration changes. 60 // and notifies observers when configuration changes.
61 // 61 //
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Sets the display's rotation for the given |source|. The new |rotation| will 161 // Sets the display's rotation for the given |source|. The new |rotation| will
162 // also become active. 162 // also become active.
163 void SetDisplayRotation(int64_t display_id, 163 void SetDisplayRotation(int64_t display_id,
164 display::Display::Rotation rotation, 164 display::Display::Rotation rotation,
165 display::Display::RotationSource source); 165 display::Display::RotationSource source);
166 166
167 // Sets the external display's configuration, including resolution change, 167 // Sets the external display's configuration, including resolution change,
168 // ui-scale change, and device scale factor change. Returns true if it changes 168 // ui-scale change, and device scale factor change. Returns true if it changes
169 // the display resolution so that the caller needs to show a notification in 169 // the display resolution so that the caller needs to show a notification in
170 // case the new resolution actually doesn't work. 170 // case the new resolution actually doesn't work.
171 bool SetDisplayMode(int64_t display_id, 171 bool SetDisplayMode(
172 const scoped_refptr<ManagedDisplayMode>& display_mode); 172 int64_t display_id,
173 const scoped_refptr<display::ManagedDisplayMode>& display_mode);
173 174
174 // Register per display properties. |overscan_insets| is NULL if 175 // Register per display properties. |overscan_insets| is NULL if
175 // the display has no custom overscan insets. 176 // the display has no custom overscan insets.
176 void RegisterDisplayProperty(int64_t display_id, 177 void RegisterDisplayProperty(int64_t display_id,
177 display::Display::Rotation rotation, 178 display::Display::Rotation rotation,
178 float ui_scale, 179 float ui_scale,
179 const gfx::Insets* overscan_insets, 180 const gfx::Insets* overscan_insets,
180 const gfx::Size& resolution_in_pixels, 181 const gfx::Size& resolution_in_pixels,
181 float device_scale_factor, 182 float device_scale_factor,
182 ui::ColorCalibrationProfile color_profile); 183 ui::ColorCalibrationProfile color_profile);
183 184
184 // Register stored rotation properties for the internal display. 185 // Register stored rotation properties for the internal display.
185 void RegisterDisplayRotationProperties(bool rotation_lock, 186 void RegisterDisplayRotationProperties(bool rotation_lock,
186 display::Display::Rotation rotation); 187 display::Display::Rotation rotation);
187 188
188 // Returns the stored rotation lock preference if it has been loaded, 189 // Returns the stored rotation lock preference if it has been loaded,
189 // otherwise false. 190 // otherwise false.
190 bool registered_internal_display_rotation_lock() const { 191 bool registered_internal_display_rotation_lock() const {
191 return registered_internal_display_rotation_lock_; 192 return registered_internal_display_rotation_lock_;
192 } 193 }
193 194
194 // Returns the stored rotation preference for the internal display if it has 195 // Returns the stored rotation preference for the internal display if it has
195 // been loaded, otherwise |display::Display::Rotate_0|. 196 // been loaded, otherwise |display::Display::Rotate_0|.
196 display::Display::Rotation registered_internal_display_rotation() const { 197 display::Display::Rotation registered_internal_display_rotation() const {
197 return registered_internal_display_rotation_; 198 return registered_internal_display_rotation_;
198 } 199 }
199 200
200 // Returns the display mode of |display_id| which is currently used. 201 // Returns the display mode of |display_id| which is currently used.
201 scoped_refptr<ManagedDisplayMode> GetActiveModeForDisplayId( 202 scoped_refptr<display::ManagedDisplayMode> GetActiveModeForDisplayId(
202 int64_t display_id) const; 203 int64_t display_id) const;
203 204
204 // Returns the display's selected mode. This returns false and doesn't 205 // Returns the display's selected mode. This returns false and doesn't
205 // set |mode_out| if the display mode is in default. 206 // set |mode_out| if the display mode is in default.
206 scoped_refptr<ManagedDisplayMode> GetSelectedModeForDisplayId( 207 scoped_refptr<display::ManagedDisplayMode> GetSelectedModeForDisplayId(
207 int64_t display_id) const; 208 int64_t display_id) const;
208 209
209 // Tells if the virtual resolution feature is enabled. 210 // Tells if the virtual resolution feature is enabled.
210 bool IsDisplayUIScalingEnabled() const; 211 bool IsDisplayUIScalingEnabled() const;
211 212
212 // Returns the current overscan insets for the specified |display_id|. 213 // Returns the current overscan insets for the specified |display_id|.
213 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for 214 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for
214 // the display. 215 // the display.
215 gfx::Insets GetOverscanInsets(int64_t display_id) const; 216 gfx::Insets GetOverscanInsets(int64_t display_id) const;
216 217
217 // Sets the color calibration of the display to |profile|. 218 // Sets the color calibration of the display to |profile|.
218 void SetColorCalibrationProfile(int64_t display_id, 219 void SetColorCalibrationProfile(int64_t display_id,
219 ui::ColorCalibrationProfile profile); 220 ui::ColorCalibrationProfile profile);
220 221
221 // Called when display configuration has changed. The new display 222 // Called when display configuration has changed. The new display
222 // configurations is passed as a vector of Display object, which 223 // configurations is passed as a vector of Display object, which
223 // contains each display's new infomration. 224 // contains each display's new infomration.
224 void OnNativeDisplaysChanged( 225 void OnNativeDisplaysChanged(
225 const std::vector<DisplayInfo>& display_info_list); 226 const std::vector<display::ManagedDisplayInfo>& display_info_list);
226 227
227 // Updates the internal display data and notifies observers about the changes. 228 // Updates the internal display data and notifies observers about the changes.
228 void UpdateDisplaysWith(const std::vector<DisplayInfo>& display_info_list); 229 void UpdateDisplaysWith(
230 const std::vector<display::ManagedDisplayInfo>& display_info_list);
229 231
230 // Updates current displays using current |display_info_|. 232 // Updates current displays using current |display_info_|.
231 void UpdateDisplays(); 233 void UpdateDisplays();
232 234
233 // Returns the display at |index|. The display at 0 is 235 // Returns the display at |index|. The display at 0 is
234 // no longer considered "primary". 236 // no longer considered "primary".
235 const display::Display& GetDisplayAt(size_t index) const; 237 const display::Display& GetDisplayAt(size_t index) const;
236 238
237 const display::Display& GetPrimaryDisplayCandidate() const; 239 const display::Display& GetPrimaryDisplayCandidate() const;
238 240
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool unified_desktop_enabled() const { return unified_desktop_enabled_; } 275 bool unified_desktop_enabled() const { return unified_desktop_enabled_; }
274 276
275 // Returns true if it's in unified desktop mode. 277 // Returns true if it's in unified desktop mode.
276 bool IsInUnifiedMode() const; 278 bool IsInUnifiedMode() const;
277 279
278 // Returns the display used for software mirrroring. Returns invalid 280 // Returns the display used for software mirrroring. Returns invalid
279 // display if not found. 281 // display if not found.
280 const display::Display GetMirroringDisplayById(int64_t id) const; 282 const display::Display GetMirroringDisplayById(int64_t id) const;
281 283
282 // Retuns the display info associated with |display_id|. 284 // Retuns the display info associated with |display_id|.
283 const DisplayInfo& GetDisplayInfo(int64_t display_id) const; 285 const display::ManagedDisplayInfo& GetDisplayInfo(int64_t display_id) const;
284 286
285 // Returns the human-readable name for the display |id|. 287 // Returns the human-readable name for the display |id|.
286 std::string GetDisplayNameForId(int64_t id); 288 std::string GetDisplayNameForId(int64_t id);
287 289
288 // Returns the display id that is capable of UI scaling. On device, 290 // Returns the display id that is capable of UI scaling. On device,
289 // this returns internal display's ID if its device scale factor is 2, 291 // this returns internal display's ID if its device scale factor is 2,
290 // or invalid ID if such internal display doesn't exist. On linux 292 // or invalid ID if such internal display doesn't exist. On linux
291 // desktop, this returns the first display ID. 293 // desktop, this returns the first display ID.
292 int64_t GetDisplayIdForUIScaling() const; 294 int64_t GetDisplayIdForUIScaling() const;
293 295
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 NativeDisplaysChangedAfterPrimaryChange); 349 NativeDisplaysChangedAfterPrimaryChange);
348 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); 350 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets);
349 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, Rotate); 351 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, Rotate);
350 friend class AcceleratorControllerTest; 352 friend class AcceleratorControllerTest;
351 friend class DisplayManagerTest; 353 friend class DisplayManagerTest;
352 friend class chromeos::DisplayNotificationsTest; 354 friend class chromeos::DisplayNotificationsTest;
353 friend class test::AshTestBase; 355 friend class test::AshTestBase;
354 friend class test::DisplayManagerTestApi; 356 friend class test::DisplayManagerTestApi;
355 friend class test::SystemGestureEventFilterTest; 357 friend class test::SystemGestureEventFilterTest;
356 358
357 typedef std::vector<DisplayInfo> DisplayInfoList;
358
359 bool software_mirroring_enabled() const { 359 bool software_mirroring_enabled() const {
360 return multi_display_mode_ == MIRRORING; 360 return multi_display_mode_ == MIRRORING;
361 }; 361 };
362 362
363 void set_change_display_upon_host_resize(bool value) { 363 void set_change_display_upon_host_resize(bool value) {
364 change_display_upon_host_resize_ = value; 364 change_display_upon_host_resize_ = value;
365 } 365 }
366 366
367 // Creates software mirroring display related information. The display 367 // Creates software mirroring display related information. The display
368 // used to mirror the content is removed from the |display_info_list|. 368 // used to mirror the content is removed from the |display_info_list|.
369 void CreateSoftwareMirroringDisplayInfo(DisplayInfoList* display_info_list); 369 void CreateSoftwareMirroringDisplayInfo(DisplayInfoList* display_info_list);
370 370
371 display::Display* FindDisplayForId(int64_t id); 371 display::Display* FindDisplayForId(int64_t id);
372 372
373 // Add the mirror display's display info if the software based 373 // Add the mirror display's display info if the software based
374 // mirroring is in use. 374 // mirroring is in use.
375 void AddMirrorDisplayInfoIfAny(DisplayInfoList* display_info_list); 375 void AddMirrorDisplayInfoIfAny(DisplayInfoList* display_info_list);
376 376
377 // Inserts and update the DisplayInfo according to the overscan 377 // Inserts and update the display::ManagedDisplayInfo according to the
378 // state. Note that The DisplayInfo stored in the |internal_display_info_| 378 // overscan
379 // state. Note that The display::ManagedDisplayInfo stored in the
380 // |internal_display_info_|
379 // can be different from |new_info| (due to overscan state), so 381 // can be different from |new_info| (due to overscan state), so
380 // you must use |GetDisplayInfo| to get the correct DisplayInfo for 382 // you must use |GetDisplayInfo| to get the correct
383 // display::ManagedDisplayInfo for
381 // a display. 384 // a display.
382 void InsertAndUpdateDisplayInfo(const DisplayInfo& new_info); 385 void InsertAndUpdateDisplayInfo(const display::ManagedDisplayInfo& new_info);
383 386
384 // Called when the display info is updated through InsertAndUpdateDisplayInfo. 387 // Called when the display info is updated through InsertAndUpdateDisplayInfo.
385 void OnDisplayInfoUpdated(const DisplayInfo& display_info); 388 void OnDisplayInfoUpdated(const display::ManagedDisplayInfo& display_info);
386 389
387 // Creates a display object from the DisplayInfo for |display_id|. 390 // Creates a display object from the display::ManagedDisplayInfo for
391 // |display_id|.
388 display::Display CreateDisplayFromDisplayInfoById(int64_t display_id); 392 display::Display CreateDisplayFromDisplayInfoById(int64_t display_id);
389 393
390 // Creates a display object from the DisplayInfo for |display_id| for 394 // Creates a display object from the display::ManagedDisplayInfo for
395 // |display_id|
396 // for
391 // mirroring. The size of the display will be scaled using |scale| 397 // mirroring. The size of the display will be scaled using |scale|
392 // with the offset using |origin|. 398 // with the offset using |origin|.
393 display::Display CreateMirroringDisplayFromDisplayInfoById( 399 display::Display CreateMirroringDisplayFromDisplayInfoById(
394 int64_t display_id, 400 int64_t display_id,
395 const gfx::Point& origin, 401 const gfx::Point& origin,
396 float scale); 402 float scale);
397 403
398 // Updates the bounds of all non-primary displays in |display_list| and 404 // Updates the bounds of all non-primary displays in |display_list| and
399 // append the indices of displays updated to |updated_indices|. 405 // append the indices of displays updated to |updated_indices|.
400 // When the size of |display_list| equals 2, the bounds are updated using 406 // When the size of |display_list| equals 2, the bounds are updated using
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // True if active_display_list is being modified and has displays that are not 438 // True if active_display_list is being modified and has displays that are not
433 // presently active. 439 // presently active.
434 // See https://crbug.com/632755 440 // See https://crbug.com/632755
435 bool is_updating_display_list_; 441 bool is_updating_display_list_;
436 442
437 int num_connected_displays_; 443 int num_connected_displays_;
438 444
439 bool force_bounds_changed_; 445 bool force_bounds_changed_;
440 446
441 // The mapping from the display ID to its internal data. 447 // The mapping from the display ID to its internal data.
442 std::map<int64_t, DisplayInfo> display_info_; 448 std::map<int64_t, display::ManagedDisplayInfo> display_info_;
443 449
444 // Selected display modes for displays. Key is the displays' ID. 450 // Selected display modes for displays. Key is the displays' ID.
445 std::map<int64_t, scoped_refptr<ManagedDisplayMode>> display_modes_; 451 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>> display_modes_;
446 452
447 // When set to true, the host window's resize event updates 453 // When set to true, the host window's resize event updates
448 // the display's size. This is set to true when running on 454 // the display's size. This is set to true when running on
449 // desktop environment (for debugging) so that resizing the host 455 // desktop environment (for debugging) so that resizing the host
450 // window will update the display properly. This is set to false 456 // window will update the display properly. This is set to false
451 // on device as well as during the unit tests. 457 // on device as well as during the unit tests.
452 bool change_display_upon_host_resize_; 458 bool change_display_upon_host_resize_;
453 459
454 MultiDisplayMode multi_display_mode_; 460 MultiDisplayMode multi_display_mode_;
455 MultiDisplayMode current_default_multi_display_mode_; 461 MultiDisplayMode current_default_multi_display_mode_;
(...skipping 10 matching lines...) Expand all
466 bool unified_desktop_enabled_; 472 bool unified_desktop_enabled_;
467 473
468 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; 474 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_;
469 475
470 DISALLOW_COPY_AND_ASSIGN(DisplayManager); 476 DISALLOW_COPY_AND_ASSIGN(DisplayManager);
471 }; 477 };
472 478
473 } // namespace ash 479 } // namespace ash
474 480
475 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ 481 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/display/display_change_observer_chromeos_unittest.cc ('k') | ash/display/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698