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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Calculate damage of |force_render_surface|. Created 3 years, 7 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); 66 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
67 bool inverse_valid = quad_to_root_transform.GetInverse(&inverse_transform); 67 bool inverse_valid = quad_to_root_transform.GetInverse(&inverse_transform);
68 if (!inverse_valid) 68 if (!inverse_valid)
69 return false; 69 return false;
70 70
71 *quad_space_damage_rect = MathUtil::ProjectEnclosingClippedRect( 71 *quad_space_damage_rect = MathUtil::ProjectEnclosingClippedRect(
72 inverse_transform, root_damage_rect); 72 inverse_transform, root_damage_rect);
73 return true; 73 return true;
74 } 74 }
75 75
76 // Recursively update the flag |has_damage_on_surface_quad|.
77 bool UpdateHasDamageOnSurfaceQuadRecursive(
weiliangc 2017/06/07 21:19:01 Since UpdateHasDamageOnSurfaceQuad is called at th
wutao 2017/06/09 02:31:32 Will push the info up in CopyQuadsToPass and Handl
78 RenderPass* pass,
79 base::flat_map<int, std::unique_ptr<RenderPass>>* passes_id_map,
80 base::flat_set<int>* updated_passes_id) {
81 if (updated_passes_id->count(pass->id))
82 return pass->has_damage_on_surface_quad;
83
84 updated_passes_id->insert(pass->id);
85 bool has_damage_on_surface_quad = false;
86 if (pass->has_damage_on_surface_quad)
87 has_damage_on_surface_quad = true;
88 for (auto* quad : pass->quad_list) {
89 if (quad->material == DrawQuad::RENDER_PASS) {
90 const RenderPassDrawQuad* pass_quad =
91 RenderPassDrawQuad::MaterialCast(quad);
92 if (!pass_quad)
jbauman 2017/05/30 22:04:07 DCHECK instead of if
wutao 2017/05/30 23:12:52 Will do.
93 continue;
94 auto iter = passes_id_map->find(pass_quad->render_pass_id);
95 if (iter == passes_id_map->end())
96 continue;
97 auto* ref_pass = iter->second.get();
98 if (!ref_pass)
99 continue;
100
101 has_damage_on_surface_quad |= UpdateHasDamageOnSurfaceQuadRecursive(
102 ref_pass, passes_id_map, updated_passes_id);
jbauman 2017/05/30 22:04:07 Could you check the performance on SurfaceAggregat
wutao 2017/05/30 23:12:52 Comparing the changes with ToT: It is very simila
103 }
104 }
105 pass->has_damage_on_surface_quad = has_damage_on_surface_quad;
106 return has_damage_on_surface_quad;
107 }
108
109 void UpdateHasDamageOnSurfaceQuad(
110 RenderPassList* dest_pass_list_,
111 std::vector<int>* dest_pass_id_list,
112 base::flat_map<int, std::unique_ptr<RenderPass>>* passes_id_map) {
113 base::flat_set<int> updated_passes_id;
114 for (int pass_id : *dest_pass_id_list) {
115 UpdateHasDamageOnSurfaceQuadRecursive(
weiliangc 2017/06/07 21:19:00 We only need the bool has_damage_in_on_surface_qua
wutao 2017/06/09 02:31:32 Yes.
116 passes_id_map->find(pass_id)->second.get(), passes_id_map,
117 &updated_passes_id);
118 }
119
120 for (int pass_id : *dest_pass_id_list) {
121 dest_pass_list_->push_back(std::move(passes_id_map->find(pass_id)->second));
122 }
123 }
124
76 } // namespace 125 } // namespace
77 126
78 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager, 127 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager,
79 ResourceProvider* provider, 128 ResourceProvider* provider,
80 bool aggregate_only_damaged) 129 bool aggregate_only_damaged)
81 : manager_(manager), 130 : manager_(manager),
82 provider_(provider), 131 provider_(provider),
83 next_render_pass_id_(1), 132 next_render_pass_id_(1),
84 aggregate_only_damaged_(aggregate_only_damaged), 133 aggregate_only_damaged_(aggregate_only_damaged),
85 weak_factory_(this) { 134 weak_factory_(this) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 size_t sqs_size = source.shared_quad_state_list.size(); 308 size_t sqs_size = source.shared_quad_state_list.size();
260 size_t dq_size = source.quad_list.size(); 309 size_t dq_size = source.quad_list.size();
261 std::unique_ptr<RenderPass> copy_pass( 310 std::unique_ptr<RenderPass> copy_pass(
262 RenderPass::Create(sqs_size, dq_size)); 311 RenderPass::Create(sqs_size, dq_size));
263 312
264 int remapped_pass_id = RemapPassId(source.id, surface_id); 313 int remapped_pass_id = RemapPassId(source.id, surface_id);
265 314
266 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, 315 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect,
267 source.transform_to_root_target, source.filters, 316 source.transform_to_root_target, source.filters,
268 source.background_filters, blending_color_space_, 317 source.background_filters, blending_color_space_,
269 source.has_transparent_background); 318 source.has_transparent_background,
319 source.force_render_surface,
320 source.has_property_change_on_contributing_render_surface,
321 source.has_damage_on_surface_quad);
270 322
271 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests); 323 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests);
272 324
273 // Contributing passes aggregated in to the pass list need to take the 325 // Contributing passes aggregated in to the pass list need to take the
274 // transform of the surface quad into account to update their transform to 326 // transform of the surface quad into account to update their transform to
275 // the root surface. 327 // the root surface.
276 copy_pass->transform_to_root_target.ConcatTransform( 328 copy_pass->transform_to_root_target.ConcatTransform(
277 surface_quad->shared_quad_state->quad_to_target_transform); 329 surface_quad->shared_quad_state->quad_to_target_transform);
278 copy_pass->transform_to_root_target.ConcatTransform(target_transform); 330 copy_pass->transform_to_root_target.ConcatTransform(target_transform);
279 copy_pass->transform_to_root_target.ConcatTransform( 331 copy_pass->transform_to_root_target.ConcatTransform(
280 dest_pass->transform_to_root_target); 332 dest_pass->transform_to_root_target);
281 333
282 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, 334 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list,
283 child_to_parent_map, gfx::Transform(), ClipData(), 335 child_to_parent_map, gfx::Transform(), ClipData(),
284 copy_pass.get(), surface_id); 336 copy_pass.get(), surface_id);
285 337
286 if (!copy_request_passes_.count(remapped_pass_id) && 338 if (!copy_request_passes_.count(remapped_pass_id) &&
339 !force_render_surface_passes_.count(remapped_pass_id) &&
287 !moved_pixel_passes_.count(remapped_pass_id)) { 340 !moved_pixel_passes_.count(remapped_pass_id)) {
288 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); 341 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
289 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { 342 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) {
290 gfx::Rect damage_rect_in_render_pass_space = 343 gfx::Rect damage_rect_in_render_pass_space =
291 MathUtil::ProjectEnclosingClippedRect(inverse_transform, 344 MathUtil::ProjectEnclosingClippedRect(inverse_transform,
292 root_damage_rect_); 345 root_damage_rect_);
293 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space); 346 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space);
294 } 347 }
295 } 348 }
296 349
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 void SurfaceAggregator::CopyQuadsToPass( 457 void SurfaceAggregator::CopyQuadsToPass(
405 const QuadList& source_quad_list, 458 const QuadList& source_quad_list,
406 const SharedQuadStateList& source_shared_quad_state_list, 459 const SharedQuadStateList& source_shared_quad_state_list,
407 const ResourceProvider::ResourceIdMap& child_to_parent_map, 460 const ResourceProvider::ResourceIdMap& child_to_parent_map,
408 const gfx::Transform& target_transform, 461 const gfx::Transform& target_transform,
409 const ClipData& clip_rect, 462 const ClipData& clip_rect,
410 RenderPass* dest_pass, 463 RenderPass* dest_pass,
411 const SurfaceId& surface_id) { 464 const SurfaceId& surface_id) {
412 const SharedQuadState* last_copied_source_shared_quad_state = nullptr; 465 const SharedQuadState* last_copied_source_shared_quad_state = nullptr;
413 const SharedQuadState* dest_shared_quad_state = nullptr; 466 const SharedQuadState* dest_shared_quad_state = nullptr;
414 // If the current frame has copy requests then aggregate the entire 467 // If the current frame has copy requests or force use of render surface, then
415 // thing, as otherwise parts of the copy requests may be ignored. 468 // aggregate the entire thing, as otherwise parts of the copy requests or
416 const bool ignore_undamaged = aggregate_only_damaged_ && 469 // render surface may be ignored.
417 !has_copy_requests_ && 470 const bool ignore_undamaged =
418 !moved_pixel_passes_.count(dest_pass->id); 471 aggregate_only_damaged_ && !has_copy_requests_ &&
472 !has_force_render_surfaces_ && !moved_pixel_passes_.count(dest_pass->id);
419 // Damage rect in the quad space of the current shared quad state. 473 // Damage rect in the quad space of the current shared quad state.
420 // TODO(jbauman): This rect may contain unnecessary area if 474 // TODO(jbauman): This rect may contain unnecessary area if
421 // transform isn't axis-aligned. 475 // transform isn't axis-aligned.
422 gfx::Rect damage_rect_in_quad_space; 476 gfx::Rect damage_rect_in_quad_space;
423 bool damage_rect_in_quad_space_valid = false; 477 bool damage_rect_in_quad_space_valid = false;
424 478
425 #if DCHECK_IS_ON() 479 #if DCHECK_IS_ON()
426 // If quads have come in with SharedQuadState out of order, or when quads have 480 // If quads have come in with SharedQuadState out of order, or when quads have
427 // invalid SharedQuadState pointer, it should DCHECK. 481 // invalid SharedQuadState pointer, it should DCHECK.
428 SharedQuadStateList::ConstIterator sqs_iter = 482 SharedQuadStateList::ConstIterator sqs_iter =
(...skipping 12 matching lines...) Expand all
441 const SurfaceDrawQuad* surface_quad = SurfaceDrawQuad::MaterialCast(quad); 495 const SurfaceDrawQuad* surface_quad = SurfaceDrawQuad::MaterialCast(quad);
442 // HandleSurfaceQuad may add other shared quad state, so reset the 496 // HandleSurfaceQuad may add other shared quad state, so reset the
443 // current data. 497 // current data.
444 last_copied_source_shared_quad_state = nullptr; 498 last_copied_source_shared_quad_state = nullptr;
445 499
446 // The primary SurfaceDrawQuad should have already dealt with the fallback 500 // The primary SurfaceDrawQuad should have already dealt with the fallback
447 // DrawQuad. 501 // DrawQuad.
448 if (surface_quad->surface_draw_quad_type == SurfaceDrawQuadType::FALLBACK) 502 if (surface_quad->surface_draw_quad_type == SurfaceDrawQuadType::FALLBACK)
449 continue; 503 continue;
450 504
505 // Check if the surface_quad has damage.
506 Surface* surface = manager_->GetSurfaceForId(surface_quad->surface_id);
507 if (surface->HasActiveFrame()) {
508 RenderPass* last_pass =
509 surface->GetActiveFrame().render_pass_list.back().get();
510 gfx::Rect damage_rect =
511 DamageRectForSurface(surface, *last_pass, last_pass->output_rect);
512 dest_pass->has_damage_on_surface_quad |= !damage_rect.IsEmpty();
513 }
514
451 HandleSurfaceQuad(surface_quad, target_transform, clip_rect, dest_pass, 515 HandleSurfaceQuad(surface_quad, target_transform, clip_rect, dest_pass,
452 ignore_undamaged, &damage_rect_in_quad_space, 516 ignore_undamaged, &damage_rect_in_quad_space,
453 &damage_rect_in_quad_space_valid); 517 &damage_rect_in_quad_space_valid);
454 } else { 518 } else {
455 if (quad->shared_quad_state != last_copied_source_shared_quad_state) { 519 if (quad->shared_quad_state != last_copied_source_shared_quad_state) {
456 dest_shared_quad_state = CopySharedQuadState( 520 dest_shared_quad_state = CopySharedQuadState(
457 quad->shared_quad_state, target_transform, clip_rect, dest_pass); 521 quad->shared_quad_state, target_transform, clip_rect, dest_pass);
458 last_copied_source_shared_quad_state = quad->shared_quad_state; 522 last_copied_source_shared_quad_state = quad->shared_quad_state;
459 if (aggregate_only_damaged_ && !has_copy_requests_) { 523 if (aggregate_only_damaged_ && !has_copy_requests_ &&
524 !has_force_render_surfaces_) {
460 damage_rect_in_quad_space_valid = CalculateQuadSpaceDamageRect( 525 damage_rect_in_quad_space_valid = CalculateQuadSpaceDamageRect(
461 dest_shared_quad_state->quad_to_target_transform, 526 dest_shared_quad_state->quad_to_target_transform,
462 dest_pass->transform_to_root_target, root_damage_rect_, 527 dest_pass->transform_to_root_target, root_damage_rect_,
463 &damage_rect_in_quad_space); 528 &damage_rect_in_quad_space);
464 } 529 }
465 } 530 }
466 531
467 if (ignore_undamaged) { 532 if (ignore_undamaged) {
468 if (damage_rect_in_quad_space_valid && 533 if (damage_rect_in_quad_space_valid &&
469 !damage_rect_in_quad_space.Intersects(quad->visible_rect)) 534 !damage_rect_in_quad_space.Intersects(quad->visible_rect))
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 DCHECK(valid_surfaces_.count(surface->surface_id())); 589 DCHECK(valid_surfaces_.count(surface->surface_id()));
525 if (!valid_surfaces_.count(surface->surface_id())) 590 if (!valid_surfaces_.count(surface->surface_id()))
526 return; 591 return;
527 592
528 // TODO(vmpstr): provider check is a hack for unittests that don't set up a 593 // TODO(vmpstr): provider check is a hack for unittests that don't set up a
529 // resource provider. 594 // resource provider.
530 ResourceProvider::ResourceIdMap empty_map; 595 ResourceProvider::ResourceIdMap empty_map;
531 const ResourceProvider::ResourceIdMap& child_to_parent_map = 596 const ResourceProvider::ResourceIdMap& child_to_parent_map =
532 provider_ ? provider_->GetChildToParentMap(ChildIdForSurface(surface)) 597 provider_ ? provider_->GetChildToParentMap(ChildIdForSurface(surface))
533 : empty_map; 598 : empty_map;
599 std::vector<int> temp_dest_pass_id_list;
600 base::flat_map<int, std::unique_ptr<RenderPass>> passes_id_map;
534 for (size_t i = 0; i < source_pass_list.size(); ++i) { 601 for (size_t i = 0; i < source_pass_list.size(); ++i) {
535 const RenderPass& source = *source_pass_list[i]; 602 const RenderPass& source = *source_pass_list[i];
536 603
537 size_t sqs_size = source.shared_quad_state_list.size(); 604 size_t sqs_size = source.shared_quad_state_list.size();
538 size_t dq_size = source.quad_list.size(); 605 size_t dq_size = source.quad_list.size();
539 std::unique_ptr<RenderPass> copy_pass( 606 std::unique_ptr<RenderPass> copy_pass(
540 RenderPass::Create(sqs_size, dq_size)); 607 RenderPass::Create(sqs_size, dq_size));
541 608
542 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests); 609 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests);
543 610
544 int remapped_pass_id = RemapPassId(source.id, surface->surface_id()); 611 int remapped_pass_id = RemapPassId(source.id, surface->surface_id());
545 612
546 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, 613 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect,
547 source.transform_to_root_target, source.filters, 614 source.transform_to_root_target, source.filters,
548 source.background_filters, blending_color_space_, 615 source.background_filters, blending_color_space_,
549 source.has_transparent_background); 616 source.has_transparent_background,
617 source.force_render_surface,
618 source.has_property_change_on_contributing_render_surface,
619 source.has_damage_on_surface_quad);
550 620
551 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, 621 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list,
552 child_to_parent_map, gfx::Transform(), ClipData(), 622 child_to_parent_map, gfx::Transform(), ClipData(),
553 copy_pass.get(), surface->surface_id()); 623 copy_pass.get(), surface->surface_id());
554 if (!copy_request_passes_.count(remapped_pass_id) && 624 if (!copy_request_passes_.count(remapped_pass_id) &&
625 !force_render_surface_passes_.count(remapped_pass_id) &&
555 !moved_pixel_passes_.count(remapped_pass_id)) { 626 !moved_pixel_passes_.count(remapped_pass_id)) {
556 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); 627 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
557 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { 628 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) {
558 gfx::Rect damage_rect_in_render_pass_space = 629 gfx::Rect damage_rect_in_render_pass_space =
559 MathUtil::ProjectEnclosingClippedRect(inverse_transform, 630 MathUtil::ProjectEnclosingClippedRect(inverse_transform,
560 root_damage_rect_); 631 root_damage_rect_);
561 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space); 632 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space);
562 } 633 }
563 } 634 }
564 635
565 dest_pass_list_->push_back(std::move(copy_pass)); 636 temp_dest_pass_id_list.push_back(copy_pass->id);
637 passes_id_map.insert(std::make_pair(copy_pass->id, std::move(copy_pass)));
566 } 638 }
639
640 UpdateHasDamageOnSurfaceQuad(dest_pass_list_, &temp_dest_pass_id_list,
641 &passes_id_map);
567 } 642 }
568 643
569 void SurfaceAggregator::ProcessAddedAndRemovedSurfaces() { 644 void SurfaceAggregator::ProcessAddedAndRemovedSurfaces() {
570 for (const auto& surface : previous_contained_surfaces_) { 645 for (const auto& surface : previous_contained_surfaces_) {
571 if (!contained_surfaces_.count(surface.first)) { 646 if (!contained_surfaces_.count(surface.first)) {
572 // Release resources of removed surface. 647 // Release resources of removed surface.
573 auto it = surface_id_to_resource_child_id_.find(surface.first); 648 auto it = surface_id_to_resource_child_id_.find(surface.first);
574 if (it != surface_id_to_resource_child_id_.end()) { 649 if (it != surface_id_to_resource_child_id_.end()) {
575 provider_->DestroyChild(it->second); 650 provider_->DestroyChild(it->second);
576 surface_id_to_resource_child_id_.erase(it); 651 surface_id_to_resource_child_id_.erase(it);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 833 }
759 834
760 CHECK(debug_weak_this.get()); 835 CHECK(debug_weak_this.get());
761 // TODO(staraz): It shouldn't need to call the callback when the damage is 836 // TODO(staraz): It shouldn't need to call the callback when the damage is
762 // from |surface| and not from |child_surfaces|. 837 // from |surface| and not from |child_surfaces|.
763 if (!damage_rect.IsEmpty()) 838 if (!damage_rect.IsEmpty())
764 surface->RunWillDrawCallback(damage_rect); 839 surface->RunWillDrawCallback(damage_rect);
765 840
766 CHECK(debug_weak_this.get()); 841 CHECK(debug_weak_this.get());
767 for (const auto& render_pass : frame.render_pass_list) { 842 for (const auto& render_pass : frame.render_pass_list) {
768 if (!render_pass->copy_requests.empty()) { 843 int remapped_pass_id = RemapPassId(render_pass->id, surface_id);
769 int remapped_pass_id = RemapPassId(render_pass->id, surface_id); 844 if (!render_pass->copy_requests.empty())
770 copy_request_passes_.insert(remapped_pass_id); 845 copy_request_passes_.insert(remapped_pass_id);
771 } 846 if (render_pass->force_render_surface)
847 force_render_surface_passes_.insert(remapped_pass_id);
772 } 848 }
773 849
774 referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id())); 850 referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id()));
775 if (!damage_rect.IsEmpty() && frame.metadata.may_contain_video) 851 if (!damage_rect.IsEmpty() && frame.metadata.may_contain_video)
776 result->may_contain_video = true; 852 result->may_contain_video = true;
777 return damage_rect; 853 return damage_rect;
778 } 854 }
779 855
780 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) { 856 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) {
781 // undrawn_surfaces are Surfaces that were identified by prewalk as being 857 // undrawn_surfaces are Surfaces that were identified by prewalk as being
(...skipping 30 matching lines...) Expand all
812 } 888 }
813 } 889 }
814 } else { 890 } else {
815 auto it = referenced_surfaces_.insert(surface_id).first; 891 auto it = referenced_surfaces_.insert(surface_id).first;
816 CopyPasses(frame, surface); 892 CopyPasses(frame, surface);
817 referenced_surfaces_.erase(it); 893 referenced_surfaces_.erase(it);
818 } 894 }
819 } 895 }
820 } 896 }
821 897
822 void SurfaceAggregator::PropagateCopyRequestPasses() { 898 void SurfaceAggregator::PropagatePasses(base::flat_set<int>* passes) {
823 std::vector<int> copy_requests_to_iterate(copy_request_passes_.begin(), 899 std::vector<int> copy_requests_to_iterate(passes->begin(), passes->end());
824 copy_request_passes_.end());
825 while (!copy_requests_to_iterate.empty()) { 900 while (!copy_requests_to_iterate.empty()) {
826 int first = copy_requests_to_iterate.back(); 901 int first = copy_requests_to_iterate.back();
827 copy_requests_to_iterate.pop_back(); 902 copy_requests_to_iterate.pop_back();
828 auto it = render_pass_dependencies_.find(first); 903 auto it = render_pass_dependencies_.find(first);
829 if (it == render_pass_dependencies_.end()) 904 if (it == render_pass_dependencies_.end())
830 continue; 905 continue;
831 for (auto pass : it->second) { 906 for (auto pass : it->second) {
832 if (copy_request_passes_.insert(pass).second) { 907 if (passes->insert(pass).second) {
833 copy_requests_to_iterate.push_back(pass); 908 copy_requests_to_iterate.push_back(pass);
834 } 909 }
835 } 910 }
836 } 911 }
837 } 912 }
838 913
839 CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) { 914 CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) {
840 uma_stats_.Reset(); 915 uma_stats_.Reset();
841 916
842 Surface* surface = manager_->GetSurfaceForId(surface_id); 917 Surface* surface = manager_->GetSurfaceForId(surface_id);
843 DCHECK(surface); 918 DCHECK(surface);
844 contained_surfaces_[surface_id] = surface->frame_index(); 919 contained_surfaces_[surface_id] = surface->frame_index();
845 920
846 if (!surface->HasActiveFrame()) 921 if (!surface->HasActiveFrame())
847 return CompositorFrame(); 922 return CompositorFrame();
848 923
849 const CompositorFrame& root_surface_frame = surface->GetActiveFrame(); 924 const CompositorFrame& root_surface_frame = surface->GetActiveFrame();
850 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); 925 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate");
851 926
852 CompositorFrame frame; 927 CompositorFrame frame;
853 928
854 dest_pass_list_ = &frame.render_pass_list; 929 dest_pass_list_ = &frame.render_pass_list;
855 930
856 valid_surfaces_.clear(); 931 valid_surfaces_.clear();
857 PrewalkResult prewalk_result; 932 PrewalkResult prewalk_result;
858 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result); 933 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result);
859 PropagateCopyRequestPasses(); 934 PropagatePasses(&copy_request_passes_);
935 PropagatePasses(&force_render_surface_passes_);
860 has_copy_requests_ = !copy_request_passes_.empty(); 936 has_copy_requests_ = !copy_request_passes_.empty();
937 has_force_render_surfaces_ = !force_render_surface_passes_.empty();
861 frame.metadata.may_contain_video = prewalk_result.may_contain_video; 938 frame.metadata.may_contain_video = prewalk_result.may_contain_video;
862 939
863 CopyUndrawnSurfaces(&prewalk_result); 940 CopyUndrawnSurfaces(&prewalk_result);
864 referenced_surfaces_.insert(surface_id); 941 referenced_surfaces_.insert(surface_id);
865 CopyPasses(root_surface_frame, surface); 942 CopyPasses(root_surface_frame, surface);
866 // CopyPasses may have mutated container, need to re-query to erase. 943 // CopyPasses may have mutated container, need to re-query to erase.
867 referenced_surfaces_.erase(referenced_surfaces_.find(surface_id)); 944 referenced_surfaces_.erase(referenced_surfaces_.find(surface_id));
868 AddColorConversionPass(); 945 AddColorConversionPass();
869 946
870 moved_pixel_passes_.clear(); 947 moved_pixel_passes_.clear();
871 copy_request_passes_.clear(); 948 copy_request_passes_.clear();
949 force_render_surface_passes_.clear();
872 render_pass_dependencies_.clear(); 950 render_pass_dependencies_.clear();
873 951
874 // Remove all render pass mappings that weren't used in the current frame. 952 // Remove all render pass mappings that weren't used in the current frame.
875 for (auto it = render_pass_allocator_map_.begin(); 953 for (auto it = render_pass_allocator_map_.begin();
876 it != render_pass_allocator_map_.end();) { 954 it != render_pass_allocator_map_.end();) {
877 if (it->second.in_use) { 955 if (it->second.in_use) {
878 it->second.in_use = false; 956 it->second.in_use = false;
879 it++; 957 it++;
880 } else { 958 } else {
881 it = render_pass_allocator_map_.erase(it); 959 it = render_pass_allocator_map_.erase(it);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 } 1008 }
931 1009
932 void SurfaceAggregator::SetOutputColorSpace( 1010 void SurfaceAggregator::SetOutputColorSpace(
933 const gfx::ColorSpace& blending_color_space, 1011 const gfx::ColorSpace& blending_color_space,
934 const gfx::ColorSpace& output_color_space) { 1012 const gfx::ColorSpace& output_color_space) {
935 blending_color_space_ = blending_color_space; 1013 blending_color_space_ = blending_color_space;
936 output_color_space_ = output_color_space; 1014 output_color_space_ = output_color_space;
937 } 1015 }
938 1016
939 } // namespace cc 1017 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698