Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ui/compositor/compositor.cc

Issue 2175293003: cc: Register namespace hierarchy after ui::Compositor's SurfaceFactory available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit test and addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <deque> 10 #include <deque>
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 if (animation_timeline_) 239 if (animation_timeline_)
240 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get()); 240 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get());
241 241
242 // Stop all outstanding draws before telling the ContextFactory to tear 242 // Stop all outstanding draws before telling the ContextFactory to tear
243 // down any contexts that the |host_| may rely upon. 243 // down any contexts that the |host_| may rely upon.
244 host_.reset(); 244 host_.reset();
245 245
246 context_factory_->RemoveCompositor(this); 246 context_factory_->RemoveCompositor(this);
247 if (context_factory_->GetSurfaceManager()) { 247 if (context_factory_->GetSurfaceManager()) {
248 for (auto& client : surface_clients_) {
249 if (client.second) {
250 context_factory_->GetSurfaceManager()
251 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first);
252 }
253 }
248 context_factory_->GetSurfaceManager()->InvalidateSurfaceClientId( 254 context_factory_->GetSurfaceManager()->InvalidateSurfaceClientId(
249 surface_id_allocator_->client_id()); 255 surface_id_allocator_->client_id());
250 } 256 }
251 } 257 }
252 258
259 void Compositor::AddSurfaceClient(uint32_t client_id) {
260 // We don't give the client a parent until the ui::Compositor has an
261 // OutputSurface.
262 uint32_t parent_client_id = 0;
263 if (host_->has_output_surface()) {
264 parent_client_id = surface_id_allocator_->client_id();
265 context_factory_->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy(
266 parent_client_id, client_id);
267 }
268 surface_clients_[client_id] = parent_client_id;
269 }
270
271 void Compositor::RemoveSurfaceClient(uint32_t client_id) {
272 auto it = surface_clients_.find(client_id);
273 DCHECK(it != surface_clients_.end());
274 if (host_->has_output_surface()) {
275 context_factory_->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy(
276 it->second, client_id);
277 }
278 surface_clients_.erase(it);
279 }
280
253 void Compositor::SetOutputSurface( 281 void Compositor::SetOutputSurface(
254 std::unique_ptr<cc::OutputSurface> output_surface) { 282 std::unique_ptr<cc::OutputSurface> output_surface) {
255 output_surface_requested_ = false; 283 output_surface_requested_ = false;
256 host_->SetOutputSurface(std::move(output_surface)); 284 host_->SetOutputSurface(std::move(output_surface));
285 // ui::Compositor uses a SingleThreadProxy and so BindToClient will be called
286 // above and SurfaceManager will be made aware of the OutputSurface's client
287 // ID.
288 for (auto& client : surface_clients_) {
289 if (client.second == surface_id_allocator_->client_id())
290 continue;
291 // If a client already has a parent, then we unregister the existing parent.
292 if (client.second) {
293 context_factory_->GetSurfaceManager()
294 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first);
295 }
296 context_factory_->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy(
297 surface_id_allocator_->client_id(), client.first);
298 client.second = surface_id_allocator_->client_id();
299 }
257 } 300 }
258 301
259 void Compositor::ScheduleDraw() { 302 void Compositor::ScheduleDraw() {
260 host_->SetNeedsCommit(); 303 host_->SetNeedsCommit();
261 } 304 }
262 305
263 void Compositor::SetRootLayer(Layer* root_layer) { 306 void Compositor::SetRootLayer(Layer* root_layer) {
264 if (root_layer_ == root_layer) 307 if (root_layer_ == root_layer)
265 return; 308 return;
266 if (root_layer_) 309 if (root_layer_)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // This function should only get called once. 399 // This function should only get called once.
357 DCHECK(!widget_valid_); 400 DCHECK(!widget_valid_);
358 widget_ = widget; 401 widget_ = widget;
359 widget_valid_ = true; 402 widget_valid_ = true;
360 if (output_surface_requested_) 403 if (output_surface_requested_)
361 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); 404 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr());
362 } 405 }
363 406
364 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { 407 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() {
365 DCHECK(!IsVisible()); 408 DCHECK(!IsVisible());
366 if (!host_->output_surface_lost()) 409 if (!host_->output_surface_lost()) {
367 host_->ReleaseOutputSurface(); 410 host_->ReleaseOutputSurface();
411 for (auto& client : surface_clients_) {
412 context_factory_->GetSurfaceManager()
413 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first);
414 client.second = 0;
415 }
416 }
368 context_factory_->RemoveCompositor(this); 417 context_factory_->RemoveCompositor(this);
369 widget_valid_ = false; 418 widget_valid_ = false;
370 gfx::AcceleratedWidget widget = widget_; 419 gfx::AcceleratedWidget widget = widget_;
371 widget_ = gfx::kNullAcceleratedWidget; 420 widget_ = gfx::kNullAcceleratedWidget;
372 return widget; 421 return widget;
373 } 422 }
374 423
375 gfx::AcceleratedWidget Compositor::widget() const { 424 gfx::AcceleratedWidget Compositor::widget() const {
376 DCHECK(widget_valid_); 425 DCHECK(widget_valid_);
377 return widget_; 426 return widget_;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 observer_list_, 559 observer_list_,
511 OnCompositingLockStateChanged(this)); 560 OnCompositingLockStateChanged(this));
512 } 561 }
513 562
514 void Compositor::CancelCompositorLock() { 563 void Compositor::CancelCompositorLock() {
515 if (compositor_lock_) 564 if (compositor_lock_)
516 compositor_lock_->CancelLock(); 565 compositor_lock_->CancelLock();
517 } 566 }
518 567
519 } // namespace ui 568 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698