OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/compositor_mus_connection.h" | 5 #include "content/renderer/mus/compositor_mus_connection.h" |
6 | 6 |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "content/renderer/input/input_handler_manager.h" | 8 #include "content/renderer/input/input_handler_manager.h" |
9 #include "content/renderer/mus/render_widget_mus_connection.h" | 9 #include "content/renderer/mus/render_widget_mus_connection.h" |
10 #include "ui/events/blink/blink_event_util.h" | 10 #include "ui/events/blink/blink_event_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 main_task_runner_(main_task_runner), | 38 main_task_runner_(main_task_runner), |
39 compositor_task_runner_(compositor_task_runner), | 39 compositor_task_runner_(compositor_task_runner), |
40 input_handler_manager_(input_handler_manager) { | 40 input_handler_manager_(input_handler_manager) { |
41 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 41 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
42 compositor_task_runner_->PostTask( | 42 compositor_task_runner_->PostTask( |
43 FROM_HERE, base::Bind(&CompositorMusConnection:: | 43 FROM_HERE, base::Bind(&CompositorMusConnection:: |
44 CreateWindowTreeClientOnCompositorThread, | 44 CreateWindowTreeClientOnCompositorThread, |
45 this, base::Passed(std::move(request)))); | 45 this, base::Passed(std::move(request)))); |
46 } | 46 } |
47 | 47 |
48 void CompositorMusConnection::AttachSurfaceOnMainThread( | 48 void CompositorMusConnection::AttachCompositorFrameSinkOnMainThread( |
49 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) { | 49 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) { |
50 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 50 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
51 compositor_task_runner_->PostTask( | 51 compositor_task_runner_->PostTask( |
52 FROM_HERE, | 52 FROM_HERE, |
53 base::Bind(&CompositorMusConnection::AttachSurfaceOnCompositorThread, | 53 base::Bind( |
54 this, base::Passed(std::move(surface_binding)))); | 54 &CompositorMusConnection::AttachCompositorFrameSinkOnCompositorThread, |
| 55 this, base::Passed(std::move(surface_binding)))); |
55 } | 56 } |
56 | 57 |
57 CompositorMusConnection::~CompositorMusConnection() { | 58 CompositorMusConnection::~CompositorMusConnection() { |
58 base::AutoLock auto_lock(window_tree_client_lock_); | 59 base::AutoLock auto_lock(window_tree_client_lock_); |
59 // Destruction must happen on the compositor task runner. | 60 // Destruction must happen on the compositor task runner. |
60 DCHECK(!window_tree_client_); | 61 DCHECK(!window_tree_client_); |
61 } | 62 } |
62 | 63 |
63 void CompositorMusConnection::AttachSurfaceOnCompositorThread( | 64 void CompositorMusConnection::AttachCompositorFrameSinkOnCompositorThread( |
64 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) { | 65 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) { |
65 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 66 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
66 window_surface_binding_ = std::move(surface_binding); | 67 window_surface_binding_ = std::move(surface_binding); |
67 if (root_) { | 68 if (root_) { |
68 root_->AttachSurface(ui::mojom::SurfaceType::DEFAULT, | 69 root_->AttachCompositorFrameSink(ui::mojom::SurfaceType::DEFAULT, |
69 std::move(window_surface_binding_)); | 70 std::move(window_surface_binding_)); |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 void CompositorMusConnection::CreateWindowTreeClientOnCompositorThread( | 74 void CompositorMusConnection::CreateWindowTreeClientOnCompositorThread( |
74 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) { | 75 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) { |
75 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 76 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
76 DCHECK(!window_tree_client_); | 77 DCHECK(!window_tree_client_); |
77 std::unique_ptr<ui::WindowTreeClient> window_tree_client = | 78 std::unique_ptr<ui::WindowTreeClient> window_tree_client = |
78 base::MakeUnique<ui::WindowTreeClient>(this, nullptr, std::move(request)); | 79 base::MakeUnique<ui::WindowTreeClient>(this, nullptr, std::move(request)); |
79 base::AutoLock auto_lock(window_tree_client_lock_); | 80 base::AutoLock auto_lock(window_tree_client_lock_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 main_task_runner_->PostTask( | 146 main_task_runner_->PostTask( |
146 FROM_HERE, | 147 FROM_HERE, |
147 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this)); | 148 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this)); |
148 } | 149 } |
149 | 150 |
150 void CompositorMusConnection::OnEmbed(ui::Window* root) { | 151 void CompositorMusConnection::OnEmbed(ui::Window* root) { |
151 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 152 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
152 root_ = root; | 153 root_ = root; |
153 root_->set_input_event_handler(this); | 154 root_->set_input_event_handler(this); |
154 if (window_surface_binding_) { | 155 if (window_surface_binding_) { |
155 root->AttachSurface(ui::mojom::SurfaceType::DEFAULT, | 156 root->AttachCompositorFrameSink(ui::mojom::SurfaceType::DEFAULT, |
156 std::move(window_surface_binding_)); | 157 std::move(window_surface_binding_)); |
157 } | 158 } |
158 } | 159 } |
159 | 160 |
160 void CompositorMusConnection::OnEmbedRootDestroyed(ui::Window* window) { | 161 void CompositorMusConnection::OnEmbedRootDestroyed(ui::Window* window) { |
161 DeleteWindowTreeClient(); | 162 DeleteWindowTreeClient(); |
162 } | 163 } |
163 | 164 |
164 void CompositorMusConnection::OnLostConnection(ui::WindowTreeClient* client) { | 165 void CompositorMusConnection::OnLostConnection(ui::WindowTreeClient* client) { |
165 DeleteWindowTreeClient(); | 166 DeleteWindowTreeClient(); |
166 } | 167 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 224 } |
224 ack_callback.reset(); | 225 ack_callback.reset(); |
225 | 226 |
226 main_task_runner_->PostTask( | 227 main_task_runner_->PostTask( |
227 FROM_HERE, | 228 FROM_HERE, |
228 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, | 229 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, |
229 base::Passed(std::move(web_event)), ack)); | 230 base::Passed(std::move(web_event)), ack)); |
230 } | 231 } |
231 | 232 |
232 } // namespace content | 233 } // namespace content |
OLD | NEW |