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

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

Issue 1375663002: Show GpuMemoryBuffer feature in chrome://gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display a matrix of formats and usages Created 5 years, 2 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
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 format, gfx::BufferUsage::SCANOUT)) { 149 format, gfx::BufferUsage::SCANOUT)) {
150 configurations.insert( 150 configurations.insert(
151 std::make_pair(format, gfx::BufferUsage::SCANOUT)); 151 std::make_pair(format, gfx::BufferUsage::SCANOUT));
152 } 152 }
153 } 153 }
154 } 154 }
155 155
156 return configurations; 156 return configurations;
157 } 157 }
158 158
159 // TODO(vignatti): extract the commonalities with function
160 // GetNativeGpuMemoryBufferConfigurations.
161 GpuMemoryBufferConfigurationList GetNativeGpuMemoryBufferEnabledSupported() {
162 GpuMemoryBufferConfigurationList configurations;
163 #if defined(OS_MACOSX)
164 bool enable_native_gpu_memory_buffers =
165 !base::CommandLine::ForCurrentProcess()->HasSwitch(
166 switches::kDisableNativeGpuMemoryBuffers);
167 #else
168 bool enable_native_gpu_memory_buffers =
169 base::CommandLine::ForCurrentProcess()->HasSwitch(
170 switches::kEnableNativeGpuMemoryBuffers);
171 #endif
172
173 // Disable native buffers when using Mesa.
174 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
175 switches::kUseGL) == gfx::kGLImplementationOSMesaName) {
176 enable_native_gpu_memory_buffers = false;
177 }
178
179 if (enable_native_gpu_memory_buffers) {
180 const gfx::BufferFormat kNativeFormats[] = {
181 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444,
182 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888,
183 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR};
184 const gfx::BufferUsage kNativeUsages[] = {gfx::BufferUsage::MAP,
185 gfx::BufferUsage::PERSISTENT_MAP};
186 for (auto& format : kNativeFormats) {
187 for (auto& usage : kNativeUsages) {
188 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage))
189 configurations.push_back(std::make_pair(format, usage));
190 }
191 }
192 }
193
194 return configurations;
195 }
196
159 BrowserGpuMemoryBufferManager* g_gpu_memory_buffer_manager = nullptr; 197 BrowserGpuMemoryBufferManager* g_gpu_memory_buffer_manager = nullptr;
160 198
161 } // namespace 199 } // namespace
162 200
163 struct BrowserGpuMemoryBufferManager::CreateGpuMemoryBufferRequest { 201 struct BrowserGpuMemoryBufferManager::CreateGpuMemoryBufferRequest {
164 CreateGpuMemoryBufferRequest(const gfx::Size& size, 202 CreateGpuMemoryBufferRequest(const gfx::Size& size,
165 gfx::BufferFormat format, 203 gfx::BufferFormat format,
166 gfx::BufferUsage usage, 204 gfx::BufferUsage usage,
167 int client_id, 205 int client_id,
168 int surface_id) 206 int surface_id)
(...skipping 27 matching lines...) Expand all
196 0), 234 0),
197 handle(handle) {} 235 handle(handle) {}
198 ~CreateGpuMemoryBufferFromHandleRequest() {} 236 ~CreateGpuMemoryBufferFromHandleRequest() {}
199 gfx::GpuMemoryBufferHandle handle; 237 gfx::GpuMemoryBufferHandle handle;
200 }; 238 };
201 239
202 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager( 240 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager(
203 int gpu_client_id, 241 int gpu_client_id,
204 uint64_t gpu_client_tracing_id) 242 uint64_t gpu_client_tracing_id)
205 : native_configurations_(GetNativeGpuMemoryBufferConfigurations()), 243 : native_configurations_(GetNativeGpuMemoryBufferConfigurations()),
244 native_enabled_and_supported_(GetNativeGpuMemoryBufferEnabledSupported()),
206 gpu_client_id_(gpu_client_id), 245 gpu_client_id_(gpu_client_id),
207 gpu_client_tracing_id_(gpu_client_tracing_id), 246 gpu_client_tracing_id_(gpu_client_tracing_id),
208 gpu_host_id_(0) { 247 gpu_host_id_(0) {
209 DCHECK(!g_gpu_memory_buffer_manager); 248 DCHECK(!g_gpu_memory_buffer_manager);
210 g_gpu_memory_buffer_manager = this; 249 g_gpu_memory_buffer_manager = this;
211 } 250 }
212 251
213 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() { 252 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() {
214 g_gpu_memory_buffer_manager = nullptr; 253 g_gpu_memory_buffer_manager = nullptr;
215 } 254 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return gpu_client_tracing_id_; 745 return gpu_client_tracing_id_;
707 } 746 }
708 747
709 // In normal cases, |client_id| is a child process id, so we can perform 748 // In normal cases, |client_id| is a child process id, so we can perform
710 // the standard conversion. 749 // the standard conversion.
711 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 750 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
712 client_id); 751 client_id);
713 } 752 }
714 753
715 } // namespace content 754 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698