Chromium Code Reviews| Index: cc/surfaces/surface_aggregator.cc |
| diff --git a/cc/surfaces/surface_aggregator.cc b/cc/surfaces/surface_aggregator.cc |
| index f2d5c270a64747f0d37c6bba7c4c778520f57da5..806849d9c3061e78052946da651f3b93095d8cd8 100644 |
| --- a/cc/surfaces/surface_aggregator.cc |
| +++ b/cc/surfaces/surface_aggregator.cc |
| @@ -183,13 +183,17 @@ bool SurfaceAggregator::ValidateResources( |
| #endif |
| bool invalid_frame = false; |
| - DrawQuad::ResourceIteratorCallback remap = |
| - base::Bind(&ValidateResourceHelper, &invalid_frame, |
| - base::ConstRef(provider_->GetChildToParentMap(child_id)), |
| - &referenced_resources); |
| + const ResourceProvider::ResourceIdMap& child_to_parent_map = |
| + provider_->GetChildToParentMap(child_id); |
| for (const auto& render_pass : frame_data->render_pass_list) { |
| - for (const auto& quad : render_pass->quad_list) |
| - quad->IterateResources(remap); |
| + for (const auto& quad : render_pass->quad_list) { |
| + quad->IterateResources( |
| + [&invalid_frame, &child_to_parent_map, &referenced_resources]( |
| + ResourceId resource_id) { |
| + return ValidateResourceHelper(&invalid_frame, child_to_parent_map, |
| + &referenced_resources, resource_id); |
|
piman
2015/05/28 18:37:59
nit: I would inline ValidateResourceHelper here. I
vmpstr
2015/05/28 19:18:50
Done.
|
| + }); |
| + } |
| } |
| if (!invalid_frame) |
| @@ -246,14 +250,9 @@ void SurfaceAggregator::HandleSurfaceQuad( |
| } |
| SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
| - DrawQuad::ResourceIteratorCallback remap; |
| - if (provider_) { |
| - int child_id = ChildIdForSurface(surface); |
| - remap = |
| - base::Bind(&ResourceRemapHelper, |
| - base::ConstRef(provider_->GetChildToParentMap(child_id))); |
| - } |
| - |
| + const ResourceProvider::ResourceIdMap& child_to_parent_map = |
| + provider_ ? provider_->GetChildToParentMap(ChildIdForSurface(surface)) |
| + : ResourceProvider::ResourceIdMap(); |
| bool merge_pass = surface_quad->opacity() == 1.f && copy_requests.empty(); |
| gfx::Rect surface_damage = DamageRectForSurface( |
| @@ -285,8 +284,9 @@ void SurfaceAggregator::HandleSurfaceQuad( |
| copy_pass->transform_to_root_target.ConcatTransform( |
| dest_pass->transform_to_root_target); |
| - CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, remap, |
| - gfx::Transform(), ClipData(), copy_pass.get(), surface_id); |
| + CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
| + child_to_parent_map, gfx::Transform(), ClipData(), |
| + copy_pass.get(), surface_id); |
| if (j == referenced_passes.size() - 1) |
| surface_damage = gfx::UnionRects(surface_damage, copy_pass->damage_rect); |
| @@ -313,8 +313,9 @@ void SurfaceAggregator::HandleSurfaceQuad( |
| ClipData quads_clip = |
| CalculateClipRect(clip_rect, surface_quad_clip_rect, target_transform); |
| - CopyQuadsToPass(quads, last_pass.shared_quad_state_list, remap, |
| - surface_transform, quads_clip, dest_pass, surface_id); |
| + CopyQuadsToPass(quads, last_pass.shared_quad_state_list, |
| + child_to_parent_map, surface_transform, quads_clip, |
| + dest_pass, surface_id); |
| } else { |
| RenderPassId remapped_pass_id = RemapPassId(last_pass.id, surface_id); |
| @@ -371,7 +372,7 @@ void SurfaceAggregator::CopySharedQuadState( |
| void SurfaceAggregator::CopyQuadsToPass( |
| const QuadList& source_quad_list, |
| const SharedQuadStateList& source_shared_quad_state_list, |
| - const DrawQuad::ResourceIteratorCallback& remap, |
| + const ResourceProvider::ResourceIdMap& child_to_parent_map, |
| const gfx::Transform& target_transform, |
| const ClipData& clip_rect, |
| RenderPass* dest_pass, |
| @@ -423,8 +424,12 @@ void SurfaceAggregator::CopyQuadsToPass( |
| dest_quad = dest_pass->CopyFromAndAppendDrawQuad( |
| quad, dest_pass->shared_quad_state_list.back()); |
| } |
| - if (!remap.is_null()) |
| - dest_quad->IterateResources(remap); |
| + if (!child_to_parent_map.empty()) { |
| + dest_quad->IterateResources( |
| + [&child_to_parent_map](ResourceId resource_id) { |
| + return ResourceRemapHelper(child_to_parent_map, resource_id); |
|
piman
2015/05/28 18:37:59
nit: same here, I would probably inline ResourceRe
vmpstr
2015/05/28 19:18:50
Done.
|
| + }); |
| + } |
| } |
| } |
| } |
| @@ -442,14 +447,9 @@ void SurfaceAggregator::CopyPasses(const DelegatedFrameData* frame_data, |
| if (invalid_frame) |
| return; |
| - DrawQuad::ResourceIteratorCallback remap; |
| - if (provider_) { |
| - int child_id = ChildIdForSurface(surface); |
| - remap = |
| - base::Bind(&ResourceRemapHelper, |
| - base::ConstRef(provider_->GetChildToParentMap(child_id))); |
| - } |
| - |
| + const ResourceProvider::ResourceIdMap& child_to_parent_map = |
| + provider_ ? provider_->GetChildToParentMap(ChildIdForSurface(surface)) |
| + : ResourceProvider::ResourceIdMap(); |
| for (size_t i = 0; i < source_pass_list.size(); ++i) { |
| const RenderPass& source = *source_pass_list[i]; |
| @@ -470,9 +470,9 @@ void SurfaceAggregator::CopyPasses(const DelegatedFrameData* frame_data, |
| source.transform_to_root_target, |
| source.has_transparent_background); |
| - CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, remap, |
| - gfx::Transform(), ClipData(), copy_pass.get(), |
| - surface->surface_id()); |
| + CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
| + child_to_parent_map, gfx::Transform(), ClipData(), |
| + copy_pass.get(), surface->surface_id()); |
| dest_pass_list_->push_back(copy_pass.Pass()); |
| } |