From 4fc2590aa54c0a556df66e5fd541a66cd429a223 Mon Sep 17 00:00:00 2001 From: vmpstr Date: Wed, 18 Nov 2015 13:05:54 -0800 Subject: cc: Use scoped_ptrs in surface multimaps. Instead of managing raw pointers, use scoped ptrs now that we can! BUG=557388 R=danakj@chromium.org, jbauman@chromium.org CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1455843005 Cr-Commit-Position: refs/heads/master@{#360412} --- cc/surfaces/surface.cc | 11 ++++------- cc/surfaces/surface.h | 3 ++- cc/surfaces/surface_aggregator.cc | 13 +++++-------- 3 files changed, 11 insertions(+), 16 deletions(-) (limited to 'cc/surfaces') diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc index f5649b1..8faff98 100644 --- a/cc/surfaces/surface.cc +++ b/cc/surfaces/surface.cc @@ -110,19 +110,16 @@ void Surface::RequestCopyOfOutput(scoped_ptr copy_request) { } void Surface::TakeCopyOutputRequests( - std::multimap* copy_requests) { + std::multimap>* copy_requests) { DCHECK(copy_requests->empty()); if (current_frame_) { for (const auto& render_pass : current_frame_->delegated_frame_data->render_pass_list) { - while (!render_pass->copy_requests.empty()) { - scoped_ptr request = - PopBack(&render_pass->copy_requests); - // TODO(vmpstr): |copy_requests| should store scoped_ptrs. - // crbug.com/557388. + for (auto& request : render_pass->copy_requests) { copy_requests->insert( - std::make_pair(render_pass->id, request.release())); + std::make_pair(render_pass->id, std::move(request))); } + render_pass->copy_requests.clear(); } } } diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h index cbfa42e..267983d 100644 --- a/cc/surfaces/surface.h +++ b/cc/surfaces/surface.h @@ -48,7 +48,8 @@ class CC_SURFACES_EXPORT Surface { // Adds each CopyOutputRequest in the current frame to copy_requests. The // caller takes ownership of them. void TakeCopyOutputRequests( - std::multimap* copy_requests); + std::multimap>* + copy_requests); // Returns the most recent frame that is eligible to be rendered. const CompositorFrame* GetEligibleFrame(); diff --git a/cc/surfaces/surface_aggregator.cc b/cc/surfaces/surface_aggregator.cc index 75df292..4c1441a 100644 --- a/cc/surfaces/surface_aggregator.cc +++ b/cc/surfaces/surface_aggregator.cc @@ -28,13 +28,12 @@ namespace { void MoveMatchingRequests( RenderPassId id, - std::multimap* copy_requests, + std::multimap>* copy_requests, std::vector>* output_requests) { auto request_range = copy_requests->equal_range(id); for (auto it = request_range.first; it != request_range.second; ++it) { DCHECK(it->second); - output_requests->push_back(scoped_ptr(it->second)); - it->second = nullptr; + output_requests->push_back(std::move(it->second)); } copy_requests->erase(request_range.first, request_range.second); } @@ -178,15 +177,13 @@ void SurfaceAggregator::HandleSurfaceQuad( if (!frame_data) return; - std::multimap copy_requests; + std::multimap> copy_requests; surface->TakeCopyOutputRequests(©_requests); const RenderPassList& render_pass_list = frame_data->render_pass_list; if (!valid_surfaces_.count(surface->surface_id())) { - for (auto& request : copy_requests) { + for (auto& request : copy_requests) request.second->SendEmptyResult(); - delete request.second; - } return; } @@ -423,7 +420,7 @@ void SurfaceAggregator::CopyPasses(const DelegatedFrameData* frame_data, Surface* surface) { // The root surface is allowed to have copy output requests, so grab them // off its render passes. - std::multimap copy_requests; + std::multimap> copy_requests; surface->TakeCopyOutputRequests(©_requests); const RenderPassList& source_pass_list = frame_data->render_pass_list; -- cgit v1.1