| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 DCHECK(frame_sink_id_.is_valid()); | 54 DCHECK(frame_sink_id_.is_valid()); |
| 55 if (scheduler_) { | 55 if (scheduler_) { |
| 56 scheduler_->SetClient(this); | 56 scheduler_->SetClient(this); |
| 57 scheduler_->SetBeginFrameSource(begin_frame_source); | 57 scheduler_->SetBeginFrameSource(begin_frame_source); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 Display::~Display() { | 61 Display::~Display() { |
| 62 // Only do this if Initialize() happened. | 62 // Only do this if Initialize() happened. |
| 63 if (client_) { | 63 if (client_) { |
| 64 scheduler_->SetSurfaceManager(nullptr); |
| 64 if (auto* context = output_surface_->context_provider()) | 65 if (auto* context = output_surface_->context_provider()) |
| 65 context->SetLostContextCallback(base::Closure()); | 66 context->SetLostContextCallback(base::Closure()); |
| 66 if (begin_frame_source_) | 67 if (begin_frame_source_) |
| 67 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_); | 68 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_); |
| 68 surface_manager_->RemoveObserver(this); | 69 surface_manager_->RemoveObserver(this); |
| 69 } | 70 } |
| 70 if (aggregator_) { | 71 if (aggregator_) { |
| 71 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { | 72 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { |
| 72 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); | 73 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); |
| 73 if (surface) | 74 if (surface) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 88 // This must be done in Initialize() so that the caller can delay this until | 89 // This must be done in Initialize() so that the caller can delay this until |
| 89 // they are ready to receive a BeginFrameSource. | 90 // they are ready to receive a BeginFrameSource. |
| 90 if (begin_frame_source_) { | 91 if (begin_frame_source_) { |
| 91 surface_manager_->RegisterBeginFrameSource(begin_frame_source_, | 92 surface_manager_->RegisterBeginFrameSource(begin_frame_source_, |
| 92 frame_sink_id_); | 93 frame_sink_id_); |
| 93 } | 94 } |
| 94 | 95 |
| 95 output_surface_->BindToClient(this); | 96 output_surface_->BindToClient(this); |
| 96 InitializeRenderer(); | 97 InitializeRenderer(); |
| 97 | 98 |
| 99 if (scheduler_) |
| 100 scheduler_->SetSurfaceManager(surface_manager_); |
| 101 |
| 98 if (auto* context = output_surface_->context_provider()) { | 102 if (auto* context = output_surface_->context_provider()) { |
| 99 // This depends on assumptions that Display::Initialize will happen | 103 // This depends on assumptions that Display::Initialize will happen |
| 100 // on the same callstack as the ContextProvider being created/initialized | 104 // on the same callstack as the ContextProvider being created/initialized |
| 101 // or else it could miss a callback before setting this. | 105 // or else it could miss a callback before setting this. |
| 102 context->SetLostContextCallback(base::Bind( | 106 context->SetLostContextCallback(base::Bind( |
| 103 &Display::DidLoseContextProvider, | 107 &Display::DidLoseContextProvider, |
| 104 // Unretained is safe since the callback is unset in this class' | 108 // Unretained is safe since the callback is unset in this class' |
| 105 // destructor and is never posted. | 109 // destructor and is never posted. |
| 106 base::Unretained(this))); | 110 base::Unretained(this))); |
| 107 } | 111 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 if (scheduler_) { | 365 if (scheduler_) { |
| 362 scheduler_->DidSwapBuffers(); | 366 scheduler_->DidSwapBuffers(); |
| 363 scheduler_->DidReceiveSwapBuffersAck(); | 367 scheduler_->DidReceiveSwapBuffersAck(); |
| 364 } | 368 } |
| 365 } | 369 } |
| 366 | 370 |
| 367 client_->DisplayDidDrawAndSwap(); | 371 client_->DisplayDidDrawAndSwap(); |
| 368 return true; | 372 return true; |
| 369 } | 373 } |
| 370 | 374 |
| 375 const SurfaceAggregator::SurfaceIndexMap& |
| 376 Display::GetPreviousContainedSurfaces() { |
| 377 DCHECK(aggregator_); |
| 378 return aggregator_->previous_contained_surfaces(); |
| 379 } |
| 380 |
| 371 void Display::DidReceiveSwapBuffersAck() { | 381 void Display::DidReceiveSwapBuffersAck() { |
| 372 if (scheduler_) | 382 if (scheduler_) |
| 373 scheduler_->DidReceiveSwapBuffersAck(); | 383 scheduler_->DidReceiveSwapBuffersAck(); |
| 374 if (renderer_) | 384 if (renderer_) |
| 375 renderer_->SwapBuffersComplete(); | 385 renderer_->SwapBuffersComplete(); |
| 376 } | 386 } |
| 377 | 387 |
| 378 void Display::DidReceiveTextureInUseResponses( | 388 void Display::DidReceiveTextureInUseResponses( |
| 379 const gpu::TextureInUseResponses& responses) { | 389 const gpu::TextureInUseResponses& responses) { |
| 380 if (renderer_) | 390 if (renderer_) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 403 } else if (surface_id == current_surface_id_) { | 413 } else if (surface_id == current_surface_id_) { |
| 404 if (scheduler_) | 414 if (scheduler_) |
| 405 scheduler_->SurfaceDamaged(surface_id); | 415 scheduler_->SurfaceDamaged(surface_id); |
| 406 *changed = true; | 416 *changed = true; |
| 407 } | 417 } |
| 408 | 418 |
| 409 if (surface_id == current_surface_id_) | 419 if (surface_id == current_surface_id_) |
| 410 UpdateRootSurfaceResourcesLocked(); | 420 UpdateRootSurfaceResourcesLocked(); |
| 411 } | 421 } |
| 412 | 422 |
| 413 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) {} | 423 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) { |
| 424 if (scheduler_) |
| 425 scheduler_->SurfaceCreated(surface_info); |
| 426 } |
| 427 |
| 428 void Display::OnSurfaceDestroyed(const SurfaceId& surface_id) { |
| 429 if (scheduler_) |
| 430 scheduler_->SurfaceDestroyed(surface_id); |
| 431 } |
| 432 |
| 433 void Display::OnSurfaceReceivedBeginFrame(const SurfaceId& surface_id, |
| 434 const BeginFrameArgs& args) { |
| 435 if (scheduler_) |
| 436 scheduler_->SurfaceReceivedBeginFrame(surface_id, args); |
| 437 } |
| 438 void Display::OnSurfaceFinishedBeginFrame(const SurfaceId& surface_id, |
| 439 const BeginFrameAck& ack) { |
| 440 if (scheduler_) |
| 441 scheduler_->SurfaceFinishedBeginFrame(surface_id, ack); |
| 442 } |
| 414 | 443 |
| 415 const SurfaceId& Display::CurrentSurfaceId() { | 444 const SurfaceId& Display::CurrentSurfaceId() { |
| 416 return current_surface_id_; | 445 return current_surface_id_; |
| 417 } | 446 } |
| 418 | 447 |
| 419 void Display::ForceImmediateDrawAndSwapIfPossible() { | 448 void Display::ForceImmediateDrawAndSwapIfPossible() { |
| 420 if (scheduler_) | 449 if (scheduler_) |
| 421 scheduler_->ForceImmediateSwapIfPossible(); | 450 scheduler_->ForceImmediateSwapIfPossible(); |
| 422 } | 451 } |
| 423 | 452 |
| 424 } // namespace cc | 453 } // namespace cc |
| OLD | NEW |