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

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

Issue 211703003: GPU: 'Pass' SharedMemory when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@GPU_ref_count_buffer
Patch Set: Rebase. Created 6 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 <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 void CommandBufferService::SetGetOffset(int32 get_offset) { 117 void CommandBufferService::SetGetOffset(int32 get_offset) {
118 DCHECK(get_offset >= 0 && get_offset < num_entries_); 118 DCHECK(get_offset >= 0 && get_offset < num_entries_);
119 get_offset_ = get_offset; 119 get_offset_ = get_offset;
120 } 120 }
121 121
122 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size, 122 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size,
123 int32* id) { 123 int32* id) {
124 *id = -1; 124 *id = -1;
125 125
126 SharedMemory buffer; 126 scoped_ptr<SharedMemory> shared_memory(new SharedMemory());
127 if (!buffer.CreateAnonymous(size)) 127 if (!shared_memory->CreateAndMapAnonymous(size))
128 return NULL; 128 return NULL;
129 129
130 static int32 next_id = 1; 130 static int32 next_id = 1;
131 *id = next_id++; 131 *id = next_id++;
132 132
133 if (!RegisterTransferBuffer(*id, &buffer, size)) { 133 if (!RegisterTransferBuffer(*id, shared_memory.Pass(), size)) {
134 *id = -1; 134 *id = -1;
135 return NULL; 135 return NULL;
136 } 136 }
137 137
138 return GetTransferBuffer(*id); 138 return GetTransferBuffer(*id);
139 } 139 }
140 140
141 void CommandBufferService::DestroyTransferBuffer(int32 id) { 141 void CommandBufferService::DestroyTransferBuffer(int32 id) {
142 transfer_buffer_manager_->DestroyTransferBuffer(id); 142 transfer_buffer_manager_->DestroyTransferBuffer(id);
143 if (id == ring_buffer_id_) { 143 if (id == ring_buffer_id_) {
144 ring_buffer_id_ = -1; 144 ring_buffer_id_ = -1;
145 ring_buffer_ = NULL; 145 ring_buffer_ = NULL;
146 num_entries_ = 0; 146 num_entries_ = 0;
147 get_offset_ = 0; 147 get_offset_ = 0;
148 put_offset_ = 0; 148 put_offset_ = 0;
149 } 149 }
150 } 150 }
151 151
152 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32 id) { 152 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32 id) {
153 return transfer_buffer_manager_->GetTransferBuffer(id); 153 return transfer_buffer_manager_->GetTransferBuffer(id);
154 } 154 }
155 155
156 bool CommandBufferService::RegisterTransferBuffer( 156 bool CommandBufferService::RegisterTransferBuffer(
157 int32 id, 157 int32 id,
158 base::SharedMemory* shared_memory, 158 scoped_ptr<base::SharedMemory> shared_memory,
159 size_t size) { 159 size_t size) {
160 return transfer_buffer_manager_->RegisterTransferBuffer(id, 160 return transfer_buffer_manager_->RegisterTransferBuffer(
161 shared_memory, 161 id, shared_memory.Pass(), size);
162 size);
163 } 162 }
164 163
165 void CommandBufferService::SetToken(int32 token) { 164 void CommandBufferService::SetToken(int32 token) {
166 token_ = token; 165 token_ = token;
167 UpdateState(); 166 UpdateState();
168 } 167 }
169 168
170 void CommandBufferService::SetParseError(error::Error error) { 169 void CommandBufferService::SetParseError(error::Error error) {
171 if (error_ == error::kNoError) { 170 if (error_ == error::kNoError) {
172 error_ = error; 171 error_ = error;
(...skipping 16 matching lines...) Expand all
189 const GetBufferChangedCallback& callback) { 188 const GetBufferChangedCallback& callback) {
190 get_buffer_change_callback_ = callback; 189 get_buffer_change_callback_ = callback;
191 } 190 }
192 191
193 void CommandBufferService::SetParseErrorCallback( 192 void CommandBufferService::SetParseErrorCallback(
194 const base::Closure& callback) { 193 const base::Closure& callback) {
195 parse_error_callback_ = callback; 194 parse_error_callback_ = callback;
196 } 195 }
197 196
198 } // namespace gpu 197 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_buffer_service.h ('k') | gpu/command_buffer/service/transfer_buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698