diff options
Diffstat (limited to 'content/common/gpu/client/gpu_memory_buffer_impl.cc')
-rw-r--r-- | content/common/gpu/client/gpu_memory_buffer_impl.cc | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc index e27e260..c469a07 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc @@ -9,51 +9,16 @@ namespace content { GpuMemoryBufferImpl::GpuMemoryBufferImpl( - scoped_ptr<base::SharedMemory> shared_memory, - size_t width, - size_t height, - unsigned internalformat) - : shared_memory_(shared_memory.Pass()), - size_(gfx::Size(width, height)), + gfx::Size size, unsigned internalformat) + : size_(size), internalformat_(internalformat), mapped_(false) { - DCHECK(!shared_memory_->memory()); DCHECK(IsFormatValid(internalformat)); } GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { } -void GpuMemoryBufferImpl::Map(AccessMode mode, void** vaddr) { - DCHECK(!mapped_); - *vaddr = NULL; - if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(internalformat_))) - return; - *vaddr = shared_memory_->memory(); - mapped_ = true; -} - -void GpuMemoryBufferImpl::Unmap() { - DCHECK(mapped_); - shared_memory_->Unmap(); - mapped_ = false; -} - -bool GpuMemoryBufferImpl::IsMapped() const { - return mapped_; -} - -uint32 GpuMemoryBufferImpl::GetStride() const { - return size_.width() * BytesPerPixel(internalformat_); -} - -gfx::GpuMemoryBufferHandle GpuMemoryBufferImpl::GetHandle() const { - gfx::GpuMemoryBufferHandle handle; - handle.type = gfx::SHARED_MEMORY_BUFFER; - handle.handle = shared_memory_->handle(); - return handle; -} - // static bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) { switch (internalformat) { @@ -77,4 +42,12 @@ size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) { } } +bool GpuMemoryBufferImpl::IsMapped() const { + return mapped_; +} + +uint32 GpuMemoryBufferImpl::GetStride() const { + return size_.width() * BytesPerPixel(internalformat_); +} + } // namespace content |