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 "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" | 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/numerics/safe_math.h" | 11 #include "base/numerics/safe_math.h" |
12 #include "base/process/memory.h" | 12 #include "base/process/memory.h" |
13 #include "ui/gfx/buffer_format_util.h" | 13 #include "ui/gfx/buffer_format_util.h" |
14 #include "ui/gl/gl_bindings.h" | 14 #include "ui/gl/gl_bindings.h" |
15 | 15 |
16 namespace content { | 16 namespace gpu { |
17 namespace { | 17 namespace { |
18 | 18 |
19 void Noop() {} | 19 void Noop() {} |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 GpuMemoryBufferImplSharedMemory::GpuMemoryBufferImplSharedMemory( | 23 GpuMemoryBufferImplSharedMemory::GpuMemoryBufferImplSharedMemory( |
24 gfx::GpuMemoryBufferId id, | 24 gfx::GpuMemoryBufferId id, |
25 const gfx::Size& size, | 25 const gfx::Size& size, |
26 gfx::BufferFormat format, | 26 gfx::BufferFormat format, |
27 const DestructionCallback& callback, | 27 const DestructionCallback& callback, |
28 scoped_ptr<base::SharedMemory> shared_memory, | 28 scoped_ptr<base::SharedMemory> shared_memory, |
29 size_t offset, | 29 size_t offset, |
30 int stride) | 30 int stride) |
31 : GpuMemoryBufferImpl(id, size, format, callback), | 31 : GpuMemoryBufferImpl(id, size, format, callback), |
32 shared_memory_(std::move(shared_memory)), | 32 shared_memory_(std::move(shared_memory)), |
33 offset_(offset), | 33 offset_(offset), |
34 stride_(stride) { | 34 stride_(stride) { |
35 DCHECK(IsSizeValidForFormat(size, format)); | 35 DCHECK(IsSizeValidForFormat(size, format)); |
36 } | 36 } |
37 | 37 |
38 GpuMemoryBufferImplSharedMemory::~GpuMemoryBufferImplSharedMemory() { | 38 GpuMemoryBufferImplSharedMemory::~GpuMemoryBufferImplSharedMemory() {} |
39 } | |
40 | 39 |
41 // static | 40 // static |
42 scoped_ptr<GpuMemoryBufferImplSharedMemory> | 41 scoped_ptr<GpuMemoryBufferImplSharedMemory> |
43 GpuMemoryBufferImplSharedMemory::Create(gfx::GpuMemoryBufferId id, | 42 GpuMemoryBufferImplSharedMemory::Create(gfx::GpuMemoryBufferId id, |
44 const gfx::Size& size, | 43 const gfx::Size& size, |
45 gfx::BufferFormat format, | 44 gfx::BufferFormat format, |
46 const DestructionCallback& callback) { | 45 const DestructionCallback& callback) { |
47 size_t buffer_size = 0u; | 46 size_t buffer_size = 0u; |
48 if (!gfx::BufferSizeForBufferFormatChecked(size, format, &buffer_size)) | 47 if (!gfx::BufferSizeForBufferFormatChecked(size, format, &buffer_size)) |
49 return nullptr; | 48 return nullptr; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const { | 213 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const { |
215 gfx::GpuMemoryBufferHandle handle; | 214 gfx::GpuMemoryBufferHandle handle; |
216 handle.type = gfx::SHARED_MEMORY_BUFFER; | 215 handle.type = gfx::SHARED_MEMORY_BUFFER; |
217 handle.id = id_; | 216 handle.id = id_; |
218 handle.offset = offset_; | 217 handle.offset = offset_; |
219 handle.stride = stride_; | 218 handle.stride = stride_; |
220 handle.handle = shared_memory_->handle(); | 219 handle.handle = shared_memory_->handle(); |
221 return handle; | 220 return handle; |
222 } | 221 } |
223 | 222 |
224 } // namespace content | 223 } // namespace gpu |
OLD | NEW |