| Index: content/common/gpu/client/gpu_memory_buffer_impl_android.cc
|
| diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_android.cc b/content/common/gpu/client/gpu_memory_buffer_impl_android.cc
|
| index 9c0fdb368c67b02d9bb7ac985828663d7b6ccf16..cc82b06c41d3bd4f8f0d166b316caccd171a0422 100644
|
| --- a/content/common/gpu/client/gpu_memory_buffer_impl_android.cc
|
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl_android.cc
|
| @@ -4,36 +4,65 @@
|
|
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
|
|
|
| +#include "base/logging.h"
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h"
|
|
|
| namespace content {
|
|
|
| // static
|
| -void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id,
|
| +void GpuMemoryBufferImpl::GetSupportedTypes(
|
| + std::vector<gfx::GpuMemoryBufferType>* types) {
|
| + const gfx::GpuMemoryBufferType supported_types[] = {
|
| + gfx::SURFACE_TEXTURE_BUFFER,
|
| + gfx::SHARED_MEMORY_BUFFER
|
| + };
|
| + types->assign(supported_types, supported_types + arraysize(supported_types));
|
| +}
|
| +
|
| +// static
|
| +bool GpuMemoryBufferImpl::IsConfigurationSupported(
|
| + gfx::GpuMemoryBufferType type,
|
| + Format format,
|
| + Usage usage) {
|
| + switch (type) {
|
| + case gfx::SHARED_MEMORY_BUFFER:
|
| + return GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) &&
|
| + GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage);
|
| + case gfx::SURFACE_TEXTURE_BUFFER:
|
| + return GpuMemoryBufferImplSurfaceTexture::IsFormatSupported(format) &&
|
| + GpuMemoryBufferImplSurfaceTexture::IsUsageSupported(usage);
|
| + default:
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +// static
|
| +void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferType type,
|
| + gfx::GpuMemoryBufferId id,
|
| const gfx::Size& size,
|
| Format format,
|
| Usage usage,
|
| int client_id,
|
| const CreationCallback& callback) {
|
| - if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(format,
|
| - usage)) {
|
| - GpuMemoryBufferImplSurfaceTexture::Create(
|
| - id, size, format, client_id, callback);
|
| - return;
|
| - }
|
| -
|
| - if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
|
| - size, format, usage)) {
|
| - GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
|
| - return;
|
| + switch (type) {
|
| + case gfx::SHARED_MEMORY_BUFFER:
|
| + GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
|
| + break;
|
| + case gfx::SURFACE_TEXTURE_BUFFER:
|
| + GpuMemoryBufferImplSurfaceTexture::Create(
|
| + id, size, format, client_id, callback);
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| }
|
| -
|
| - callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
|
| }
|
|
|
| // static
|
| void GpuMemoryBufferImpl::AllocateForChildProcess(
|
| + gfx::GpuMemoryBufferType type,
|
| gfx::GpuMemoryBufferId id,
|
| const gfx::Size& size,
|
| Format format,
|
| @@ -41,21 +70,19 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
|
| base::ProcessHandle child_process,
|
| int child_client_id,
|
| const AllocationCallback& callback) {
|
| - if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(format,
|
| - usage)) {
|
| - GpuMemoryBufferImplSurfaceTexture::AllocateForChildProcess(
|
| - id, size, format, child_client_id, callback);
|
| - return;
|
| - }
|
| -
|
| - if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
|
| - size, format, usage)) {
|
| - GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
|
| - id, size, format, child_process, callback);
|
| - return;
|
| + switch (type) {
|
| + case gfx::SHARED_MEMORY_BUFFER:
|
| + GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
|
| + id, size, format, child_process, callback);
|
| + break;
|
| + case gfx::SURFACE_TEXTURE_BUFFER:
|
| + GpuMemoryBufferImplSurfaceTexture::AllocateForChildProcess(
|
| + id, size, format, child_client_id, callback);
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| }
|
| -
|
| - callback.Run(gfx::GpuMemoryBufferHandle());
|
| }
|
|
|
| // static
|
| @@ -92,6 +119,7 @@ scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
|
| return GpuMemoryBufferImplSurfaceTexture::CreateFromHandle(
|
| handle, size, format, callback);
|
| default:
|
| + NOTREACHED();
|
| return scoped_ptr<GpuMemoryBufferImpl>();
|
| }
|
| }
|
|
|