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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 context_factory_->SetDisplayColorSpace(this, color_space); | 372 context_factory_->SetDisplayColorSpace(this, color_space); |
373 } | 373 } |
374 | 374 |
375 void Compositor::SetBackgroundColor(SkColor color) { | 375 void Compositor::SetBackgroundColor(SkColor color) { |
376 host_->set_background_color(color); | 376 host_->set_background_color(color); |
377 ScheduleDraw(); | 377 ScheduleDraw(); |
378 } | 378 } |
379 | 379 |
380 void Compositor::SetVisible(bool visible) { | 380 void Compositor::SetVisible(bool visible) { |
381 host_->SetVisible(visible); | 381 host_->SetVisible(visible); |
| 382 // Compositor is not registered with context_factory_ until |
| 383 // first CreateOutputSurface call, so this may not do anything. |
| 384 context_factory_->SetDisplayVisible(this, visible); |
382 } | 385 } |
383 | 386 |
384 bool Compositor::IsVisible() { | 387 bool Compositor::IsVisible() { |
385 return host_->visible(); | 388 return host_->visible(); |
386 } | 389 } |
387 | 390 |
388 void Compositor::SetAuthoritativeVSyncInterval( | 391 void Compositor::SetAuthoritativeVSyncInterval( |
389 const base::TimeDelta& interval) { | 392 const base::TimeDelta& interval) { |
390 context_factory_->SetAuthoritativeVSyncInterval(this, interval); | 393 context_factory_->SetAuthoritativeVSyncInterval(this, interval); |
391 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 394 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
392 cc::switches::kDisableBeginFrameScheduling)) { | 395 cc::switches::kDisableBeginFrameScheduling)) { |
393 vsync_manager_->SetAuthoritativeVSyncInterval(interval); | 396 vsync_manager_->SetAuthoritativeVSyncInterval(interval); |
394 } | 397 } |
395 } | 398 } |
396 | 399 |
397 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { | 400 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
398 // This function should only get called once. | 401 // This function should only get called once. |
399 DCHECK(!widget_valid_); | 402 DCHECK(!widget_valid_); |
400 widget_ = widget; | 403 widget_ = widget; |
401 widget_valid_ = true; | 404 widget_valid_ = true; |
402 if (output_surface_requested_) | 405 if (output_surface_requested_) { |
403 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 406 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
| 407 // Compositor is not registered with context_factory_ until |
| 408 // first CreateOutputSurface call. |
| 409 context_factory_->SetDisplayVisible(this, host_->visible()); |
| 410 } |
404 } | 411 } |
405 | 412 |
406 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { | 413 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { |
407 DCHECK(!IsVisible()); | 414 DCHECK(!IsVisible()); |
408 if (!host_->output_surface_lost()) { | 415 if (!host_->output_surface_lost()) { |
409 host_->ReleaseOutputSurface(); | 416 host_->ReleaseOutputSurface(); |
410 for (auto& client : surface_clients_) { | 417 for (auto& client : surface_clients_) { |
411 context_factory_->GetSurfaceManager() | 418 context_factory_->GetSurfaceManager() |
412 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first); | 419 ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first); |
413 client.second = 0; | 420 client.second = 0; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 493 |
487 void Compositor::UpdateLayerTreeHost() { | 494 void Compositor::UpdateLayerTreeHost() { |
488 if (!root_layer()) | 495 if (!root_layer()) |
489 return; | 496 return; |
490 SendDamagedRectsRecursive(root_layer()); | 497 SendDamagedRectsRecursive(root_layer()); |
491 } | 498 } |
492 | 499 |
493 void Compositor::RequestNewOutputSurface() { | 500 void Compositor::RequestNewOutputSurface() { |
494 DCHECK(!output_surface_requested_); | 501 DCHECK(!output_surface_requested_); |
495 output_surface_requested_ = true; | 502 output_surface_requested_ = true; |
496 if (widget_valid_) | 503 if (widget_valid_) { |
497 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 504 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
| 505 // Compositor is not registered with context_factory_ until |
| 506 // first CreateOutputSurface call. |
| 507 context_factory_->SetDisplayVisible(this, host_->visible()); |
| 508 } |
498 } | 509 } |
499 | 510 |
500 void Compositor::DidInitializeOutputSurface() { | 511 void Compositor::DidInitializeOutputSurface() { |
501 } | 512 } |
502 | 513 |
503 void Compositor::DidFailToInitializeOutputSurface() { | 514 void Compositor::DidFailToInitializeOutputSurface() { |
504 // The OutputSurface should already be bound/initialized before being given to | 515 // The OutputSurface should already be bound/initialized before being given to |
505 // the Compositor. | 516 // the Compositor. |
506 NOTREACHED(); | 517 NOTREACHED(); |
507 } | 518 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 observer_list_, | 580 observer_list_, |
570 OnCompositingLockStateChanged(this)); | 581 OnCompositingLockStateChanged(this)); |
571 } | 582 } |
572 | 583 |
573 void Compositor::CancelCompositorLock() { | 584 void Compositor::CancelCompositorLock() { |
574 if (compositor_lock_) | 585 if (compositor_lock_) |
575 compositor_lock_->CancelLock(); | 586 compositor_lock_->CancelLock(); |
576 } | 587 } |
577 | 588 |
578 } // namespace ui | 589 } // namespace ui |
OLD | NEW |