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 if (!surface->HasActiveFrame() || | |
sunnyps
2017/05/25 20:49:13
nit: Can surface->HasActiveFrame() be false? If no
Eric Seckler
2017/05/26 10:57:52
I think the only place where that may happen is wh
| |
402 surface->GetActiveFrame().resource_list.empty()) { | |
403 aggregator_->ReleaseResources(surface_id); | |
404 } | |
398 } | 405 } |
406 *changed = true; | |
407 } else if (surface_id == current_surface_id_) { | |
408 *changed = true; | |
399 } | 409 } |
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 } | 410 } |
408 | 411 |
412 if (scheduler_) | |
413 scheduler_->SurfaceDamaged(surface_id, ack, *changed); | |
414 | |
409 if (surface_id == current_surface_id_) | 415 if (surface_id == current_surface_id_) |
410 UpdateRootSurfaceResourcesLocked(); | 416 UpdateRootSurfaceResourcesLocked(); |
411 } | 417 } |
412 | 418 |
413 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) {} | 419 bool Display::SurfaceHasUndrawnFrame(const SurfaceId& surface_id) const { |
420 if (!surface_manager_) | |
421 return false; | |
422 | |
423 Surface* surface = surface_manager_->GetSurfaceForId(surface_id); | |
424 if (!surface) | |
425 return false; | |
426 | |
427 return surface->HasUndrawnActiveFrame(); | |
428 } | |
429 | |
430 void Display::OnSurfaceCreated(const SurfaceInfo& surface_info) { | |
431 if (scheduler_) | |
432 scheduler_->SurfaceCreated(surface_info); | |
433 } | |
434 | |
435 void Display::OnSurfaceDestroyed(const SurfaceId& surface_id) { | |
436 if (scheduler_) | |
437 scheduler_->SurfaceDestroyed(surface_id); | |
438 } | |
439 | |
440 void Display::OnSurfaceDamageExpected(const SurfaceId& surface_id, | |
441 const BeginFrameArgs& args) { | |
442 if (scheduler_) | |
443 scheduler_->SurfaceDamageExpected(surface_id, args); | |
444 } | |
414 | 445 |
415 void Display::OnSurfaceDiscarded(const SurfaceId& surface_id) { | 446 void Display::OnSurfaceDiscarded(const SurfaceId& surface_id) { |
416 if (aggregator_) | 447 if (aggregator_) |
417 aggregator_->ReleaseResources(surface_id); | 448 aggregator_->ReleaseResources(surface_id); |
418 } | 449 } |
419 | 450 |
420 const SurfaceId& Display::CurrentSurfaceId() { | 451 const SurfaceId& Display::CurrentSurfaceId() { |
421 return current_surface_id_; | 452 return current_surface_id_; |
422 } | 453 } |
423 | 454 |
424 void Display::ForceImmediateDrawAndSwapIfPossible() { | 455 void Display::ForceImmediateDrawAndSwapIfPossible() { |
425 if (scheduler_) | 456 if (scheduler_) |
426 scheduler_->ForceImmediateSwapIfPossible(); | 457 scheduler_->ForceImmediateSwapIfPossible(); |
427 } | 458 } |
428 | 459 |
429 } // namespace cc | 460 } // namespace cc |
OLD | NEW |