summaryrefslogtreecommitdiffstats
path: root/cc/surfaces
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2015-11-18 13:05:54 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-18 21:07:23 +0000
commit4fc2590aa54c0a556df66e5fd541a66cd429a223 (patch)
tree38ec174e33cf1e44fd9e593dd4690875f13ef53c /cc/surfaces
parent2571678733bc6b8643cff305b2cf601f77d871c6 (diff)
downloadchromium_src-4fc2590aa54c0a556df66e5fd541a66cd429a223.zip
chromium_src-4fc2590aa54c0a556df66e5fd541a66cd429a223.tar.gz
chromium_src-4fc2590aa54c0a556df66e5fd541a66cd429a223.tar.bz2
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}
Diffstat (limited to 'cc/surfaces')
-rw-r--r--cc/surfaces/surface.cc11
-rw-r--r--cc/surfaces/surface.h3
-rw-r--r--cc/surfaces/surface_aggregator.cc13
3 files changed, 11 insertions, 16 deletions
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<CopyOutputRequest> copy_request) {
}
void Surface::TakeCopyOutputRequests(
- std::multimap<RenderPassId, CopyOutputRequest*>* copy_requests) {
+ std::multimap<RenderPassId, scoped_ptr<CopyOutputRequest>>* 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<CopyOutputRequest> 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<RenderPassId, CopyOutputRequest*>* copy_requests);
+ std::multimap<RenderPassId, scoped_ptr<CopyOutputRequest>>*
+ 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<RenderPassId, CopyOutputRequest*>* copy_requests,
+ std::multimap<RenderPassId, scoped_ptr<CopyOutputRequest>>* copy_requests,
std::vector<scoped_ptr<CopyOutputRequest>>* 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<CopyOutputRequest>(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<RenderPassId, CopyOutputRequest*> copy_requests;
+ std::multimap<RenderPassId, scoped_ptr<CopyOutputRequest>> copy_requests;
surface->TakeCopyOutputRequests(&copy_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<RenderPassId, CopyOutputRequest*> copy_requests;
+ std::multimap<RenderPassId, scoped_ptr<CopyOutputRequest>> copy_requests;
surface->TakeCopyOutputRequests(&copy_requests);
const RenderPassList& source_pass_list = frame_data->render_pass_list;