Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: cc/surfaces/surface_factory.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 20 matching lines...) Expand all
31 DestroyAll(); 31 DestroyAll();
32 } 32 }
33 33
34 void SurfaceFactory::DestroyAll() { 34 void SurfaceFactory::DestroyAll() {
35 for (auto& pair : surface_map_) 35 for (auto& pair : surface_map_)
36 manager_->Destroy(std::move(pair.second)); 36 manager_->Destroy(std::move(pair.second));
37 surface_map_.clear(); 37 surface_map_.clear();
38 } 38 }
39 39
40 void SurfaceFactory::Create(SurfaceId surface_id) { 40 void SurfaceFactory::Create(SurfaceId surface_id) {
41 scoped_ptr<Surface> surface(new Surface(surface_id, this)); 41 std::unique_ptr<Surface> surface(new Surface(surface_id, this));
42 manager_->RegisterSurface(surface.get()); 42 manager_->RegisterSurface(surface.get());
43 DCHECK(!surface_map_.count(surface_id)); 43 DCHECK(!surface_map_.count(surface_id));
44 surface_map_[surface_id] = std::move(surface); 44 surface_map_[surface_id] = std::move(surface);
45 } 45 }
46 46
47 void SurfaceFactory::Destroy(SurfaceId surface_id) { 47 void SurfaceFactory::Destroy(SurfaceId surface_id) {
48 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); 48 OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
49 DCHECK(it != surface_map_.end()); 49 DCHECK(it != surface_map_.end());
50 DCHECK(it->second->factory().get() == this); 50 DCHECK(it->second->factory().get() == this);
51 scoped_ptr<Surface> surface(std::move(it->second)); 51 std::unique_ptr<Surface> surface(std::move(it->second));
52 surface_map_.erase(it); 52 surface_map_.erase(it);
53 manager_->Destroy(std::move(surface)); 53 manager_->Destroy(std::move(surface));
54 } 54 }
55 55
56 void SurfaceFactory::SubmitCompositorFrame(SurfaceId surface_id, 56 void SurfaceFactory::SubmitCompositorFrame(
57 scoped_ptr<CompositorFrame> frame, 57 SurfaceId surface_id,
58 const DrawCallback& callback) { 58 std::unique_ptr<CompositorFrame> frame,
59 const DrawCallback& callback) {
59 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); 60 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame");
60 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); 61 OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
61 DCHECK(it != surface_map_.end()); 62 DCHECK(it != surface_map_.end());
62 DCHECK(it->second->factory().get() == this); 63 DCHECK(it->second->factory().get() == this);
63 it->second->QueueFrame(std::move(frame), callback); 64 it->second->QueueFrame(std::move(frame), callback);
64 if (!manager_->SurfaceModified(surface_id)) { 65 if (!manager_->SurfaceModified(surface_id)) {
65 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 66 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
66 it->second->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); 67 it->second->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED);
67 } 68 }
68 } 69 }
69 70
70 void SurfaceFactory::RequestCopyOfSurface( 71 void SurfaceFactory::RequestCopyOfSurface(
71 SurfaceId surface_id, 72 SurfaceId surface_id,
72 scoped_ptr<CopyOutputRequest> copy_request) { 73 std::unique_ptr<CopyOutputRequest> copy_request) {
73 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); 74 OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
74 if (it == surface_map_.end()) { 75 if (it == surface_map_.end()) {
75 copy_request->SendEmptyResult(); 76 copy_request->SendEmptyResult();
76 return; 77 return;
77 } 78 }
78 DCHECK(it->second->factory().get() == this); 79 DCHECK(it->second->factory().get() == this);
79 it->second->RequestCopyOfOutput(std::move(copy_request)); 80 it->second->RequestCopyOfOutput(std::move(copy_request));
80 manager_->SurfaceModified(surface_id); 81 manager_->SurfaceModified(surface_id);
81 } 82 }
82 83
83 void SurfaceFactory::WillDrawSurface(SurfaceId id, 84 void SurfaceFactory::WillDrawSurface(SurfaceId id,
84 const gfx::Rect& damage_rect) { 85 const gfx::Rect& damage_rect) {
85 client_->WillDrawSurface(id, damage_rect); 86 client_->WillDrawSurface(id, damage_rect);
86 } 87 }
87 88
88 void SurfaceFactory::ReceiveFromChild( 89 void SurfaceFactory::ReceiveFromChild(
89 const TransferableResourceArray& resources) { 90 const TransferableResourceArray& resources) {
90 holder_.ReceiveFromChild(resources); 91 holder_.ReceiveFromChild(resources);
91 } 92 }
92 93
93 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 94 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
94 holder_.RefResources(resources); 95 holder_.RefResources(resources);
95 } 96 }
96 97
97 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 98 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
98 holder_.UnrefResources(resources); 99 holder_.UnrefResources(resources);
99 } 100 }
100 101
101 } // namespace cc 102 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698