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

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

Issue 165393003: gpu: Generate mailboxes on client side (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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
(...skipping 20 matching lines...) Expand all
31 31
32 class GURL; 32 class GURL;
33 class TransportTextureService; 33 class TransportTextureService;
34 struct GPUCreateCommandBufferConfig; 34 struct GPUCreateCommandBufferConfig;
35 35
36 namespace base { 36 namespace base {
37 class MessageLoop; 37 class MessageLoop;
38 class MessageLoopProxy; 38 class MessageLoopProxy;
39 } 39 }
40 40
41 namespace gpu {
42 struct Mailbox;
43 }
44
45 namespace IPC { 41 namespace IPC {
46 class SyncMessageFilter; 42 class SyncMessageFilter;
47 } 43 }
48 44
49 namespace content { 45 namespace content {
50 class CommandBufferProxyImpl; 46 class CommandBufferProxyImpl;
51 class GpuChannelHost; 47 class GpuChannelHost;
52 48
53 struct GpuListenerInfo { 49 struct GpuListenerInfo {
54 GpuListenerInfo(); 50 GpuListenerInfo();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void RemoveRoute(int route_id); 140 void RemoveRoute(int route_id);
145 141
146 GpuChannelHostFactory* factory() const { return factory_; } 142 GpuChannelHostFactory* factory() const { return factory_; }
147 143
148 // Returns a handle to the shared memory that can be sent via IPC to the 144 // Returns a handle to the shared memory that can be sent via IPC to the
149 // GPU process. The caller is responsible for ensuring it is closed. Returns 145 // GPU process. The caller is responsible for ensuring it is closed. Returns
150 // an invalid handle on failure. 146 // an invalid handle on failure.
151 base::SharedMemoryHandle ShareToGpuProcess( 147 base::SharedMemoryHandle ShareToGpuProcess(
152 base::SharedMemoryHandle source_handle); 148 base::SharedMemoryHandle source_handle);
153 149
154 // Generates |num| unique mailbox names that can be used with
155 // GL_texture_mailbox_CHROMIUM. Unlike genMailboxCHROMIUM, this IPC is
156 // handled only on the GPU process' IO thread, and so is not effectively
157 // a finish.
158 bool GenerateMailboxNames(unsigned num, std::vector<gpu::Mailbox>* names);
159
160 // Reserve one unused transfer buffer ID. 150 // Reserve one unused transfer buffer ID.
161 int32 ReserveTransferBufferId(); 151 int32 ReserveTransferBufferId();
162 152
163 // Returns a GPU memory buffer handle to the buffer that can be sent via 153 // Returns a GPU memory buffer handle to the buffer that can be sent via
164 // IPC to the GPU process. The caller is responsible for ensuring it is 154 // IPC to the GPU process. The caller is responsible for ensuring it is
165 // closed. Returns an invalid handle on failure. 155 // closed. Returns an invalid handle on failure.
166 gfx::GpuMemoryBufferHandle ShareGpuMemoryBufferToGpuProcess( 156 gfx::GpuMemoryBufferHandle ShareGpuMemoryBufferToGpuProcess(
167 gfx::GpuMemoryBufferHandle source_handle); 157 gfx::GpuMemoryBufferHandle source_handle);
168 158
169 // Reserve one unused gpu memory buffer ID. 159 // Reserve one unused gpu memory buffer ID.
(...skipping 23 matching lines...) Expand all
193 // IPC::ChannelProxy::MessageFilter implementation 183 // IPC::ChannelProxy::MessageFilter implementation
194 // (called on the IO thread): 184 // (called on the IO thread):
195 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 185 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
196 virtual void OnChannelError() OVERRIDE; 186 virtual void OnChannelError() OVERRIDE;
197 187
198 // The following methods can be called on any thread. 188 // The following methods can be called on any thread.
199 189
200 // Whether the channel is lost. 190 // Whether the channel is lost.
201 bool IsLost() const; 191 bool IsLost() const;
202 192
203 // Gets mailboxes from the pool, and return the number of mailboxes to ask
204 // the GPU process to maintain a good pool size. The caller is responsible
205 // for sending the GpuChannelMsg_GenerateMailboxNamesAsync message.
206 size_t GetMailboxNames(size_t num, std::vector<gpu::Mailbox>* names);
207
208 private: 193 private:
209 virtual ~MessageFilter(); 194 virtual ~MessageFilter();
210 bool OnControlMessageReceived(const IPC::Message& msg);
211
212 // Message handlers.
213 void OnGenerateMailboxNamesReply(const std::vector<gpu::Mailbox>& names);
214 195
215 // Threading notes: |listeners_| is only accessed on the IO thread. Every 196 // Threading notes: |listeners_| is only accessed on the IO thread. Every
216 // other field is protected by |lock_|. 197 // other field is protected by |lock_|.
217 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; 198 typedef base::hash_map<int, GpuListenerInfo> ListenerMap;
218 ListenerMap listeners_; 199 ListenerMap listeners_;
219 200
220 // Protects all fields below this one. 201 // Protects all fields below this one.
221 mutable base::Lock lock_; 202 mutable base::Lock lock_;
222 203
223 // Whether the channel has been lost. 204 // Whether the channel has been lost.
224 bool lost_; 205 bool lost_;
225
226 // A pool of valid mailbox names.
227 std::vector<gpu::Mailbox> mailbox_name_pool_;
228
229 // Number of pending mailbox requested from the GPU process.
230 size_t requested_mailboxes_;
231 }; 206 };
232 207
233 // Threading notes: all fields are constant during the lifetime of |this| 208 // Threading notes: all fields are constant during the lifetime of |this|
234 // except: 209 // except:
235 // - |next_transfer_buffer_id_|, atomic type 210 // - |next_transfer_buffer_id_|, atomic type
236 // - |next_gpu_memory_buffer_id_|, atomic type 211 // - |next_gpu_memory_buffer_id_|, atomic type
237 // - |proxies_|, protected by |context_lock_| 212 // - |proxies_|, protected by |context_lock_|
238 GpuChannelHostFactory* const factory_; 213 GpuChannelHostFactory* const factory_;
239 214
240 const gpu::GPUInfo gpu_info_; 215 const gpu::GPUInfo gpu_info_;
(...skipping 15 matching lines...) Expand all
256 // Used to look up a proxy from its routing id. 231 // Used to look up a proxy from its routing id.
257 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; 232 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap;
258 ProxyMap proxies_; 233 ProxyMap proxies_;
259 234
260 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); 235 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost);
261 }; 236 };
262 237
263 } // namespace content 238 } // namespace content
264 239
265 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ 240 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698