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

Side by Side Diff: content/browser/gpu/gpu_process_host.h

Issue 302603004: Plumb GpuMemoryBuffer allocation to GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 6 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
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_BROWSER_GPU_GPU_PROCESS_HOST_H_ 5 #ifndef CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 16 matching lines...) Expand all
27 #include "ipc/message_filter.h" 27 #include "ipc/message_filter.h"
28 #include "ui/gfx/native_widget_types.h" 28 #include "ui/gfx/native_widget_types.h"
29 #include "ui/gfx/size.h" 29 #include "ui/gfx/size.h"
30 #include "url/gurl.h" 30 #include "url/gurl.h"
31 31
32 struct GPUCreateCommandBufferConfig; 32 struct GPUCreateCommandBufferConfig;
33 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; 33 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
34 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; 34 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
35 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; 35 struct GpuHostMsg_AcceleratedSurfaceRelease_Params;
36 36
37 namespace gfx {
38 struct GpuMemoryBufferHandle;
39 }
40
37 namespace IPC { 41 namespace IPC {
38 struct ChannelHandle; 42 struct ChannelHandle;
39 } 43 }
40 44
41 namespace content { 45 namespace content {
42 class BrowserChildProcessHostImpl; 46 class BrowserChildProcessHostImpl;
43 class GpuMainThread; 47 class GpuMainThread;
44 class RenderWidgetHostViewFrameSubscriber; 48 class RenderWidgetHostViewFrameSubscriber;
45 class ShaderDiskCache; 49 class ShaderDiskCache;
46 50
47 typedef base::Thread* (*GpuMainThreadFactoryFunction)(const std::string& id); 51 typedef base::Thread* (*GpuMainThreadFactoryFunction)(const std::string& id);
48 52
49 class GpuProcessHost : public BrowserChildProcessHostDelegate, 53 class GpuProcessHost : public BrowserChildProcessHostDelegate,
50 public IPC::Sender, 54 public IPC::Sender,
51 public base::NonThreadSafe { 55 public base::NonThreadSafe {
52 public: 56 public:
53 enum GpuProcessKind { 57 enum GpuProcessKind {
54 GPU_PROCESS_KIND_UNSANDBOXED, 58 GPU_PROCESS_KIND_UNSANDBOXED,
55 GPU_PROCESS_KIND_SANDBOXED, 59 GPU_PROCESS_KIND_SANDBOXED,
56 GPU_PROCESS_KIND_COUNT 60 GPU_PROCESS_KIND_COUNT
57 }; 61 };
58 62
59 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> 63 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)>
60 EstablishChannelCallback; 64 EstablishChannelCallback;
61 65
62 typedef base::Callback<void(bool)> CreateCommandBufferCallback; 66 typedef base::Callback<void(bool)> CreateCommandBufferCallback;
63 67
64 typedef base::Callback<void(const gfx::Size)> CreateImageCallback; 68 typedef base::Callback<void(const gfx::Size)> CreateImageCallback;
65 69
70 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>
71 CreateGpuMemoryBufferCallback;
72
66 static bool gpu_enabled() { return gpu_enabled_; } 73 static bool gpu_enabled() { return gpu_enabled_; }
67 74
68 // Creates a new GpuProcessHost or gets an existing one, resulting in the 75 // Creates a new GpuProcessHost or gets an existing one, resulting in the
69 // launching of a GPU process if required. Returns null on failure. It 76 // launching of a GPU process if required. Returns null on failure. It
70 // is not safe to store the pointer once control has returned to the message 77 // is not safe to store the pointer once control has returned to the message
71 // loop as it can be destroyed. Instead store the associated GPU host ID. 78 // loop as it can be destroyed. Instead store the associated GPU host ID.
72 // This could return NULL if GPU access is not allowed (blacklisted). 79 // This could return NULL if GPU access is not allowed (blacklisted).
73 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, 80 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind,
74 CauseForGpuLaunch cause); 81 CauseForGpuLaunch cause);
75 82
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Tells the GPU process to create a new image using the given window. 125 // Tells the GPU process to create a new image using the given window.
119 void CreateImage( 126 void CreateImage(
120 gfx::PluginWindowHandle window, 127 gfx::PluginWindowHandle window,
121 int client_id, 128 int client_id,
122 int image_id, 129 int image_id,
123 const CreateImageCallback& callback); 130 const CreateImageCallback& callback);
124 131
125 // Tells the GPU process to delete image. 132 // Tells the GPU process to delete image.
126 void DeleteImage(int client_id, int image_id, int sync_point); 133 void DeleteImage(int client_id, int image_id, int sync_point);
127 134
135 void CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle,
136 const gfx::Size& size,
137 unsigned internalformat,
138 unsigned usage,
139 const CreateGpuMemoryBufferCallback& callback);
140 void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle,
141 int sync_point);
142
128 // What kind of GPU process, e.g. sandboxed or unsandboxed. 143 // What kind of GPU process, e.g. sandboxed or unsandboxed.
129 GpuProcessKind kind(); 144 GpuProcessKind kind();
130 145
131 void ForceShutdown(); 146 void ForceShutdown();
132 147
133 void BeginFrameSubscription( 148 void BeginFrameSubscription(
134 int surface_id, 149 int surface_id,
135 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber); 150 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber);
136 void EndFrameSubscription(int surface_id); 151 void EndFrameSubscription(int surface_id);
137 void LoadedShader(const std::string& key, const std::string& data); 152 void LoadedShader(const std::string& key, const std::string& data);
(...skipping 14 matching lines...) Expand all
152 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 167 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
153 virtual void OnProcessLaunched() OVERRIDE; 168 virtual void OnProcessLaunched() OVERRIDE;
154 virtual void OnProcessCrashed(int exit_code) OVERRIDE; 169 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
155 170
156 // Message handlers. 171 // Message handlers.
157 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); 172 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info);
158 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); 173 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle);
159 void OnCommandBufferCreated(bool succeeded); 174 void OnCommandBufferCreated(bool succeeded);
160 void OnDestroyCommandBuffer(int32 surface_id); 175 void OnDestroyCommandBuffer(int32 surface_id);
161 void OnImageCreated(const gfx::Size size); 176 void OnImageCreated(const gfx::Size size);
177 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle);
162 void OnDidCreateOffscreenContext(const GURL& url); 178 void OnDidCreateOffscreenContext(const GURL& url);
163 void OnDidLoseContext(bool offscreen, 179 void OnDidLoseContext(bool offscreen,
164 gpu::error::ContextLostReason reason, 180 gpu::error::ContextLostReason reason,
165 const GURL& url); 181 const GURL& url);
166 void OnDidDestroyOffscreenContext(const GURL& url); 182 void OnDidDestroyOffscreenContext(const GURL& url);
167 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); 183 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats);
168 #if defined(OS_MACOSX) 184 #if defined(OS_MACOSX)
169 void OnAcceleratedSurfaceBuffersSwapped( 185 void OnAcceleratedSurfaceBuffersSwapped(
170 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); 186 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
171 #endif 187 #endif
(...skipping 17 matching lines...) Expand all
189 // These are the channel requests that we have already sent to 205 // These are the channel requests that we have already sent to
190 // the GPU process, but haven't heard back about yet. 206 // the GPU process, but haven't heard back about yet.
191 std::queue<EstablishChannelCallback> channel_requests_; 207 std::queue<EstablishChannelCallback> channel_requests_;
192 208
193 // The pending create command buffer requests we need to reply to. 209 // The pending create command buffer requests we need to reply to.
194 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; 210 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_;
195 211
196 // The pending create image requests we need to reply to. 212 // The pending create image requests we need to reply to.
197 std::queue<CreateImageCallback> create_image_requests_; 213 std::queue<CreateImageCallback> create_image_requests_;
198 214
215 // The pending create gpu memory buffer requests we need to reply to.
216 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_;
199 217
200 // Qeueud messages to send when the process launches. 218 // Qeueud messages to send when the process launches.
201 std::queue<IPC::Message*> queued_messages_; 219 std::queue<IPC::Message*> queued_messages_;
202 220
203 // Whether the GPU process is valid, set to false after Send() failed. 221 // Whether the GPU process is valid, set to false after Send() failed.
204 bool valid_; 222 bool valid_;
205 223
206 // Whether we are running a GPU thread inside the browser process instead 224 // Whether we are running a GPU thread inside the browser process instead
207 // of a separate GPU process. 225 // of a separate GPU process.
208 bool in_process_; 226 bool in_process_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > 278 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> >
261 SurfaceRefMap; 279 SurfaceRefMap;
262 SurfaceRefMap surface_refs_; 280 SurfaceRefMap surface_refs_;
263 281
264 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); 282 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
265 }; 283 };
266 284
267 } // namespace content 285 } // namespace content
268 286
269 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 287 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698