| 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 "cc/surfaces/display.h" | 5 #include "cc/surfaces/display.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // This must be done in Initialize() so that the caller can delay this until | 88 // This must be done in Initialize() so that the caller can delay this until |
| 89 // they are ready to receive a BeginFrameSource. | 89 // they are ready to receive a BeginFrameSource. |
| 90 if (begin_frame_source_) { | 90 if (begin_frame_source_) { |
| 91 surface_manager_->RegisterBeginFrameSource(begin_frame_source_, | 91 surface_manager_->RegisterBeginFrameSource(begin_frame_source_, |
| 92 frame_sink_id_); | 92 frame_sink_id_); |
| 93 } | 93 } |
| 94 | 94 |
| 95 output_surface_->BindToClient(this); | 95 output_surface_->BindToClient(this); |
| 96 InitializeRenderer(); | 96 InitializeRenderer(); |
| 97 | 97 |
| 98 if (scheduler_) |
| 99 scheduler_->SetSurfaceManager(surface_manager_); |
| 100 |
| 98 if (auto* context = output_surface_->context_provider()) { | 101 if (auto* context = output_surface_->context_provider()) { |
| 99 // This depends on assumptions that Display::Initialize will happen | 102 // This depends on assumptions that Display::Initialize will happen |
| 100 // on the same callstack as the ContextProvider being created/initialized | 103 // on the same callstack as the ContextProvider being created/initialized |
| 101 // or else it could miss a callback before setting this. | 104 // or else it could miss a callback before setting this. |
| 102 context->SetLostContextCallback(base::Bind( | 105 context->SetLostContextCallback(base::Bind( |
| 103 &Display::DidLoseContextProvider, | 106 &Display::DidLoseContextProvider, |
| 104 // Unretained is safe since the callback is unset in this class' | 107 // Unretained is safe since the callback is unset in this class' |
| 105 // destructor and is never posted. | 108 // destructor and is never posted. |
| 106 base::Unretained(this))); | 109 base::Unretained(this))); |
| 107 } | 110 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 if (scheduler_) { | 364 if (scheduler_) { |
| 362 scheduler_->DidSwapBuffers(); | 365 scheduler_->DidSwapBuffers(); |
| 363 scheduler_->DidReceiveSwapBuffersAck(); | 366 scheduler_->DidReceiveSwapBuffersAck(); |
| 364 } | 367 } |
| 365 } | 368 } |
| 366 | 369 |
| 367 client_->DisplayDidDrawAndSwap(); | 370 client_->DisplayDidDrawAndSwap(); |
| 368 return true; | 371 return true; |
| 369 } | 372 } |
| 370 | 373 |
| 374 const SurfaceAggregator::SurfaceIndexMap& |
| 375 Display::GetPreviousContainedSurfaces() { |
| 376 DCHECK(aggregator_); |
| 377 return aggregator_->previous_contained_surfaces(); |
| 378 } |
| 379 |
| 371 void Display::DidReceiveSwapBuffersAck() { | 380 void Display::DidReceiveSwapBuffersAck() { |
| 372 if (scheduler_) | 381 if (scheduler_) |
| 373 scheduler_->DidReceiveSwapBuffersAck(); | 382 scheduler_->DidReceiveSwapBuffersAck(); |
| 374 if (renderer_) | 383 if (renderer_) |
| 375 renderer_->SwapBuffersComplete(); | 384 renderer_->SwapBuffersComplete(); |
| 376 } | 385 } |
| 377 | 386 |
| 378 void Display::DidReceiveTextureInUseResponses( | 387 void Display::DidReceiveTextureInUseResponses( |
| 379 const gpu::TextureInUseResponses& responses) { | 388 const gpu::TextureInUseResponses& responses) { |
| 380 if (renderer_) | 389 if (renderer_) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 405 scheduler_->SurfaceDamaged(surface_id); | 414 scheduler_->SurfaceDamaged(surface_id); |
| 406 *changed = true; | 415 *changed = true; |
| 407 } | 416 } |
| 408 | 417 |
| 409 if (surface_id == current_surface_id_) | 418 if (surface_id == current_surface_id_) |
| 410 UpdateRootSurfaceResourcesLocked(); | 419 UpdateRootSurfaceResourcesLocked(); |
| 411 } | 420 } |
| 412 | 421 |
| 413 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) {} | 422 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) {} |
| 414 | 423 |
| 424 void Display::OnSurfaceProducerStateChanged(const SurfaceId& surface_id) { |
| 425 if (!scheduler_) |
| 426 return; |
| 427 |
| 428 if ((aggregator_ && |
| 429 aggregator_->previous_contained_surfaces().count(surface_id)) || |
| 430 surface_id == current_surface_id_) { |
| 431 scheduler_->OnSurfaceProducerStateChanged(surface_id); |
| 432 } |
| 433 } |
| 434 |
| 415 const SurfaceId& Display::CurrentSurfaceId() { | 435 const SurfaceId& Display::CurrentSurfaceId() { |
| 416 return current_surface_id_; | 436 return current_surface_id_; |
| 417 } | 437 } |
| 418 | 438 |
| 419 void Display::ForceImmediateDrawAndSwapIfPossible() { | 439 void Display::ForceImmediateDrawAndSwapIfPossible() { |
| 420 if (scheduler_) | 440 if (scheduler_) |
| 421 scheduler_->ForceImmediateSwapIfPossible(); | 441 scheduler_->ForceImmediateSwapIfPossible(); |
| 422 } | 442 } |
| 423 | 443 |
| 424 } // namespace cc | 444 } // namespace cc |
| OLD | NEW |