Index: content/common/gpu/client/command_buffer_proxy_impl.cc |
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc |
index 8241812cc2af9aa068f6bce602727e67ecf841eb..49bd355b02028c33bdd1a7fbf38b9a571a0ed3cf 100644 |
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc |
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc |
@@ -347,7 +347,7 @@ gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() { |
return capabilities_; |
} |
-int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, |
+int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer* const buffers, |
size_t width, |
size_t height, |
unsigned internalformat) { |
@@ -359,34 +359,55 @@ int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, |
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
channel_->gpu_memory_buffer_manager(); |
- gfx::GpuMemoryBuffer* gpu_memory_buffer = |
- gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer); |
- DCHECK(gpu_memory_buffer); |
- // This handle is owned by the GPU process and must be passed to it or it |
- // will leak. In otherwords, do not early out on error between here and the |
- // sending of the CreateImage IPC below. |
+ int num_buffers = |
+ gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat); |
+ std::vector<gfx::GpuMemoryBufferHandle> handles; |
+ handles.reserve(num_buffers); |
+ std::vector<gfx::GpuMemoryBuffer::Format> formats; |
+ formats.reserve(num_buffers); |
bool requires_sync_point = false; |
- gfx::GpuMemoryBufferHandle handle = |
- channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), |
- &requires_sync_point); |
- |
- DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
- gfx::Size(width, height), gpu_memory_buffer->GetFormat())); |
- DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
- internalformat, gpu_memory_buffer->GetFormat())); |
+ |
+ for (int i = 0; i < num_buffers; ++i) { |
+ gfx::GpuMemoryBuffer* gpu_memory_buffer = |
+ gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffers[i]); |
+ DCHECK(gpu_memory_buffer); |
+ |
+ formats.push_back(gpu_memory_buffer->GetFormat()); |
+ DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
+ gfx::Size(width, height), formats[i])); |
+ DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
+ internalformat, i, formats[i])); |
+ |
+ bool buffer_requires_sync_point = false; |
+ // This handle is owned by the GPU process and must be passed to it or it |
+ // will leak. In other words, do not early out on error between here and the |
+ // sending of the CreateImage IPC below. |
+ handles[i] = channel_->ShareGpuMemoryBufferToGpuProcess( |
+ gpu_memory_buffer->GetHandle(), &buffer_requires_sync_point); |
+ |
+ // We want to set a destruction sync point on all buffers if one happen to |
+ // require one. |
+ requires_sync_point |= buffer_requires_sync_point; |
+ } |
+ |
if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, |
new_id, |
- handle, |
+ handles, |
gfx::Size(width, height), |
- gpu_memory_buffer->GetFormat(), |
+ formats, |
internalformat))) { |
return -1; |
} |
if (requires_sync_point) { |
- gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, |
- InsertSyncPoint()); |
+ for (int i = 0; i < num_buffers; ++i) { |
+ gfx::GpuMemoryBuffer* gpu_memory_buffer = |
+ gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer( |
+ buffers[i]); |
+ gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, |
+ InsertSyncPoint()); |
+ } |
} |
return new_id; |
@@ -406,15 +427,28 @@ int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( |
unsigned internalformat, |
unsigned usage) { |
CheckLock(); |
- scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
- channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( |
- gfx::Size(width, height), |
- gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), |
- gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); |
- if (!buffer) |
- return -1; |
- return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); |
+ int num_buffers = |
+ gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat); |
+ DCHECK_GE(num_buffers, 1); |
+ |
+ ScopedVector<gfx::GpuMemoryBuffer> buffers; |
+ ClientBuffer client_buffers[num_buffers]; |
+ for (int i = 0; i < num_buffers; ++i) { |
+ gfx::GpuMemoryBuffer::Format format = |
+ gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat, |
+ i); |
+ buffers.push_back( |
+ channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( |
+ gfx::Size(width, height), format, |
+ gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); |
+ |
+ if (!buffers[i]) |
+ return -1; |
+ |
+ client_buffers[i] = buffers[i]->AsClientBuffer(); |
+ } |
+ return CreateImage(client_buffers, width, height, internalformat); |
} |
int CommandBufferProxyImpl::GetRouteID() const { |