Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_MUS_WS_PLATFORM_SCREEN_H_ | |
| 6 #define COMPONENTS_MUS_WS_PLATFORM_SCREEN_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <set> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/callback.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "ui/display/types/native_display_observer.h" | |
| 16 #include "ui/gfx/geometry/rect.h" | |
| 17 | |
| 18 namespace ui { | |
| 19 class NativeDisplayDelegate; | |
| 20 class DisplaySnapshot; | |
| 21 } | |
| 22 | |
| 23 namespace mus { | |
| 24 namespace ws { | |
| 25 | |
| 26 // PlatformScreen provides the necessary functionality to configure all | |
| 27 // attached physical displays. | |
| 28 class PlatformScreen : public ui::NativeDisplayObserver { | |
|
sky
2016/05/03 23:33:39
I find the class confusing because it has a bunch
rjkroege
2016/05/04 01:37:40
Done.
| |
| 29 public: | |
| 30 PlatformScreen(); | |
| 31 ~PlatformScreen() override; | |
| 32 | |
| 33 // Initializes platform specific screen resources. Assumes that the ozone | |
| 34 // platform implementation has been initialized. | |
| 35 void Init(); | |
| 36 | |
| 37 // The PhysicalScreen will invoke this callback when a previously requested | |
| 38 // display configuration has been confirmed. | |
| 39 using ConfiguredDisplayCallback = base::Callback<void(int64_t, gfx::Rect)>; | |
| 40 | |
| 41 // ConfigurePhysicalDisplay() configures a single physical display and returns | |
| 42 // pending bounds for it via callback. | |
| 43 void ConfigurePhysicalDisplay(const ConfiguredDisplayCallback& callback); | |
| 44 | |
| 45 private: | |
| 46 // Some ozone platforms do not configure physical displays and so do not | |
| 47 // callback into this class via the implementation of NativeDisplayObserver. | |
| 48 // FixedSizeScreenConfiguration() short-circuits the implementation of display | |
| 49 // configuration in this case by calling the |callback| provided to | |
| 50 // ConfigurePhysicalDisplay() with a hard-coded |id| and |bounds|. | |
| 51 void FixedSizeScreenConfiguration(ConfiguredDisplayCallback callback); | |
| 52 | |
| 53 // TODO(rjkroege): NativeDisplayObserver is misnamed as it tracks changes in | |
| 54 // the physical "Screen". Consider renaming it to NativeScreenObserver. | |
| 55 // ui::NativeDisplayObserver: | |
| 56 void OnConfigurationChanged() override; | |
| 57 | |
| 58 // Additional display management callbacks. | |
| 59 void OnDisplaysAquired(const ConfiguredDisplayCallback& callback, | |
| 60 const std::vector<ui::DisplaySnapshot*>& displays); | |
| 61 void OnDisplayConfigured(const ConfiguredDisplayCallback& callback, | |
| 62 int64_t id, | |
| 63 const gfx::Rect& bounds, | |
| 64 bool success); | |
| 65 | |
| 66 // Flags used to keep track of the current state of display configuration. | |
| 67 // |is_configuring| is true if configuring the Screen and starts false. | |
| 68 bool is_configuring_; | |
| 69 | |
| 70 // If |is_configuring_| is true and another display configuration event | |
| 71 // happens, the event is deferred. |should_configure_| is set to true and a | |
| 72 // display configuration will be scheduled after the current one finishes. | |
| 73 // NB: events are handled once per vblank. | |
| 74 bool should_configure_; | |
| 75 | |
| 76 std::unique_ptr<ui::NativeDisplayDelegate> native_display_delegate_; | |
| 77 ConfiguredDisplayCallback callback_; | |
| 78 | |
| 79 base::WeakPtrFactory<PlatformScreen> weak_ptr_factory_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(PlatformScreen); | |
| 82 }; | |
| 83 | |
| 84 } // namespace ws | |
| 85 } // namespace mus | |
| 86 | |
| 87 #endif // COMPONENTS_MUS_WS_PLATFORM_SCREEN_H_ | |
| OLD | NEW |