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

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

Issue 2098953003: Make cc::CompositorFrames movable [Part 2 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android compiles locally Created 4 years, 6 months 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
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
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 if (it == render_pass_dependencies_.end()) 763 if (it == render_pass_dependencies_.end())
764 continue; 764 continue;
765 for (auto pass : it->second) { 765 for (auto pass : it->second) {
766 if (copy_request_passes_.insert(pass).second) { 766 if (copy_request_passes_.insert(pass).second) {
767 copy_requests_to_iterate.push_back(pass); 767 copy_requests_to_iterate.push_back(pass);
768 } 768 }
769 } 769 }
770 } 770 }
771 } 771 }
772 772
773 std::unique_ptr<CompositorFrame> SurfaceAggregator::Aggregate( 773 CompositorFrame SurfaceAggregator::Aggregate(SurfaceId surface_id) {
774 SurfaceId surface_id) {
775 Surface* surface = manager_->GetSurfaceForId(surface_id); 774 Surface* surface = manager_->GetSurfaceForId(surface_id);
776 DCHECK(surface); 775 DCHECK(surface);
777 contained_surfaces_[surface_id] = surface->frame_index(); 776 contained_surfaces_[surface_id] = surface->frame_index();
778 const CompositorFrame* root_surface_frame = surface->GetEligibleFrame(); 777 const CompositorFrame* root_surface_frame = surface->GetEligibleFrame();
779 if (!root_surface_frame) 778 if (!root_surface_frame->delegated_frame_data)
780 return nullptr; 779 return CompositorFrame();
781 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); 780 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate");
782 781
783 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 782 CompositorFrame frame;
784 frame->delegated_frame_data = base::WrapUnique(new DelegatedFrameData); 783 frame.delegated_frame_data = base::WrapUnique(new DelegatedFrameData);
785 784
786 DCHECK(root_surface_frame->delegated_frame_data); 785 dest_resource_list_ = &frame.delegated_frame_data->resource_list;
787 786 dest_pass_list_ = &frame.delegated_frame_data->render_pass_list;
788 dest_resource_list_ = &frame->delegated_frame_data->resource_list;
789 dest_pass_list_ = &frame->delegated_frame_data->render_pass_list;
790 787
791 valid_surfaces_.clear(); 788 valid_surfaces_.clear();
792 PrewalkResult prewalk_result; 789 PrewalkResult prewalk_result;
793 root_damage_rect_ = 790 root_damage_rect_ =
794 PrewalkTree(surface_id, false, RenderPassId(), &prewalk_result); 791 PrewalkTree(surface_id, false, RenderPassId(), &prewalk_result);
795 PropagateCopyRequestPasses(); 792 PropagateCopyRequestPasses();
796 has_copy_requests_ = !copy_request_passes_.empty(); 793 has_copy_requests_ = !copy_request_passes_.empty();
797 794
798 CopyUndrawnSurfaces(&prewalk_result); 795 CopyUndrawnSurfaces(&prewalk_result);
799 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; 796 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first;
800 CopyPasses(root_surface_frame->delegated_frame_data.get(), surface); 797 CopyPasses(root_surface_frame->delegated_frame_data.get(), surface);
801 referenced_surfaces_.erase(it); 798 referenced_surfaces_.erase(it);
802 799
803 moved_pixel_passes_.clear(); 800 moved_pixel_passes_.clear();
804 copy_request_passes_.clear(); 801 copy_request_passes_.clear();
805 render_pass_dependencies_.clear(); 802 render_pass_dependencies_.clear();
806 803
807 DCHECK(referenced_surfaces_.empty()); 804 DCHECK(referenced_surfaces_.empty());
808 805
809 if (dest_pass_list_->empty()) 806 if (dest_pass_list_->empty())
810 return nullptr; 807 return CompositorFrame();
811 808
812 dest_pass_list_ = NULL; 809 dest_pass_list_ = NULL;
813 ProcessAddedAndRemovedSurfaces(); 810 ProcessAddedAndRemovedSurfaces();
814 contained_surfaces_.swap(previous_contained_surfaces_); 811 contained_surfaces_.swap(previous_contained_surfaces_);
815 contained_surfaces_.clear(); 812 contained_surfaces_.clear();
816 813
817 for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin(); 814 for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin();
818 it != previous_contained_surfaces_.end(); 815 it != previous_contained_surfaces_.end();
819 ++it) { 816 ++it) {
820 Surface* surface = manager_->GetSurfaceForId(it->first); 817 Surface* surface = manager_->GetSurfaceForId(it->first);
821 if (surface) 818 if (surface)
822 surface->TakeLatencyInfo(&frame->metadata.latency_info); 819 surface->TakeLatencyInfo(&frame.metadata.latency_info);
823 } 820 }
824 821
825 // TODO(jamesr): Aggregate all resource references into the returned frame's 822 // TODO(jamesr): Aggregate all resource references into the returned frame's
826 // resource list. 823 // resource list.
827 824
828 return frame; 825 return frame;
829 } 826 }
830 827
831 void SurfaceAggregator::ReleaseResources(SurfaceId surface_id) { 828 void SurfaceAggregator::ReleaseResources(SurfaceId surface_id) {
832 SurfaceToResourceChildIdMap::iterator it = 829 SurfaceToResourceChildIdMap::iterator it =
833 surface_id_to_resource_child_id_.find(surface_id); 830 surface_id_to_resource_child_id_.find(surface_id);
834 if (it != surface_id_to_resource_child_id_.end()) { 831 if (it != surface_id_to_resource_child_id_.end()) {
835 provider_->DestroyChild(it->second); 832 provider_->DestroyChild(it->second);
836 surface_id_to_resource_child_id_.erase(it); 833 surface_id_to_resource_child_id_.erase(it);
837 } 834 }
838 } 835 }
839 836
840 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { 837 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) {
841 auto it = previous_contained_surfaces_.find(surface_id); 838 auto it = previous_contained_surfaces_.find(surface_id);
842 if (it == previous_contained_surfaces_.end()) 839 if (it == previous_contained_surfaces_.end())
843 return; 840 return;
844 // Set the last drawn index as 0 to ensure full damage next time it's drawn. 841 // Set the last drawn index as 0 to ensure full damage next time it's drawn.
845 it->second = 0; 842 it->second = 0;
846 } 843 }
847 844
848 } // namespace cc 845 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698