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/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 auto request_range = copy_requests->equal_range(id); | 35 auto request_range = copy_requests->equal_range(id); |
36 for (auto it = request_range.first; it != request_range.second; ++it) { | 36 for (auto it = request_range.first; it != request_range.second; ++it) { |
37 DCHECK(it->second); | 37 DCHECK(it->second); |
38 output_requests->push_back(std::move(it->second)); | 38 output_requests->push_back(std::move(it->second)); |
39 } | 39 } |
40 copy_requests->erase(request_range.first, request_range.second); | 40 copy_requests->erase(request_range.first, request_range.second); |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 SurfaceAggregator::SurfaceAggregator(SurfaceAggregatorClient* client, | 45 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager, |
46 SurfaceManager* manager, | |
47 ResourceProvider* provider, | 46 ResourceProvider* provider, |
48 bool aggregate_only_damaged) | 47 bool aggregate_only_damaged) |
49 : client_(client), | 48 : manager_(manager), |
50 manager_(manager), | |
51 provider_(provider), | 49 provider_(provider), |
52 next_render_pass_id_(1), | 50 next_render_pass_id_(1), |
53 aggregate_only_damaged_(aggregate_only_damaged) { | 51 aggregate_only_damaged_(aggregate_only_damaged) { |
54 DCHECK(manager_); | 52 DCHECK(manager_); |
55 } | 53 } |
56 | 54 |
57 SurfaceAggregator::~SurfaceAggregator() { | 55 SurfaceAggregator::~SurfaceAggregator() { |
58 // Notify client of all surfaces being removed. | 56 // Notify client of all surfaces being removed. |
59 contained_surfaces_.clear(); | 57 contained_surfaces_.clear(); |
60 ProcessAddedAndRemovedSurfaces(); | 58 ProcessAddedAndRemovedSurfaces(); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 surface_id_to_resource_child_id_.find(surface.first); | 469 surface_id_to_resource_child_id_.find(surface.first); |
472 if (it != surface_id_to_resource_child_id_.end()) { | 470 if (it != surface_id_to_resource_child_id_.end()) { |
473 provider_->DestroyChild(it->second); | 471 provider_->DestroyChild(it->second); |
474 surface_id_to_resource_child_id_.erase(it); | 472 surface_id_to_resource_child_id_.erase(it); |
475 } | 473 } |
476 | 474 |
477 // Notify client of removed surface. | 475 // Notify client of removed surface. |
478 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first); | 476 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first); |
479 if (surface_ptr) { | 477 if (surface_ptr) { |
480 surface_ptr->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); | 478 surface_ptr->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); |
481 client_->RemoveSurface(surface_ptr); | |
482 } | 479 } |
483 } | 480 } |
484 } | 481 } |
485 | |
486 for (const auto& surface : contained_surfaces_) { | |
487 if (!previous_contained_surfaces_.count(surface.first)) { | |
488 // Notify client of added surface. | |
489 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first); | |
490 if (surface_ptr) | |
491 client_->AddSurface(surface_ptr); | |
492 } | |
493 } | |
494 } | 482 } |
495 | 483 |
496 // Walk the Surface tree from surface_id. Validate the resources of the current | 484 // Walk the Surface tree from surface_id. Validate the resources of the current |
497 // surface and its descendants, check if there are any copy requests, and | 485 // surface and its descendants, check if there are any copy requests, and |
498 // return the combined damage rect. | 486 // return the combined damage rect. |
499 gfx::Rect SurfaceAggregator::PrewalkTree(SurfaceId surface_id, | 487 gfx::Rect SurfaceAggregator::PrewalkTree(SurfaceId surface_id, |
500 PrewalkResult* result) { | 488 PrewalkResult* result) { |
501 if (referenced_surfaces_.count(surface_id)) | 489 if (referenced_surfaces_.count(surface_id)) |
502 return gfx::Rect(); | 490 return gfx::Rect(); |
503 Surface* surface = manager_->GetSurfaceForId(surface_id); | 491 Surface* surface = manager_->GetSurfaceForId(surface_id); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 693 |
706 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { | 694 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { |
707 auto it = previous_contained_surfaces_.find(surface_id); | 695 auto it = previous_contained_surfaces_.find(surface_id); |
708 if (it == previous_contained_surfaces_.end()) | 696 if (it == previous_contained_surfaces_.end()) |
709 return; | 697 return; |
710 // Set the last drawn index as 0 to ensure full damage next time it's drawn. | 698 // Set the last drawn index as 0 to ensure full damage next time it's drawn. |
711 it->second = 0; | 699 it->second = 0; |
712 } | 700 } |
713 | 701 |
714 } // namespace cc | 702 } // namespace cc |
OLD | NEW |