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

Side by Side Diff: gpu/command_buffer/common/buffer.cc

Issue 2012533004: Add generated and hand-written passthrough command handlers with stub Doers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/buffer.h" 5 #include "gpu/command_buffer/common/buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 25 matching lines...) Expand all
36 Buffer::~Buffer() {} 36 Buffer::~Buffer() {}
37 37
38 void* Buffer::GetDataAddress(uint32_t data_offset, uint32_t data_size) const { 38 void* Buffer::GetDataAddress(uint32_t data_offset, uint32_t data_size) const {
39 base::CheckedNumeric<uint32_t> end = data_offset; 39 base::CheckedNumeric<uint32_t> end = data_offset;
40 end += data_size; 40 end += data_size;
41 if (!end.IsValid() || end.ValueOrDie() > static_cast<uint32_t>(size_)) 41 if (!end.IsValid() || end.ValueOrDie() > static_cast<uint32_t>(size_))
42 return NULL; 42 return NULL;
43 return static_cast<uint8_t*>(memory_) + data_offset; 43 return static_cast<uint8_t*>(memory_) + data_offset;
44 } 44 }
45 45
46 void* Buffer::GetDataAddressAndSize(uint32_t data_offset,
47 uint32_t* data_size) const {
48 if (data_offset > static_cast<uint32_t>(size_))
49 return NULL;
50 *data_size = GetRemainingSize(data_offset);
51 return static_cast<uint8_t*>(memory_) + data_offset;
52 }
53
54 uint32_t Buffer::GetRemainingSize(uint32_t data_offset) const {
55 base::CheckedNumeric<uint32_t> offset = data_offset;
56 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
57 return 0;
58 return static_cast<uint32_t>(size_) - data_offset;
59 }
60
46 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( 61 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing(
47 uint64_t tracing_process_id, 62 uint64_t tracing_process_id,
48 int32_t buffer_id) { 63 int32_t buffer_id) {
49 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( 64 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf(
50 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id)); 65 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id));
51 } 66 }
52 67
53 } // namespace gpu 68 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698