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

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: rebase 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
« no previous file with comments | « gpu/command_buffer/common/buffer.h ('k') | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (data_offset > static_cast<uint32_t>(size_))
56 return 0;
57 return static_cast<uint32_t>(size_) - data_offset;
58 }
59
46 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( 60 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing(
47 uint64_t tracing_process_id, 61 uint64_t tracing_process_id,
48 int32_t buffer_id) { 62 int32_t buffer_id) {
49 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( 63 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf(
50 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id)); 64 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id));
51 } 65 }
52 66
53 } // namespace gpu 67 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/buffer.h ('k') | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698