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

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: Comments 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 size_t width,
137 size_t height,
138 unsigned internalformat,
139 unsigned usage,
140 const CreateGpuMemoryBufferCallback& callback);
141 void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle,
142 int sync_point);
143
128 // What kind of GPU process, e.g. sandboxed or unsandboxed. 144 // What kind of GPU process, e.g. sandboxed or unsandboxed.
129 GpuProcessKind kind(); 145 GpuProcessKind kind();
130 146
131 void ForceShutdown(); 147 void ForceShutdown();
132 148
133 void BeginFrameSubscription( 149 void BeginFrameSubscription(
134 int surface_id, 150 int surface_id,
135 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber); 151 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber);
136 void EndFrameSubscription(int surface_id); 152 void EndFrameSubscription(int surface_id);
137 void LoadedShader(const std::string& key, const std::string& data); 153 void LoadedShader(const std::string& key, const std::string& data);
(...skipping 14 matching lines...) Expand all
152 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 168 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
153 virtual void OnProcessLaunched() OVERRIDE; 169 virtual void OnProcessLaunched() OVERRIDE;
154 virtual void OnProcessCrashed(int exit_code) OVERRIDE; 170 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
155 171
156 // Message handlers. 172 // Message handlers.
157 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); 173 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info);
158 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); 174 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle);
159 void OnCommandBufferCreated(bool succeeded); 175 void OnCommandBufferCreated(bool succeeded);
160 void OnDestroyCommandBuffer(int32 surface_id); 176 void OnDestroyCommandBuffer(int32 surface_id);
161 void OnImageCreated(const gfx::Size size); 177 void OnImageCreated(const gfx::Size size);
178 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle);
162 void OnDidCreateOffscreenContext(const GURL& url); 179 void OnDidCreateOffscreenContext(const GURL& url);
163 void OnDidLoseContext(bool offscreen, 180 void OnDidLoseContext(bool offscreen,
164 gpu::error::ContextLostReason reason, 181 gpu::error::ContextLostReason reason,
165 const GURL& url); 182 const GURL& url);
166 void OnDidDestroyOffscreenContext(const GURL& url); 183 void OnDidDestroyOffscreenContext(const GURL& url);
167 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); 184 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats);
168 #if defined(OS_MACOSX) 185 #if defined(OS_MACOSX)
169 void OnAcceleratedSurfaceBuffersSwapped( 186 void OnAcceleratedSurfaceBuffersSwapped(
170 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); 187 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
171 #endif 188 #endif
(...skipping 17 matching lines...) Expand all
189 // These are the channel requests that we have already sent to 206 // These are the channel requests that we have already sent to
190 // the GPU process, but haven't heard back about yet. 207 // the GPU process, but haven't heard back about yet.
191 std::queue<EstablishChannelCallback> channel_requests_; 208 std::queue<EstablishChannelCallback> channel_requests_;
192 209
193 // The pending create command buffer requests we need to reply to. 210 // The pending create command buffer requests we need to reply to.
194 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; 211 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_;
195 212
196 // The pending create image requests we need to reply to. 213 // The pending create image requests we need to reply to.
197 std::queue<CreateImageCallback> create_image_requests_; 214 std::queue<CreateImageCallback> create_image_requests_;
198 215
216 // The pending create gpu memory buffer requests we need to reply to.
217 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_;
199 218
200 // Qeueud messages to send when the process launches. 219 // Qeueud messages to send when the process launches.
201 std::queue<IPC::Message*> queued_messages_; 220 std::queue<IPC::Message*> queued_messages_;
202 221
203 // Whether the GPU process is valid, set to false after Send() failed. 222 // Whether the GPU process is valid, set to false after Send() failed.
204 bool valid_; 223 bool valid_;
205 224
206 // Whether we are running a GPU thread inside the browser process instead 225 // Whether we are running a GPU thread inside the browser process instead
207 // of a separate GPU process. 226 // of a separate GPU process.
208 bool in_process_; 227 bool in_process_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > 279 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> >
261 SurfaceRefMap; 280 SurfaceRefMap;
262 SurfaceRefMap surface_refs_; 281 SurfaceRefMap surface_refs_;
263 282
264 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); 283 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
265 }; 284 };
266 285
267 } // namespace content 286 } // namespace content
268 287
269 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 288 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698