| Index: content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
|
| diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc b/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
|
| index c4e9a03fe77f4ff2ab85fec5e67792f271f91a7c..478d7c97674f9ad67a2848309113dd0eb45171f0 100644
|
| --- a/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
|
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
|
| @@ -4,34 +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_io_surface.h"
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
|
|
|
| namespace content {
|
|
|
| // static
|
| -void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id,
|
| +void GpuMemoryBufferImpl::GetSupportedTypes(
|
| + std::vector<gfx::GpuMemoryBufferType>* types) {
|
| + const gfx::GpuMemoryBufferType supported_types[] = {
|
| + gfx::IO_SURFACE_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::IO_SURFACE_BUFFER:
|
| + return GpuMemoryBufferImplIOSurface::IsFormatSupported(format) &&
|
| + GpuMemoryBufferImplIOSurface::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 (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(format, usage)) {
|
| - GpuMemoryBufferImplIOSurface::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::IO_SURFACE_BUFFER:
|
| + GpuMemoryBufferImplIOSurface::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,
|
| @@ -39,20 +70,19 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
|
| base::ProcessHandle child_process,
|
| int child_client_id,
|
| const AllocationCallback& callback) {
|
| - if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(format, usage)) {
|
| - GpuMemoryBufferImplIOSurface::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::IO_SURFACE_BUFFER:
|
| + GpuMemoryBufferImplIOSurface::AllocateForChildProcess(
|
| + id, size, format, child_client_id, callback);
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| }
|
| -
|
| - callback.Run(gfx::GpuMemoryBufferHandle());
|
| }
|
|
|
| // static
|
| @@ -89,6 +119,7 @@ scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
|
| return GpuMemoryBufferImplIOSurface::CreateFromHandle(
|
| handle, size, format, callback);
|
| default:
|
| + NOTREACHED();
|
| return scoped_ptr<GpuMemoryBufferImpl>();
|
| }
|
| }
|
|
|