Index: content/common/gpu/gpu_channel.cc |
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc |
index c12c762c6004f725973182513535274cc6ac2cc7..4df55ea251328faa550a26f32c0d5259bf73c8d3 100644 |
--- a/content/common/gpu/gpu_channel.cc |
+++ b/content/common/gpu/gpu_channel.cc |
@@ -827,18 +827,38 @@ uint64 GpuChannel::GetMemoryUsage() { |
return size; |
} |
-scoped_refptr<gfx::GLImage> GpuChannel::CreateImageForGpuMemoryBuffer( |
- const gfx::GpuMemoryBufferHandle& handle, |
+scoped_refptr<gfx::GLImage> GpuChannel::CreateImageForGpuMemoryBuffers( |
+ const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
const gfx::Size& size, |
- gfx::GpuMemoryBuffer::Format format, |
+ const std::vector<gfx::GpuMemoryBuffer::Format>& formats, |
uint32 internalformat) { |
- switch (handle.type) { |
+ size_t num_buffers = |
+ gpu::ImageFactory::NumberOfPlanesForImageFormat(internalformat); |
+ |
+ // Make sure that the gives vectors have the correct size. |
+ DCHECK_EQ(handles.size(), num_buffers); |
+ DCHECK_EQ(formats.size(), num_buffers); |
+ |
+ // Check if all the handle types are equal, and if they aren't, return an |
+ // empty image. |
+ gfx::GpuMemoryBufferType handle_type = handles[0].type; |
+ for (size_t i = 1; i < num_buffers; ++i) { |
+ if (handles[i].type != handle_type) |
+ return scoped_refptr<gfx::GLImage>(); |
+ } |
+ |
+ switch (handle_type) { |
case gfx::SHARED_MEMORY_BUFFER: { |
+ if (num_buffers != 1) { |
+ DLOG(ERROR) |
+ << "SHARED_MEMORY_BUFFER doesn't support multi-plane formats."; |
+ return scoped_refptr<gfx::GLImage>(); |
+ } |
+ |
scoped_refptr<gfx::GLImageSharedMemory> image( |
new gfx::GLImageSharedMemory(size, internalformat)); |
- if (!image->Initialize(handle, format)) |
+ if (!image->Initialize(handles[0], formats[0])) |
return scoped_refptr<gfx::GLImage>(); |
- |
return image; |
} |
default: { |
@@ -848,11 +868,8 @@ scoped_refptr<gfx::GLImage> GpuChannel::CreateImageForGpuMemoryBuffer( |
return manager->gpu_memory_buffer_factory() |
->AsImageFactory() |
- ->CreateImageForGpuMemoryBuffer(handle, |
- size, |
- format, |
- internalformat, |
- client_id_); |
+ ->CreateImageForGpuMemoryBuffers(handles, size, formats, |
+ internalformat, client_id_); |
} |
} |
} |