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

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

Issue 1963693003: Revert of Correctly handle damage involving filters in SurfaceAggregator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_unittest.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"
13 #include "base/logging.h" 12 #include "base/logging.h"
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
16 #include "base/stl_util.h" 15 #include "base/stl_util.h"
17 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
18 #include "cc/base/math_util.h" 17 #include "cc/base/math_util.h"
19 #include "cc/output/compositor_frame.h" 18 #include "cc/output/compositor_frame.h"
20 #include "cc/output/delegated_frame_data.h" 19 #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"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 for (size_t j = 0; j < passes_to_copy; ++j) { 209 for (size_t j = 0; j < passes_to_copy; ++j) {
211 const RenderPass& source = *referenced_passes[j]; 210 const RenderPass& source = *referenced_passes[j];
212 211
213 size_t sqs_size = source.shared_quad_state_list.size(); 212 size_t sqs_size = source.shared_quad_state_list.size();
214 size_t dq_size = source.quad_list.size(); 213 size_t dq_size = source.quad_list.size();
215 std::unique_ptr<RenderPass> copy_pass( 214 std::unique_ptr<RenderPass> copy_pass(
216 RenderPass::Create(sqs_size, dq_size)); 215 RenderPass::Create(sqs_size, dq_size));
217 216
218 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); 217 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id);
219 218
220 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, 219 copy_pass->SetAll(remapped_pass_id, source.output_rect, gfx::Rect(),
221 source.transform_to_root_target, 220 source.transform_to_root_target,
222 source.has_transparent_background); 221 source.has_transparent_background);
223 222
224 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests); 223 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests);
225 224
226 // Contributing passes aggregated in to the pass list need to take the 225 // Contributing passes aggregated in to the pass list need to take the
227 // transform of the surface quad into account to update their transform to 226 // transform of the surface quad into account to update their transform to
228 // the root surface. 227 // the root surface.
229 copy_pass->transform_to_root_target.ConcatTransform( 228 copy_pass->transform_to_root_target.ConcatTransform(
230 surface_quad->shared_quad_state->quad_to_target_transform); 229 surface_quad->shared_quad_state->quad_to_target_transform);
231 copy_pass->transform_to_root_target.ConcatTransform(target_transform); 230 copy_pass->transform_to_root_target.ConcatTransform(target_transform);
232 copy_pass->transform_to_root_target.ConcatTransform( 231 copy_pass->transform_to_root_target.ConcatTransform(
233 dest_pass->transform_to_root_target); 232 dest_pass->transform_to_root_target);
234 233
235 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, 234 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list,
236 child_to_parent_map, gfx::Transform(), ClipData(), 235 child_to_parent_map, gfx::Transform(), ClipData(),
237 copy_pass.get(), surface_id); 236 copy_pass.get(), surface_id);
238 237
239 if (!copy_request_passes_.count(remapped_pass_id) &&
240 !moved_pixel_passes_.count(remapped_pass_id)) {
241 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
242 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) {
243 gfx::Rect damage_rect_in_render_pass_space =
244 MathUtil::ProjectEnclosingClippedRect(inverse_transform,
245 root_damage_rect_);
246 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space);
247 }
248 }
249
250 dest_pass_list_->push_back(std::move(copy_pass)); 238 dest_pass_list_->push_back(std::move(copy_pass));
251 } 239 }
252 240
253 gfx::Transform surface_transform = 241 gfx::Transform surface_transform =
254 surface_quad->shared_quad_state->quad_to_target_transform; 242 surface_quad->shared_quad_state->quad_to_target_transform;
255 surface_transform.ConcatTransform(target_transform); 243 surface_transform.ConcatTransform(target_transform);
256 244
257 const RenderPass& last_pass = *render_pass_list.back(); 245 const RenderPass& last_pass = *render_pass_list.back();
258 if (merge_pass) { 246 if (merge_pass) {
259 // TODO(jamesr): Clean up last pass special casing. 247 // TODO(jamesr): Clean up last pass special casing.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 const SharedQuadStateList& source_shared_quad_state_list, 336 const SharedQuadStateList& source_shared_quad_state_list,
349 const ResourceProvider::ResourceIdMap& child_to_parent_map, 337 const ResourceProvider::ResourceIdMap& child_to_parent_map,
350 const gfx::Transform& target_transform, 338 const gfx::Transform& target_transform,
351 const ClipData& clip_rect, 339 const ClipData& clip_rect,
352 RenderPass* dest_pass, 340 RenderPass* dest_pass,
353 SurfaceId surface_id) { 341 SurfaceId surface_id) {
354 const SharedQuadState* last_copied_source_shared_quad_state = nullptr; 342 const SharedQuadState* last_copied_source_shared_quad_state = nullptr;
355 const SharedQuadState* dest_shared_quad_state = nullptr; 343 const SharedQuadState* dest_shared_quad_state = nullptr;
356 // If the current frame has copy requests then aggregate the entire 344 // If the current frame has copy requests then aggregate the entire
357 // thing, as otherwise parts of the copy requests may be ignored. 345 // thing, as otherwise parts of the copy requests may be ignored.
358 const bool ignore_undamaged = aggregate_only_damaged_ && 346 const bool ignore_undamaged = aggregate_only_damaged_ && !has_copy_requests_;
359 !has_copy_requests_ &&
360 !moved_pixel_passes_.count(dest_pass->id);
361 // Damage rect in the quad space of the current shared quad state. 347 // Damage rect in the quad space of the current shared quad state.
362 // TODO(jbauman): This rect may contain unnecessary area if 348 // TODO(jbauman): This rect may contain unnecessary area if
363 // transform isn't axis-aligned. 349 // transform isn't axis-aligned.
364 gfx::Rect damage_rect_in_quad_space; 350 gfx::Rect damage_rect_in_quad_space;
365 bool damage_rect_in_quad_space_valid = false; 351 bool damage_rect_in_quad_space_valid = false;
366 352
367 #if DCHECK_IS_ON() 353 #if DCHECK_IS_ON()
368 // If quads have come in with SharedQuadState out of order, or when quads have 354 // If quads have come in with SharedQuadState out of order, or when quads have
369 // invalid SharedQuadState pointer, it should DCHECK. 355 // invalid SharedQuadState pointer, it should DCHECK.
370 SharedQuadStateList::ConstIterator sqs_iter = 356 SharedQuadStateList::ConstIterator sqs_iter =
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 size_t sqs_size = source.shared_quad_state_list.size(); 455 size_t sqs_size = source.shared_quad_state_list.size();
470 size_t dq_size = source.quad_list.size(); 456 size_t dq_size = source.quad_list.size();
471 std::unique_ptr<RenderPass> copy_pass( 457 std::unique_ptr<RenderPass> copy_pass(
472 RenderPass::Create(sqs_size, dq_size)); 458 RenderPass::Create(sqs_size, dq_size));
473 459
474 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests); 460 MoveMatchingRequests(source.id, &copy_requests, &copy_pass->copy_requests);
475 461
476 RenderPassId remapped_pass_id = 462 RenderPassId remapped_pass_id =
477 RemapPassId(source.id, surface->surface_id()); 463 RemapPassId(source.id, surface->surface_id());
478 464
479 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, 465 copy_pass->SetAll(remapped_pass_id, source.output_rect, gfx::Rect(),
480 source.transform_to_root_target, 466 source.transform_to_root_target,
481 source.has_transparent_background); 467 source.has_transparent_background);
482 468
483 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, 469 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list,
484 child_to_parent_map, gfx::Transform(), ClipData(), 470 child_to_parent_map, gfx::Transform(), ClipData(),
485 copy_pass.get(), surface->surface_id()); 471 copy_pass.get(), surface->surface_id());
486 if (!copy_request_passes_.count(remapped_pass_id) &&
487 !moved_pixel_passes_.count(remapped_pass_id)) {
488 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
489 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) {
490 gfx::Rect damage_rect_in_render_pass_space =
491 MathUtil::ProjectEnclosingClippedRect(inverse_transform,
492 root_damage_rect_);
493 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space);
494 }
495 }
496 472
497 dest_pass_list_->push_back(std::move(copy_pass)); 473 dest_pass_list_->push_back(std::move(copy_pass));
498 } 474 }
499 } 475 }
500 476
501 void SurfaceAggregator::ProcessAddedAndRemovedSurfaces() { 477 void SurfaceAggregator::ProcessAddedAndRemovedSurfaces() {
502 for (const auto& surface : previous_contained_surfaces_) { 478 for (const auto& surface : previous_contained_surfaces_) {
503 if (!contained_surfaces_.count(surface.first)) { 479 if (!contained_surfaces_.count(surface.first)) {
504 // Release resources of removed surface. 480 // Release resources of removed surface.
505 SurfaceToResourceChildIdMap::iterator it = 481 SurfaceToResourceChildIdMap::iterator it =
506 surface_id_to_resource_child_id_.find(surface.first); 482 surface_id_to_resource_child_id_.find(surface.first);
507 if (it != surface_id_to_resource_child_id_.end()) { 483 if (it != surface_id_to_resource_child_id_.end()) {
508 provider_->DestroyChild(it->second); 484 provider_->DestroyChild(it->second);
509 surface_id_to_resource_child_id_.erase(it); 485 surface_id_to_resource_child_id_.erase(it);
510 } 486 }
511 487
512 // Notify client of removed surface. 488 // Notify client of removed surface.
513 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first); 489 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first);
514 if (surface_ptr) { 490 if (surface_ptr) {
515 surface_ptr->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); 491 surface_ptr->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED);
516 } 492 }
517 } 493 }
518 } 494 }
519 } 495 }
520 496
521 // Walk the Surface tree from surface_id. Validate the resources of the current 497 // Walk the Surface tree from surface_id. Validate the resources of the current
522 // surface and its descendants, check if there are any copy requests, and 498 // surface and its descendants, check if there are any copy requests, and
523 // return the combined damage rect. 499 // return the combined damage rect.
524 gfx::Rect SurfaceAggregator::PrewalkTree(SurfaceId surface_id, 500 gfx::Rect SurfaceAggregator::PrewalkTree(SurfaceId surface_id,
525 bool in_moved_pixel_pass,
526 RenderPassId parent_pass,
527 PrewalkResult* result) { 501 PrewalkResult* result) {
528 // This is for debugging a possible use after free. 502 // This is for debugging a possible use after free.
529 // TODO(jbauman): Remove this once we have enough information. 503 // TODO(jbauman): Remove this once we have enough information.
530 // http://crbug.com/560181 504 // http://crbug.com/560181
531 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr(); 505 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr();
532 506
533 if (referenced_surfaces_.count(surface_id)) 507 if (referenced_surfaces_.count(surface_id))
534 return gfx::Rect(); 508 return gfx::Rect();
535 Surface* surface = manager_->GetSurfaceForId(surface_id); 509 Surface* surface = manager_->GetSurfaceForId(surface_id);
536 if (!surface) { 510 if (!surface) {
(...skipping 21 matching lines...) Expand all
558 ResourceProvider::ResourceIdSet referenced_resources; 532 ResourceProvider::ResourceIdSet referenced_resources;
559 size_t reserve_size = frame_data->resource_list.size(); 533 size_t reserve_size = frame_data->resource_list.size();
560 referenced_resources.reserve(reserve_size); 534 referenced_resources.reserve(reserve_size);
561 535
562 bool invalid_frame = false; 536 bool invalid_frame = false;
563 ResourceProvider::ResourceIdMap empty_map; 537 ResourceProvider::ResourceIdMap empty_map;
564 const ResourceProvider::ResourceIdMap& child_to_parent_map = 538 const ResourceProvider::ResourceIdMap& child_to_parent_map =
565 provider_ ? provider_->GetChildToParentMap(child_id) : empty_map; 539 provider_ ? provider_->GetChildToParentMap(child_id) : empty_map;
566 540
567 CHECK(debug_weak_this.get()); 541 CHECK(debug_weak_this.get());
568 if (!frame_data->render_pass_list.empty()) { 542 // Each pair in the vector is a child surface and the transform from its
569 RenderPassId remapped_pass_id = 543 // target to the root target of this surface.
570 RemapPassId(frame_data->render_pass_list.back()->id, surface_id); 544 std::vector<std::pair<SurfaceId, gfx::Transform>> child_surfaces;
571 if (in_moved_pixel_pass) 545 for (const auto& render_pass : frame_data->render_pass_list) {
572 moved_pixel_passes_.insert(remapped_pass_id);
573 if (parent_pass.IsValid())
574 render_pass_dependencies_[parent_pass].insert(remapped_pass_id);
575 }
576
577 struct SurfaceInfo {
578 SurfaceId id;
579 bool has_moved_pixels;
580 RenderPassId parent_pass;
581 gfx::Transform target_to_surface_transform;
582 };
583 std::vector<SurfaceInfo> child_surfaces;
584
585 for (const auto& render_pass : base::Reversed(frame_data->render_pass_list)) {
586 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id);
587 bool in_moved_pixel_pass = !!moved_pixel_passes_.count(remapped_pass_id);
588 for (const auto& quad : render_pass->quad_list) { 546 for (const auto& quad : render_pass->quad_list) {
589 if (quad->material == DrawQuad::SURFACE_CONTENT) { 547 if (quad->material == DrawQuad::SURFACE_CONTENT) {
590 const SurfaceDrawQuad* surface_quad = 548 const SurfaceDrawQuad* surface_quad =
591 SurfaceDrawQuad::MaterialCast(quad); 549 SurfaceDrawQuad::MaterialCast(quad);
592 gfx::Transform target_to_surface_transform( 550 gfx::Transform target_to_surface_transform(
593 render_pass->transform_to_root_target, 551 render_pass->transform_to_root_target,
594 surface_quad->shared_quad_state->quad_to_target_transform); 552 surface_quad->shared_quad_state->quad_to_target_transform);
595 child_surfaces.push_back( 553 child_surfaces.push_back(std::make_pair(surface_quad->surface_id,
596 SurfaceInfo{surface_quad->surface_id, in_moved_pixel_pass, 554 target_to_surface_transform));
597 remapped_pass_id, target_to_surface_transform});
598 } else if (quad->material == DrawQuad::RENDER_PASS) {
599 const RenderPassDrawQuad* render_pass_quad =
600 RenderPassDrawQuad::MaterialCast(quad);
601 if (in_moved_pixel_pass ||
602 render_pass_quad->filters.HasFilterThatMovesPixels()) {
603 moved_pixel_passes_.insert(
604 RemapPassId(render_pass_quad->render_pass_id, surface_id));
605 }
606 if (render_pass_quad->background_filters.HasFilterThatMovesPixels()) {
607 in_moved_pixel_pass = true;
608 }
609 render_pass_dependencies_[remapped_pass_id].insert(
610 RemapPassId(render_pass_quad->render_pass_id, surface_id));
611 } 555 }
612 556
613 if (!provider_) 557 if (!provider_)
614 continue; 558 continue;
615 for (ResourceId resource_id : quad->resources) { 559 for (ResourceId resource_id : quad->resources) {
616 if (!child_to_parent_map.count(resource_id)) { 560 if (!child_to_parent_map.count(resource_id)) {
617 invalid_frame = true; 561 invalid_frame = true;
618 break; 562 break;
619 } 563 }
620 referenced_resources.insert(resource_id); 564 referenced_resources.insert(resource_id);
621 } 565 }
622 } 566 }
623 } 567 }
624 568
625 if (invalid_frame) 569 if (invalid_frame)
626 return gfx::Rect(); 570 return gfx::Rect();
627 CHECK(debug_weak_this.get()); 571 CHECK(debug_weak_this.get());
628 valid_surfaces_.insert(surface->surface_id()); 572 valid_surfaces_.insert(surface->surface_id());
629 573
630 if (provider_) 574 if (provider_)
631 provider_->DeclareUsedResourcesFromChild(child_id, referenced_resources); 575 provider_->DeclareUsedResourcesFromChild(child_id, referenced_resources);
632 CHECK(debug_weak_this.get()); 576 CHECK(debug_weak_this.get());
633 577
634 gfx::Rect damage_rect; 578 gfx::Rect damage_rect;
635 gfx::Rect full_damage;
636 if (!frame_data->render_pass_list.empty()) { 579 if (!frame_data->render_pass_list.empty()) {
637 RenderPass* last_pass = frame_data->render_pass_list.back().get(); 580 RenderPass* last_pass = frame_data->render_pass_list.back().get();
638 full_damage = last_pass->output_rect;
639 damage_rect = 581 damage_rect =
640 DamageRectForSurface(surface, *last_pass, last_pass->output_rect); 582 DamageRectForSurface(surface, *last_pass, last_pass->output_rect);
641 } 583 }
642 584
643 // Avoid infinite recursion by adding current surface to 585 // Avoid infinite recursion by adding current surface to
644 // referenced_surfaces_. 586 // referenced_surfaces_.
645 SurfaceSet::iterator it = 587 SurfaceSet::iterator it =
646 referenced_surfaces_.insert(surface->surface_id()).first; 588 referenced_surfaces_.insert(surface->surface_id()).first;
647 for (const auto& surface_info : child_surfaces) { 589 for (const auto& surface_info : child_surfaces) {
648 gfx::Rect surface_damage = 590 gfx::Rect surface_damage = PrewalkTree(surface_info.first, result);
649 PrewalkTree(surface_info.id, surface_info.has_moved_pixels, 591 damage_rect.Union(
650 surface_info.parent_pass, result); 592 MathUtil::MapEnclosingClippedRect(surface_info.second, surface_damage));
651 if (surface_damage.IsEmpty())
652 continue;
653 if (surface_info.has_moved_pixels) {
654 // Areas outside the rect hit by target_to_surface_transform may be
655 // modified if there is a filter that moves pixels.
656 damage_rect = full_damage;
657 continue;
658 }
659
660 damage_rect.Union(MathUtil::MapEnclosingClippedRect(
661 surface_info.target_to_surface_transform, surface_damage));
662 } 593 }
663 594
664 CHECK(debug_weak_this.get()); 595 CHECK(debug_weak_this.get());
665 for (const auto& surface_id : surface_frame->metadata.referenced_surfaces) { 596 for (const auto& surface_id : surface_frame->metadata.referenced_surfaces) {
666 if (!contained_surfaces_.count(surface_id)) { 597 if (!contained_surfaces_.count(surface_id)) {
667 result->undrawn_surfaces.insert(surface_id); 598 result->undrawn_surfaces.insert(surface_id);
668 PrewalkTree(surface_id, false, RenderPassId(), result); 599 PrewalkTree(surface_id, result);
669 } 600 }
670 } 601 }
671 602
672 CHECK(debug_weak_this.get()); 603 CHECK(debug_weak_this.get());
673 if (surface->factory()) 604 if (surface->factory())
674 surface->factory()->WillDrawSurface(surface->surface_id(), damage_rect); 605 surface->factory()->WillDrawSurface(surface->surface_id(), damage_rect);
675 606
676 CHECK(debug_weak_this.get()); 607 CHECK(debug_weak_this.get());
677 for (const auto& render_pass : frame_data->render_pass_list) { 608 for (const auto& render_pass : frame_data->render_pass_list)
678 if (!render_pass->copy_requests.empty()) { 609 result->has_copy_requests |= !render_pass->copy_requests.empty();
679 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id);
680 copy_request_passes_.insert(remapped_pass_id);
681 }
682 }
683 610
684 referenced_surfaces_.erase(it); 611 referenced_surfaces_.erase(it);
685 return damage_rect; 612 return damage_rect;
686 } 613 }
687 614
688 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) { 615 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) {
689 // undrawn_surfaces are Surfaces that were identified by prewalk as being 616 // undrawn_surfaces are Surfaces that were identified by prewalk as being
690 // referenced by a drawn Surface, but aren't contained in a SurfaceDrawQuad. 617 // referenced by a drawn Surface, but aren't contained in a SurfaceDrawQuad.
691 // They need to be iterated over to ensure that any copy requests on them 618 // They need to be iterated over to ensure that any copy requests on them
692 // (or on Surfaces they reference) are executed. 619 // (or on Surfaces they reference) are executed.
(...skipping 28 matching lines...) Expand all
721 } 648 }
722 } 649 }
723 } else { 650 } else {
724 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; 651 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first;
725 CopyPasses(surface_frame->delegated_frame_data.get(), surface); 652 CopyPasses(surface_frame->delegated_frame_data.get(), surface);
726 referenced_surfaces_.erase(it); 653 referenced_surfaces_.erase(it);
727 } 654 }
728 } 655 }
729 } 656 }
730 657
731 void SurfaceAggregator::PropagateCopyRequestPasses() {
732 std::vector<RenderPassId> copy_requests_to_iterate(
733 copy_request_passes_.begin(), copy_request_passes_.end());
734 while (!copy_requests_to_iterate.empty()) {
735 RenderPassId first = copy_requests_to_iterate.back();
736 copy_requests_to_iterate.pop_back();
737 auto it = render_pass_dependencies_.find(first);
738 if (it == render_pass_dependencies_.end())
739 continue;
740 for (auto pass : it->second) {
741 if (copy_request_passes_.insert(pass).second) {
742 copy_requests_to_iterate.push_back(pass);
743 }
744 }
745 }
746 }
747
748 std::unique_ptr<CompositorFrame> SurfaceAggregator::Aggregate( 658 std::unique_ptr<CompositorFrame> SurfaceAggregator::Aggregate(
749 SurfaceId surface_id) { 659 SurfaceId surface_id) {
750 Surface* surface = manager_->GetSurfaceForId(surface_id); 660 Surface* surface = manager_->GetSurfaceForId(surface_id);
751 DCHECK(surface); 661 DCHECK(surface);
752 contained_surfaces_[surface_id] = surface->frame_index(); 662 contained_surfaces_[surface_id] = surface->frame_index();
753 const CompositorFrame* root_surface_frame = surface->GetEligibleFrame(); 663 const CompositorFrame* root_surface_frame = surface->GetEligibleFrame();
754 if (!root_surface_frame) 664 if (!root_surface_frame)
755 return nullptr; 665 return nullptr;
756 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); 666 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate");
757 667
758 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 668 std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
759 frame->delegated_frame_data = base::WrapUnique(new DelegatedFrameData); 669 frame->delegated_frame_data = base::WrapUnique(new DelegatedFrameData);
760 670
761 DCHECK(root_surface_frame->delegated_frame_data); 671 DCHECK(root_surface_frame->delegated_frame_data);
762 672
763 dest_resource_list_ = &frame->delegated_frame_data->resource_list; 673 dest_resource_list_ = &frame->delegated_frame_data->resource_list;
764 dest_pass_list_ = &frame->delegated_frame_data->render_pass_list; 674 dest_pass_list_ = &frame->delegated_frame_data->render_pass_list;
765 675
766 valid_surfaces_.clear(); 676 valid_surfaces_.clear();
767 PrewalkResult prewalk_result; 677 PrewalkResult prewalk_result;
768 root_damage_rect_ = 678 root_damage_rect_ = PrewalkTree(surface_id, &prewalk_result);
769 PrewalkTree(surface_id, false, RenderPassId(), &prewalk_result); 679 has_copy_requests_ = prewalk_result.has_copy_requests;
770 PropagateCopyRequestPasses();
771 has_copy_requests_ = !copy_request_passes_.empty();
772 680
773 CopyUndrawnSurfaces(&prewalk_result); 681 CopyUndrawnSurfaces(&prewalk_result);
774 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; 682 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first;
775 CopyPasses(root_surface_frame->delegated_frame_data.get(), surface); 683 CopyPasses(root_surface_frame->delegated_frame_data.get(), surface);
776 referenced_surfaces_.erase(it); 684 referenced_surfaces_.erase(it);
777 685
778 moved_pixel_passes_.clear();
779 copy_request_passes_.clear();
780 render_pass_dependencies_.clear();
781
782 DCHECK(referenced_surfaces_.empty()); 686 DCHECK(referenced_surfaces_.empty());
783 687
784 if (dest_pass_list_->empty()) 688 if (dest_pass_list_->empty())
785 return nullptr; 689 return nullptr;
690 dest_pass_list_->back()->damage_rect = root_damage_rect_;
786 691
787 dest_pass_list_ = NULL; 692 dest_pass_list_ = NULL;
788 ProcessAddedAndRemovedSurfaces(); 693 ProcessAddedAndRemovedSurfaces();
789 contained_surfaces_.swap(previous_contained_surfaces_); 694 contained_surfaces_.swap(previous_contained_surfaces_);
790 contained_surfaces_.clear(); 695 contained_surfaces_.clear();
791 696
792 for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin(); 697 for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin();
793 it != previous_contained_surfaces_.end(); 698 it != previous_contained_surfaces_.end();
794 ++it) { 699 ++it) {
795 Surface* surface = manager_->GetSurfaceForId(it->first); 700 Surface* surface = manager_->GetSurfaceForId(it->first);
(...skipping 18 matching lines...) Expand all
814 719
815 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { 720 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) {
816 auto it = previous_contained_surfaces_.find(surface_id); 721 auto it = previous_contained_surfaces_.find(surface_id);
817 if (it == previous_contained_surfaces_.end()) 722 if (it == previous_contained_surfaces_.end())
818 return; 723 return;
819 // Set the last drawn index as 0 to ensure full damage next time it's drawn. 724 // Set the last drawn index as 0 to ensure full damage next time it's drawn.
820 it->second = 0; 725 it->second = 0;
821 } 726 }
822 727
823 } // namespace cc 728 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698