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

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

Issue 1831513003: Pull gpu service/client shared memory buffer code to GpuMemoryBufferSupport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed ifdef mixup Created 4 years, 9 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 <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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "base/trace_event/process_memory_dump.h" 14 #include "base/trace_event/process_memory_dump.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "content/browser/gpu/gpu_process_host.h" 17 #include "content/browser/gpu/gpu_process_host.h"
18 #include "content/common/child_process_host_impl.h" 18 #include "content/common/child_process_host_impl.h"
19 #include "content/common/generic_shared_memory_id_generator.h" 19 #include "content/common/generic_shared_memory_id_generator.h"
20 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 20 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
21 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 21 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
22 #include "content/common/gpu/gpu_memory_buffer_factory.h"
23 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
24 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
25 #include "gpu/GLES2/gl2extchromium.h" 24 #include "gpu/GLES2/gl2extchromium.h"
25 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
26 #include "ui/gfx/buffer_format_util.h" 26 #include "ui/gfx/buffer_format_util.h"
27 #include "ui/gl/gl_switches.h" 27 #include "ui/gl/gl_switches.h"
28 28
29 #if defined(OS_MACOSX)
30 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h"
31 #endif
32
33 #if defined(OS_ANDROID)
34 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h"
35 #endif
36
37 #if defined(USE_OZONE)
38 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h"
39 #endif
40
41 namespace content { 29 namespace content {
42 namespace { 30 namespace {
43 31
44 void HostCreateGpuMemoryBuffer( 32 void HostCreateGpuMemoryBuffer(
45 int surface_id, 33 int surface_id,
46 GpuProcessHost* host, 34 GpuProcessHost* host,
47 gfx::GpuMemoryBufferId id, 35 gfx::GpuMemoryBufferId id,
48 const gfx::Size& size, 36 const gfx::Size& size,
49 gfx::BufferFormat format, 37 gfx::BufferFormat format,
50 gfx::BufferUsage usage, 38 gfx::BufferUsage usage,
(...skipping 20 matching lines...) Expand all
71 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, 59 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner,
72 const GpuMemoryBufferImpl::DestructionCallback& destruction_callback, 60 const GpuMemoryBufferImpl::DestructionCallback& destruction_callback,
73 const gpu::SyncToken& sync_token) { 61 const gpu::SyncToken& sync_token) {
74 destruction_task_runner->PostTask( 62 destruction_task_runner->PostTask(
75 FROM_HERE, base::Bind(destruction_callback, sync_token)); 63 FROM_HERE, base::Bind(destruction_callback, sync_token));
76 } 64 }
77 65
78 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported( 66 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported(
79 gfx::BufferFormat format, 67 gfx::BufferFormat format,
80 gfx::BufferUsage usage) { 68 gfx::BufferUsage usage) {
81 switch (GpuMemoryBufferFactory::GetNativeType()) { 69 switch (gpu::GetNativeGpuMemoryBufferType()) {
82 case gfx::SHARED_MEMORY_BUFFER: 70 case gfx::SHARED_MEMORY_BUFFER:
83 return false; 71 return false;
84 #if defined(OS_MACOSX)
85 case gfx::IO_SURFACE_BUFFER: 72 case gfx::IO_SURFACE_BUFFER:
86 return GpuMemoryBufferFactoryIOSurface::
87 IsGpuMemoryBufferConfigurationSupported(format, usage);
88 #endif
89 #if defined(OS_ANDROID)
90 case gfx::SURFACE_TEXTURE_BUFFER: 73 case gfx::SURFACE_TEXTURE_BUFFER:
91 return GpuMemoryBufferFactorySurfaceTexture::
92 IsGpuMemoryBufferConfigurationSupported(format, usage);
93 #endif
94 #if defined(USE_OZONE)
95 case gfx::OZONE_NATIVE_PIXMAP: 74 case gfx::OZONE_NATIVE_PIXMAP:
96 return GpuMemoryBufferFactoryOzoneNativePixmap:: 75 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
97 IsGpuMemoryBufferConfigurationSupported(format, usage);
98 #endif
99 default: 76 default:
100 NOTREACHED(); 77 NOTREACHED();
101 return false; 78 return false;
102 } 79 }
103 } 80 }
104 81
105 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() { 82 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() {
106 GpuMemoryBufferConfigurationSet configurations; 83 GpuMemoryBufferConfigurationSet configurations;
107 84
108 if (BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled()) { 85 if (BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled()) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 uint32_t BrowserGpuMemoryBufferManager::GetImageTextureTarget( 209 uint32_t BrowserGpuMemoryBufferManager::GetImageTextureTarget(
233 gfx::BufferFormat format, 210 gfx::BufferFormat format,
234 gfx::BufferUsage usage) { 211 gfx::BufferUsage usage) {
235 GpuMemoryBufferConfigurationSet native_configurations = 212 GpuMemoryBufferConfigurationSet native_configurations =
236 GetNativeGpuMemoryBufferConfigurations(); 213 GetNativeGpuMemoryBufferConfigurations();
237 if (native_configurations.find(std::make_pair(format, usage)) == 214 if (native_configurations.find(std::make_pair(format, usage)) ==
238 native_configurations.end()) { 215 native_configurations.end()) {
239 return GL_TEXTURE_2D; 216 return GL_TEXTURE_2D;
240 } 217 }
241 218
242 switch (GpuMemoryBufferFactory::GetNativeType()) { 219 switch (gpu::GetNativeGpuMemoryBufferType()) {
243 case gfx::SURFACE_TEXTURE_BUFFER: 220 case gfx::SURFACE_TEXTURE_BUFFER:
244 case gfx::OZONE_NATIVE_PIXMAP: 221 case gfx::OZONE_NATIVE_PIXMAP:
245 // GPU memory buffers that are shared with the GL using EGLImages 222 // GPU memory buffers that are shared with the GL using EGLImages
246 // require TEXTURE_EXTERNAL_OES. 223 // require TEXTURE_EXTERNAL_OES.
247 return GL_TEXTURE_EXTERNAL_OES; 224 return GL_TEXTURE_EXTERNAL_OES;
248 case gfx::IO_SURFACE_BUFFER: 225 case gfx::IO_SURFACE_BUFFER:
249 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. 226 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB.
250 return GL_TEXTURE_RECTANGLE_ARB; 227 return GL_TEXTURE_RECTANGLE_ARB;
251 case gfx::SHARED_MEMORY_BUFFER: 228 case gfx::SHARED_MEMORY_BUFFER:
252 return GL_TEXTURE_2D; 229 return GL_TEXTURE_2D;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 487
511 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferFromHandleOnIO( 488 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferFromHandleOnIO(
512 CreateGpuMemoryBufferFromHandleRequest* request) { 489 CreateGpuMemoryBufferFromHandleRequest* request) {
513 DCHECK_CURRENTLY_ON(BrowserThread::IO); 490 DCHECK_CURRENTLY_ON(BrowserThread::IO);
514 491
515 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId(); 492 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId();
516 493
517 // Use service side allocation for native types. 494 // Use service side allocation for native types.
518 if (request->handle.type != gfx::SHARED_MEMORY_BUFFER) { 495 if (request->handle.type != gfx::SHARED_MEMORY_BUFFER) {
519 // Early out if service side allocation is not supported. 496 // Early out if service side allocation is not supported.
520 if (request->handle.type != GpuMemoryBufferFactory::GetNativeType() || 497 if (request->handle.type != gpu::GetNativeGpuMemoryBufferType() ||
521 !IsNativeGpuMemoryBufferConfiguration(request->format, 498 !IsNativeGpuMemoryBufferConfiguration(request->format,
522 request->usage)) { 499 request->usage)) {
523 request->event.Signal(); 500 request->event.Signal();
524 return; 501 return;
525 } 502 }
526 // Note: Unretained is safe as this is only used for synchronous allocation 503 // Note: Unretained is safe as this is only used for synchronous allocation
527 // from a non-IO thread. 504 // from a non-IO thread.
528 CreateGpuMemoryBufferOnIO( 505 CreateGpuMemoryBufferOnIO(
529 base::Bind(&HostCreateGpuMemoryBufferFromHandle, request->handle), 506 base::Bind(&HostCreateGpuMemoryBufferFromHandle, request->handle),
530 new_id, request->size, request->format, request->usage, 507 new_id, request->size, request->format, request->usage,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 return gpu_client_tracing_id_; 724 return gpu_client_tracing_id_;
748 } 725 }
749 726
750 // In normal cases, |client_id| is a child process id, so we can perform 727 // In normal cases, |client_id| is a child process id, so we can perform
751 // the standard conversion. 728 // the standard conversion.
752 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 729 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
753 client_id); 730 client_id);
754 } 731 }
755 732
756 } // namespace content 733 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698