| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 376 } |
| 377 | 377 |
| 378 void Display::DidReceiveTextureInUseResponses( | 378 void Display::DidReceiveTextureInUseResponses( |
| 379 const gpu::TextureInUseResponses& responses) { | 379 const gpu::TextureInUseResponses& responses) { |
| 380 if (renderer_) | 380 if (renderer_) |
| 381 renderer_->DidReceiveTextureInUseResponses(responses); | 381 renderer_->DidReceiveTextureInUseResponses(responses); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void Display::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 384 void Display::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
| 385 aggregator_->SetFullDamageForSurface(current_surface_id_); | 385 aggregator_->SetFullDamageForSurface(current_surface_id_); |
| 386 if (scheduler_) | 386 if (scheduler_) { |
| 387 scheduler_->SurfaceDamaged(current_surface_id_); | 387 BeginFrameAck ack; |
| 388 ack.has_damage = true; |
| 389 scheduler_->SurfaceDamaged(current_surface_id_, ack, true); |
| 390 } |
| 388 } | 391 } |
| 389 | 392 |
| 390 void Display::OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) { | 393 void Display::OnSurfaceDamaged(const SurfaceId& surface_id, |
| 391 if (aggregator_ && | 394 const BeginFrameAck& ack, |
| 392 aggregator_->previous_contained_surfaces().count(surface_id)) { | 395 bool* changed) { |
| 393 Surface* surface = surface_manager_->GetSurfaceForId(surface_id); | 396 if (ack.has_damage) { |
| 394 if (surface) { | 397 if (aggregator_ && |
| 395 if (!surface->HasActiveFrame() || | 398 aggregator_->previous_contained_surfaces().count(surface_id)) { |
| 396 surface->GetActiveFrame().resource_list.empty()) { | 399 Surface* surface = surface_manager_->GetSurfaceForId(surface_id); |
| 397 aggregator_->ReleaseResources(surface_id); | 400 if (surface) { |
| 401 DCHECK(surface->HasActiveFrame()); |
| 402 if (surface->GetActiveFrame().resource_list.empty()) |
| 403 aggregator_->ReleaseResources(surface_id); |
| 398 } | 404 } |
| 405 *changed = true; |
| 406 } else if (surface_id == current_surface_id_) { |
| 407 *changed = true; |
| 399 } | 408 } |
| 400 if (scheduler_) | |
| 401 scheduler_->SurfaceDamaged(surface_id); | |
| 402 *changed = true; | |
| 403 } else if (surface_id == current_surface_id_) { | |
| 404 if (scheduler_) | |
| 405 scheduler_->SurfaceDamaged(surface_id); | |
| 406 *changed = true; | |
| 407 } | 409 } |
| 408 | 410 |
| 411 if (scheduler_) |
| 412 scheduler_->SurfaceDamaged(surface_id, ack, *changed); |
| 413 |
| 409 if (surface_id == current_surface_id_) | 414 if (surface_id == current_surface_id_) |
| 410 UpdateRootSurfaceResourcesLocked(); | 415 UpdateRootSurfaceResourcesLocked(); |
| 411 } | 416 } |
| 412 | 417 |
| 413 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) {} | 418 bool Display::SurfaceHasUndrawnFrame(const SurfaceId& surface_id) const { |
| 419 if (!surface_manager_) |
| 420 return false; |
| 421 |
| 422 Surface* surface = surface_manager_->GetSurfaceForId(surface_id); |
| 423 if (!surface) |
| 424 return false; |
| 425 |
| 426 return surface->HasUndrawnActiveFrame(); |
| 427 } |
| 428 |
| 429 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) { |
| 430 if (scheduler_) |
| 431 scheduler_->SurfaceCreated(surface_info); |
| 432 } |
| 433 |
| 434 void Display::OnSurfaceDestroyed(const SurfaceId& surface_id) { |
| 435 if (scheduler_) |
| 436 scheduler_->SurfaceDestroyed(surface_id); |
| 437 } |
| 438 |
| 439 void Display::OnSurfaceDamageExpected(const SurfaceId& surface_id, |
| 440 const BeginFrameArgs& args) { |
| 441 if (scheduler_) |
| 442 scheduler_->SurfaceDamageExpected(surface_id, args); |
| 443 } |
| 414 | 444 |
| 415 void Display::OnSurfaceDiscarded(const SurfaceId& surface_id) { | 445 void Display::OnSurfaceDiscarded(const SurfaceId& surface_id) { |
| 416 if (aggregator_) | 446 if (aggregator_) |
| 417 aggregator_->ReleaseResources(surface_id); | 447 aggregator_->ReleaseResources(surface_id); |
| 418 } | 448 } |
| 419 | 449 |
| 420 const SurfaceId& Display::CurrentSurfaceId() { | 450 const SurfaceId& Display::CurrentSurfaceId() { |
| 421 return current_surface_id_; | 451 return current_surface_id_; |
| 422 } | 452 } |
| 423 | 453 |
| 424 void Display::ForceImmediateDrawAndSwapIfPossible() { | 454 void Display::ForceImmediateDrawAndSwapIfPossible() { |
| 425 if (scheduler_) | 455 if (scheduler_) |
| 426 scheduler_->ForceImmediateSwapIfPossible(); | 456 scheduler_->ForceImmediateSwapIfPossible(); |
| 427 } | 457 } |
| 428 | 458 |
| 429 } // namespace cc | 459 } // namespace cc |
| OLD | NEW |