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

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

Issue 2676373004: Implement service-side surface synchronization (Closed)
Patch Set: Better unit test name Created 3 years, 10 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const ClipData& clip_rect, 161 const ClipData& clip_rect,
162 RenderPass* dest_pass) { 162 RenderPass* dest_pass) {
163 SurfaceId surface_id = surface_quad->surface_id; 163 SurfaceId surface_id = surface_quad->surface_id;
164 // If this surface's id is already in our referenced set then it creates 164 // If this surface's id is already in our referenced set then it creates
165 // a cycle in the graph and should be dropped. 165 // a cycle in the graph and should be dropped.
166 if (referenced_surfaces_.count(surface_id)) 166 if (referenced_surfaces_.count(surface_id))
167 return; 167 return;
168 Surface* surface = manager_->GetSurfaceForId(surface_id); 168 Surface* surface = manager_->GetSurfaceForId(surface_id);
169 if (!surface) 169 if (!surface)
170 return; 170 return;
171 if (!surface->HasFrame()) 171 if (!surface->HasActiveFrame())
172 return; 172 return;
173 const CompositorFrame& frame = surface->GetEligibleFrame(); 173 const CompositorFrame& frame = surface->GetActiveFrame();
174 174
175 // A map keyed by RenderPass id. 175 // A map keyed by RenderPass id.
176 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests; 176 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests;
177 surface->TakeCopyOutputRequests(&copy_requests); 177 surface->TakeCopyOutputRequests(&copy_requests);
178 178
179 const RenderPassList& render_pass_list = frame.render_pass_list; 179 const RenderPassList& render_pass_list = frame.render_pass_list;
180 if (!valid_surfaces_.count(surface->surface_id())) { 180 if (!valid_surfaces_.count(surface->surface_id())) {
181 for (auto& request : copy_requests) 181 for (auto& request : copy_requests)
182 request.second->SendEmptyResult(); 182 request.second->SendEmptyResult();
183 return; 183 return;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr(); 529 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr();
530 530
531 if (referenced_surfaces_.count(surface_id)) 531 if (referenced_surfaces_.count(surface_id))
532 return gfx::Rect(); 532 return gfx::Rect();
533 Surface* surface = manager_->GetSurfaceForId(surface_id); 533 Surface* surface = manager_->GetSurfaceForId(surface_id);
534 if (!surface) { 534 if (!surface) {
535 contained_surfaces_[surface_id] = 0; 535 contained_surfaces_[surface_id] = 0;
536 return gfx::Rect(); 536 return gfx::Rect();
537 } 537 }
538 contained_surfaces_[surface_id] = surface->frame_index(); 538 contained_surfaces_[surface_id] = surface->frame_index();
539 if (!surface->HasFrame()) 539 if (!surface->HasActiveFrame())
540 return gfx::Rect(); 540 return gfx::Rect();
541 const CompositorFrame& frame = surface->GetEligibleFrame(); 541 const CompositorFrame& frame = surface->GetActiveFrame();
542 int child_id = 0; 542 int child_id = 0;
543 // TODO(jbauman): hack for unit tests that don't set up rp 543 // TODO(jbauman): hack for unit tests that don't set up rp
544 if (provider_) { 544 if (provider_) {
545 child_id = ChildIdForSurface(surface); 545 child_id = ChildIdForSurface(surface);
546 if (surface->factory()) 546 if (surface->factory())
547 surface->factory()->RefResources(frame.resource_list); 547 surface->factory()->RefResources(frame.resource_list);
548 provider_->ReceiveFromChild(child_id, frame.resource_list); 548 provider_->ReceiveFromChild(child_id, frame.resource_list);
549 } 549 }
550 CHECK(debug_weak_this.get()); 550 CHECK(debug_weak_this.get());
551 551
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // (or on Surfaces they reference) are executed. 712 // (or on Surfaces they reference) are executed.
713 std::vector<SurfaceId> surfaces_to_copy( 713 std::vector<SurfaceId> surfaces_to_copy(
714 prewalk_result->undrawn_surfaces.begin(), 714 prewalk_result->undrawn_surfaces.begin(),
715 prewalk_result->undrawn_surfaces.end()); 715 prewalk_result->undrawn_surfaces.end());
716 716
717 for (size_t i = 0; i < surfaces_to_copy.size(); i++) { 717 for (size_t i = 0; i < surfaces_to_copy.size(); i++) {
718 SurfaceId surface_id = surfaces_to_copy[i]; 718 SurfaceId surface_id = surfaces_to_copy[i];
719 Surface* surface = manager_->GetSurfaceForId(surface_id); 719 Surface* surface = manager_->GetSurfaceForId(surface_id);
720 if (!surface) 720 if (!surface)
721 continue; 721 continue;
722 if (!surface->HasFrame()) 722 if (!surface->HasActiveFrame())
723 continue; 723 continue;
724 const CompositorFrame& frame = surface->GetEligibleFrame(); 724 const CompositorFrame& frame = surface->GetActiveFrame();
725 bool surface_has_copy_requests = false; 725 bool surface_has_copy_requests = false;
726 for (const auto& render_pass : frame.render_pass_list) { 726 for (const auto& render_pass : frame.render_pass_list) {
727 surface_has_copy_requests |= !render_pass->copy_requests.empty(); 727 surface_has_copy_requests |= !render_pass->copy_requests.empty();
728 } 728 }
729 if (!surface_has_copy_requests) { 729 if (!surface_has_copy_requests) {
730 // Children are not necessarily included in undrawn_surfaces (because 730 // Children are not necessarily included in undrawn_surfaces (because
731 // 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
732 // copy requests, so make sure to check them as well. 732 // copy requests, so make sure to check them as well.
733 for (const auto& child_id : frame.metadata.referenced_surfaces) { 733 for (const auto& child_id : frame.metadata.referenced_surfaces) {
734 // 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
(...skipping 27 matching lines...) Expand all
762 } 762 }
763 } 763 }
764 } 764 }
765 } 765 }
766 766
767 CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) { 767 CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) {
768 Surface* surface = manager_->GetSurfaceForId(surface_id); 768 Surface* surface = manager_->GetSurfaceForId(surface_id);
769 DCHECK(surface); 769 DCHECK(surface);
770 contained_surfaces_[surface_id] = surface->frame_index(); 770 contained_surfaces_[surface_id] = surface->frame_index();
771 771
772 if (!surface->HasFrame()) 772 if (!surface->HasActiveFrame())
773 return CompositorFrame(); 773 return CompositorFrame();
774 774
775 const CompositorFrame& root_surface_frame = surface->GetEligibleFrame(); 775 const CompositorFrame& root_surface_frame = surface->GetActiveFrame();
776 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); 776 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate");
777 777
778 CompositorFrame frame; 778 CompositorFrame frame;
779 779
780 dest_resource_list_ = &frame.resource_list; 780 dest_resource_list_ = &frame.resource_list;
781 dest_pass_list_ = &frame.render_pass_list; 781 dest_pass_list_ = &frame.render_pass_list;
782 782
783 valid_surfaces_.clear(); 783 valid_surfaces_.clear();
784 PrewalkResult prewalk_result; 784 PrewalkResult prewalk_result;
785 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result); 785 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 842
843 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { 843 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) {
844 auto it = previous_contained_surfaces_.find(surface_id); 844 auto it = previous_contained_surfaces_.find(surface_id);
845 if (it == previous_contained_surfaces_.end()) 845 if (it == previous_contained_surfaces_.end())
846 return; 846 return;
847 // Set the last drawn index as 0 to ensure full damage next time it's drawn. 847 // Set the last drawn index as 0 to ensure full damage next time it's drawn.
848 it->second = 0; 848 it->second = 0;
849 } 849 }
850 850
851 } // namespace cc 851 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698