OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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) {} |
| 11 |
| 12 CommonDecoder::Bucket::~Bucket() {} |
| 13 |
10 void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { | 14 void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { |
11 if (OffsetSizeValid(offset, size)) { | 15 if (OffsetSizeValid(offset, size)) { |
12 return data_.get() + offset; | 16 return data_.get() + offset; |
13 } | 17 } |
14 return NULL; | 18 return NULL; |
15 } | 19 } |
16 | 20 |
17 void CommonDecoder::Bucket::SetSize(size_t size) { | 21 void CommonDecoder::Bucket::SetSize(size_t size) { |
18 if (size != size_) { | 22 if (size != size_) { |
19 data_.reset(size ? new int8[size] : NULL); | 23 data_.reset(size ? new int8[size] : NULL); |
(...skipping 20 matching lines...) Expand all Loading... |
40 | 44 |
41 bool CommonDecoder::Bucket::GetAsString(std::string* str) { | 45 bool CommonDecoder::Bucket::GetAsString(std::string* str) { |
42 DCHECK(str); | 46 DCHECK(str); |
43 if (size_ == 0) { | 47 if (size_ == 0) { |
44 return false; | 48 return false; |
45 } | 49 } |
46 str->assign(GetDataAs<const char*>(0, size_ - 1), size_ - 1); | 50 str->assign(GetDataAs<const char*>(0, size_ - 1), size_ - 1); |
47 return true; | 51 return true; |
48 } | 52 } |
49 | 53 |
| 54 CommonDecoder::CommonDecoder() : engine_(NULL) {} |
| 55 |
| 56 CommonDecoder::~CommonDecoder() {} |
| 57 |
50 void* CommonDecoder::GetAddressAndCheckSize(unsigned int shm_id, | 58 void* CommonDecoder::GetAddressAndCheckSize(unsigned int shm_id, |
51 unsigned int offset, | 59 unsigned int offset, |
52 unsigned int size) { | 60 unsigned int size) { |
53 Buffer buffer = engine_->GetSharedMemoryBuffer(shm_id); | 61 Buffer buffer = engine_->GetSharedMemoryBuffer(shm_id); |
54 if (!buffer.ptr) | 62 if (!buffer.ptr) |
55 return NULL; | 63 return NULL; |
56 unsigned int end = offset + size; | 64 unsigned int end = offset + size; |
57 if (end > buffer.size || end < offset) { | 65 if (end > buffer.size || end < offset) { |
58 return NULL; | 66 return NULL; |
59 } | 67 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 319 } |
312 const void* src = bucket->GetData(offset, size); | 320 const void* src = bucket->GetData(offset, size); |
313 if (!src) { | 321 if (!src) { |
314 return error::kInvalidArguments; | 322 return error::kInvalidArguments; |
315 } | 323 } |
316 memcpy(data, src, size); | 324 memcpy(data, src, size); |
317 return error::kNoError; | 325 return error::kNoError; |
318 } | 326 } |
319 | 327 |
320 } // namespace gpu | 328 } // namespace gpu |
OLD | NEW |