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..9e8d5a0962bda741f5f62a4ba15bfd30b9d65cdc 100644 |
--- a/gpu/command_buffer/common/buffer.cc |
+++ b/gpu/command_buffer/common/buffer.cc |
@@ -43,6 +43,21 @@ 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 { |
+ if (data_offset > static_cast<uint32_t>(size_)) |
+ return NULL; |
+ *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_)) |
piman
2016/05/25 23:34:42
Not sure of the goal of the offset.IsValid() check
Geoff Lang
2016/05/27 14:31:28
Whoops, yes, forgot to remove the CheckedNumerics
|
+ return 0; |
+ return static_cast<uint32_t>(size_) - data_offset; |
+} |
+ |
base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( |
uint64_t tracing_process_id, |
int32_t buffer_id) { |