Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 continue; | 294 continue; |
| 295 // If a client already has a parent, then we unregister the existing parent. | 295 // If a client already has a parent, then we unregister the existing parent. |
| 296 if (client.second) { | 296 if (client.second) { |
| 297 context_factory_->GetSurfaceManager() | 297 context_factory_->GetSurfaceManager() |
| 298 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first); | 298 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first); |
| 299 } | 299 } |
| 300 context_factory_->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy( | 300 context_factory_->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy( |
| 301 surface_id_allocator_->client_id(), client.first); | 301 surface_id_allocator_->client_id(), client.first); |
| 302 client.second = surface_id_allocator_->client_id(); | 302 client.second = surface_id_allocator_->client_id(); |
| 303 } | 303 } |
| 304 // Visibility is reset when the output surface is lost, so update it to match | |
| 305 // the Compositor's. | |
| 306 context_factory_->SetDisplayVisible(this, host_->visible()); | |
| 304 } | 307 } |
| 305 | 308 |
| 306 void Compositor::ScheduleDraw() { | 309 void Compositor::ScheduleDraw() { |
| 307 host_->SetNeedsCommit(); | 310 host_->SetNeedsCommit(); |
| 308 } | 311 } |
| 309 | 312 |
| 310 void Compositor::SetRootLayer(Layer* root_layer) { | 313 void Compositor::SetRootLayer(Layer* root_layer) { |
| 311 if (root_layer_ == root_layer) | 314 if (root_layer_ == root_layer) |
| 312 return; | 315 return; |
| 313 if (root_layer_) | 316 if (root_layer_) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 context_factory_->SetDisplayColorSpace(this, color_space); | 375 context_factory_->SetDisplayColorSpace(this, color_space); |
| 373 } | 376 } |
| 374 | 377 |
| 375 void Compositor::SetBackgroundColor(SkColor color) { | 378 void Compositor::SetBackgroundColor(SkColor color) { |
| 376 host_->set_background_color(color); | 379 host_->set_background_color(color); |
| 377 ScheduleDraw(); | 380 ScheduleDraw(); |
| 378 } | 381 } |
| 379 | 382 |
| 380 void Compositor::SetVisible(bool visible) { | 383 void Compositor::SetVisible(bool visible) { |
| 381 host_->SetVisible(visible); | 384 host_->SetVisible(visible); |
| 385 // Visibility is reset when the output surface is lost, so this must also be | |
| 386 // updated then. | |
| 387 context_factory_->SetDisplayVisible(this, visible); | |
| 382 } | 388 } |
| 383 | 389 |
| 384 bool Compositor::IsVisible() { | 390 bool Compositor::IsVisible() { |
| 385 return host_->visible(); | 391 return host_->visible(); |
| 386 } | 392 } |
| 387 | 393 |
| 388 bool Compositor::ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) { | 394 bool Compositor::ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) { |
| 389 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset); | 395 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset); |
| 390 } | 396 } |
| 391 | 397 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 | 501 |
| 496 void Compositor::UpdateLayerTreeHost() { | 502 void Compositor::UpdateLayerTreeHost() { |
| 497 if (!root_layer()) | 503 if (!root_layer()) |
| 498 return; | 504 return; |
| 499 SendDamagedRectsRecursive(root_layer()); | 505 SendDamagedRectsRecursive(root_layer()); |
| 500 } | 506 } |
| 501 | 507 |
| 502 void Compositor::RequestNewOutputSurface() { | 508 void Compositor::RequestNewOutputSurface() { |
| 503 DCHECK(!output_surface_requested_); | 509 DCHECK(!output_surface_requested_); |
| 504 output_surface_requested_ = true; | 510 output_surface_requested_ = true; |
| 505 if (widget_valid_) | 511 if (widget_valid_) { |
|
sunnyps
2016/08/16 20:18:13
nit: the extra braces are unnecessary
| |
| 506 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 512 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
| 513 } | |
| 507 } | 514 } |
| 508 | 515 |
| 509 void Compositor::DidInitializeOutputSurface() { | 516 void Compositor::DidInitializeOutputSurface() { |
| 510 } | 517 } |
| 511 | 518 |
| 512 void Compositor::DidFailToInitializeOutputSurface() { | 519 void Compositor::DidFailToInitializeOutputSurface() { |
| 513 // The OutputSurface should already be bound/initialized before being given to | 520 // The OutputSurface should already be bound/initialized before being given to |
| 514 // the Compositor. | 521 // the Compositor. |
| 515 NOTREACHED(); | 522 NOTREACHED(); |
| 516 } | 523 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 observer_list_, | 585 observer_list_, |
| 579 OnCompositingLockStateChanged(this)); | 586 OnCompositingLockStateChanged(this)); |
| 580 } | 587 } |
| 581 | 588 |
| 582 void Compositor::CancelCompositorLock() { | 589 void Compositor::CancelCompositorLock() { |
| 583 if (compositor_lock_) | 590 if (compositor_lock_) |
| 584 compositor_lock_->CancelLock(); | 591 compositor_lock_->CancelLock(); |
| 585 } | 592 } |
| 586 | 593 |
| 587 } // namespace ui | 594 } // namespace ui |
| OLD | NEW |