Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 1421293006: Mac: Use GpuMemoryBuffers by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable when native GMBs are disabled Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 IsGpuMemoryBufferConfigurationSupported(format, usage); 94 IsGpuMemoryBufferConfigurationSupported(format, usage);
95 #endif 95 #endif
96 default: 96 default:
97 NOTREACHED(); 97 NOTREACHED();
98 return false; 98 return false;
99 } 99 }
100 } 100 }
101 101
102 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() { 102 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() {
103 GpuMemoryBufferConfigurationSet configurations; 103 GpuMemoryBufferConfigurationSet configurations;
104 #if defined(OS_MACOSX)
105 bool enable_native_gpu_memory_buffers =
106 !base::CommandLine::ForCurrentProcess()->HasSwitch(
107 switches::kDisableNativeGpuMemoryBuffers);
108 #else
109 bool enable_native_gpu_memory_buffers =
110 base::CommandLine::ForCurrentProcess()->HasSwitch(
111 switches::kEnableNativeGpuMemoryBuffers);
112 #endif
113 104
114 #if defined(USE_OZONE) || defined(OS_MACOSX) 105 if (BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled()) {
115 bool force_native_gpu_read_write_formats = true;
116 #else
117 bool force_native_gpu_read_write_formats = false;
118 #endif
119
120 // Disable native buffers when using Mesa.
121 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
122 switches::kUseGL) == gfx::kGLImplementationOSMesaName) {
123 enable_native_gpu_memory_buffers = false;
124 force_native_gpu_read_write_formats = false;
125 }
126
127 if (enable_native_gpu_memory_buffers) {
128 const gfx::BufferFormat kNativeFormats[] = { 106 const gfx::BufferFormat kNativeFormats[] = {
129 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444, 107 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444,
130 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888, 108 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888,
131 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR}; 109 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR};
132 const gfx::BufferUsage kNativeUsages[] = { 110 const gfx::BufferUsage kNativeUsages[] = {
133 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, 111 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT,
134 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, 112 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
135 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; 113 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT};
136 for (auto& format : kNativeFormats) { 114 for (auto& format : kNativeFormats) {
137 for (auto& usage : kNativeUsages) { 115 for (auto& usage : kNativeUsages) {
138 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage)) 116 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage))
139 configurations.insert(std::make_pair(format, usage)); 117 configurations.insert(std::make_pair(format, usage));
140 } 118 }
141 } 119 }
142 } 120 }
143 121
122 #if defined(USE_OZONE) || defined(OS_MACOSX)
123 // Disable native buffers only when using Mesa.
124 bool force_native_gpu_read_write_formats =
125 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
126 switches::kUseGL) != gfx::kGLImplementationOSMesaName;
127 #else
128 bool force_native_gpu_read_write_formats = false;
129 #endif
144 if (force_native_gpu_read_write_formats) { 130 if (force_native_gpu_read_write_formats) {
145 const gfx::BufferFormat kGPUReadWriteFormats[] = { 131 const gfx::BufferFormat kGPUReadWriteFormats[] = {
146 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888, 132 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888,
147 gfx::BufferFormat::BGRA_8888, gfx::BufferFormat::BGRX_8888, 133 gfx::BufferFormat::BGRA_8888, gfx::BufferFormat::BGRX_8888,
148 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR}; 134 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR};
149 const gfx::BufferUsage kGPUReadWriteUsages[] = { 135 const gfx::BufferUsage kGPUReadWriteUsages[] = {
150 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT}; 136 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT};
151 for (auto& format : kGPUReadWriteFormats) { 137 for (auto& format : kGPUReadWriteFormats) {
152 for (auto& usage : kGPUReadWriteUsages) { 138 for (auto& usage : kGPUReadWriteUsages) {
153 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage)) 139 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage))
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() { 202 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() {
217 g_gpu_memory_buffer_manager = nullptr; 203 g_gpu_memory_buffer_manager = nullptr;
218 } 204 }
219 205
220 // static 206 // static
221 BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() { 207 BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() {
222 return g_gpu_memory_buffer_manager; 208 return g_gpu_memory_buffer_manager;
223 } 209 }
224 210
225 // static 211 // static
212 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() {
213 // Disable native buffers when using Mesa.
214 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
215 switches::kUseGL) == gfx::kGLImplementationOSMesaName) {
216 return false;
217 }
218
219 #if defined(OS_MACOSX)
220 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
221 switches::kDisableNativeGpuMemoryBuffers);
222 #else
223 return base::CommandLine::ForCurrentProcess()->HasSwitch(
224 switches::kEnableNativeGpuMemoryBuffers);
225 #endif
226 }
227
228 // static
226 uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget( 229 uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget(
227 gfx::BufferFormat format, 230 gfx::BufferFormat format,
228 gfx::BufferUsage usage) { 231 gfx::BufferUsage usage) {
229 GpuMemoryBufferConfigurationSet native_configurations = 232 GpuMemoryBufferConfigurationSet native_configurations =
230 GetNativeGpuMemoryBufferConfigurations(); 233 GetNativeGpuMemoryBufferConfigurations();
231 if (native_configurations.find(std::make_pair(format, usage)) == 234 if (native_configurations.find(std::make_pair(format, usage)) ==
232 native_configurations.end()) { 235 native_configurations.end()) {
233 return GL_TEXTURE_2D; 236 return GL_TEXTURE_2D;
234 } 237 }
235 238
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 return gpu_client_tracing_id_; 742 return gpu_client_tracing_id_;
740 } 743 }
741 744
742 // In normal cases, |client_id| is a child process id, so we can perform 745 // In normal cases, |client_id| is a child process id, so we can perform
743 // the standard conversion. 746 // the standard conversion.
744 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 747 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
745 client_id); 748 client_id);
746 } 749 }
747 750
748 } // namespace content 751 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_memory_buffer_manager.h ('k') | content/browser/gpu/compositor_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698