Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SERVICES_UI_DISPLAY_PLATFORM_SCREEN_IMPL_OZONE_H_ | 5 #ifndef SERVICES_UI_DISPLAY_PLATFORM_SCREEN_IMPL_OZONE_H_ |
| 6 #define SERVICES_UI_DISPLAY_PLATFORM_SCREEN_IMPL_OZONE_H_ | 6 #define SERVICES_UI_DISPLAY_PLATFORM_SCREEN_IMPL_OZONE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "services/ui/display/platform_screen.h" | 15 #include "services/ui/display/platform_screen.h" |
| 16 #include "ui/display/chromeos/display_configurator.h" | 16 #include "ui/display/chromeos/display_configurator.h" |
| 17 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 18 | 18 |
| 19 namespace display { | 19 namespace display { |
| 20 | 20 |
| 21 // PlatformScreenImplOzone provides the necessary functionality to configure all | 21 // PlatformScreenImplOzone provides the necessary functionality to configure all |
| 22 // attached physical displays on the ozone platform. | 22 // attached physical displays on the ozone platform. |
| 23 class PlatformScreenImplOzone : public PlatformScreen, | 23 class PlatformScreenImplOzone : public PlatformScreen, |
| 24 public ui::DisplayConfigurator::Observer { | 24 public ui::DisplayConfigurator::Observer { |
| 25 public: | 25 public: |
| 26 PlatformScreenImplOzone(); | 26 PlatformScreenImplOzone(); |
| 27 ~PlatformScreenImplOzone() override; | 27 ~PlatformScreenImplOzone() override; |
| 28 | 28 |
| 29 private: | |
| 30 // PlatformScreen: | 29 // PlatformScreen: |
| 31 void Init(PlatformScreenDelegate* delegate) override; | 30 void Init(PlatformScreenDelegate* delegate) override; |
| 32 int64_t GetPrimaryDisplayId() const override; | 31 int64_t GetPrimaryDisplayId() const override; |
| 33 | 32 |
| 33 private: | |
| 34 // TODO(kylechar): This struct is just temporary until we migrate | |
| 35 // DisplayManager code out of ash so it can be used here. | |
| 36 struct DisplayInfo { | |
| 37 DisplayInfo(int64_t new_id, const gfx::Rect& new_bounds) | |
| 38 : id(new_id), bounds(new_bounds) {} | |
| 39 | |
| 40 int64_t id; | |
| 41 // The display bounds. | |
| 42 gfx::Rect bounds; | |
| 43 bool modified = false; | |
|
sky
2016/09/02 18:29:28
Add a description as to what this means and intend
kylechar
2016/09/06 15:35:55
Done.
| |
| 44 bool removed = false; | |
| 45 }; | |
| 46 using CachedDisplayIterator = std::vector<DisplayInfo>::iterator; | |
| 47 | |
| 48 // Processes list of display snapshots and sets |removed| on any displays that | |
| 49 // have been removed. Updates |primary_display_id_| if the primary display was | |
| 50 // removed. Does not remove displays from |cached_displays_| or send updates | |
| 51 // to delegate. | |
| 52 void ProcessRemovedDisplays( | |
| 53 const ui::DisplayConfigurator::DisplayStateList& snapshots); | |
| 54 | |
| 55 // Processes list of display snapshots and updates the bounds of any displays | |
| 56 // in |cached_displays_| that have changed size. Does not send updates to | |
| 57 // delegate. | |
| 58 void ProcessModifiedDisplays( | |
| 59 const ui::DisplayConfigurator::DisplayStateList& snapshots); | |
| 60 | |
| 61 // Looks at |cached_displays_| for modified or removed displays. Also updates | |
| 62 // display bounds in response to modified or removed displays. Sends updates | |
| 63 // to the delegate when appropriate by calling OnDisplayModified() or | |
| 64 // OnDisplayRemoved(). Makes at most one function call per display. | |
| 65 // | |
| 66 // Usually used after ProcessRemovedDisplays() and ProcessModifiedDisplays(). | |
| 67 void UpdateCachedDisplays(); | |
| 68 | |
| 69 // Processes list of display snapshots and adds any new displays to | |
| 70 // |cached_displays_|. Updates delegate by calling OnDisplayAdded(). | |
| 71 void AddNewDisplays( | |
| 72 const ui::DisplayConfigurator::DisplayStateList& snapshots); | |
| 73 | |
| 74 // Returns an iterator to the cached display with |display_id| or an end | |
| 75 // iterator if there is no display with that id. | |
| 76 CachedDisplayIterator GetCachedDisplayIterator(int64_t display_id); | |
| 77 | |
| 34 // ui::DisplayConfigurator::Observer: | 78 // ui::DisplayConfigurator::Observer: |
| 35 void OnDisplayModeChanged( | 79 void OnDisplayModeChanged( |
| 36 const ui::DisplayConfigurator::DisplayStateList& displays) override; | 80 const ui::DisplayConfigurator::DisplayStateList& displays) override; |
| 37 void OnDisplayModeChangeFailed( | 81 void OnDisplayModeChangeFailed( |
| 38 const ui::DisplayConfigurator::DisplayStateList& displays, | 82 const ui::DisplayConfigurator::DisplayStateList& displays, |
| 39 ui::MultipleDisplayState failed_new_state) override; | 83 ui::MultipleDisplayState failed_new_state) override; |
| 40 | 84 |
| 41 PlatformScreenDelegate* delegate_ = nullptr; | 85 PlatformScreenDelegate* delegate_ = nullptr; |
| 42 ui::DisplayConfigurator display_configurator_; | 86 ui::DisplayConfigurator display_configurator_; |
| 43 | 87 |
| 44 // TODO(kylechar): These values can/should be replaced by DisplayLayout. | 88 // TODO(kylechar): These values can/should be replaced by DisplayLayout. |
| 45 int64_t primary_display_id_ = display::Display::kInvalidDisplayID; | 89 int64_t primary_display_id_ = display::Display::kInvalidDisplayID; |
| 46 std::set<uint64_t> displays_; | 90 std::vector<DisplayInfo> cached_displays_; |
| 47 gfx::Point next_display_origin_; | 91 gfx::Point next_display_origin_; |
| 48 | 92 |
| 49 DISALLOW_COPY_AND_ASSIGN(PlatformScreenImplOzone); | 93 DISALLOW_COPY_AND_ASSIGN(PlatformScreenImplOzone); |
| 50 }; | 94 }; |
| 51 | 95 |
| 52 } // namespace display | 96 } // namespace display |
| 53 | 97 |
| 54 #endif // SERVICES_UI_DISPLAY_PLATFORM_SCREEN_IMPL_OZONE_H_ | 98 #endif // SERVICES_UI_DISPLAY_PLATFORM_SCREEN_IMPL_OZONE_H_ |
| OLD | NEW |