diff options
author | ccameron <ccameron@chromium.org> | 2015-11-09 23:13:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-10 07:14:33 +0000 |
commit | a956c997fd06f9e1798b1d81d99a7eb1f23bb0b1 (patch) | |
tree | 0cad6c9612a7bef6c1ddab1f4aaa10ba24d3a2e0 | |
parent | d45a6adf19f317d2711ae47b312d86be39259013 (diff) | |
download | chromium_src-a956c997fd06f9e1798b1d81d99a7eb1f23bb0b1.zip chromium_src-a956c997fd06f9e1798b1d81d99a7eb1f23bb0b1.tar.gz chromium_src-a956c997fd06f9e1798b1d81d99a7eb1f23bb0b1.tar.bz2 |
Mac: Use GpuMemoryBuffers by default
Keep the feature disabled by default when GPU raster is enabled, as
the two features are incompatible.
BUG=533677
Committed: https://crrev.com/532a123352590fe939e3266ea51cc96e2559cefe
Cr-Commit-Position: refs/heads/master@{#358411}
Review URL: https://codereview.chromium.org/1421293006
Cr-Commit-Position: refs/heads/master@{#358800}
-rw-r--r-- | content/browser/gpu/browser_gpu_memory_buffer_manager.cc | 49 | ||||
-rw-r--r-- | content/browser/gpu/browser_gpu_memory_buffer_manager.h | 2 | ||||
-rw-r--r-- | content/browser/gpu/compositor_util.cc | 27 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 4 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 1 |
5 files changed, 58 insertions, 25 deletions
diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc index b7f36b6..7a5921a 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc @@ -101,30 +101,8 @@ bool IsNativeGpuMemoryBufferFactoryConfigurationSupported( GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() { GpuMemoryBufferConfigurationSet configurations; -#if defined(OS_MACOSX) - bool enable_native_gpu_memory_buffers = - !base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableNativeGpuMemoryBuffers); -#else - bool enable_native_gpu_memory_buffers = - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableNativeGpuMemoryBuffers); -#endif - -#if defined(USE_OZONE) || defined(OS_MACOSX) - bool force_native_gpu_read_write_formats = true; -#else - bool force_native_gpu_read_write_formats = false; -#endif - // Disable native buffers when using Mesa. - if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kUseGL) == gfx::kGLImplementationOSMesaName) { - enable_native_gpu_memory_buffers = false; - force_native_gpu_read_write_formats = false; - } - - if (enable_native_gpu_memory_buffers) { + if (BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled()) { const gfx::BufferFormat kNativeFormats[] = { gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444, gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888, @@ -141,6 +119,14 @@ GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() { } } +#if defined(USE_OZONE) || defined(OS_MACOSX) + // Disable native buffers only when using Mesa. + bool force_native_gpu_read_write_formats = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kUseGL) != gfx::kGLImplementationOSMesaName; +#else + bool force_native_gpu_read_write_formats = false; +#endif if (force_native_gpu_read_write_formats) { const gfx::BufferFormat kGPUReadWriteFormats[] = { gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888, @@ -223,6 +209,23 @@ BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() { } // static +bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() { + // Disable native buffers when using Mesa. + if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kUseGL) == gfx::kGLImplementationOSMesaName) { + return false; + } + +#if defined(OS_MACOSX) + return !base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableNativeGpuMemoryBuffers); +#else + return base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableNativeGpuMemoryBuffers); +#endif +} + +// static uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget( gfx::BufferFormat format, gfx::BufferUsage usage) { diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.h b/content/browser/gpu/browser_gpu_memory_buffer_manager.h index 09c8f73..c54be22 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.h +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.h @@ -51,6 +51,8 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager static BrowserGpuMemoryBufferManager* current(); + static bool IsNativeGpuMemoryBuffersEnabled(); + static uint32 GetImageTextureTarget(gfx::BufferFormat format, gfx::BufferUsage usage); diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc index 1b77f8b..10f507b 100644 --- a/content/browser/gpu/compositor_util.cc +++ b/content/browser/gpu/compositor_util.cc @@ -12,6 +12,7 @@ #include "build/build_config.h" #include "cc/base/math_util.h" #include "cc/base/switches.h" +#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" #include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/public/common/content_switches.h" #include "gpu/config/gpu_feature_type.h" @@ -219,8 +220,30 @@ bool IsPartialRasterEnabled() { bool IsGpuMemoryBufferCompositorResourcesEnabled() { const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - return command_line.HasSwitch( - switches::kEnableGpuMemoryBufferCompositorResources); + if (command_line.HasSwitch( + switches::kEnableGpuMemoryBufferCompositorResources)) { + return true; + } + if (command_line.HasSwitch( + switches::kDisableGpuMemoryBufferCompositorResources)) { + return false; + } + + // Native GPU memory buffers are required. + if (!BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled()) + return false; + + // GPU rasterization does not support GL_TEXTURE_RECTANGLE_ARB, which is + // required by GpuMemoryBuffers on Mac. + // http://crbug.com/551072 + if (IsForceGpuRasterizationEnabled() || IsGpuRasterizationEnabled()) + return false; + +#if defined(OS_MACOSX) + return true; +#else + return false; +#endif } bool IsGpuRasterizationEnabled() { diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 44acc09..09d758d 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -122,6 +122,10 @@ const char kDisableGpuCompositing[] = "disable-gpu-compositing"; // Disable proactive early init of GPU process. const char kDisableGpuEarlyInit[] = "disable-gpu-early-init"; +// Do not force that all compositor resources be backed by GPU memory buffers. +const char kDisableGpuMemoryBufferCompositorResources[] = + "disable-gpu-memory-buffer-compositor-resources"; + // Disable GpuMemoryBuffer backed VideoFrames. const char kDisableGpuMemoryBufferVideoFrames[] = "disable-gpu-memory-buffer-video-frames"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 079cab7..5c41bee 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -49,6 +49,7 @@ CONTENT_EXPORT extern const char kDisableFlashStage3d[]; CONTENT_EXPORT extern const char kDisableGpu[]; CONTENT_EXPORT extern const char kDisableGpuCompositing[]; CONTENT_EXPORT extern const char kDisableGpuEarlyInit[]; +CONTENT_EXPORT extern const char kDisableGpuMemoryBufferCompositorResources[]; CONTENT_EXPORT extern const char kDisableGpuMemoryBufferVideoFrames[]; extern const char kDisableGpuProcessCrashLimit[]; CONTENT_EXPORT extern const char kDisableGpuRasterization[]; |