OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 SERVICES_UI_DISPLAY_SCREEN_MANAGER_FORWARDING_H_ | |
6 #define SERVICES_UI_DISPLAY_SCREEN_MANAGER_FORWARDING_H_ | |
7 | |
8 #include <memory> | |
9 #include <unordered_map> | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 #include "mojo/public/cpp/bindings/binding.h" | |
14 #include "services/service_manager/public/cpp/interface_factory.h" | |
15 #include "services/ui/display/screen_manager.h" | |
16 #include "ui/display/mojo/native_display_delegate.mojom.h" | |
17 #include "ui/display/types/native_display_observer.h" | |
18 | |
19 namespace display { | |
20 | |
21 class NativeDisplayDelegate; | |
22 | |
23 // ScreenManager implementation that implements mojom::NativeDisplayDelegate. | |
24 // This will own a real NativeDisplayDelegate and forwards calls to and | |
25 // responses from it over Mojo. | |
26 class ScreenManagerForwarding | |
27 : public ScreenManager, | |
28 public NativeDisplayObserver, | |
29 public mojom::NativeDisplayDelegate, | |
30 service_manager::InterfaceFactory<mojom::NativeDisplayDelegate> { | |
31 public: | |
32 ScreenManagerForwarding(); | |
33 ~ScreenManagerForwarding() override; | |
34 | |
35 // ScreenManager: | |
36 void AddInterfaces(service_manager::InterfaceRegistry* registry) override; | |
37 void Init(ScreenManagerDelegate* delegate) override; | |
38 void RequestCloseDisplay(int64_t display_id) override; | |
39 | |
40 // NativeDisplayObserver: | |
41 void OnConfigurationChanged() override; | |
42 void OnDisplaySnapshotsInvalidated() override; | |
43 | |
44 // mojom::NativeDisplayDelegate: | |
45 void Initialize(mojom::NativeDisplayObserverPtr observer) override; | |
46 void TakeDisplayControl(const TakeDisplayControlCallback& callback) override; | |
47 void RelinquishDisplayControl( | |
48 const RelinquishDisplayControlCallback& callback) override; | |
49 void GetDisplays(const GetDisplaysCallback& callback) override; | |
50 void Configure(int64_t display_id, | |
51 std::unique_ptr<display::DisplayMode> mode, | |
52 const gfx::Point& origin, | |
53 const ConfigureCallback& callback) override; | |
54 void GetHDCPState(int64_t display_id, | |
55 const GetHDCPStateCallback& callback) override; | |
56 void SetHDCPState(int64_t display_id, | |
57 display::HDCPState state, | |
58 const SetHDCPStateCallback& callback) override; | |
59 void SetColorCorrection( | |
60 int64_t display_id, | |
61 const std::vector<display::GammaRampRGBEntry>& degamma_lut, | |
62 const std::vector<display::GammaRampRGBEntry>& gamma_lut, | |
63 const std::vector<float>& correction_matrix) override; | |
64 | |
65 // service_manager::InterfaceFactory<mojom::NativeDisplayDelegate>: | |
66 void Create(const service_manager::Identity& remote_identity, | |
67 mojom::NativeDisplayDelegateRequest request) override; | |
68 | |
69 private: | |
70 // Forwards results from GetDisplays() back with |callback|. | |
71 void ForwardGetDisplays( | |
72 const mojom::NativeDisplayDelegate::GetDisplaysCallback& callback, | |
73 const std::vector<DisplaySnapshot*>& displays); | |
74 | |
75 // Forwards results from call to Configure() back with |callback|. | |
76 void ForwardConfigure( | |
77 DisplaySnapshot* snapshot, | |
78 const DisplayMode* mode, | |
79 const gfx::Point& origin, | |
80 const mojom::NativeDisplayDelegate::ConfigureCallback& callback, | |
81 bool status); | |
82 | |
83 mojo::Binding<mojom::NativeDisplayDelegate> binding_; | |
84 mojom::NativeDisplayObserverPtr observer_; | |
85 | |
86 std::unique_ptr<display::NativeDisplayDelegate> native_display_delegate_; | |
87 | |
88 // Cached pointers to snapshots owned by the |native_display_delegate_|. | |
sky
2017/04/07 14:45:54
Thanks for the comment!
| |
89 std::unordered_map<int64_t, DisplaySnapshot*> snapshot_map_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(ScreenManagerForwarding); | |
92 }; | |
93 | |
94 } // namespace display | |
95 | |
96 #endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_FORWARDING_H_ | |
OLD | NEW |