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

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

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: [WIP] Review comments follow-up Created 6 years, 11 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"
11 #include "gpu/command_buffer/common/cmd_buffer_common.h" 11 #include "gpu/command_buffer/common/cmd_buffer_common.h"
12 #include "gpu/command_buffer/common/command_buffer_shared.h" 12 #include "gpu/command_buffer/common/command_buffer_shared.h"
13 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 13 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
14 14
15 using ::base::SharedMemory; 15 using ::base::SharedMemory;
16 16
17 namespace gpu { 17 namespace gpu {
18 18
19 CommandBufferService::CommandBufferService( 19 CommandBufferService::CommandBufferService(
20 TransferBufferManagerInterface* transfer_buffer_manager) 20 TransferBufferManagerInterface* transfer_buffer_manager)
21 : ring_buffer_id_(-1), 21 : ring_buffer_id_(-1),
22 shared_state_(NULL), 22 shared_state_(NULL),
23 num_entries_(0), 23 num_entries_(0),
24 get_offset_(0), 24 get_offset_(0),
25 put_offset_(0), 25 put_offset_(0),
26 transfer_buffer_manager_(transfer_buffer_manager), 26 transfer_buffer_manager_(transfer_buffer_manager),
27 token_(0), 27 token_(0),
28 serial_(0),
28 generation_(0), 29 generation_(0),
29 error_(error::kNoError), 30 error_(error::kNoError),
30 context_lost_reason_(error::kUnknown) { 31 context_lost_reason_(error::kUnknown) {
31 } 32 }
32 33
33 CommandBufferService::~CommandBufferService() { 34 CommandBufferService::~CommandBufferService() {
34 } 35 }
35 36
36 bool CommandBufferService::Initialize() { 37 bool CommandBufferService::Initialize() {
37 return true; 38 return true;
38 } 39 }
39 40
40 CommandBufferService::State CommandBufferService::GetState() { 41 CommandBufferService::State CommandBufferService::GetState() {
41 State state; 42 State state;
42 state.num_entries = num_entries_; 43 state.num_entries = num_entries_;
43 state.get_offset = get_offset_; 44 state.get_offset = get_offset_;
44 state.put_offset = put_offset_; 45 state.put_offset = put_offset_;
45 state.token = token_; 46 state.token = token_;
47 state.serial = serial_;
46 state.error = error_; 48 state.error = error_;
47 state.context_lost_reason = context_lost_reason_; 49 state.context_lost_reason = context_lost_reason_;
48 state.generation = ++generation_; 50 state.generation = ++generation_;
49 51
50 return state; 52 return state;
51 } 53 }
52 54
53 CommandBufferService::State CommandBufferService::GetLastState() { 55 CommandBufferService::State CommandBufferService::GetLastState() {
54 return GetState(); 56 return GetState();
55 } 57 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return transfer_buffer_manager_->RegisterTransferBuffer(id, 169 return transfer_buffer_manager_->RegisterTransferBuffer(id,
168 shared_memory, 170 shared_memory,
169 size); 171 size);
170 } 172 }
171 173
172 void CommandBufferService::SetToken(int32 token) { 174 void CommandBufferService::SetToken(int32 token) {
173 token_ = token; 175 token_ = token;
174 UpdateState(); 176 UpdateState();
175 } 177 }
176 178
179 void CommandBufferService::SetSerial(uint32 serial) {
180 serial_ = serial;
181 UpdateState();
182 }
183
177 void CommandBufferService::SetParseError(error::Error error) { 184 void CommandBufferService::SetParseError(error::Error error) {
178 if (error_ == error::kNoError) { 185 if (error_ == error::kNoError) {
179 error_ = error; 186 error_ = error;
180 if (!parse_error_callback_.is_null()) 187 if (!parse_error_callback_.is_null())
181 parse_error_callback_.Run(); 188 parse_error_callback_.Run();
182 } 189 }
183 } 190 }
184 191
185 void CommandBufferService::SetContextLostReason( 192 void CommandBufferService::SetContextLostReason(
186 error::ContextLostReason reason) { 193 error::ContextLostReason reason) {
187 context_lost_reason_ = reason; 194 context_lost_reason_ = reason;
188 } 195 }
189 196
190 void CommandBufferService::SetPutOffsetChangeCallback( 197 void CommandBufferService::SetPutOffsetChangeCallback(
191 const base::Closure& callback) { 198 const base::Closure& callback) {
192 put_offset_change_callback_ = callback; 199 put_offset_change_callback_ = callback;
193 } 200 }
194 201
195 void CommandBufferService::SetGetBufferChangeCallback( 202 void CommandBufferService::SetGetBufferChangeCallback(
196 const GetBufferChangedCallback& callback) { 203 const GetBufferChangedCallback& callback) {
197 get_buffer_change_callback_ = callback; 204 get_buffer_change_callback_ = callback;
198 } 205 }
199 206
200 void CommandBufferService::SetParseErrorCallback( 207 void CommandBufferService::SetParseErrorCallback(
201 const base::Closure& callback) { 208 const base::Closure& callback) {
202 parse_error_callback_ = callback; 209 parse_error_callback_ = callback;
203 } 210 }
204 211
205 } // namespace gpu 212 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698