OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // Allow for a null request in tests. | 182 // Allow for a null request in tests. |
183 if (request.is_pending()) | 183 if (request.is_pending()) |
184 binding_.Bind(std::move(request)); | 184 binding_.Bind(std::move(request)); |
185 client::GetTransientWindowClient()->AddObserver(this); | 185 client::GetTransientWindowClient()->AddObserver(this); |
186 if (window_manager_delegate) | 186 if (window_manager_delegate) |
187 window_manager_delegate->SetWindowManagerClient(this); | 187 window_manager_delegate->SetWindowManagerClient(this); |
188 if (connector) { // |connector| can be null in tests. | 188 if (connector) { // |connector| can be null in tests. |
189 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); | 189 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); |
190 compositor_context_factory_ = | 190 compositor_context_factory_ = |
191 base::MakeUnique<MusContextFactory>(gpu_.get()); | 191 base::MakeUnique<MusContextFactory>(gpu_.get()); |
| 192 initial_context_factory_ = Env::GetInstance()->context_factory(); |
192 Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); | 193 Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); |
193 } | 194 } |
194 } | 195 } |
195 | 196 |
196 WindowTreeClient::~WindowTreeClient() { | 197 WindowTreeClient::~WindowTreeClient() { |
197 in_destructor_ = true; | 198 in_destructor_ = true; |
198 | 199 |
199 for (WindowTreeClientObserver& observer : observers_) | 200 for (WindowTreeClientObserver& observer : observers_) |
200 observer.OnWillDestroyClient(this); | 201 observer.OnWillDestroyClient(this); |
201 | 202 |
202 // Clients should properly delete all of their windows before shutdown. | 203 // Clients should properly delete all of their windows before shutdown. |
203 CHECK(windows_.empty()); | 204 CHECK(windows_.empty()); |
204 | 205 |
205 capture_synchronizer_.reset(); | 206 capture_synchronizer_.reset(); |
206 | 207 |
207 client::GetTransientWindowClient()->RemoveObserver(this); | 208 client::GetTransientWindowClient()->RemoveObserver(this); |
| 209 |
| 210 Env* env = Env::GetInstance(); |
| 211 if (compositor_context_factory_ && |
| 212 env->context_factory() == compositor_context_factory_.get()) { |
| 213 env->set_context_factory(initial_context_factory_); |
| 214 } |
208 } | 215 } |
209 | 216 |
210 void WindowTreeClient::ConnectViaWindowTreeFactory() { | 217 void WindowTreeClient::ConnectViaWindowTreeFactory() { |
211 // The client id doesn't really matter, we use 101 purely for debugging. | 218 // The client id doesn't really matter, we use 101 purely for debugging. |
212 client_id_ = 101; | 219 client_id_ = 101; |
213 | 220 |
214 ui::mojom::WindowTreeFactoryPtr factory; | 221 ui::mojom::WindowTreeFactoryPtr factory; |
215 connector_->BindInterface(ui::mojom::kServiceName, &factory); | 222 connector_->BindInterface(ui::mojom::kServiceName, &factory); |
216 ui::mojom::WindowTreePtr window_tree; | 223 ui::mojom::WindowTreePtr window_tree; |
217 factory->CreateWindowTree(MakeRequest(&window_tree), | 224 factory->CreateWindowTree(MakeRequest(&window_tree), |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1828 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1822 this, capture_synchronizer_.get(), window)); | 1829 this, capture_synchronizer_.get(), window)); |
1823 } | 1830 } |
1824 | 1831 |
1825 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1832 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1826 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1833 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1827 this, focus_synchronizer_.get(), window)); | 1834 this, focus_synchronizer_.get(), window)); |
1828 } | 1835 } |
1829 | 1836 |
1830 } // namespace aura | 1837 } // namespace aura |
OLD | NEW |