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

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

Issue 10543125: gpu: Add support for GLX_EXT_texture_from_pixmap extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add kGLImplementationMockGL case to gl_image_android.cc. Created 8 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_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 <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "base/process.h" 14 #include "base/process.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/gpu/gpu_process_launch_causes.h" 18 #include "content/common/gpu/gpu_process_launch_causes.h"
19 #include "content/public/browser/browser_child_process_host_delegate.h" 19 #include "content/public/browser/browser_child_process_host_delegate.h"
20 #include "content/public/common/gpu_info.h" 20 #include "content/public/common/gpu_info.h"
21 #include "ipc/ipc_sender.h" 21 #include "ipc/ipc_sender.h"
22 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
23 #include "ui/gfx/size.h"
23 24
24 class GpuMainThread; 25 class GpuMainThread;
25 struct GPUCreateCommandBufferConfig; 26 struct GPUCreateCommandBufferConfig;
26 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
27 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
28 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; 29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params;
29 30
30 class BrowserChildProcessHostImpl; 31 class BrowserChildProcessHostImpl;
31 32
32 namespace IPC { 33 namespace IPC {
33 struct ChannelHandle; 34 struct ChannelHandle;
34 } 35 }
35 36
36 class GpuProcessHost : public content::BrowserChildProcessHostDelegate, 37 class GpuProcessHost : public content::BrowserChildProcessHostDelegate,
37 public IPC::Sender, 38 public IPC::Sender,
38 public base::NonThreadSafe { 39 public base::NonThreadSafe {
39 public: 40 public:
40 enum GpuProcessKind { 41 enum GpuProcessKind {
41 GPU_PROCESS_KIND_UNSANDBOXED, 42 GPU_PROCESS_KIND_UNSANDBOXED,
42 GPU_PROCESS_KIND_SANDBOXED, 43 GPU_PROCESS_KIND_SANDBOXED,
43 GPU_PROCESS_KIND_COUNT 44 GPU_PROCESS_KIND_COUNT
44 }; 45 };
45 46
46 typedef base::Callback<void(const IPC::ChannelHandle&, 47 typedef base::Callback<void(const IPC::ChannelHandle&,
47 const content::GPUInfo&)> 48 const content::GPUInfo&)>
48 EstablishChannelCallback; 49 EstablishChannelCallback;
49 50
50 typedef base::Callback<void(int32)> CreateCommandBufferCallback; 51 typedef base::Callback<void(int32)> CreateCommandBufferCallback;
51 52
53 typedef base::Callback<void(const gfx::Size)> CreateImageCallback;
54
52 static bool gpu_enabled() { return gpu_enabled_; } 55 static bool gpu_enabled() { return gpu_enabled_; }
53 56
54 // Creates a new GpuProcessHost or gets an existing one, resulting in the 57 // Creates a new GpuProcessHost or gets an existing one, resulting in the
55 // launching of a GPU process if required. Returns null on failure. It 58 // launching of a GPU process if required. Returns null on failure. It
56 // is not safe to store the pointer once control has returned to the message 59 // is not safe to store the pointer once control has returned to the message
57 // loop as it can be destroyed. Instead store the associated GPU host ID. 60 // loop as it can be destroyed. Instead store the associated GPU host ID.
58 // This could return NULL if GPU access is not allowed (blacklisted). 61 // This could return NULL if GPU access is not allowed (blacklisted).
59 static GpuProcessHost* Get(GpuProcessKind kind, 62 static GpuProcessHost* Get(GpuProcessKind kind,
60 content::CauseForGpuLaunch cause); 63 content::CauseForGpuLaunch cause);
61 64
(...skipping 21 matching lines...) Expand all
83 86
84 // Tells the GPU process to create a new command buffer that draws into the 87 // Tells the GPU process to create a new command buffer that draws into the
85 // given surface. 88 // given surface.
86 void CreateViewCommandBuffer( 89 void CreateViewCommandBuffer(
87 const gfx::GLSurfaceHandle& compositing_surface, 90 const gfx::GLSurfaceHandle& compositing_surface,
88 int surface_id, 91 int surface_id,
89 int client_id, 92 int client_id,
90 const GPUCreateCommandBufferConfig& init_params, 93 const GPUCreateCommandBufferConfig& init_params,
91 const CreateCommandBufferCallback& callback); 94 const CreateCommandBufferCallback& callback);
92 95
96 // Tells the GPU process to create a new image using the given window.
97 void CreateImage(
98 gfx::PluginWindowHandle window,
99 int client_id,
100 int image_id,
101 const CreateImageCallback& callback);
102
103 // Tells the GPU process to delete image.
104 void DeleteImage(int client_id, int image_id, int sync_point);
105
93 // Whether this GPU process is set up to use software rendering. 106 // Whether this GPU process is set up to use software rendering.
94 bool software_rendering(); 107 bool software_rendering();
95 108
96 // What kind of GPU process, e.g. sandboxed or unsandboxed. 109 // What kind of GPU process, e.g. sandboxed or unsandboxed.
97 GpuProcessKind kind(); 110 GpuProcessKind kind();
98 111
99 void ForceShutdown(); 112 void ForceShutdown();
100 113
101 private: 114 private:
102 static bool HostIsValid(GpuProcessHost* host); 115 static bool HostIsValid(GpuProcessHost* host);
(...skipping 10 matching lines...) Expand all
113 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 126 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
114 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 127 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
115 virtual void OnProcessLaunched() OVERRIDE; 128 virtual void OnProcessLaunched() OVERRIDE;
116 virtual void OnProcessCrashed(int exit_code) OVERRIDE; 129 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
117 130
118 // Message handlers. 131 // Message handlers.
119 void OnInitialized(bool result); 132 void OnInitialized(bool result);
120 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); 133 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle);
121 void OnCommandBufferCreated(const int32 route_id); 134 void OnCommandBufferCreated(const int32 route_id);
122 void OnDestroyCommandBuffer(int32 surface_id); 135 void OnDestroyCommandBuffer(int32 surface_id);
136 void OnImageCreated(const gfx::Size size);
123 137
124 #if defined(OS_MACOSX) 138 #if defined(OS_MACOSX)
125 void OnAcceleratedSurfaceBuffersSwapped( 139 void OnAcceleratedSurfaceBuffersSwapped(
126 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); 140 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
127 #endif 141 #endif
128 // Note: Different implementations depending on USE_AURA. 142 // Note: Different implementations depending on USE_AURA.
129 #if defined(OS_WIN) 143 #if defined(OS_WIN)
130 void OnAcceleratedSurfaceBuffersSwapped( 144 void OnAcceleratedSurfaceBuffersSwapped(
131 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); 145 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
132 void OnAcceleratedSurfacePostSubBuffer( 146 void OnAcceleratedSurfacePostSubBuffer(
133 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); 147 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params);
134 void OnAcceleratedSurfaceSuspend(int32 surface_id); 148 void OnAcceleratedSurfaceSuspend(int32 surface_id);
135 void OnAcceleratedSurfaceRelease( 149 void OnAcceleratedSurfaceRelease(
136 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); 150 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params);
137 #endif 151 #endif
138 152
139 bool LaunchGpuProcess(const std::string& channel_id); 153 bool LaunchGpuProcess(const std::string& channel_id);
140 154
141 void SendOutstandingReplies(); 155 void SendOutstandingReplies();
142 void EstablishChannelError( 156 void EstablishChannelError(
143 const EstablishChannelCallback& callback, 157 const EstablishChannelCallback& callback,
144 const IPC::ChannelHandle& channel_handle, 158 const IPC::ChannelHandle& channel_handle,
145 base::ProcessHandle client_process_for_gpu, 159 base::ProcessHandle client_process_for_gpu,
146 const content::GPUInfo& gpu_info); 160 const content::GPUInfo& gpu_info);
147 void CreateCommandBufferError(const CreateCommandBufferCallback& callback, 161 void CreateCommandBufferError(const CreateCommandBufferCallback& callback,
148 int32 route_id); 162 int32 route_id);
163 void CreateImageError(const CreateImageCallback& callback,
164 const gfx::Size size);
149 165
150 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. 166 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair.
151 int host_id_; 167 int host_id_;
152 168
153 // These are the channel requests that we have already sent to 169 // These are the channel requests that we have already sent to
154 // the GPU process, but haven't heard back about yet. 170 // the GPU process, but haven't heard back about yet.
155 std::queue<EstablishChannelCallback> channel_requests_; 171 std::queue<EstablishChannelCallback> channel_requests_;
156 172
157 // The pending create command buffer requests we need to reply to. 173 // The pending create command buffer requests we need to reply to.
158 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; 174 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_;
159 175
176 // The pending create image requests we need to reply to.
177 std::queue<CreateImageCallback> create_image_requests_;
178
160 #if defined(TOOLKIT_GTK) 179 #if defined(TOOLKIT_GTK)
161 // Encapsulates surfaces that we lock when creating view command buffers. 180 // Encapsulates surfaces that we lock when creating view command buffers.
162 // We release this lock once the command buffer (or associated GPU process) 181 // We release this lock once the command buffer (or associated GPU process)
163 // is destroyed. This prevents the browser from destroying the surface 182 // is destroyed. This prevents the browser from destroying the surface
164 // while the GPU process is drawing to it. 183 // while the GPU process is drawing to it.
165 184
166 // Multimap is used to simulate reference counting, see comment in 185 // Multimap is used to simulate reference counting, see comment in
167 // GpuProcessHostUIShim::CreateViewCommandBuffer. 186 // GpuProcessHostUIShim::CreateViewCommandBuffer.
168 class SurfaceRef; 187 class SurfaceRef;
169 typedef std::multimap<int, linked_ptr<SurfaceRef> > SurfaceRefMap; 188 typedef std::multimap<int, linked_ptr<SurfaceRef> > SurfaceRefMap;
(...skipping 27 matching lines...) Expand all
197 static bool gpu_enabled_; 216 static bool gpu_enabled_;
198 217
199 static bool hardware_gpu_enabled_; 218 static bool hardware_gpu_enabled_;
200 219
201 scoped_ptr<BrowserChildProcessHostImpl> process_; 220 scoped_ptr<BrowserChildProcessHostImpl> process_;
202 221
203 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); 222 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
204 }; 223 };
205 224
206 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 225 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_channel_host_factory.cc ('k') | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698