Chromium Code Reviews| Index: content/common/gpu/gpu_command_buffer_stub.cc |
| diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc |
| index e14cf986092b9c8817dcd3024e2474890734c368..eeab83ba443df069b85d8e926152dc7b7c50bc37 100644 |
| --- a/content/common/gpu/gpu_command_buffer_stub.cc |
| +++ b/content/common/gpu/gpu_command_buffer_stub.cc |
| @@ -940,11 +940,12 @@ void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( |
| } |
| } |
| -void GpuCommandBufferStub::OnCreateImage(int32 id, |
| - gfx::GpuMemoryBufferHandle handle, |
| - gfx::Size size, |
| - gfx::GpuMemoryBuffer::Format format, |
| - uint32 internalformat) { |
| +void GpuCommandBufferStub::OnCreateImage( |
| + int32 id, |
| + std::vector<gfx::GpuMemoryBufferHandle> handles, |
| + gfx::Size size, |
| + std::vector<gfx::GpuMemoryBuffer::Format> formats, |
| + uint32 internalformat) { |
| TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage"); |
| if (!decoder_) |
| @@ -957,26 +958,46 @@ void GpuCommandBufferStub::OnCreateImage(int32 id, |
| return; |
| } |
| - if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( |
| - format, decoder_->GetCapabilities())) { |
| - LOG(ERROR) << "Format is not supported."; |
| + int num_buffers = |
| + gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat); |
| + if (num_buffers < 1) { |
| + LOG(ERROR) << "Internalformat is not supported."; |
|
reveman
2015/03/12 19:37:22
Please add an gpu::ImageFactory::IsFormatSupported
emircan
2015/03/12 22:34:26
Done.
|
| return; |
| } |
| - if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(size, |
| - format)) { |
| - LOG(ERROR) << "Invalid image size for format."; |
| + // Checks to make sure that the input isn't coming from a malicious renderer. |
| + if (static_cast<int>(handles.size()) != num_buffers) { |
| + LOG(ERROR) << "Invalid number of GpuMemoryBufferHandle given for " |
| + "internalformat."; |
| return; |
| } |
| - |
| - if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
| - internalformat, format)) { |
| - LOG(ERROR) << "Incompatible image format."; |
| + if (static_cast<int>(formats.size()) != num_buffers) { |
| + LOG(ERROR) << "Invalid number of GpuMemoryBuffer::Format given for " |
| + "internalformat."; |
| return; |
| } |
| - scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer( |
| - handle, size, format, internalformat); |
| + for (int i = 0; i < num_buffers; ++i) { |
| + const gfx::GpuMemoryBuffer::Format& format = formats[i]; |
| + if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( |
| + format, decoder_->GetCapabilities())) { |
| + LOG(ERROR) << "Format is not supported."; |
| + return; |
| + } |
| + if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
| + size, format)) { |
| + LOG(ERROR) << "Invalid image size for format."; |
| + return; |
| + } |
| + if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
| + internalformat, i, format)) { |
| + LOG(ERROR) << "Incompatible image format."; |
| + return; |
| + } |
| + } |
| + |
| + scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffers( |
| + handles, size, formats, internalformat); |
| if (!image.get()) |
| return; |