| // Copyright 2013 The Chromium Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| #include "gpu/ipc/common/gpu_memory_buffer_impl.h" | |
| #include "base/logging.h" | |
| namespace gpu { | |
| GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, | |
| const gfx::Size& size, | |
| gfx::BufferFormat format, | |
| const DestructionCallback& callback) | |
| : id_(id), | |
| size_(size), | |
| format_(format), | |
| callback_(callback), | |
| mapped_(false) {} | |
| GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { | |
| DCHECK(!mapped_); | |
| if (!callback_.is_null()) | |
| callback_.Run(destruction_sync_token_); | |
| } | |
| gfx::Size GpuMemoryBufferImpl::GetSize() const { | |
| return size_; | |
| } | |
| gfx::BufferFormat GpuMemoryBufferImpl::GetFormat() const { | |
| return format_; | |
| } | |
| gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const { | |
| return id_; | |
| } | |
| ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { | |
| return reinterpret_cast<ClientBuffer>(this); | |
| } | |
| } // namespace gpu |