Chromium Code Reviews| 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..e6463b4cb3a3c7f79b4833b0595ff2ffc924e191 100644 |
| --- a/content/common/gpu/gpu_channel.cc |
| +++ b/content/common/gpu/gpu_channel.cc |
| @@ -827,18 +827,39 @@ 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 = |
|
reveman
2015/03/18 16:59:01
num_buffers = IsImageFormatSupported, that doesn't
emircan
2015/03/18 23:51:26
Done.
|
| + gpu::ImageFactory::IsImageFormatSupported(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>(); |
| + } |
|
reveman
2015/03/18 16:59:01
We could do this in a more C++-ish way with someth
emircan
2015/03/18 23:51:26
Acknowledged.
I agree it looks better with find_i
|
| + |
| + switch (handle_type) { |
| case gfx::SHARED_MEMORY_BUFFER: { |
| + // TODO(emircan): See http://crbug.com/439520; support passing multiple |
| + // buffers when new multi-planar formats are added. |
|
reveman
2015/03/18 16:59:01
I think you can remove this comment as it's not cl
emircan
2015/03/18 23:51:26
Done.
|
| + if (num_buffers != 1) { |
| + NOTIMPLEMENTED(); |
|
reveman
2015/03/18 16:59:01
I don't think we need NOTIMPLEMENTED here. Just a
emircan
2015/03/18 23:51:26
Changed it to a DLOG(ERROR). Possible to make it a
|
| + 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 +869,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_); |
| } |
| } |
| } |