OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_shm.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 return true; | 22 return true; |
23 } | 23 } |
24 | 24 |
25 bool GpuMemoryBufferImplShm::InitializeFromSharedMemory( | 25 bool GpuMemoryBufferImplShm::InitializeFromSharedMemory( |
26 scoped_ptr<base::SharedMemory> shared_memory) { | 26 scoped_ptr<base::SharedMemory> shared_memory) { |
27 shared_memory_ = shared_memory.Pass(); | 27 shared_memory_ = shared_memory.Pass(); |
28 DCHECK(!shared_memory_->memory()); | 28 DCHECK(!shared_memory_->memory()); |
29 return true; | 29 return true; |
30 } | 30 } |
31 | 31 |
32 void* GpuMemoryBufferImplShm::Map(AccessMode mode) { | 32 void* GpuMemoryBufferImplShm::Map() { |
33 DCHECK(!mapped_); | 33 DCHECK(!mapped_); |
34 if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(internalformat_))) | 34 if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(internalformat_))) |
35 return NULL; | 35 return NULL; |
36 mapped_ = true; | 36 mapped_ = true; |
37 return shared_memory_->memory(); | 37 return shared_memory_->memory(); |
38 } | 38 } |
39 | 39 |
40 void GpuMemoryBufferImplShm::Unmap() { | 40 void GpuMemoryBufferImplShm::Unmap() { |
41 DCHECK(mapped_); | 41 DCHECK(mapped_); |
42 shared_memory_->Unmap(); | 42 shared_memory_->Unmap(); |
43 mapped_ = false; | 43 mapped_ = false; |
44 } | 44 } |
45 | 45 |
46 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplShm::GetHandle() const { | 46 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplShm::GetHandle() const { |
47 gfx::GpuMemoryBufferHandle handle; | 47 gfx::GpuMemoryBufferHandle handle; |
48 handle.type = gfx::SHARED_MEMORY_BUFFER; | 48 handle.type = gfx::SHARED_MEMORY_BUFFER; |
49 handle.handle = shared_memory_->handle(); | 49 handle.handle = shared_memory_->handle(); |
50 return handle; | 50 return handle; |
51 } | 51 } |
52 | 52 |
53 } // namespace content | 53 } // namespace content |
OLD | NEW |