Chromium Code Reviews| Index: content/browser/gpu/browser_gpu_channel_host_factory.cc |
| diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc |
| index 205542cdc81e918839841fbbeb55d99e16c6cadd..a2e4627e202fb09ad1c1bf237268d059600da893 100644 |
| --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc |
| +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc |
| @@ -16,6 +16,7 @@ |
| #include "content/browser/gpu/gpu_process_host.h" |
| #include "content/browser/gpu/gpu_surface_tracker.h" |
| #include "content/common/child_process_host_impl.h" |
| +#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
| #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| #include "content/common/gpu/gpu_messages.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -254,16 +255,26 @@ bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( |
| } |
| // static |
| -uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget() { |
| - if (!IsGpuMemoryBufferFactoryUsageEnabled(gfx::GpuMemoryBuffer::MAP)) |
| +uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget( |
| + gfx::GpuMemoryBuffer::Format format, |
| + gfx::GpuMemoryBuffer::Usage usage) { |
| + if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) |
| return GL_TEXTURE_2D; |
| std::vector<gfx::GpuMemoryBufferType> supported_types; |
| GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); |
| DCHECK(!supported_types.empty()); |
| - // The GPU service will always use the preferred type. |
| + // The GPU service will always use the preferred type, if the |format| and |
| + // |usage| allows. |
| gfx::GpuMemoryBufferType type = supported_types[0]; |
| + // If the native buffer type does not support the |format| and |usage| then |
| + // we must fallback to shared memory buffers, which do support them. |
|
reveman
2015/05/20 14:26:07
The condition for |format| and |usage| not being s
danakj
2015/05/20 17:51:14
Done.
|
| + if (!IsGpuMemoryBufferConfigurationSupportedInternal(format, usage)) { |
| + DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format)); |
| + DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)); |
| + type = gfx::SHARED_MEMORY_BUFFER; |
|
reveman
2015/05/20 14:26:08
I don't see a good reason for handling this differ
danakj
2015/05/20 17:51:14
Done.
|
| + } |
| switch (type) { |
| case gfx::SURFACE_TEXTURE_BUFFER: |
| @@ -467,11 +478,18 @@ void BrowserGpuChannelHostFactory::AddFilterOnIO( |
| bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported( |
| gfx::GpuMemoryBuffer::Format format, |
| gfx::GpuMemoryBuffer::Usage usage) { |
| + return IsGpuMemoryBufferConfigurationSupportedInternal(format, usage); |
| +} |
| + |
| +// static |
| +bool BrowserGpuChannelHostFactory:: |
| + IsGpuMemoryBufferConfigurationSupportedInternal( |
| + gfx::GpuMemoryBuffer::Format format, |
| + gfx::GpuMemoryBuffer::Usage usage) { |
| // Return early if usage is not enabled. |
| if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) |
|
reveman
2015/05/20 14:26:07
Please remove this check from this helper function
danakj
2015/05/20 17:51:14
Done.
|
| return false; |
| - // Preferred type is always used by factory. |
| std::vector<gfx::GpuMemoryBufferType> supported_types; |
| GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); |
|
reveman
2015/05/20 14:26:07
Please pass the type as a parameter to this helper
danakj
2015/05/20 17:51:14
Done.
|
| DCHECK(!supported_types.empty()); |