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

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

Issue 1643293002: BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() return true if at least one native… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 case gfx::OZONE_NATIVE_PIXMAP: 95 case gfx::OZONE_NATIVE_PIXMAP:
96 return GpuMemoryBufferFactoryOzoneNativePixmap:: 96 return GpuMemoryBufferFactoryOzoneNativePixmap::
97 IsGpuMemoryBufferConfigurationSupported(format, usage); 97 IsGpuMemoryBufferConfigurationSupported(format, usage);
98 #endif 98 #endif
99 default: 99 default:
100 NOTREACHED(); 100 NOTREACHED();
101 return false; 101 return false;
102 } 102 }
103 } 103 }
104 104
105 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() { 105 GpuMemoryBufferConfigurationSet
106 GetNativeGpuMemoryBufferConfigurationsForTileUpdate() {
107 // Disable native buffers when using Mesa.
108 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
109 switches::kUseGL) == gfx::kGLImplementationOSMesaName) {
110 return GpuMemoryBufferConfigurationSet();
111 }
112
113 #if defined(OS_MACOSX)
114 bool enabled_in_command_line =
115 !base::CommandLine::ForCurrentProcess()->HasSwitch(
116 switches::kDisableNativeGpuMemoryBuffers);
117 #else
118 bool enabled_in_command_line =
119 base::CommandLine::ForCurrentProcess()->HasSwitch(
120 switches::kEnableNativeGpuMemoryBuffers);
121 #endif
122
106 GpuMemoryBufferConfigurationSet configurations; 123 GpuMemoryBufferConfigurationSet configurations;
107 124 if (enabled_in_command_line) {
108 if (BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled()) {
109 const gfx::BufferFormat kNativeFormats[] = { 125 const gfx::BufferFormat kNativeFormats[] = {
110 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444, 126 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444,
111 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888, 127 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888,
112 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR}; 128 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR};
113 const gfx::BufferUsage kNativeUsages[] = { 129 const gfx::BufferUsage kNativeUsages[] = {
114 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, 130 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT,
115 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, 131 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
116 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; 132 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT};
117 for (auto& format : kNativeFormats) { 133 for (auto& format : kNativeFormats) {
118 for (auto& usage : kNativeUsages) { 134 for (auto& usage : kNativeUsages) {
119 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage)) 135 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage))
120 configurations.insert(std::make_pair(format, usage)); 136 configurations.insert(std::make_pair(format, usage));
121 } 137 }
122 } 138 }
123 } 139 }
124 140
141 return configurations;
142 }
143
144 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() {
145 GpuMemoryBufferConfigurationSet configurations =
146 GetNativeGpuMemoryBufferConfigurationsForTileUpdate();
147
125 #if defined(USE_OZONE) || defined(OS_MACOSX) 148 #if defined(USE_OZONE) || defined(OS_MACOSX)
126 // Disable native buffers only when using Mesa. 149 // Disable native buffers only when using Mesa.
127 bool force_native_gpu_read_write_formats = 150 bool force_native_gpu_read_write_formats =
128 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 151 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
129 switches::kUseGL) != gfx::kGLImplementationOSMesaName; 152 switches::kUseGL) != gfx::kGLImplementationOSMesaName;
130 #else 153 #else
131 bool force_native_gpu_read_write_formats = false; 154 bool force_native_gpu_read_write_formats = false;
132 #endif 155 #endif
133 if (force_native_gpu_read_write_formats) { 156 if (force_native_gpu_read_write_formats) {
134 const gfx::BufferFormat kGPUReadWriteFormats[] = { 157 const gfx::BufferFormat kGPUReadWriteFormats[] = {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 gfx::BufferFormat format, 205 gfx::BufferFormat format,
183 int client_id) 206 int client_id)
184 : CreateGpuMemoryBufferRequest(size, 207 : CreateGpuMemoryBufferRequest(size,
185 format, 208 format,
186 gfx::BufferUsage::GPU_READ, 209 gfx::BufferUsage::GPU_READ,
187 client_id, 210 client_id,
188 0), 211 0),
189 handle(handle) {} 212 handle(handle) {}
190 ~CreateGpuMemoryBufferFromHandleRequest() {} 213 ~CreateGpuMemoryBufferFromHandleRequest() {}
191 gfx::GpuMemoryBufferHandle handle; 214 gfx::GpuMemoryBufferHandle handle;
192 }; 215 };
reveman 2016/01/29 19:27:12 This represents the value of the command line flag
dshwang 2016/01/29 19:35:26 It's not changed. This CL change only behavior of
reveman 2016/01/29 19:38:11 hm, not sure how this comment ended up here. I was
193 216
194 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager( 217 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager(
195 int gpu_client_id, 218 int gpu_client_id,
196 uint64_t gpu_client_tracing_id) 219 uint64_t gpu_client_tracing_id)
197 : native_configurations_(GetNativeGpuMemoryBufferConfigurations()), 220 : native_configurations_(GetNativeGpuMemoryBufferConfigurations()),
198 gpu_client_id_(gpu_client_id), 221 gpu_client_id_(gpu_client_id),
199 gpu_client_tracing_id_(gpu_client_tracing_id), 222 gpu_client_tracing_id_(gpu_client_tracing_id),
200 gpu_host_id_(0) { 223 gpu_host_id_(0) {
201 DCHECK(!g_gpu_memory_buffer_manager); 224 DCHECK(!g_gpu_memory_buffer_manager);
202 g_gpu_memory_buffer_manager = this; 225 g_gpu_memory_buffer_manager = this;
203 } 226 }
204 227
205 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() { 228 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() {
206 g_gpu_memory_buffer_manager = nullptr; 229 g_gpu_memory_buffer_manager = nullptr;
207 } 230 }
208 231
209 // static 232 // static
210 BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() { 233 BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() {
211 return g_gpu_memory_buffer_manager; 234 return g_gpu_memory_buffer_manager;
212 } 235 }
213 236
214 // static 237 // static
215 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() { 238 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() {
216 // Disable native buffers when using Mesa. 239 GpuMemoryBufferConfigurationSet configurations =
217 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 240 GetNativeGpuMemoryBufferConfigurationsForTileUpdate();
218 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { 241 return !configurations.empty();
219 return false;
220 }
221
222 #if defined(OS_MACOSX)
223 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
224 switches::kDisableNativeGpuMemoryBuffers);
225 #else
226 return base::CommandLine::ForCurrentProcess()->HasSwitch(
227 switches::kEnableNativeGpuMemoryBuffers);
228 #endif
229 } 242 }
230 243
231 // static 244 // static
232 uint32_t BrowserGpuMemoryBufferManager::GetImageTextureTarget( 245 uint32_t BrowserGpuMemoryBufferManager::GetImageTextureTarget(
233 gfx::BufferFormat format, 246 gfx::BufferFormat format,
234 gfx::BufferUsage usage) { 247 gfx::BufferUsage usage) {
235 GpuMemoryBufferConfigurationSet native_configurations = 248 GpuMemoryBufferConfigurationSet native_configurations =
236 GetNativeGpuMemoryBufferConfigurations(); 249 GetNativeGpuMemoryBufferConfigurations();
237 if (native_configurations.find(std::make_pair(format, usage)) == 250 if (native_configurations.find(std::make_pair(format, usage)) ==
238 native_configurations.end()) { 251 native_configurations.end()) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 return gpu_client_tracing_id_; 760 return gpu_client_tracing_id_;
748 } 761 }
749 762
750 // In normal cases, |client_id| is a child process id, so we can perform 763 // In normal cases, |client_id| is a child process id, so we can perform
751 // the standard conversion. 764 // the standard conversion.
752 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 765 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
753 client_id); 766 client_id);
754 } 767 }
755 768
756 } // namespace content 769 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698