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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_mac.cc

Issue 701033005: content: Move type selection logic out of GpuMemoryBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review feedback Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/gpu/client/gpu_memory_buffer_impl.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6 6
7 #include "base/logging.h"
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 // static 13 // static
13 void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id, 14 void GpuMemoryBufferImpl::GetSupportedTypes(
15 std::vector<gfx::GpuMemoryBufferType>* types) {
16 const gfx::GpuMemoryBufferType supported_types[] = {
17 gfx::IO_SURFACE_BUFFER,
18 gfx::SHARED_MEMORY_BUFFER
19 };
20 types->assign(supported_types, supported_types + arraysize(supported_types));
21 }
22
23 // static
24 bool GpuMemoryBufferImpl::IsConfigurationSupported(
25 gfx::GpuMemoryBufferType type,
26 Format format,
27 Usage usage) {
28 switch (type) {
29 case gfx::SHARED_MEMORY_BUFFER:
30 return GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) &&
31 GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage);
32 case gfx::IO_SURFACE_BUFFER:
33 return GpuMemoryBufferImplIOSurface::IsFormatSupported(format) &&
34 GpuMemoryBufferImplIOSurface::IsUsageSupported(usage);
35 default:
36 NOTREACHED();
37 return false;
38 }
39 }
40
41 // static
42 void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferType type,
43 gfx::GpuMemoryBufferId id,
14 const gfx::Size& size, 44 const gfx::Size& size,
15 Format format, 45 Format format,
16 Usage usage, 46 Usage usage,
17 int client_id, 47 int client_id,
18 const CreationCallback& callback) { 48 const CreationCallback& callback) {
19 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(format, usage)) { 49 switch (type) {
20 GpuMemoryBufferImplIOSurface::Create(id, size, format, client_id, callback); 50 case gfx::SHARED_MEMORY_BUFFER:
21 return; 51 GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
52 break;
53 case gfx::IO_SURFACE_BUFFER:
54 GpuMemoryBufferImplIOSurface::Create(
55 id, size, format, client_id, callback);
56 break;
57 default:
58 NOTREACHED();
59 break;
22 } 60 }
23
24 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
25 size, format, usage)) {
26 GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
27 return;
28 }
29
30 callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
31 } 61 }
32 62
33 // static 63 // static
34 void GpuMemoryBufferImpl::AllocateForChildProcess( 64 void GpuMemoryBufferImpl::AllocateForChildProcess(
65 gfx::GpuMemoryBufferType type,
35 gfx::GpuMemoryBufferId id, 66 gfx::GpuMemoryBufferId id,
36 const gfx::Size& size, 67 const gfx::Size& size,
37 Format format, 68 Format format,
38 Usage usage, 69 Usage usage,
39 base::ProcessHandle child_process, 70 base::ProcessHandle child_process,
40 int child_client_id, 71 int child_client_id,
41 const AllocationCallback& callback) { 72 const AllocationCallback& callback) {
42 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(format, usage)) { 73 switch (type) {
43 GpuMemoryBufferImplIOSurface::AllocateForChildProcess( 74 case gfx::SHARED_MEMORY_BUFFER:
44 id, size, format, child_client_id, callback); 75 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
45 return; 76 id, size, format, child_process, callback);
77 break;
78 case gfx::IO_SURFACE_BUFFER:
79 GpuMemoryBufferImplIOSurface::AllocateForChildProcess(
80 id, size, format, child_client_id, callback);
81 break;
82 default:
83 NOTREACHED();
84 break;
46 } 85 }
47
48 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
49 size, format, usage)) {
50 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
51 id, size, format, child_process, callback);
52 return;
53 }
54
55 callback.Run(gfx::GpuMemoryBufferHandle());
56 } 86 }
57 87
58 // static 88 // static
59 void GpuMemoryBufferImpl::DeletedByChildProcess( 89 void GpuMemoryBufferImpl::DeletedByChildProcess(
60 gfx::GpuMemoryBufferType type, 90 gfx::GpuMemoryBufferType type,
61 gfx::GpuMemoryBufferId id, 91 gfx::GpuMemoryBufferId id,
62 base::ProcessHandle child_process, 92 base::ProcessHandle child_process,
63 int child_client_id, 93 int child_client_id,
64 uint32 sync_point) { 94 uint32 sync_point) {
65 switch (type) { 95 switch (type) {
(...skipping 16 matching lines...) Expand all
82 Format format, 112 Format format,
83 const DestructionCallback& callback) { 113 const DestructionCallback& callback) {
84 switch (handle.type) { 114 switch (handle.type) {
85 case gfx::SHARED_MEMORY_BUFFER: 115 case gfx::SHARED_MEMORY_BUFFER:
86 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( 116 return GpuMemoryBufferImplSharedMemory::CreateFromHandle(
87 handle, size, format, callback); 117 handle, size, format, callback);
88 case gfx::IO_SURFACE_BUFFER: 118 case gfx::IO_SURFACE_BUFFER:
89 return GpuMemoryBufferImplIOSurface::CreateFromHandle( 119 return GpuMemoryBufferImplIOSurface::CreateFromHandle(
90 handle, size, format, callback); 120 handle, size, format, callback);
91 default: 121 default:
122 NOTREACHED();
92 return scoped_ptr<GpuMemoryBufferImpl>(); 123 return scoped_ptr<GpuMemoryBufferImpl>();
93 } 124 }
94 } 125 }
95 126
96 } // namespace content 127 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_linux.cc ('k') | content/common/gpu/client/gpu_memory_buffer_impl_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698