Index: gpu/command_buffer/service/in_process_command_buffer.cc |
diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc |
index c4fa167800478e1887431a4b14524413271e8053..ce6ea433aa08d8c4a3d7d9e79739198289b8843b 100644 |
--- a/gpu/command_buffer/service/in_process_command_buffer.cc |
+++ b/gpu/command_buffer/service/in_process_command_buffer.cc |
@@ -700,41 +700,53 @@ gpu::Capabilities InProcessCommandBuffer::GetCapabilities() { |
return capabilities_; |
} |
-int32 InProcessCommandBuffer::CreateImage(ClientBuffer buffer, |
+int32 InProcessCommandBuffer::CreateImage(ClientBuffer* const buffers, |
size_t width, |
size_t height, |
unsigned internalformat) { |
CheckSequencedThread(); |
DCHECK(gpu_memory_buffer_manager_); |
- gfx::GpuMemoryBuffer* gpu_memory_buffer = |
- gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer); |
- DCHECK(gpu_memory_buffer); |
- |
int32 new_id = next_image_id_.GetNext(); |
- DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
- internalformat, gpu_memory_buffer->GetFormat())); |
- |
- // This handle is owned by the GPU thread and must be passed to it or it |
- // will leak. In otherwords, do not early out on error between here and the |
- // queuing of the CreateImage task below. |
- bool requires_sync_point = false; |
- gfx::GpuMemoryBufferHandle handle = |
- ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(), |
- &requires_sync_point); |
+ int num_buffers = |
+ gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat); |
+ |
+ gfx::GpuMemoryBuffer* gpu_memory_buffers[num_buffers]; |
+ std::vector<gfx::GpuMemoryBufferHandle> handles(num_buffers); |
+ std::vector<gfx::GpuMemoryBuffer::Format> formats(num_buffers); |
+ bool requires_sync_point[num_buffers]; |
+ for (int i = 0; i < num_buffers; ++i) { |
+ gpu_memory_buffers[i] = |
+ gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffers[i]); |
+ DCHECK(gpu_memory_buffers[i]); |
+ |
+ formats[i] = gpu_memory_buffers[i]->GetFormat(); |
+ DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
+ internalformat, formats[i])); |
+ |
+ requires_sync_point[i] = false; |
+ |
+ // This handle is owned by the GPU thread and must be passed to it or it |
+ // will leak. In otherwords, do not early out on error between here and the |
+ // queuing of the CreateImage task below. |
+ handles[i] = ShareGpuMemoryBufferToGpuThread( |
+ gpu_memory_buffers[i]->GetHandle(), &requires_sync_point[i]); |
+ } |
QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, |
base::Unretained(this), |
new_id, |
- handle, |
+ handles, |
gfx::Size(width, height), |
- gpu_memory_buffer->GetFormat(), |
+ formats, |
internalformat)); |
- if (requires_sync_point) { |
- gpu_memory_buffer_manager_->SetDestructionSyncPoint(gpu_memory_buffer, |
- InsertSyncPoint()); |
+ for (int i = 0; i < num_buffers; ++i) { |
+ if (requires_sync_point[i]) { |
+ gpu_memory_buffer_manager_->SetDestructionSyncPoint(gpu_memory_buffers[i], |
+ InsertSyncPoint()); |
+ } |
} |
return new_id; |
@@ -742,9 +754,9 @@ int32 InProcessCommandBuffer::CreateImage(ClientBuffer buffer, |
void InProcessCommandBuffer::CreateImageOnGpuThread( |
int32 id, |
- const gfx::GpuMemoryBufferHandle& handle, |
+ const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
const gfx::Size& size, |
- gfx::GpuMemoryBuffer::Format format, |
+ const std::vector<gfx::GpuMemoryBuffer::Format>& formats, |
uint32 internalformat) { |
if (!decoder_) |
return; |
@@ -761,8 +773,8 @@ void InProcessCommandBuffer::CreateImageOnGpuThread( |
DCHECK(image_factory_); |
scoped_refptr<gfx::GLImage> image = |
- image_factory_->CreateImageForGpuMemoryBuffer( |
- handle, size, format, internalformat, kClientId); |
+ image_factory_->CreateImageForGpuMemoryBuffer(handles, size, formats, |
+ internalformat, kClientId); |
if (!image.get()) |
return; |
@@ -798,16 +810,27 @@ int32 InProcessCommandBuffer::CreateGpuMemoryBufferImage( |
unsigned usage) { |
CheckSequencedThread(); |
+ std::vector<gfx::GpuMemoryBuffer::Format> gpu_memory_buffer_formats; |
+ gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormats( |
+ internalformat, &gpu_memory_buffer_formats); |
+ int num_buffers = gpu_memory_buffer_formats.size(); |
+ |
+ DCHECK_GE(num_buffers, 1); |
DCHECK(gpu_memory_buffer_manager_); |
- scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
- 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); |
+ |
+ ScopedVector<gfx::GpuMemoryBuffer> buffers; |
+ ClientBuffer client_buffers[num_buffers]; |
+ for (int i = 0; i < num_buffers; ++i) { |
+ buffers.push_back(gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
+ gfx::Size(width, height), gpu_memory_buffer_formats[i], |
+ gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); |
+ |
+ if (!buffers[i]) |
+ return -1; |
+ |
+ client_buffers[i] = buffers[i]->AsClientBuffer(); |
+ } |
+ return CreateImage(client_buffers, width, height, internalformat); |
} |
uint32 InProcessCommandBuffer::InsertSyncPoint() { |