Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: cc/surfaces/surface_aggregator.cc

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

Powered by Google App Engine
This is Rietveld 408576698