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 #include "content/renderer/mus/renderer_window_tree_client.h" | |
6 | |
7 #include <map> | |
8 | |
9 #include "base/lazy_instance.h" | |
10 #include "services/ui/public/cpp/window_compositor_frame_sink.h" | |
11 | |
12 namespace content { | |
13 | |
14 namespace { | |
15 typedef std::map<int, RendererWindowTreeClient*> ConnectionMap; | |
16 base::LazyInstance<ConnectionMap>::Leaky g_connections = | |
17 LAZY_INSTANCE_INITIALIZER; | |
18 } // namespace | |
19 | |
20 // static | |
21 RendererWindowTreeClient* RendererWindowTreeClient::Get(int routing_id) { | |
22 auto it = g_connections.Get().find(routing_id); | |
23 if (it != g_connections.Get().end()) | |
24 return it->second; | |
25 return nullptr; | |
26 } | |
27 | |
28 // static | |
29 void RendererWindowTreeClient::Create(int routing_id) { | |
30 DCHECK(g_connections.Get().find(routing_id) == g_connections.Get().end()); | |
31 RendererWindowTreeClient* connection = | |
32 new RendererWindowTreeClient(routing_id); | |
33 g_connections.Get().insert(std::make_pair(routing_id, connection)); | |
34 } | |
35 | |
36 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) | |
37 : routing_id_(routing_id), binding_(this) {} | |
38 | |
39 RendererWindowTreeClient::~RendererWindowTreeClient() { | |
40 g_connections.Get().erase(routing_id_); | |
41 } | |
42 | |
43 void RendererWindowTreeClient::Bind( | |
44 ui::mojom::WindowTreeClientRequest request) { | |
45 binding_.Bind(std::move(request)); | |
46 } | |
47 | |
48 std::unique_ptr<cc::CompositorFrameSink> | |
49 RendererWindowTreeClient::CreateCompositorFrameSink( | |
50 const cc::FrameSinkId& frame_sink_id, | |
51 scoped_refptr<cc::ContextProvider> context_provider, | |
52 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { | |
53 std::unique_ptr<ui::WindowCompositorFrameSinkBinding> frame_sink_binding; | |
54 auto frame_sink = ui::WindowCompositorFrameSink::Create( | |
55 frame_sink_id, std::move(context_provider), gpu_memory_buffer_manager, | |
56 &frame_sink_binding); | |
57 if (tree_) { | |
58 tree_->AttachCompositorFrameSink( | |
59 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), | |
60 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); | |
61 } else { | |
62 pending_frame_sink_ = std::move(frame_sink_binding); | |
63 } | |
64 return std::move(frame_sink); | |
65 } | |
66 | |
67 void RendererWindowTreeClient::DestroySelf() { | |
68 delete this; | |
69 } | |
70 | |
71 void RendererWindowTreeClient::OnEmbed(ui::ClientSpecificId client_id, | |
72 ui::mojom::WindowDataPtr root, | |
73 ui::mojom::WindowTreePtr tree, | |
74 int64_t display_id, | |
75 ui::Id focused_window_id, | |
76 bool drawn) { | |
77 root_window_id_ = root->window_id; | |
78 tree_ = std::move(tree); | |
79 if (pending_frame_sink_) { | |
80 tree_->AttachCompositorFrameSink( | |
81 root_window_id_, pending_frame_sink_->TakeFrameSinkRequest(), | |
82 mojo::MakeProxy(pending_frame_sink_->TakeFrameSinkClient())); | |
83 pending_frame_sink_ = nullptr; | |
84 } | |
85 } | |
86 | |
87 void RendererWindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) { | |
88 // TODO(sad): Embedded mus-client (oopif) is gone. Figure out what to do. | |
89 } | |
90 | |
91 void RendererWindowTreeClient::OnUnembed(ui::Id window_id) { | |
92 CHECK_EQ(window_id, root_window_id_); | |
93 DestroySelf(); | |
94 } | |
95 | |
96 void RendererWindowTreeClient::OnTopLevelCreated(uint32_t change_id, | |
97 ui::mojom::WindowDataPtr data, | |
98 int64_t display_id, | |
99 bool drawn) { | |
100 NOTREACHED(); | |
101 } | |
102 | |
103 void RendererWindowTreeClient::OnWindowDeleted(ui::Id window_id) { | |
104 // TODO(sad): With OOPIF, |window_id| may not be |root_window_id_|. We need to | |
105 // make sure that works correctly. | |
106 CHECK_EQ(window_id, root_window_id_); | |
107 DestroySelf(); | |
108 } | |
109 | |
110 void RendererWindowTreeClient::OnWindowInputEvent( | |
111 uint32_t event_id, | |
112 ui::Id window_id, | |
113 std::unique_ptr<ui::Event> event, | |
114 bool matches_pointer_watcher) { | |
115 NOTREACHED(); | |
116 } | |
117 | |
118 void RendererWindowTreeClient::OnPointerEventObserved( | |
119 std::unique_ptr<ui::Event> event, | |
120 uint32_t window_id) { | |
121 NOTREACHED(); | |
122 } | |
123 | |
124 void RendererWindowTreeClient::OnWindowSurfaceChanged( | |
125 ui::Id window_id, | |
126 const cc::SurfaceInfo& surface_info) { | |
127 NOTIMPLEMENTED(); | |
Fady Samuel
2017/01/24 02:04:38
We would get to here when an OOPIF submits a Compo
sadrul
2017/01/24 18:02:41
Acknowledged.
| |
128 } | |
129 | |
130 void RendererWindowTreeClient::GetWindowManager( | |
131 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { | |
132 NOTREACHED(); | |
133 } | |
134 | |
135 } // namespace content | |
OLD | NEW |