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

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

Issue 9999003: Optimize GetBucketContents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common_decoder.h" 5 #include "gpu/command_buffer/service/common_decoder.h"
6 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 6 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
7 7
8 namespace gpu { 8 namespace gpu {
9 9
10 CommonDecoder::Bucket::Bucket() : size_(0) {} 10 CommonDecoder::Bucket::Bucket() : size_(0) {}
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 Bucket* bucket = GetBucket(bucket_id); 279 Bucket* bucket = GetBucket(bucket_id);
280 if (!bucket) { 280 if (!bucket) {
281 return error::kInvalidArguments; 281 return error::kInvalidArguments;
282 } 282 }
283 if (!bucket->SetData(data, offset, size)) { 283 if (!bucket->SetData(data, offset, size)) {
284 return error::kInvalidArguments; 284 return error::kInvalidArguments;
285 } 285 }
286 return error::kNoError; 286 return error::kNoError;
287 } 287 }
288 288
289 error::Error CommonDecoder::HandleGetBucketSize( 289 error::Error CommonDecoder::HandleGetBucketStart(
290 uint32 immediate_data_size, 290 uint32 immediate_data_size,
291 const cmd::GetBucketSize& args) { 291 const cmd::GetBucketStart& args) {
292 uint32 bucket_id = args.bucket_id; 292 uint32 bucket_id = args.bucket_id;
293 uint32* data = GetSharedMemoryAs<uint32*>( 293 uint32* result = GetSharedMemoryAs<uint32*>(
294 args.shared_memory_id, args.shared_memory_offset, sizeof(*data)); 294 args.result_memory_id, args.result_memory_offset, sizeof(*result));
295 if (!data) { 295 int32 data_memory_id = args.data_memory_id;
296 uint32 data_memory_offset = args.data_memory_offset;
297 uint32 data_memory_size = args.data_memory_size;
298 uint8* data = NULL;
299 if (data_memory_size != 0 || data_memory_id != 0 || data_memory_offset != 0) {
300 data = GetSharedMemoryAs<uint8*>(
301 args.data_memory_id, args.data_memory_offset, args.data_memory_size);
302 if (!data) {
303 return error::kInvalidArguments;
304 }
305 }
306 if (!result) {
296 return error::kInvalidArguments; 307 return error::kInvalidArguments;
297 } 308 }
298 // Check that the client initialized the result. 309 // Check that the client initialized the result.
299 if (*data != 0) { 310 if (*result != 0) {
300 return error::kInvalidArguments; 311 return error::kInvalidArguments;
301 } 312 }
302 Bucket* bucket = GetBucket(bucket_id); 313 Bucket* bucket = GetBucket(bucket_id);
303 if (!bucket) { 314 if (!bucket) {
304 return error::kInvalidArguments; 315 return error::kInvalidArguments;
305 } 316 }
306 *data = bucket->size(); 317 uint32 bucket_size = bucket->size();
318 *result = bucket_size;
319 if (data) {
320 uint32 size = std::min(data_memory_size, bucket_size);
321 memcpy(data, bucket->GetData(0, size), size);
322 }
307 return error::kNoError; 323 return error::kNoError;
308 } 324 }
309 325
310 error::Error CommonDecoder::HandleGetBucketData( 326 error::Error CommonDecoder::HandleGetBucketData(
311 uint32 immediate_data_size, 327 uint32 immediate_data_size,
312 const cmd::GetBucketData& args) { 328 const cmd::GetBucketData& args) {
313 uint32 bucket_id = args.bucket_id; 329 uint32 bucket_id = args.bucket_id;
314 uint32 offset = args.offset; 330 uint32 offset = args.offset;
315 uint32 size = args.size; 331 uint32 size = args.size;
316 void* data = GetSharedMemoryAs<void*>( 332 void* data = GetSharedMemoryAs<void*>(
317 args.shared_memory_id, args.shared_memory_offset, size); 333 args.shared_memory_id, args.shared_memory_offset, size);
318 if (!data) { 334 if (!data) {
319 return error::kInvalidArguments; 335 return error::kInvalidArguments;
320 } 336 }
321 Bucket* bucket = GetBucket(bucket_id); 337 Bucket* bucket = GetBucket(bucket_id);
322 if (!bucket) { 338 if (!bucket) {
323 return error::kInvalidArguments; 339 return error::kInvalidArguments;
324 } 340 }
325 const void* src = bucket->GetData(offset, size); 341 const void* src = bucket->GetData(offset, size);
326 if (!src) { 342 if (!src) {
327 return error::kInvalidArguments; 343 return error::kInvalidArguments;
328 } 344 }
329 memcpy(data, src, size); 345 memcpy(data, src, size);
330 return error::kNoError; 346 return error::kNoError;
331 } 347 }
332 348
333 } // namespace gpu 349 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/cmd_buffer_common.h ('k') | gpu/command_buffer/service/common_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698