Chromium Code Reviews| Index: content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc |
| diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f8ca46fe4e2e797725e06ace622101ed0caf6a51 |
| --- /dev/null |
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc |
| @@ -0,0 +1,108 @@ |
| +// Copyright 2014 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 "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.h" |
| + |
| +#include "base/bind.h" |
| +#include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" |
| +#include "ui/gl/gl_bindings.h" |
| + |
| +namespace content { |
| +namespace { |
| + |
| +uint32_t g_next_buffer_id = 1; |
| + |
| +} // namespace |
| + |
| +GpuMemoryBufferImplOzoneNativeBuffer::GpuMemoryBufferImplOzoneNativeBuffer( |
| + const gfx::Size& size, |
| + unsigned internalformat) |
| + : GpuMemoryBufferImpl(size, internalformat) { |
| +} |
| + |
| +GpuMemoryBufferImplOzoneNativeBuffer::~GpuMemoryBufferImplOzoneNativeBuffer() { |
| +} |
| + |
| +// static |
| +void GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId( |
| + const gfx::Size& size, |
| + unsigned internalformat, |
| + unsigned usage, |
| + int child_id, |
| + const AllocationCallback& callback) { |
| + gfx::GpuMemoryBufferHandle handle; |
| + handle.global_id.primary_id = g_next_buffer_id++; |
|
reveman
2014/08/13 17:00:26
Note: this assumes that this function will only be
achaulk
2014/08/13 17:10:13
Done.
|
| + handle.global_id.secondary_id = child_id; |
| + handle.type = gfx::OZONE_NATIVE_BUFFER; |
| + GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer( |
| + handle, |
| + size, |
| + internalformat, |
| + usage, |
| + base::Bind(&OnGpuMemoryBufferCreated, callback)); |
| +} |
| + |
| +// static |
| +bool GpuMemoryBufferImplOzoneNativeBuffer::IsFormatSupported( |
| + unsigned internalformat) { |
| + switch (internalformat) { |
| + case GL_RGBA8_OES: |
| + return true; |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| +// static |
| +bool GpuMemoryBufferImplOzoneNativeBuffer::IsUsageSupported(unsigned usage) { |
| + switch (usage) { |
| + case GL_IMAGE_SCANOUT_CHROMIUM: |
| + return true; |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| +// static |
| +bool GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( |
| + unsigned internalformat, |
| + unsigned usage) { |
| + return IsFormatSupported(internalformat) && IsUsageSupported(usage); |
| +} |
| + |
| +bool GpuMemoryBufferImplOzoneNativeBuffer::InitializeFromHandle( |
| + const gfx::GpuMemoryBufferHandle& handle) { |
| + id_ = handle.global_id; |
| + return true; |
| +} |
| + |
| +void* GpuMemoryBufferImplOzoneNativeBuffer::Map() { |
| + NOTREACHED(); |
| + return NULL; |
| +} |
| + |
| +void GpuMemoryBufferImplOzoneNativeBuffer::Unmap() { |
| + NOTREACHED(); |
| +} |
| + |
| +uint32 GpuMemoryBufferImplOzoneNativeBuffer::GetStride() const { |
| + NOTREACHED(); |
| + return 0; |
| +} |
| + |
| +gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativeBuffer::GetHandle() |
| + const { |
| + gfx::GpuMemoryBufferHandle handle; |
| + handle.type = gfx::OZONE_NATIVE_BUFFER; |
| + handle.global_id = id_; |
| + return handle; |
| +} |
| + |
| +void GpuMemoryBufferImplOzoneNativeBuffer::OnGpuMemoryBufferCreated( |
| + const AllocationCallback& callback, |
| + const gfx::GpuMemoryBufferHandle& handle) { |
| + callback.Run(handle); |
| +} |
| + |
| +} // namespace content |