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