OLD | NEW |
---|---|
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_ozone.h" | |
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
8 | 9 |
9 namespace content { | 10 namespace content { |
11 #if defined(USE_OZONE) | |
reveman
2014/08/11 19:43:05
No idefs in these files. Please add a platform spe
achaulk
2014/08/12 19:03:56
Ok
| |
12 namespace { | |
13 const int kBrowserClientId = 1; | |
14 } // namespace | |
15 #endif // defined(USE_OZONE) | |
10 | 16 |
11 // static | 17 // static |
12 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( | 18 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( |
13 const gfx::Size& size, | 19 const gfx::Size& size, |
14 unsigned internalformat, | 20 unsigned internalformat, |
15 unsigned usage) { | 21 unsigned usage) { |
22 #if defined(USE_OZONE) | |
23 if (GpuMemoryBufferImplOzone::IsConfigurationSupported( | |
24 size, internalformat, usage)) { | |
25 scoped_ptr<GpuMemoryBufferImplOzone> buffer( | |
26 new GpuMemoryBufferImplOzone(size, internalformat, kBrowserClientId)); | |
27 if (!buffer->Initialize()) | |
28 return scoped_ptr<GpuMemoryBufferImpl>(); | |
29 | |
30 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
31 } | |
32 #endif // defined(USE_OZONE) | |
reveman
2014/08/11 19:43:05
do we need browser compositor support for this?
achaulk
2014/08/12 19:03:57
Not for using them. We will eventually to render t
reveman
2014/08/12 20:19:11
I'm failing to see how this works. Latest patch is
achaulk
2014/08/12 21:38:01
That is something that we will need to figure out
| |
33 | |
16 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 34 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
17 size, internalformat, usage)) { | 35 size, internalformat, usage)) { |
18 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 36 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
19 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 37 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
20 if (!buffer->Initialize()) | 38 if (!buffer->Initialize()) |
21 return scoped_ptr<GpuMemoryBufferImpl>(); | 39 return scoped_ptr<GpuMemoryBufferImpl>(); |
22 | 40 |
23 return buffer.PassAs<GpuMemoryBufferImpl>(); | 41 return buffer.PassAs<GpuMemoryBufferImpl>(); |
24 } | 42 } |
25 | 43 |
26 return scoped_ptr<GpuMemoryBufferImpl>(); | 44 return scoped_ptr<GpuMemoryBufferImpl>(); |
27 } | 45 } |
28 | 46 |
29 // static | 47 // static |
30 void GpuMemoryBufferImpl::AllocateForChildProcess( | 48 void GpuMemoryBufferImpl::AllocateForChildProcess( |
31 const gfx::Size& size, | 49 const gfx::Size& size, |
32 unsigned internalformat, | 50 unsigned internalformat, |
33 unsigned usage, | 51 unsigned usage, |
34 base::ProcessHandle child_process, | 52 base::ProcessHandle child_process, |
53 int client_id, | |
54 GpuMemoryBufferFactoryHost* gpu_factory_host, | |
35 const AllocationCallback& callback) { | 55 const AllocationCallback& callback) { |
56 #if defined(USE_OZONE) | |
57 if (GpuMemoryBufferImplOzone::IsConfigurationSupported( | |
58 size, internalformat, usage)) { | |
59 GpuMemoryBufferImplOzone::AllocateSharedMemoryForChildProcess( | |
60 size, | |
61 internalformat, | |
62 child_process, | |
63 client_id, | |
64 gpu_factory_host, | |
65 callback); | |
66 return; | |
67 } | |
68 #endif // defined(USE_OZONE) | |
36 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 69 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
37 size, internalformat, usage)) { | 70 size, internalformat, usage)) { |
38 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( | 71 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( |
39 size, internalformat, child_process, callback); | 72 size, internalformat, child_process, callback); |
40 return; | 73 return; |
41 } | 74 } |
42 | 75 |
43 callback.Run(gfx::GpuMemoryBufferHandle()); | 76 callback.Run(gfx::GpuMemoryBufferHandle()); |
44 } | 77 } |
45 | 78 |
(...skipping 11 matching lines...) Expand all Loading... | |
57 unsigned internalformat) { | 90 unsigned internalformat) { |
58 switch (handle.type) { | 91 switch (handle.type) { |
59 case gfx::SHARED_MEMORY_BUFFER: { | 92 case gfx::SHARED_MEMORY_BUFFER: { |
60 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 93 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
61 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 94 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
62 if (!buffer->InitializeFromHandle(handle)) | 95 if (!buffer->InitializeFromHandle(handle)) |
63 return scoped_ptr<GpuMemoryBufferImpl>(); | 96 return scoped_ptr<GpuMemoryBufferImpl>(); |
64 | 97 |
65 return buffer.PassAs<GpuMemoryBufferImpl>(); | 98 return buffer.PassAs<GpuMemoryBufferImpl>(); |
66 } | 99 } |
100 #if defined(USE_OZONE) | |
101 case gfx::OZONE_NATIVE_BUFFER: { | |
102 scoped_ptr<GpuMemoryBufferImplOzone> buffer( | |
103 new GpuMemoryBufferImplOzone(size, internalformat, 0)); | |
104 if (!buffer->InitializeFromHandle(handle)) | |
105 return scoped_ptr<GpuMemoryBufferImpl>(); | |
106 | |
107 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
108 } | |
109 #endif // defined(USE_OZONE) | |
67 default: | 110 default: |
68 return scoped_ptr<GpuMemoryBufferImpl>(); | 111 return scoped_ptr<GpuMemoryBufferImpl>(); |
69 } | 112 } |
70 } | 113 } |
71 | 114 |
72 } // namespace content | 115 } // namespace content |
OLD | NEW |