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

Side by Side Diff: content/common/gpu/client/gpu_channel_host.h

Issue 19762004: Add multi-process GpuMemoryBuffer framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/atomic_sequence_num.h" 11 #include "base/atomic_sequence_num.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/process/process.h" 16 #include "base/process/process.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/common/gpu/gpu_process_launch_causes.h" 19 #include "content/common/gpu/gpu_process_launch_causes.h"
20 #include "content/common/message_router.h" 20 #include "content/common/message_router.h"
21 #include "gpu/config/gpu_info.h" 21 #include "gpu/config/gpu_info.h"
22 #include "ipc/ipc_channel_handle.h" 22 #include "ipc/ipc_channel_handle.h"
23 #include "ipc/ipc_channel_proxy.h" 23 #include "ipc/ipc_channel_proxy.h"
24 #include "ipc/ipc_sync_channel.h" 24 #include "ipc/ipc_sync_channel.h"
25 #include "media/video/video_decode_accelerator.h" 25 #include "media/video/video_decode_accelerator.h"
26 #include "media/video/video_encode_accelerator.h" 26 #include "media/video/video_encode_accelerator.h"
27 #include "ui/gfx/gpu_memory_buffer.h"
27 #include "ui/gfx/native_widget_types.h" 28 #include "ui/gfx/native_widget_types.h"
28 #include "ui/gfx/size.h" 29 #include "ui/gfx/size.h"
29 #include "ui/gl/gpu_preference.h" 30 #include "ui/gl/gpu_preference.h"
30 31
31 class GURL; 32 class GURL;
32 class TransportTextureService; 33 class TransportTextureService;
33 struct GPUCreateCommandBufferConfig; 34 struct GPUCreateCommandBufferConfig;
34 35
35 namespace base { 36 namespace base {
36 class MessageLoop; 37 class MessageLoop;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 virtual base::WaitableEvent* GetShutDownEvent() = 0; 71 virtual base::WaitableEvent* GetShutDownEvent() = 0;
71 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0; 72 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0;
72 virtual int32 CreateViewCommandBuffer( 73 virtual int32 CreateViewCommandBuffer(
73 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) = 0; 74 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) = 0;
74 virtual GpuChannelHost* EstablishGpuChannelSync(CauseForGpuLaunch) = 0; 75 virtual GpuChannelHost* EstablishGpuChannelSync(CauseForGpuLaunch) = 0;
75 virtual void CreateImage( 76 virtual void CreateImage(
76 gfx::PluginWindowHandle window, 77 gfx::PluginWindowHandle window,
77 int32 image_id, 78 int32 image_id,
78 const CreateImageCallback& callback) = 0; 79 const CreateImageCallback& callback) = 0;
79 virtual void DeleteImage(int32 image_id, int32 sync_point) = 0; 80 virtual void DeleteImage(int32 image_id, int32 sync_point) = 0;
81 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
82 size_t width,
83 size_t height,
84 unsigned internalformat) = 0;
80 }; 85 };
81 86
82 // Encapsulates an IPC channel between the client and one GPU process. 87 // Encapsulates an IPC channel between the client and one GPU process.
83 // On the GPU process side there's a corresponding GpuChannel. 88 // On the GPU process side there's a corresponding GpuChannel.
84 // Every method can be called on any thread with a message loop, except for the 89 // Every method can be called on any thread with a message loop, except for the
85 // IO thread. 90 // IO thread.
86 class GpuChannelHost : public IPC::Sender, 91 class GpuChannelHost : public IPC::Sender,
87 public base::RefCountedThreadSafe<GpuChannelHost> { 92 public base::RefCountedThreadSafe<GpuChannelHost> {
88 public: 93 public:
89 // Must be called on the main thread (as defined by the factory). 94 // Must be called on the main thread (as defined by the factory).
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 160
156 // Generates |num| unique mailbox names that can be used with 161 // Generates |num| unique mailbox names that can be used with
157 // GL_texture_mailbox_CHROMIUM. Unlike genMailboxCHROMIUM, this IPC is 162 // GL_texture_mailbox_CHROMIUM. Unlike genMailboxCHROMIUM, this IPC is
158 // handled only on the GPU process' IO thread, and so is not effectively 163 // handled only on the GPU process' IO thread, and so is not effectively
159 // a finish. 164 // a finish.
160 bool GenerateMailboxNames(unsigned num, std::vector<gpu::Mailbox>* names); 165 bool GenerateMailboxNames(unsigned num, std::vector<gpu::Mailbox>* names);
161 166
162 // Reserve one unused transfer buffer ID. 167 // Reserve one unused transfer buffer ID.
163 int32 ReserveTransferBufferId(); 168 int32 ReserveTransferBufferId();
164 169
170 // Returns a GPU memory buffer handle to the buffer that can be sent via
171 // IPC to the GPU process. The caller is responsible for ensuring it is
172 // closed. Returns an invalid handle on failure.
173 gfx::GpuMemoryBufferHandle ShareGpuMemoryBufferToGpuProcess(
174 gfx::GpuMemoryBufferHandle source_handle);
175
176 // Reserve one unused gpu memory buffer ID.
177 int32 ReserveGpuMemoryBufferId();
178
165 private: 179 private:
166 friend class base::RefCountedThreadSafe<GpuChannelHost>; 180 friend class base::RefCountedThreadSafe<GpuChannelHost>;
167 GpuChannelHost(GpuChannelHostFactory* factory, 181 GpuChannelHost(GpuChannelHostFactory* factory,
168 int gpu_host_id, 182 int gpu_host_id,
169 int client_id, 183 int client_id,
170 const gpu::GPUInfo& gpu_info); 184 const gpu::GPUInfo& gpu_info);
171 virtual ~GpuChannelHost(); 185 virtual ~GpuChannelHost();
172 void Connect(const IPC::ChannelHandle& channel_handle); 186 void Connect(const IPC::ChannelHandle& channel_handle);
173 187
174 // A filter used internally to route incoming messages from the IO thread 188 // A filter used internally to route incoming messages from the IO thread
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // A pool of valid mailbox names. 235 // A pool of valid mailbox names.
222 std::vector<gpu::Mailbox> mailbox_name_pool_; 236 std::vector<gpu::Mailbox> mailbox_name_pool_;
223 237
224 // Number of pending mailbox requested from the GPU process. 238 // Number of pending mailbox requested from the GPU process.
225 size_t requested_mailboxes_; 239 size_t requested_mailboxes_;
226 }; 240 };
227 241
228 // Threading notes: all fields are constant during the lifetime of |this| 242 // Threading notes: all fields are constant during the lifetime of |this|
229 // except: 243 // except:
230 // - |next_transfer_buffer_id_|, atomic type 244 // - |next_transfer_buffer_id_|, atomic type
245 // - |next_gpu_memory_buffer_id_|, atomic type
231 // - |proxies_|, protected by |context_lock_| 246 // - |proxies_|, protected by |context_lock_|
232 GpuChannelHostFactory* const factory_; 247 GpuChannelHostFactory* const factory_;
233 const int client_id_; 248 const int client_id_;
234 const int gpu_host_id_; 249 const int gpu_host_id_;
235 250
236 const gpu::GPUInfo gpu_info_; 251 const gpu::GPUInfo gpu_info_;
237 252
238 scoped_ptr<IPC::SyncChannel> channel_; 253 scoped_ptr<IPC::SyncChannel> channel_;
239 scoped_refptr<MessageFilter> channel_filter_; 254 scoped_refptr<MessageFilter> channel_filter_;
240 255
241 // A filter for sending messages from thread other than the main thread. 256 // A filter for sending messages from thread other than the main thread.
242 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; 257 scoped_refptr<IPC::SyncMessageFilter> sync_filter_;
243 258
244 // Transfer buffer IDs are allocated in sequence. 259 // Transfer buffer IDs are allocated in sequence.
245 base::AtomicSequenceNumber next_transfer_buffer_id_; 260 base::AtomicSequenceNumber next_transfer_buffer_id_;
246 261
262 // Gpu memory buffer IDs are allocated in sequence.
263 base::AtomicSequenceNumber next_gpu_memory_buffer_id_;
264
247 // Protects proxies_. 265 // Protects proxies_.
248 mutable base::Lock context_lock_; 266 mutable base::Lock context_lock_;
249 // Used to look up a proxy from its routing id. 267 // Used to look up a proxy from its routing id.
250 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; 268 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap;
251 ProxyMap proxies_; 269 ProxyMap proxies_;
252 270
253 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); 271 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost);
254 }; 272 };
255 273
256 } // namespace content 274 } // namespace content
257 275
258 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ 276 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698