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

Side by Side Diff: gpu/command_buffer/service/command_buffer_service.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/command_buffer_service.h" 5 #include "gpu/command_buffer/service/command_buffer_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
11 #include <memory>
11 12
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
14 #include "gpu/command_buffer/common/cmd_buffer_common.h" 15 #include "gpu/command_buffer/common/cmd_buffer_common.h"
15 #include "gpu/command_buffer/common/command_buffer_shared.h" 16 #include "gpu/command_buffer/common/command_buffer_shared.h"
16 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 17 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
17 18
18 using ::base::SharedMemory; 19 using ::base::SharedMemory;
19 20
20 namespace gpu { 21 namespace gpu {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 put_offset_ = 0; 99 put_offset_ = 0;
99 SetGetOffset(0); 100 SetGetOffset(0);
100 if (!get_buffer_change_callback_.is_null()) { 101 if (!get_buffer_change_callback_.is_null()) {
101 get_buffer_change_callback_.Run(ring_buffer_id_); 102 get_buffer_change_callback_.Run(ring_buffer_id_);
102 } 103 }
103 104
104 UpdateState(); 105 UpdateState();
105 } 106 }
106 107
107 void CommandBufferService::SetSharedStateBuffer( 108 void CommandBufferService::SetSharedStateBuffer(
108 scoped_ptr<BufferBacking> shared_state_buffer) { 109 std::unique_ptr<BufferBacking> shared_state_buffer) {
109 shared_state_buffer_ = std::move(shared_state_buffer); 110 shared_state_buffer_ = std::move(shared_state_buffer);
110 DCHECK(shared_state_buffer_->GetSize() >= sizeof(*shared_state_)); 111 DCHECK(shared_state_buffer_->GetSize() >= sizeof(*shared_state_));
111 112
112 shared_state_ = 113 shared_state_ =
113 static_cast<CommandBufferSharedState*>(shared_state_buffer_->GetMemory()); 114 static_cast<CommandBufferSharedState*>(shared_state_buffer_->GetMemory());
114 115
115 UpdateState(); 116 UpdateState();
116 } 117 }
117 118
118 void CommandBufferService::SetGetOffset(int32_t get_offset) { 119 void CommandBufferService::SetGetOffset(int32_t get_offset) {
119 DCHECK(get_offset >= 0 && get_offset < num_entries_); 120 DCHECK(get_offset >= 0 && get_offset < num_entries_);
120 get_offset_ = get_offset; 121 get_offset_ = get_offset;
121 } 122 }
122 123
123 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size, 124 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size,
124 int32_t* id) { 125 int32_t* id) {
125 *id = -1; 126 *id = -1;
126 127
127 scoped_ptr<SharedMemory> shared_memory(new SharedMemory()); 128 std::unique_ptr<SharedMemory> shared_memory(new SharedMemory());
128 if (!shared_memory->CreateAndMapAnonymous(size)) { 129 if (!shared_memory->CreateAndMapAnonymous(size)) {
129 if (error_ == error::kNoError) 130 if (error_ == error::kNoError)
130 error_ = gpu::error::kOutOfBounds; 131 error_ = gpu::error::kOutOfBounds;
131 return NULL; 132 return NULL;
132 } 133 }
133 134
134 static int32_t next_id = 1; 135 static int32_t next_id = 1;
135 *id = next_id++; 136 *id = next_id++;
136 137
137 if (!RegisterTransferBuffer( 138 if (!RegisterTransferBuffer(
(...skipping 17 matching lines...) Expand all
155 put_offset_ = 0; 156 put_offset_ = 0;
156 } 157 }
157 } 158 }
158 159
159 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32_t id) { 160 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32_t id) {
160 return transfer_buffer_manager_->GetTransferBuffer(id); 161 return transfer_buffer_manager_->GetTransferBuffer(id);
161 } 162 }
162 163
163 bool CommandBufferService::RegisterTransferBuffer( 164 bool CommandBufferService::RegisterTransferBuffer(
164 int32_t id, 165 int32_t id,
165 scoped_ptr<BufferBacking> buffer) { 166 std::unique_ptr<BufferBacking> buffer) {
166 return transfer_buffer_manager_->RegisterTransferBuffer(id, 167 return transfer_buffer_manager_->RegisterTransferBuffer(id,
167 std::move(buffer)); 168 std::move(buffer));
168 } 169 }
169 170
170 void CommandBufferService::SetToken(int32_t token) { 171 void CommandBufferService::SetToken(int32_t token) {
171 token_ = token; 172 token_ = token;
172 UpdateState(); 173 UpdateState();
173 } 174 }
174 175
175 void CommandBufferService::SetParseError(error::Error error) { 176 void CommandBufferService::SetParseError(error::Error error) {
(...skipping 22 matching lines...) Expand all
198 const GetBufferChangedCallback& callback) { 199 const GetBufferChangedCallback& callback) {
199 get_buffer_change_callback_ = callback; 200 get_buffer_change_callback_ = callback;
200 } 201 }
201 202
202 void CommandBufferService::SetParseErrorCallback( 203 void CommandBufferService::SetParseErrorCallback(
203 const base::Closure& callback) { 204 const base::Closure& callback) {
204 parse_error_callback_ = callback; 205 parse_error_callback_ = callback;
205 } 206 }
206 207
207 } // namespace gpu 208 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_buffer_service.h ('k') | gpu/command_buffer/service/command_buffer_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698