| OLD | NEW |
| 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 |
| 17 bool BufferBacking::is_shared() const { |
| 18 return false; |
| 19 } |
| 20 |
| 16 SharedMemoryBufferBacking::SharedMemoryBufferBacking( | 21 SharedMemoryBufferBacking::SharedMemoryBufferBacking( |
| 17 std::unique_ptr<base::SharedMemory> shared_memory, | 22 std::unique_ptr<base::SharedMemory> shared_memory, |
| 18 size_t size) | 23 size_t size) |
| 19 : shared_memory_(std::move(shared_memory)), size_(size) {} | 24 : shared_memory_(std::move(shared_memory)), size_(size) {} |
| 20 | 25 |
| 21 SharedMemoryBufferBacking::~SharedMemoryBufferBacking() {} | 26 SharedMemoryBufferBacking::~SharedMemoryBufferBacking() {} |
| 22 | 27 |
| 28 bool SharedMemoryBufferBacking::is_shared() const { |
| 29 return true; |
| 30 } |
| 31 |
| 23 void* SharedMemoryBufferBacking::GetMemory() const { | 32 void* SharedMemoryBufferBacking::GetMemory() const { |
| 24 return shared_memory_->memory(); | 33 return shared_memory_->memory(); |
| 25 } | 34 } |
| 26 | 35 |
| 27 size_t SharedMemoryBufferBacking::GetSize() const { return size_; } | 36 size_t SharedMemoryBufferBacking::GetSize() const { return size_; } |
| 28 | 37 |
| 29 Buffer::Buffer(std::unique_ptr<BufferBacking> backing) | 38 Buffer::Buffer(std::unique_ptr<BufferBacking> backing) |
| 30 : backing_(std::move(backing)), | 39 : backing_(std::move(backing)), |
| 31 memory_(backing_->GetMemory()), | 40 memory_(backing_->GetMemory()), |
| 32 size_(backing_->GetSize()) { | 41 size_(backing_->GetSize()) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 58 } | 67 } |
| 59 | 68 |
| 60 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( | 69 base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( |
| 61 uint64_t tracing_process_id, | 70 uint64_t tracing_process_id, |
| 62 int32_t buffer_id) { | 71 int32_t buffer_id) { |
| 63 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( | 72 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( |
| 64 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id)); | 73 "gpu-buffer-x-process/%" PRIx64 "/%d", tracing_process_id, buffer_id)); |
| 65 } | 74 } |
| 66 | 75 |
| 67 } // namespace gpu | 76 } // namespace gpu |
| OLD | NEW |