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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 const RenderPass& source = *referenced_passes[j]; | 218 const RenderPass& source = *referenced_passes[j]; |
| 219 | 219 |
| 220 size_t sqs_size = source.shared_quad_state_list.size(); | 220 size_t sqs_size = source.shared_quad_state_list.size(); |
| 221 size_t dq_size = source.quad_list.size(); | 221 size_t dq_size = source.quad_list.size(); |
| 222 std::unique_ptr<RenderPass> copy_pass( | 222 std::unique_ptr<RenderPass> copy_pass( |
| 223 RenderPass::Create(sqs_size, dq_size)); | 223 RenderPass::Create(sqs_size, dq_size)); |
| 224 | 224 |
| 225 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); | 225 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); |
| 226 | 226 |
| 227 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, | 227 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, |
| 228 source.transform_to_root_target, | 228 source.transform_to_root_target, source.filters, |
| 229 source.background_filters, | |
| 229 source.has_transparent_background); | 230 source.has_transparent_background); |
| 230 | 231 |
| 231 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 232 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
| 232 | 233 |
| 233 // Contributing passes aggregated in to the pass list need to take the | 234 // Contributing passes aggregated in to the pass list need to take the |
| 234 // transform of the surface quad into account to update their transform to | 235 // transform of the surface quad into account to update their transform to |
| 235 // the root surface. | 236 // the root surface. |
| 236 copy_pass->transform_to_root_target.ConcatTransform( | 237 copy_pass->transform_to_root_target.ConcatTransform( |
| 237 surface_quad->shared_quad_state->quad_to_target_transform); | 238 surface_quad->shared_quad_state->quad_to_target_transform); |
| 238 copy_pass->transform_to_root_target.ConcatTransform(target_transform); | 239 copy_pass->transform_to_root_target.ConcatTransform(target_transform); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 RenderPassId remapped_pass_id = RemapPassId(last_pass.id, surface_id); | 288 RenderPassId remapped_pass_id = RemapPassId(last_pass.id, surface_id); |
| 288 | 289 |
| 289 SharedQuadState* shared_quad_state = | 290 SharedQuadState* shared_quad_state = |
| 290 CopySharedQuadState(surface_quad->shared_quad_state, target_transform, | 291 CopySharedQuadState(surface_quad->shared_quad_state, target_transform, |
| 291 clip_rect, dest_pass); | 292 clip_rect, dest_pass); |
| 292 | 293 |
| 293 RenderPassDrawQuad* quad = | 294 RenderPassDrawQuad* quad = |
| 294 dest_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 295 dest_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 295 quad->SetNew(shared_quad_state, surface_quad->rect, | 296 quad->SetNew(shared_quad_state, surface_quad->rect, |
| 296 surface_quad->visible_rect, remapped_pass_id, 0, | 297 surface_quad->visible_rect, remapped_pass_id, 0, |
| 297 gfx::Vector2dF(), gfx::Size(), FilterOperations(), | 298 gfx::Vector2dF(), gfx::Size(), gfx::Vector2dF(), |
| 298 gfx::Vector2dF(), gfx::PointF(), FilterOperations()); | 299 gfx::PointF()); |
| 299 } | 300 } |
| 300 | 301 |
| 301 referenced_surfaces_.erase(it); | 302 referenced_surfaces_.erase(it); |
| 302 } | 303 } |
| 303 | 304 |
| 304 SharedQuadState* SurfaceAggregator::CopySharedQuadState( | 305 SharedQuadState* SurfaceAggregator::CopySharedQuadState( |
| 305 const SharedQuadState* source_sqs, | 306 const SharedQuadState* source_sqs, |
| 306 const gfx::Transform& target_transform, | 307 const gfx::Transform& target_transform, |
| 307 const ClipData& clip_rect, | 308 const ClipData& clip_rect, |
| 308 RenderPass* dest_render_pass) { | 309 RenderPass* dest_render_pass) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 size_t dq_size = source.quad_list.size(); | 486 size_t dq_size = source.quad_list.size(); |
| 486 std::unique_ptr<RenderPass> copy_pass( | 487 std::unique_ptr<RenderPass> copy_pass( |
| 487 RenderPass::Create(sqs_size, dq_size)); | 488 RenderPass::Create(sqs_size, dq_size)); |
| 488 | 489 |
| 489 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 490 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
| 490 | 491 |
| 491 RenderPassId remapped_pass_id = | 492 RenderPassId remapped_pass_id = |
| 492 RemapPassId(source.id, surface->surface_id()); | 493 RemapPassId(source.id, surface->surface_id()); |
| 493 | 494 |
| 494 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, | 495 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, |
| 495 source.transform_to_root_target, | 496 source.transform_to_root_target, source.filters, |
| 497 source.background_filters, | |
| 496 source.has_transparent_background); | 498 source.has_transparent_background); |
| 497 | 499 |
| 498 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 500 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
| 499 child_to_parent_map, gfx::Transform(), ClipData(), | 501 child_to_parent_map, gfx::Transform(), ClipData(), |
| 500 copy_pass.get(), surface->surface_id()); | 502 copy_pass.get(), surface->surface_id()); |
| 501 if (!copy_request_passes_.count(remapped_pass_id) && | 503 if (!copy_request_passes_.count(remapped_pass_id) && |
| 502 !moved_pixel_passes_.count(remapped_pass_id)) { | 504 !moved_pixel_passes_.count(remapped_pass_id)) { |
| 503 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); | 505 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); |
| 504 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { | 506 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { |
| 505 gfx::Rect damage_rect_in_render_pass_space = | 507 gfx::Rect damage_rect_in_render_pass_space = |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 530 surface_ptr->RunDrawCallbacks(); | 532 surface_ptr->RunDrawCallbacks(); |
| 531 } | 533 } |
| 532 } | 534 } |
| 533 } | 535 } |
| 534 } | 536 } |
| 535 | 537 |
| 536 // Walk the Surface tree from surface_id. Validate the resources of the current | 538 // Walk the Surface tree from surface_id. Validate the resources of the current |
| 537 // surface and its descendants, check if there are any copy requests, and | 539 // surface and its descendants, check if there are any copy requests, and |
| 538 // return the combined damage rect. | 540 // return the combined damage rect. |
| 539 gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id, | 541 gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id, |
| 540 bool in_moved_pixel_pass, | 542 bool in_moved_pixel_surface, |
| 541 RenderPassId parent_pass, | 543 RenderPassId parent_pass, |
| 542 PrewalkResult* result) { | 544 PrewalkResult* result) { |
| 543 // This is for debugging a possible use after free. | 545 // This is for debugging a possible use after free. |
| 544 // TODO(jbauman): Remove this once we have enough information. | 546 // TODO(jbauman): Remove this once we have enough information. |
| 545 // http://crbug.com/560181 | 547 // http://crbug.com/560181 |
| 546 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr(); | 548 base::WeakPtr<SurfaceAggregator> debug_weak_this = weak_factory_.GetWeakPtr(); |
| 547 | 549 |
| 548 if (referenced_surfaces_.count(surface_id)) | 550 if (referenced_surfaces_.count(surface_id)) |
| 549 return gfx::Rect(); | 551 return gfx::Rect(); |
| 550 Surface* surface = manager_->GetSurfaceForId(surface_id); | 552 Surface* surface = manager_->GetSurfaceForId(surface_id); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 572 | 574 |
| 573 bool invalid_frame = false; | 575 bool invalid_frame = false; |
| 574 ResourceProvider::ResourceIdMap empty_map; | 576 ResourceProvider::ResourceIdMap empty_map; |
| 575 const ResourceProvider::ResourceIdMap& child_to_parent_map = | 577 const ResourceProvider::ResourceIdMap& child_to_parent_map = |
| 576 provider_ ? provider_->GetChildToParentMap(child_id) : empty_map; | 578 provider_ ? provider_->GetChildToParentMap(child_id) : empty_map; |
| 577 | 579 |
| 578 CHECK(debug_weak_this.get()); | 580 CHECK(debug_weak_this.get()); |
| 579 if (!frame.render_pass_list.empty()) { | 581 if (!frame.render_pass_list.empty()) { |
| 580 RenderPassId remapped_pass_id = | 582 RenderPassId remapped_pass_id = |
| 581 RemapPassId(frame.render_pass_list.back()->id, surface_id); | 583 RemapPassId(frame.render_pass_list.back()->id, surface_id); |
| 582 if (in_moved_pixel_pass) | 584 if (in_moved_pixel_surface) |
| 583 moved_pixel_passes_.insert(remapped_pass_id); | 585 moved_pixel_passes_.insert(remapped_pass_id); |
| 584 if (parent_pass.IsValid()) | 586 if (parent_pass.IsValid()) |
| 585 render_pass_dependencies_[parent_pass].insert(remapped_pass_id); | 587 render_pass_dependencies_[parent_pass].insert(remapped_pass_id); |
| 586 } | 588 } |
| 587 | 589 |
| 588 struct SurfaceInfo { | 590 struct SurfaceInfo { |
| 591 SurfaceInfo(const SurfaceId& id, | |
| 592 bool has_moved_pixels, | |
| 593 const RenderPassId& parent_pass, | |
| 594 const gfx::Transform& target_to_surface_transform) | |
| 595 : id(id), | |
| 596 has_moved_pixels(has_moved_pixels), | |
| 597 parent_pass(parent_pass), | |
| 598 target_to_surface_transform(target_to_surface_transform) {} | |
| 599 | |
| 589 SurfaceId id; | 600 SurfaceId id; |
| 590 bool has_moved_pixels; | 601 bool has_moved_pixels; |
| 591 RenderPassId parent_pass; | 602 RenderPassId parent_pass; |
| 592 gfx::Transform target_to_surface_transform; | 603 gfx::Transform target_to_surface_transform; |
| 593 }; | 604 }; |
| 594 std::vector<SurfaceInfo> child_surfaces; | 605 std::vector<SurfaceInfo> child_surfaces; |
| 595 | 606 |
| 607 std::unordered_set<RenderPassId, RenderPassIdHash> | |
| 608 pixel_moving_background_filter_passes; | |
| 609 for (const auto& render_pass : frame.render_pass_list) { | |
| 610 if (render_pass->background_filters.HasFilterThatMovesPixels()) { | |
| 611 pixel_moving_background_filter_passes.insert( | |
| 612 RemapPassId(render_pass->id, surface_id)); | |
| 613 } | |
| 614 } | |
| 615 | |
| 596 for (const auto& render_pass : base::Reversed(frame.render_pass_list)) { | 616 for (const auto& render_pass : base::Reversed(frame.render_pass_list)) { |
| 597 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id); | 617 RenderPassId remapped_pass_id = RemapPassId(render_pass->id, surface_id); |
| 618 if (render_pass->filters.HasFilterThatMovesPixels()) | |
| 619 moved_pixel_passes_.insert(remapped_pass_id); | |
| 598 bool in_moved_pixel_pass = !!moved_pixel_passes_.count(remapped_pass_id); | 620 bool in_moved_pixel_pass = !!moved_pixel_passes_.count(remapped_pass_id); |
|
danakj
2016/12/14 23:23:57
It could be nice to not force a lookup to happen i
ajuma
2016/12/15 16:49:20
Done.
| |
| 599 for (auto* quad : render_pass->quad_list) { | 621 for (auto* quad : render_pass->quad_list) { |
| 600 if (quad->material == DrawQuad::SURFACE_CONTENT) { | 622 if (quad->material == DrawQuad::SURFACE_CONTENT) { |
| 601 const SurfaceDrawQuad* surface_quad = | 623 const SurfaceDrawQuad* surface_quad = |
| 602 SurfaceDrawQuad::MaterialCast(quad); | 624 SurfaceDrawQuad::MaterialCast(quad); |
| 603 gfx::Transform target_to_surface_transform( | 625 gfx::Transform target_to_surface_transform( |
| 604 render_pass->transform_to_root_target, | 626 render_pass->transform_to_root_target, |
| 605 surface_quad->shared_quad_state->quad_to_target_transform); | 627 surface_quad->shared_quad_state->quad_to_target_transform); |
| 606 child_surfaces.push_back( | 628 child_surfaces.emplace_back(surface_quad->surface_id, |
| 607 SurfaceInfo{surface_quad->surface_id, in_moved_pixel_pass, | 629 in_moved_pixel_pass, remapped_pass_id, |
| 608 remapped_pass_id, target_to_surface_transform}); | 630 target_to_surface_transform); |
| 609 } else if (quad->material == DrawQuad::RENDER_PASS) { | 631 } else if (quad->material == DrawQuad::RENDER_PASS) { |
| 610 const RenderPassDrawQuad* render_pass_quad = | 632 const RenderPassDrawQuad* render_pass_quad = |
| 611 RenderPassDrawQuad::MaterialCast(quad); | 633 RenderPassDrawQuad::MaterialCast(quad); |
| 612 if (in_moved_pixel_pass || | 634 if (in_moved_pixel_pass) { |
| 613 render_pass_quad->filters.HasFilterThatMovesPixels()) { | |
| 614 moved_pixel_passes_.insert( | 635 moved_pixel_passes_.insert( |
| 615 RemapPassId(render_pass_quad->render_pass_id, surface_id)); | 636 RemapPassId(render_pass_quad->render_pass_id, surface_id)); |
| 616 } | 637 } |
| 617 if (render_pass_quad->background_filters.HasFilterThatMovesPixels()) { | 638 if (pixel_moving_background_filter_passes.count( |
| 639 render_pass_quad->render_pass_id)) { | |
| 618 in_moved_pixel_pass = true; | 640 in_moved_pixel_pass = true; |
| 619 } | 641 } |
| 620 render_pass_dependencies_[remapped_pass_id].insert( | 642 render_pass_dependencies_[remapped_pass_id].insert( |
| 621 RemapPassId(render_pass_quad->render_pass_id, surface_id)); | 643 RemapPassId(render_pass_quad->render_pass_id, surface_id)); |
| 622 } | 644 } |
| 623 | 645 |
| 624 if (!provider_) | 646 if (!provider_) |
| 625 continue; | 647 continue; |
| 626 for (ResourceId resource_id : quad->resources) { | 648 for (ResourceId resource_id : quad->resources) { |
| 627 if (!child_to_parent_map.count(resource_id)) { | 649 if (!child_to_parent_map.count(resource_id)) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 | 849 |
| 828 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { | 850 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { |
| 829 auto it = previous_contained_surfaces_.find(surface_id); | 851 auto it = previous_contained_surfaces_.find(surface_id); |
| 830 if (it == previous_contained_surfaces_.end()) | 852 if (it == previous_contained_surfaces_.end()) |
| 831 return; | 853 return; |
| 832 // Set the last drawn index as 0 to ensure full damage next time it's drawn. | 854 // Set the last drawn index as 0 to ensure full damage next time it's drawn. |
| 833 it->second = 0; | 855 it->second = 0; |
| 834 } | 856 } |
| 835 | 857 |
| 836 } // namespace cc | 858 } // namespace cc |
| OLD | NEW |