| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/containers/adapters.h" | 12 #include "base/containers/adapters.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "cc/base/math_util.h" | 18 #include "cc/base/math_util.h" |
| 19 #include "cc/output/compositor_frame.h" | 19 #include "cc/output/compositor_frame.h" |
| 20 #include "cc/output/delegated_frame_data.h" |
| 20 #include "cc/quads/draw_quad.h" | 21 #include "cc/quads/draw_quad.h" |
| 21 #include "cc/quads/render_pass_draw_quad.h" | 22 #include "cc/quads/render_pass_draw_quad.h" |
| 22 #include "cc/quads/shared_quad_state.h" | 23 #include "cc/quads/shared_quad_state.h" |
| 23 #include "cc/quads/solid_color_draw_quad.h" | 24 #include "cc/quads/solid_color_draw_quad.h" |
| 24 #include "cc/quads/surface_draw_quad.h" | 25 #include "cc/quads/surface_draw_quad.h" |
| 25 #include "cc/quads/texture_draw_quad.h" | 26 #include "cc/quads/texture_draw_quad.h" |
| 26 #include "cc/resources/resource_provider.h" | 27 #include "cc/resources/resource_provider.h" |
| 27 #include "cc/surfaces/surface.h" | 28 #include "cc/surfaces/surface.h" |
| 28 #include "cc/surfaces/surface_factory.h" | 29 #include "cc/surfaces/surface_factory.h" |
| 29 #include "cc/surfaces/surface_manager.h" | 30 #include "cc/surfaces/surface_manager.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const ClipData& clip_rect, | 181 const ClipData& clip_rect, |
| 181 RenderPass* dest_pass) { | 182 RenderPass* dest_pass) { |
| 182 SurfaceId surface_id = surface_quad->surface_id; | 183 SurfaceId surface_id = surface_quad->surface_id; |
| 183 // If this surface's id is already in our referenced set then it creates | 184 // If this surface's id is already in our referenced set then it creates |
| 184 // a cycle in the graph and should be dropped. | 185 // a cycle in the graph and should be dropped. |
| 185 if (referenced_surfaces_.count(surface_id)) | 186 if (referenced_surfaces_.count(surface_id)) |
| 186 return; | 187 return; |
| 187 Surface* surface = manager_->GetSurfaceForId(surface_id); | 188 Surface* surface = manager_->GetSurfaceForId(surface_id); |
| 188 if (!surface) | 189 if (!surface) |
| 189 return; | 190 return; |
| 190 if (!surface->HasFrame()) | 191 const CompositorFrame& frame = surface->GetEligibleFrame(); |
| 192 const DelegatedFrameData* frame_data = frame.delegated_frame_data.get(); |
| 193 if (!frame_data) |
| 191 return; | 194 return; |
| 192 const CompositorFrame& frame = surface->GetEligibleFrame(); | |
| 193 | 195 |
| 194 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>> copy_requests; | 196 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>> copy_requests; |
| 195 surface->TakeCopyOutputRequests(©_requests); | 197 surface->TakeCopyOutputRequests(©_requests); |
| 196 | 198 |
| 197 const RenderPassList& render_pass_list = frame.render_pass_list; | 199 const RenderPassList& render_pass_list = frame_data->render_pass_list; |
| 198 if (!valid_surfaces_.count(surface->surface_id())) { | 200 if (!valid_surfaces_.count(surface->surface_id())) { |
| 199 for (auto& request : copy_requests) | 201 for (auto& request : copy_requests) |
| 200 request.second->SendEmptyResult(); | 202 request.second->SendEmptyResult(); |
| 201 return; | 203 return; |
| 202 } | 204 } |
| 203 | 205 |
| 204 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 206 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
| 205 // TODO(vmpstr): provider check is a hack for unittests that don't set up a | 207 // TODO(vmpstr): provider check is a hack for unittests that don't set up a |
| 206 // resource provider. | 208 // resource provider. |
| 207 ResourceProvider::ResourceIdMap empty_map; | 209 ResourceProvider::ResourceIdMap empty_map; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 455 |
| 454 DCHECK_EQ(it->first, resource_id); | 456 DCHECK_EQ(it->first, resource_id); |
| 455 ResourceId remapped_id = it->second; | 457 ResourceId remapped_id = it->second; |
| 456 resource_id = remapped_id; | 458 resource_id = remapped_id; |
| 457 } | 459 } |
| 458 } | 460 } |
| 459 } | 461 } |
| 460 } | 462 } |
| 461 } | 463 } |
| 462 | 464 |
| 463 void SurfaceAggregator::CopyPasses(const CompositorFrame& frame, | 465 void SurfaceAggregator::CopyPasses(const DelegatedFrameData* frame_data, |
| 464 Surface* surface) { | 466 Surface* surface) { |
| 465 // The root surface is allowed to have copy output requests, so grab them | 467 // The root surface is allowed to have copy output requests, so grab them |
| 466 // off its render passes. | 468 // off its render passes. |
| 467 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>> copy_requests; | 469 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>> copy_requests; |
| 468 surface->TakeCopyOutputRequests(©_requests); | 470 surface->TakeCopyOutputRequests(©_requests); |
| 469 | 471 |
| 470 const RenderPassList& source_pass_list = frame.render_pass_list; | 472 const RenderPassList& source_pass_list = frame_data->render_pass_list; |
| 471 DCHECK(valid_surfaces_.count(surface->surface_id())); | 473 DCHECK(valid_surfaces_.count(surface->surface_id())); |
| 472 if (!valid_surfaces_.count(surface->surface_id())) | 474 if (!valid_surfaces_.count(surface->surface_id())) |
| 473 return; | 475 return; |
| 474 | 476 |
| 475 // TODO(vmpstr): provider check is a hack for unittests that don't set up a | 477 // TODO(vmpstr): provider check is a hack for unittests that don't set up a |
| 476 // resource provider. | 478 // resource provider. |
| 477 ResourceProvider::ResourceIdMap empty_map; | 479 ResourceProvider::ResourceIdMap empty_map; |
| 478 const ResourceProvider::ResourceIdMap& child_to_parent_map = | 480 const ResourceProvider::ResourceIdMap& child_to_parent_map = |
| 479 provider_ ? provider_->GetChildToParentMap(ChildIdForSurface(surface)) | 481 provider_ ? provider_->GetChildToParentMap(ChildIdForSurface(surface)) |
| 480 : empty_map; | 482 : empty_map; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr(); | 548 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr(); |
| 547 | 549 |
| 548 if (referenced_surfaces_.count(surface_id)) | 550 if (referenced_surfaces_.count(surface_id)) |
| 549 return gfx::Rect(); | 551 return gfx::Rect(); |
| 550 Surface* surface = manager_->GetSurfaceForId(surface_id); | 552 Surface* surface = manager_->GetSurfaceForId(surface_id); |
| 551 if (!surface) { | 553 if (!surface) { |
| 552 contained_surfaces_[surface_id] = 0; | 554 contained_surfaces_[surface_id] = 0; |
| 553 return gfx::Rect(); | 555 return gfx::Rect(); |
| 554 } | 556 } |
| 555 contained_surfaces_[surface_id] = surface->frame_index(); | 557 contained_surfaces_[surface_id] = surface->frame_index(); |
| 556 if (!surface->HasFrame()) | 558 const CompositorFrame& surface_frame = surface->GetEligibleFrame(); |
| 559 const DelegatedFrameData* frame_data = |
| 560 surface_frame.delegated_frame_data.get(); |
| 561 if (!frame_data) |
| 557 return gfx::Rect(); | 562 return gfx::Rect(); |
| 558 const CompositorFrame& frame = surface->GetEligibleFrame(); | |
| 559 int child_id = 0; | 563 int child_id = 0; |
| 560 // TODO(jbauman): hack for unit tests that don't set up rp | 564 // TODO(jbauman): hack for unit tests that don't set up rp |
| 561 if (provider_) { | 565 if (provider_) { |
| 562 child_id = ChildIdForSurface(surface); | 566 child_id = ChildIdForSurface(surface); |
| 563 if (surface->factory()) | 567 if (surface->factory()) |
| 564 surface->factory()->RefResources(frame.resource_list); | 568 surface->factory()->RefResources(frame_data->resource_list); |
| 565 provider_->ReceiveFromChild(child_id, frame.resource_list); | 569 provider_->ReceiveFromChild(child_id, frame_data->resource_list); |
| 566 } | 570 } |
| 567 CHECK(debug_weak_this.get()); | 571 CHECK(debug_weak_this.get()); |
| 568 | 572 |
| 569 ResourceProvider::ResourceIdSet referenced_resources; | 573 ResourceProvider::ResourceIdSet referenced_resources; |
| 570 size_t reserve_size = frame.resource_list.size(); | 574 size_t reserve_size = frame_data->resource_list.size(); |
| 571 referenced_resources.reserve(reserve_size); | 575 referenced_resources.reserve(reserve_size); |
| 572 | 576 |
| 573 bool invalid_frame = false; | 577 bool invalid_frame = false; |
| 574 ResourceProvider::ResourceIdMap empty_map; | 578 ResourceProvider::ResourceIdMap empty_map; |
| 575 const ResourceProvider::ResourceIdMap& child_to_parent_map = | 579 const ResourceProvider::ResourceIdMap& child_to_parent_map = |
| 576 provider_ ? provider_->GetChildToParentMap(child_id) : empty_map; | 580 provider_ ? provider_->GetChildToParentMap(child_id) : empty_map; |
| 577 | 581 |
| 578 CHECK(debug_weak_this.get()); | 582 CHECK(debug_weak_this.get()); |
| 579 if (!frame.render_pass_list.empty()) { | 583 if (!frame_data->render_pass_list.empty()) { |
| 580 RenderPassId remapped_pass_id = | 584 RenderPassId remapped_pass_id = |
| 581 RemapPassId(frame.render_pass_list.back()->id, surface_id); | 585 RemapPassId(frame_data->render_pass_list.back()->id, surface_id); |
| 582 if (in_moved_pixel_pass) | 586 if (in_moved_pixel_pass) |
| 583 moved_pixel_passes_.insert(remapped_pass_id); | 587 moved_pixel_passes_.insert(remapped_pass_id); |
| 584 if (parent_pass.IsValid()) | 588 if (parent_pass.IsValid()) |
| 585 render_pass_dependencies_[parent_pass].insert(remapped_pass_id); | 589 render_pass_dependencies_[parent_pass].insert(remapped_pass_id); |
| 586 } | 590 } |
| 587 | 591 |
| 588 struct SurfaceInfo { | 592 struct SurfaceInfo { |
| 589 SurfaceId id; | 593 SurfaceId id; |
| 590 bool has_moved_pixels; | 594 bool has_moved_pixels; |
| 591 RenderPassId parent_pass; | 595 RenderPassId parent_pass; |
| 592 gfx::Transform target_to_surface_transform; | 596 gfx::Transform target_to_surface_transform; |
| 593 }; | 597 }; |
| 594 std::vector<SurfaceInfo> child_surfaces; | 598 std::vector<SurfaceInfo> child_surfaces; |
| 595 | 599 |
| 596 for (const auto& render_pass : base::Reversed(frame.render_pass_list)) { | 600 for (const auto& render_pass : base::Reversed(frame_data->render_pass_list)) { |
| 597 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id); | 601 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id); |
| 598 bool in_moved_pixel_pass = !!moved_pixel_passes_.count(remapped_pass_id); | 602 bool in_moved_pixel_pass = !!moved_pixel_passes_.count(remapped_pass_id); |
| 599 for (auto* quad : render_pass->quad_list) { | 603 for (auto* quad : render_pass->quad_list) { |
| 600 if (quad->material == DrawQuad::SURFACE_CONTENT) { | 604 if (quad->material == DrawQuad::SURFACE_CONTENT) { |
| 601 const SurfaceDrawQuad* surface_quad = | 605 const SurfaceDrawQuad* surface_quad = |
| 602 SurfaceDrawQuad::MaterialCast(quad); | 606 SurfaceDrawQuad::MaterialCast(quad); |
| 603 gfx::Transform target_to_surface_transform( | 607 gfx::Transform target_to_surface_transform( |
| 604 render_pass->transform_to_root_target, | 608 render_pass->transform_to_root_target, |
| 605 surface_quad->shared_quad_state->quad_to_target_transform); | 609 surface_quad->shared_quad_state->quad_to_target_transform); |
| 606 child_surfaces.push_back( | 610 child_surfaces.push_back( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 637 return gfx::Rect(); | 641 return gfx::Rect(); |
| 638 CHECK(debug_weak_this.get()); | 642 CHECK(debug_weak_this.get()); |
| 639 valid_surfaces_.insert(surface->surface_id()); | 643 valid_surfaces_.insert(surface->surface_id()); |
| 640 | 644 |
| 641 if (provider_) | 645 if (provider_) |
| 642 provider_->DeclareUsedResourcesFromChild(child_id, referenced_resources); | 646 provider_->DeclareUsedResourcesFromChild(child_id, referenced_resources); |
| 643 CHECK(debug_weak_this.get()); | 647 CHECK(debug_weak_this.get()); |
| 644 | 648 |
| 645 gfx::Rect damage_rect; | 649 gfx::Rect damage_rect; |
| 646 gfx::Rect full_damage; | 650 gfx::Rect full_damage; |
| 647 if (!frame.render_pass_list.empty()) { | 651 if (!frame_data->render_pass_list.empty()) { |
| 648 RenderPass* last_pass = frame.render_pass_list.back().get(); | 652 RenderPass* last_pass = frame_data->render_pass_list.back().get(); |
| 649 full_damage = last_pass->output_rect; | 653 full_damage = last_pass->output_rect; |
| 650 damage_rect = | 654 damage_rect = |
| 651 DamageRectForSurface(surface, *last_pass, last_pass->output_rect); | 655 DamageRectForSurface(surface, *last_pass, last_pass->output_rect); |
| 652 } | 656 } |
| 653 | 657 |
| 654 // Avoid infinite recursion by adding current surface to | 658 // Avoid infinite recursion by adding current surface to |
| 655 // referenced_surfaces_. | 659 // referenced_surfaces_. |
| 656 SurfaceSet::iterator it = | 660 SurfaceSet::iterator it = |
| 657 referenced_surfaces_.insert(surface->surface_id()).first; | 661 referenced_surfaces_.insert(surface->surface_id()).first; |
| 658 for (const auto& surface_info : child_surfaces) { | 662 for (const auto& surface_info : child_surfaces) { |
| 659 gfx::Rect surface_damage = | 663 gfx::Rect surface_damage = |
| 660 PrewalkTree(surface_info.id, surface_info.has_moved_pixels, | 664 PrewalkTree(surface_info.id, surface_info.has_moved_pixels, |
| 661 surface_info.parent_pass, result); | 665 surface_info.parent_pass, result); |
| 662 if (surface_damage.IsEmpty()) | 666 if (surface_damage.IsEmpty()) |
| 663 continue; | 667 continue; |
| 664 if (surface_info.has_moved_pixels) { | 668 if (surface_info.has_moved_pixels) { |
| 665 // Areas outside the rect hit by target_to_surface_transform may be | 669 // Areas outside the rect hit by target_to_surface_transform may be |
| 666 // modified if there is a filter that moves pixels. | 670 // modified if there is a filter that moves pixels. |
| 667 damage_rect = full_damage; | 671 damage_rect = full_damage; |
| 668 continue; | 672 continue; |
| 669 } | 673 } |
| 670 | 674 |
| 671 damage_rect.Union(MathUtil::MapEnclosingClippedRect( | 675 damage_rect.Union(MathUtil::MapEnclosingClippedRect( |
| 672 surface_info.target_to_surface_transform, surface_damage)); | 676 surface_info.target_to_surface_transform, surface_damage)); |
| 673 } | 677 } |
| 674 | 678 |
| 675 CHECK(debug_weak_this.get()); | 679 CHECK(debug_weak_this.get()); |
| 676 for (const auto& surface_id : frame.metadata.referenced_surfaces) { | 680 for (const auto& surface_id : surface_frame.metadata.referenced_surfaces) { |
| 677 if (!contained_surfaces_.count(surface_id)) { | 681 if (!contained_surfaces_.count(surface_id)) { |
| 678 result->undrawn_surfaces.insert(surface_id); | 682 result->undrawn_surfaces.insert(surface_id); |
| 679 PrewalkTree(surface_id, false, RenderPassId(), result); | 683 PrewalkTree(surface_id, false, RenderPassId(), result); |
| 680 } | 684 } |
| 681 } | 685 } |
| 682 | 686 |
| 683 CHECK(debug_weak_this.get()); | 687 CHECK(debug_weak_this.get()); |
| 684 if (surface->factory()) { | 688 if (surface->factory()) { |
| 685 surface->factory()->WillDrawSurface(surface->surface_id().local_frame_id(), | 689 surface->factory()->WillDrawSurface(surface->surface_id().local_frame_id(), |
| 686 damage_rect); | 690 damage_rect); |
| 687 } | 691 } |
| 688 | 692 |
| 689 CHECK(debug_weak_this.get()); | 693 CHECK(debug_weak_this.get()); |
| 690 for (const auto& render_pass : frame.render_pass_list) { | 694 for (const auto& render_pass : frame_data->render_pass_list) { |
| 691 if (!render_pass->copy_requests.empty()) { | 695 if (!render_pass->copy_requests.empty()) { |
| 692 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id); | 696 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id); |
| 693 copy_request_passes_.insert(remapped_pass_id); | 697 copy_request_passes_.insert(remapped_pass_id); |
| 694 } | 698 } |
| 695 } | 699 } |
| 696 | 700 |
| 697 referenced_surfaces_.erase(it); | 701 referenced_surfaces_.erase(it); |
| 698 if (!damage_rect.IsEmpty() && frame.metadata.may_contain_video) | 702 if (!damage_rect.IsEmpty() && surface_frame.metadata.may_contain_video) |
| 699 result->may_contain_video = true; | 703 result->may_contain_video = true; |
| 700 return damage_rect; | 704 return damage_rect; |
| 701 } | 705 } |
| 702 | 706 |
| 703 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) { | 707 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) { |
| 704 // undrawn_surfaces are Surfaces that were identified by prewalk as being | 708 // undrawn_surfaces are Surfaces that were identified by prewalk as being |
| 705 // referenced by a drawn Surface, but aren't contained in a SurfaceDrawQuad. | 709 // referenced by a drawn Surface, but aren't contained in a SurfaceDrawQuad. |
| 706 // They need to be iterated over to ensure that any copy requests on them | 710 // They need to be iterated over to ensure that any copy requests on them |
| 707 // (or on Surfaces they reference) are executed. | 711 // (or on Surfaces they reference) are executed. |
| 708 std::vector<SurfaceId> surfaces_to_copy( | 712 std::vector<SurfaceId> surfaces_to_copy( |
| 709 prewalk_result->undrawn_surfaces.begin(), | 713 prewalk_result->undrawn_surfaces.begin(), |
| 710 prewalk_result->undrawn_surfaces.end()); | 714 prewalk_result->undrawn_surfaces.end()); |
| 711 | 715 |
| 712 for (size_t i = 0; i < surfaces_to_copy.size(); i++) { | 716 for (size_t i = 0; i < surfaces_to_copy.size(); i++) { |
| 713 SurfaceId surface_id = surfaces_to_copy[i]; | 717 SurfaceId surface_id = surfaces_to_copy[i]; |
| 714 Surface* surface = manager_->GetSurfaceForId(surface_id); | 718 Surface* surface = manager_->GetSurfaceForId(surface_id); |
| 715 if (!surface) | 719 if (!surface) |
| 716 continue; | 720 continue; |
| 717 if (!surface->HasFrame()) | 721 const CompositorFrame& surface_frame = surface->GetEligibleFrame(); |
| 722 if (!surface_frame.delegated_frame_data) |
| 718 continue; | 723 continue; |
| 719 const CompositorFrame& frame = surface->GetEligibleFrame(); | |
| 720 bool surface_has_copy_requests = false; | 724 bool surface_has_copy_requests = false; |
| 721 for (const auto& render_pass : frame.render_pass_list) { | 725 for (const auto& render_pass : |
| 726 surface_frame.delegated_frame_data->render_pass_list) { |
| 722 surface_has_copy_requests |= !render_pass->copy_requests.empty(); | 727 surface_has_copy_requests |= !render_pass->copy_requests.empty(); |
| 723 } | 728 } |
| 724 if (!surface_has_copy_requests) { | 729 if (!surface_has_copy_requests) { |
| 725 // Children are not necessarily included in undrawn_surfaces (because | 730 // Children are not necessarily included in undrawn_surfaces (because |
| 726 // they weren't referenced directly from a drawn surface), but may have | 731 // they weren't referenced directly from a drawn surface), but may have |
| 727 // copy requests, so make sure to check them as well. | 732 // copy requests, so make sure to check them as well. |
| 728 for (const auto& child_id : frame.metadata.referenced_surfaces) { | 733 for (const auto& child_id : surface_frame.metadata.referenced_surfaces) { |
| 729 // Don't iterate over the child Surface if it was already listed as a | 734 // Don't iterate over the child Surface if it was already listed as a |
| 730 // child of a different Surface, or in the case where there's infinite | 735 // child of a different Surface, or in the case where there's infinite |
| 731 // recursion. | 736 // recursion. |
| 732 if (!prewalk_result->undrawn_surfaces.count(child_id)) { | 737 if (!prewalk_result->undrawn_surfaces.count(child_id)) { |
| 733 surfaces_to_copy.push_back(child_id); | 738 surfaces_to_copy.push_back(child_id); |
| 734 prewalk_result->undrawn_surfaces.insert(child_id); | 739 prewalk_result->undrawn_surfaces.insert(child_id); |
| 735 } | 740 } |
| 736 } | 741 } |
| 737 } else { | 742 } else { |
| 738 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 743 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
| 739 CopyPasses(frame, surface); | 744 CopyPasses(surface_frame.delegated_frame_data.get(), surface); |
| 740 referenced_surfaces_.erase(it); | 745 referenced_surfaces_.erase(it); |
| 741 } | 746 } |
| 742 } | 747 } |
| 743 } | 748 } |
| 744 | 749 |
| 745 void SurfaceAggregator::PropagateCopyRequestPasses() { | 750 void SurfaceAggregator::PropagateCopyRequestPasses() { |
| 746 std::vector<RenderPassId> copy_requests_to_iterate( | 751 std::vector<RenderPassId> copy_requests_to_iterate( |
| 747 copy_request_passes_.begin(), copy_request_passes_.end()); | 752 copy_request_passes_.begin(), copy_request_passes_.end()); |
| 748 while (!copy_requests_to_iterate.empty()) { | 753 while (!copy_requests_to_iterate.empty()) { |
| 749 RenderPassId first = copy_requests_to_iterate.back(); | 754 RenderPassId first = copy_requests_to_iterate.back(); |
| 750 copy_requests_to_iterate.pop_back(); | 755 copy_requests_to_iterate.pop_back(); |
| 751 auto it = render_pass_dependencies_.find(first); | 756 auto it = render_pass_dependencies_.find(first); |
| 752 if (it == render_pass_dependencies_.end()) | 757 if (it == render_pass_dependencies_.end()) |
| 753 continue; | 758 continue; |
| 754 for (auto pass : it->second) { | 759 for (auto pass : it->second) { |
| 755 if (copy_request_passes_.insert(pass).second) { | 760 if (copy_request_passes_.insert(pass).second) { |
| 756 copy_requests_to_iterate.push_back(pass); | 761 copy_requests_to_iterate.push_back(pass); |
| 757 } | 762 } |
| 758 } | 763 } |
| 759 } | 764 } |
| 760 } | 765 } |
| 761 | 766 |
| 762 CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) { | 767 CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) { |
| 763 Surface* surface = manager_->GetSurfaceForId(surface_id); | 768 Surface* surface = manager_->GetSurfaceForId(surface_id); |
| 764 DCHECK(surface); | 769 DCHECK(surface); |
| 765 contained_surfaces_[surface_id] = surface->frame_index(); | 770 contained_surfaces_[surface_id] = surface->frame_index(); |
| 766 | 771 const CompositorFrame& root_surface_frame = surface->GetEligibleFrame(); |
| 767 if (!surface->HasFrame()) | 772 if (!root_surface_frame.delegated_frame_data) |
| 768 return CompositorFrame(); | 773 return CompositorFrame(); |
| 769 | |
| 770 const CompositorFrame& root_surface_frame = surface->GetEligibleFrame(); | |
| 771 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); | 774 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); |
| 772 | 775 |
| 773 CompositorFrame frame; | 776 CompositorFrame frame; |
| 777 frame.delegated_frame_data = base::WrapUnique(new DelegatedFrameData); |
| 774 | 778 |
| 775 dest_resource_list_ = &frame.resource_list; | 779 dest_resource_list_ = &frame.delegated_frame_data->resource_list; |
| 776 dest_pass_list_ = &frame.render_pass_list; | 780 dest_pass_list_ = &frame.delegated_frame_data->render_pass_list; |
| 777 | 781 |
| 778 valid_surfaces_.clear(); | 782 valid_surfaces_.clear(); |
| 779 PrewalkResult prewalk_result; | 783 PrewalkResult prewalk_result; |
| 780 root_damage_rect_ = | 784 root_damage_rect_ = |
| 781 PrewalkTree(surface_id, false, RenderPassId(), &prewalk_result); | 785 PrewalkTree(surface_id, false, RenderPassId(), &prewalk_result); |
| 782 PropagateCopyRequestPasses(); | 786 PropagateCopyRequestPasses(); |
| 783 has_copy_requests_ = !copy_request_passes_.empty(); | 787 has_copy_requests_ = !copy_request_passes_.empty(); |
| 784 frame.metadata.may_contain_video = prewalk_result.may_contain_video; | 788 frame.metadata.may_contain_video = prewalk_result.may_contain_video; |
| 785 | 789 |
| 786 CopyUndrawnSurfaces(&prewalk_result); | 790 CopyUndrawnSurfaces(&prewalk_result); |
| 787 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 791 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
| 788 CopyPasses(root_surface_frame, surface); | 792 CopyPasses(root_surface_frame.delegated_frame_data.get(), surface); |
| 789 referenced_surfaces_.erase(it); | 793 referenced_surfaces_.erase(it); |
| 790 | 794 |
| 791 moved_pixel_passes_.clear(); | 795 moved_pixel_passes_.clear(); |
| 792 copy_request_passes_.clear(); | 796 copy_request_passes_.clear(); |
| 793 render_pass_dependencies_.clear(); | 797 render_pass_dependencies_.clear(); |
| 794 | 798 |
| 795 DCHECK(referenced_surfaces_.empty()); | 799 DCHECK(referenced_surfaces_.empty()); |
| 796 | 800 |
| 797 if (dest_pass_list_->empty()) | 801 if (dest_pass_list_->empty()) |
| 798 return CompositorFrame(); | 802 return CompositorFrame(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 827 | 831 |
| 828 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { | 832 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { |
| 829 auto it = previous_contained_surfaces_.find(surface_id); | 833 auto it = previous_contained_surfaces_.find(surface_id); |
| 830 if (it == previous_contained_surfaces_.end()) | 834 if (it == previous_contained_surfaces_.end()) |
| 831 return; | 835 return; |
| 832 // Set the last drawn index as 0 to ensure full damage next time it's drawn. | 836 // Set the last drawn index as 0 to ensure full damage next time it's drawn. |
| 833 it->second = 0; | 837 it->second = 0; |
| 834 } | 838 } |
| 835 | 839 |
| 836 } // namespace cc | 840 } // namespace cc |
| OLD | NEW |