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

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

Issue 685983005: gpu: Associate all GpuMemoryBuffers with unique IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more ozone build fix 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 "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
8 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 // static 12 // static
13 void GpuMemoryBufferImpl::Create(const gfx::Size& size, 13 void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id,
14 const gfx::Size& size,
14 Format format, 15 Format format,
15 Usage usage, 16 Usage usage,
16 int client_id, 17 int client_id,
17 const CreationCallback& callback) { 18 const CreationCallback& callback) {
18 if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(format, 19 if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(format,
19 usage)) { 20 usage)) {
20 GpuMemoryBufferImplSurfaceTexture::Create( 21 GpuMemoryBufferImplSurfaceTexture::Create(
21 size, format, client_id, callback); 22 id, size, format, client_id, callback);
22 return; 23 return;
23 } 24 }
24 25
25 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( 26 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
26 size, format, usage)) { 27 size, format, usage)) {
27 GpuMemoryBufferImplSharedMemory::Create(size, format, callback); 28 GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
28 return; 29 return;
29 } 30 }
30 31
31 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); 32 callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
32 } 33 }
33 34
34 // static 35 // static
35 void GpuMemoryBufferImpl::AllocateForChildProcess( 36 void GpuMemoryBufferImpl::AllocateForChildProcess(
37 gfx::GpuMemoryBufferId id,
36 const gfx::Size& size, 38 const gfx::Size& size,
37 Format format, 39 Format format,
38 Usage usage, 40 Usage usage,
39 base::ProcessHandle child_process, 41 base::ProcessHandle child_process,
40 int child_client_id, 42 int child_client_id,
41 const AllocationCallback& callback) { 43 const AllocationCallback& callback) {
42 if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(format, 44 if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(format,
43 usage)) { 45 usage)) {
44 GpuMemoryBufferImplSurfaceTexture::AllocateForChildProcess( 46 GpuMemoryBufferImplSurfaceTexture::AllocateForChildProcess(
45 size, format, child_client_id, callback); 47 id, size, format, child_client_id, callback);
46 return; 48 return;
47 } 49 }
48 50
49 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( 51 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
50 size, format, usage)) { 52 size, format, usage)) {
51 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( 53 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
52 size, format, child_process, callback); 54 id, size, format, child_process, callback);
53 return; 55 return;
54 } 56 }
55 57
56 callback.Run(gfx::GpuMemoryBufferHandle()); 58 callback.Run(gfx::GpuMemoryBufferHandle());
57 } 59 }
58 60
59 // static 61 // static
60 void GpuMemoryBufferImpl::DeletedByChildProcess( 62 void GpuMemoryBufferImpl::DeletedByChildProcess(
61 gfx::GpuMemoryBufferType type, 63 gfx::GpuMemoryBufferType type,
62 const gfx::GpuMemoryBufferId& id, 64 gfx::GpuMemoryBufferId id,
63 base::ProcessHandle child_process, 65 base::ProcessHandle child_process,
64 int child_client_id, 66 int child_client_id,
65 uint32 sync_point) { 67 uint32 sync_point) {
66 switch (type) { 68 switch (type) {
67 case gfx::SHARED_MEMORY_BUFFER: 69 case gfx::SHARED_MEMORY_BUFFER:
68 break; 70 break;
69 case gfx::SURFACE_TEXTURE_BUFFER: 71 case gfx::SURFACE_TEXTURE_BUFFER:
70 if (id.secondary_id != child_client_id) { 72 GpuMemoryBufferImplSurfaceTexture::DeletedByChildProcess(
71 LOG(ERROR) 73 id, child_client_id, sync_point);
72 << "Child attempting to delete GpuMemoryBuffer it does not own";
73 } else {
74 GpuMemoryBufferImplSurfaceTexture::DeletedByChildProcess(id,
75 sync_point);
76 }
77 break; 74 break;
78 default: 75 default:
79 NOTREACHED(); 76 NOTREACHED();
77 break;
80 } 78 }
81 } 79 }
82 80
83 // static 81 // static
84 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( 82 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
85 const gfx::GpuMemoryBufferHandle& handle, 83 const gfx::GpuMemoryBufferHandle& handle,
86 const gfx::Size& size, 84 const gfx::Size& size,
87 Format format, 85 Format format,
88 const DestructionCallback& callback) { 86 const DestructionCallback& callback) {
89 switch (handle.type) { 87 switch (handle.type) {
90 case gfx::SHARED_MEMORY_BUFFER: 88 case gfx::SHARED_MEMORY_BUFFER:
91 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( 89 return GpuMemoryBufferImplSharedMemory::CreateFromHandle(
92 handle, size, format, callback); 90 handle, size, format, callback);
93 case gfx::SURFACE_TEXTURE_BUFFER: 91 case gfx::SURFACE_TEXTURE_BUFFER:
94 return GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( 92 return GpuMemoryBufferImplSurfaceTexture::CreateFromHandle(
95 handle, size, format, callback); 93 handle, size, format, callback);
96 default: 94 default:
97 return scoped_ptr<GpuMemoryBufferImpl>(); 95 return scoped_ptr<GpuMemoryBufferImpl>();
98 } 96 }
99 } 97 }
100 98
101 } // namespace content 99 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl.cc ('k') | content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698