OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/renderer/mus/renderer_window_tree_client.h" | 5 #include "content/renderer/mus/renderer_window_tree_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "services/ui/public/cpp/client_compositor_frame_sink.h" | 10 #include "services/ui/public/cpp/client_compositor_frame_sink.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 g_connections.Get().insert(std::make_pair(routing_id, connection)); | 34 g_connections.Get().insert(std::make_pair(routing_id, connection)); |
35 } | 35 } |
36 | 36 |
37 // static | 37 // static |
38 void RendererWindowTreeClient::Destroy(int routing_id) { | 38 void RendererWindowTreeClient::Destroy(int routing_id) { |
39 auto* client = Get(routing_id); | 39 auto* client = Get(routing_id); |
40 if (client) | 40 if (client) |
41 client->DestroySelf(); | 41 client->DestroySelf(); |
42 } | 42 } |
43 | 43 |
44 void RendererWindowTreeClient::Bind( | |
45 ui::mojom::WindowTreeClientRequest request) { | |
46 binding_.Bind(std::move(request)); | |
47 } | |
48 | |
49 void RendererWindowTreeClient::RequestCompositorFrameSink( | |
50 scoped_refptr<cc::ContextProvider> context_provider, | |
51 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
52 const CompositorFrameSinkCallback& callback) { | |
53 DCHECK(pending_compositor_frame_sink_request_.is_null()); | |
54 if (frame_sink_id_.is_valid()) { | |
55 RequestCompositorFrameSinkInternal(std::move(context_provider), | |
56 gpu_memory_buffer_manager, callback); | |
57 return; | |
58 } | |
59 | |
60 pending_compositor_frame_sink_request_ = | |
61 base::Bind(&RendererWindowTreeClient::RequestCompositorFrameSinkInternal, | |
piman
2017/03/22 00:38:22
Why use a callback for this? Couldn't we just call
Fady Samuel
2017/03/22 00:40:40
Ohh I'm just stashing the params in the callback.
| |
62 base::Unretained(this), std::move(context_provider), | |
63 gpu_memory_buffer_manager, callback); | |
64 } | |
65 | |
44 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) | 66 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) |
45 : routing_id_(routing_id), binding_(this) {} | 67 : routing_id_(routing_id), binding_(this) {} |
46 | 68 |
47 RendererWindowTreeClient::~RendererWindowTreeClient() { | 69 RendererWindowTreeClient::~RendererWindowTreeClient() { |
48 g_connections.Get().erase(routing_id_); | 70 g_connections.Get().erase(routing_id_); |
49 } | 71 } |
50 | 72 |
51 void RendererWindowTreeClient::Bind( | 73 void RendererWindowTreeClient::RequestCompositorFrameSinkInternal( |
52 ui::mojom::WindowTreeClientRequest request) { | |
53 binding_.Bind(std::move(request)); | |
54 } | |
55 | |
56 std::unique_ptr<cc::CompositorFrameSink> | |
57 RendererWindowTreeClient::CreateCompositorFrameSink( | |
58 const cc::FrameSinkId& frame_sink_id, | |
59 scoped_refptr<cc::ContextProvider> context_provider, | 74 scoped_refptr<cc::ContextProvider> context_provider, |
60 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { | 75 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
76 const CompositorFrameSinkCallback& callback) { | |
61 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding; | 77 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding; |
62 auto frame_sink = ui::ClientCompositorFrameSink::Create( | 78 auto frame_sink = ui::ClientCompositorFrameSink::Create( |
63 frame_sink_id, std::move(context_provider), gpu_memory_buffer_manager, | 79 frame_sink_id_, std::move(context_provider), gpu_memory_buffer_manager, |
64 &frame_sink_binding); | 80 &frame_sink_binding); |
65 if (tree_) { | 81 tree_->AttachCompositorFrameSink( |
66 tree_->AttachCompositorFrameSink( | 82 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), |
67 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), | 83 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); |
68 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); | 84 callback.Run(std::move(frame_sink)); |
69 } else { | |
70 pending_frame_sink_ = std::move(frame_sink_binding); | |
71 } | |
72 return std::move(frame_sink); | |
73 } | 85 } |
74 | 86 |
75 void RendererWindowTreeClient::DestroySelf() { | 87 void RendererWindowTreeClient::DestroySelf() { |
76 delete this; | 88 delete this; |
77 } | 89 } |
78 | 90 |
79 void RendererWindowTreeClient::OnEmbed(ui::ClientSpecificId client_id, | 91 void RendererWindowTreeClient::OnEmbed(ui::ClientSpecificId client_id, |
80 ui::mojom::WindowDataPtr root, | 92 ui::mojom::WindowDataPtr root, |
81 ui::mojom::WindowTreePtr tree, | 93 ui::mojom::WindowTreePtr tree, |
82 int64_t display_id, | 94 int64_t display_id, |
83 ui::Id focused_window_id, | 95 ui::Id focused_window_id, |
84 bool drawn) { | 96 bool drawn, |
97 const cc::FrameSinkId& frame_sink_id) { | |
98 frame_sink_id_ = frame_sink_id; | |
85 root_window_id_ = root->window_id; | 99 root_window_id_ = root->window_id; |
86 tree_ = std::move(tree); | 100 tree_ = std::move(tree); |
87 if (pending_frame_sink_) { | 101 if (!pending_compositor_frame_sink_request_.is_null()) |
88 tree_->AttachCompositorFrameSink( | 102 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); |
89 root_window_id_, pending_frame_sink_->TakeFrameSinkRequest(), | |
90 mojo::MakeProxy(pending_frame_sink_->TakeFrameSinkClient())); | |
91 pending_frame_sink_ = nullptr; | |
92 } | |
93 } | 103 } |
94 | 104 |
95 void RendererWindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) { | 105 void RendererWindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) { |
96 // TODO(sad): Embedded mus-client (oopif) is gone. Figure out what to do. | 106 // TODO(sad): Embedded mus-client (oopif) is gone. Figure out what to do. |
97 } | 107 } |
98 | 108 |
99 void RendererWindowTreeClient::OnUnembed(ui::Id window_id) { | 109 void RendererWindowTreeClient::OnUnembed(ui::Id window_id) { |
100 CHECK_EQ(window_id, root_window_id_); | 110 CHECK_EQ(window_id, root_window_id_); |
101 DestroySelf(); | 111 DestroySelf(); |
102 } | 112 } |
103 | 113 |
104 void RendererWindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id, | 114 void RendererWindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id, |
105 ui::Id old_capture_window_id) {} | 115 ui::Id old_capture_window_id) {} |
106 | 116 |
107 void RendererWindowTreeClient::OnTopLevelCreated(uint32_t change_id, | 117 void RendererWindowTreeClient::OnTopLevelCreated( |
108 ui::mojom::WindowDataPtr data, | 118 uint32_t change_id, |
109 int64_t display_id, | 119 ui::mojom::WindowDataPtr data, |
110 bool drawn) { | 120 int64_t display_id, |
121 bool drawn, | |
122 const cc::FrameSinkId& frame_sink_id) { | |
111 NOTREACHED(); | 123 NOTREACHED(); |
112 } | 124 } |
113 | 125 |
114 void RendererWindowTreeClient::OnWindowBoundsChanged( | 126 void RendererWindowTreeClient::OnWindowBoundsChanged( |
115 ui::Id window_id, | 127 ui::Id window_id, |
116 const gfx::Rect& old_bounds, | 128 const gfx::Rect& old_bounds, |
117 const gfx::Rect& new_bounds, | 129 const gfx::Rect& new_bounds, |
118 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {} | 130 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {} |
119 | 131 |
120 void RendererWindowTreeClient::OnClientAreaChanged( | 132 void RendererWindowTreeClient::OnClientAreaChanged( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 bool success) {} | 239 bool success) {} |
228 | 240 |
229 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} | 241 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} |
230 | 242 |
231 void RendererWindowTreeClient::GetWindowManager( | 243 void RendererWindowTreeClient::GetWindowManager( |
232 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { | 244 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { |
233 NOTREACHED(); | 245 NOTREACHED(); |
234 } | 246 } |
235 | 247 |
236 } // namespace content | 248 } // namespace content |
OLD | NEW |