Chromium Code Reviews| Index: gpu/command_buffer/common/buffer.cc |
| diff --git a/gpu/command_buffer/common/buffer.cc b/gpu/command_buffer/common/buffer.cc |
| index 1bb9523079dd3c094685b9ad306df7697b7526eb..26f78a82251d733a338bf144ac22be044cef4ca7 100644 |
| --- a/gpu/command_buffer/common/buffer.cc |
| +++ b/gpu/command_buffer/common/buffer.cc |
| @@ -43,6 +43,22 @@ void* Buffer::GetDataAddress(uint32_t data_offset, uint32_t data_size) const { |
| return static_cast<uint8_t*>(memory_) + data_offset; |
| } |
| +void* Buffer::GetDataAddressAndSize(uint32_t data_offset, |
| + uint32_t* data_size) const { |
| + base::CheckedNumeric<uint32_t> offset = data_offset; |
| + if (!offset.IsValid() || offset.ValueOrDie() > static_cast<uint32_t>(size_)) |
| + return NULL; |
|
Zhenyao Mo
2016/05/25 20:05:49
I don't really understand why this is necessary (a
Geoff Lang
2016/05/25 20:44:30
Removed the checks, probably a result of an initia
|
| + *data_size = GetRemainingSize(data_offset); |
| + return static_cast<uint8_t*>(memory_) + data_offset; |
| +} |
| + |
| +uint32_t Buffer::GetRemainingSize(uint32_t data_offset) const { |
| + base::CheckedNumeric<uint32_t> offset = data_offset; |
| + if (!offset.IsValid() || offset.ValueOrDie() > static_cast<uint32_t>(size_)) |
| + return 0; |
| + return static_cast<uint32_t>(size_) - data_offset; |
| +} |
| + |
| base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( |
| uint64_t tracing_process_id, |
| int32_t buffer_id) { |