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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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/cmd_buffer_common.cc » ('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>
8 #include <stdint.h>
9
7 #include "base/format_macros.h" 10 #include "base/format_macros.h"
8 #include "base/logging.h" 11 #include "base/logging.h"
9 #include "base/numerics/safe_math.h" 12 #include "base/numerics/safe_math.h"
10 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
11 14
12 namespace gpu { 15 namespace gpu {
13 SharedMemoryBufferBacking::SharedMemoryBufferBacking( 16 SharedMemoryBufferBacking::SharedMemoryBufferBacking(
14 scoped_ptr<base::SharedMemory> shared_memory, 17 scoped_ptr<base::SharedMemory> shared_memory,
15 size_t size) 18 size_t size)
16 : shared_memory_(std::move(shared_memory)), size_(size) {} 19 : shared_memory_(std::move(shared_memory)), size_(size) {}
17 20
18 SharedMemoryBufferBacking::~SharedMemoryBufferBacking() {} 21 SharedMemoryBufferBacking::~SharedMemoryBufferBacking() {}
19 22
20 void* SharedMemoryBufferBacking::GetMemory() const { 23 void* SharedMemoryBufferBacking::GetMemory() const {
21 return shared_memory_->memory(); 24 return shared_memory_->memory();
22 } 25 }
23 26
24 size_t SharedMemoryBufferBacking::GetSize() const { return size_; } 27 size_t SharedMemoryBufferBacking::GetSize() const { return size_; }
25 28
26 Buffer::Buffer(scoped_ptr<BufferBacking> backing) 29 Buffer::Buffer(scoped_ptr<BufferBacking> backing)
27 : backing_(std::move(backing)), 30 : backing_(std::move(backing)),
28 memory_(backing_->GetMemory()), 31 memory_(backing_->GetMemory()),
29 size_(backing_->GetSize()) { 32 size_(backing_->GetSize()) {
30 DCHECK(memory_) << "The memory must be mapped to create a Buffer"; 33 DCHECK(memory_) << "The memory must be mapped to create a Buffer";
31 } 34 }
32 35
33 Buffer::~Buffer() {} 36 Buffer::~Buffer() {}
34 37
35 void* Buffer::GetDataAddress(uint32 data_offset, uint32 data_size) const { 38 void* Buffer::GetDataAddress(uint32_t data_offset, uint32_t data_size) const {
36 base::CheckedNumeric<uint32> end = data_offset; 39 base::CheckedNumeric<uint32_t> end = data_offset;
37 end += data_size; 40 end += data_size;
38 if (!end.IsValid() || end.ValueOrDie() > static_cast<uint32>(size_)) 41 if (!end.IsValid() || end.ValueOrDie() > static_cast<uint32_t>(size_))
39 return NULL; 42 return NULL;
40 return static_cast<uint8*>(memory_) + data_offset; 43 return static_cast<uint8_t*>(memory_) + data_offset;
41 } 44 }
42 45
43 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( 46 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing(
44 uint64_t tracing_process_id, 47 uint64_t tracing_process_id,
45 int32_t buffer_id) { 48 int32_t buffer_id) {
46 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( 49 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf(
47 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id)); 50 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id));
48 } 51 }
49 52
50 } // namespace gpu 53 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/buffer.h ('k') | gpu/command_buffer/common/cmd_buffer_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698