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

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

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/numerics/safe_math.h" 12 #include "base/numerics/safe_math.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 14
15 namespace gpu { 15 namespace gpu {
16 SharedMemoryBufferBacking::SharedMemoryBufferBacking( 16 SharedMemoryBufferBacking::SharedMemoryBufferBacking(
17 scoped_ptr<base::SharedMemory> shared_memory, 17 std::unique_ptr<base::SharedMemory> shared_memory,
18 size_t size) 18 size_t size)
19 : shared_memory_(std::move(shared_memory)), size_(size) {} 19 : shared_memory_(std::move(shared_memory)), size_(size) {}
20 20
21 SharedMemoryBufferBacking::~SharedMemoryBufferBacking() {} 21 SharedMemoryBufferBacking::~SharedMemoryBufferBacking() {}
22 22
23 void* SharedMemoryBufferBacking::GetMemory() const { 23 void* SharedMemoryBufferBacking::GetMemory() const {
24 return shared_memory_->memory(); 24 return shared_memory_->memory();
25 } 25 }
26 26
27 size_t SharedMemoryBufferBacking::GetSize() const { return size_; } 27 size_t SharedMemoryBufferBacking::GetSize() const { return size_; }
28 28
29 Buffer::Buffer(scoped_ptr<BufferBacking> backing) 29 Buffer::Buffer(std::unique_ptr<BufferBacking> backing)
30 : backing_(std::move(backing)), 30 : backing_(std::move(backing)),
31 memory_(backing_->GetMemory()), 31 memory_(backing_->GetMemory()),
32 size_(backing_->GetSize()) { 32 size_(backing_->GetSize()) {
33 DCHECK(memory_) << "The memory must be mapped to create a Buffer"; 33 DCHECK(memory_) << "The memory must be mapped to create a Buffer";
34 } 34 }
35 35
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 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( 46 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing(
47 uint64_t tracing_process_id, 47 uint64_t tracing_process_id,
48 int32_t buffer_id) { 48 int32_t buffer_id) {
49 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( 49 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf(
50 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id)); 50 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id));
51 } 51 }
52 52
53 } // namespace gpu 53 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/buffer.h ('k') | gpu/command_buffer/common/command_buffer_shared_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698