OLD | NEW |
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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
24 | 24 |
25 class GpuMainThread; | 25 class GpuMainThread; |
26 struct GPUCreateCommandBufferConfig; | 26 struct GPUCreateCommandBufferConfig; |
27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
30 | 30 |
31 class BrowserChildProcessHostImpl; | 31 class BrowserChildProcessHostImpl; |
| 32 class RenderWidgetHelper; |
32 | 33 |
33 class GpuProcessHost : public content::BrowserChildProcessHostDelegate, | 34 class GpuProcessHost : public content::BrowserChildProcessHostDelegate, |
34 public IPC::Message::Sender, | 35 public IPC::Message::Sender, |
35 public base::NonThreadSafe { | 36 public base::NonThreadSafe { |
36 public: | 37 public: |
37 enum GpuProcessKind { | 38 enum GpuProcessKind { |
38 GPU_PROCESS_KIND_UNSANDBOXED, | 39 GPU_PROCESS_KIND_UNSANDBOXED, |
39 GPU_PROCESS_KIND_SANDBOXED, | 40 GPU_PROCESS_KIND_SANDBOXED, |
40 GPU_PROCESS_KIND_COUNT | 41 GPU_PROCESS_KIND_COUNT |
41 }; | 42 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const CreateCommandBufferCallback& callback); | 89 const CreateCommandBufferCallback& callback); |
89 | 90 |
90 // Whether this GPU process is set up to use software rendering. | 91 // Whether this GPU process is set up to use software rendering. |
91 bool software_rendering(); | 92 bool software_rendering(); |
92 | 93 |
93 // What kind of GPU process, e.g. sandboxed or unsandboxed. | 94 // What kind of GPU process, e.g. sandboxed or unsandboxed. |
94 GpuProcessKind kind(); | 95 GpuProcessKind kind(); |
95 | 96 |
96 void ForceShutdown(); | 97 void ForceShutdown(); |
97 | 98 |
| 99 // The GpuMessageFilter hands over the RenderWidgetHelper so we can call |
| 100 // DidReceiveUpdateMsg when SwapBuffers arrive. |
| 101 void RegisterRenderWidgetHelper( |
| 102 int render_process_id, |
| 103 const scoped_refptr<RenderWidgetHelper>& render_widget_helper); |
| 104 void UnregisterRenderWidgetHelper(int render_process_id); |
| 105 |
98 private: | 106 private: |
99 static bool HostIsValid(GpuProcessHost* host); | 107 static bool HostIsValid(GpuProcessHost* host); |
100 | 108 |
101 GpuProcessHost(int host_id, GpuProcessKind kind); | 109 GpuProcessHost(int host_id, GpuProcessKind kind); |
102 virtual ~GpuProcessHost(); | 110 virtual ~GpuProcessHost(); |
103 | 111 |
104 bool Init(); | 112 bool Init(); |
105 | 113 |
106 // Post an IPC message to the UI shim's message handler on the UI thread. | 114 // Post an IPC message to the UI shim's message handler on the UI thread. |
107 void RouteOnUIThread(const IPC::Message& message); | 115 void RouteOnUIThread(const IPC::Message& message); |
108 | 116 |
109 // BrowserChildProcessHostDelegate implementation. | 117 // BrowserChildProcessHostDelegate implementation. |
110 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 118 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
111 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 119 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
112 virtual void OnProcessLaunched() OVERRIDE; | 120 virtual void OnProcessLaunched() OVERRIDE; |
113 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 121 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
114 | 122 |
115 // Message handlers. | 123 // Message handlers. |
116 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 124 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
117 void OnCommandBufferCreated(const int32 route_id); | 125 void OnCommandBufferCreated(const int32 route_id); |
118 void OnDestroyCommandBuffer(int32 surface_id); | 126 void OnDestroyCommandBuffer(int32 surface_id); |
119 | 127 |
| 128 #if defined(OS_MACOSX) |
| 129 void OnAcceleratedSurfaceBuffersSwapped( |
| 130 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 131 #endif |
120 #if defined(OS_WIN) && !defined(USE_AURA) | 132 #if defined(OS_WIN) && !defined(USE_AURA) |
121 void OnAcceleratedSurfaceBuffersSwapped( | 133 void OnAcceleratedSurfaceBuffersSwapped( |
122 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 134 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
123 void OnAcceleratedSurfacePostSubBuffer( | 135 void OnAcceleratedSurfacePostSubBuffer( |
124 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); | 136 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); |
125 void OnAcceleratedSurfaceSuspend(int32 surface_id); | 137 void OnAcceleratedSurfaceSuspend(int32 surface_id); |
126 void OnAcceleratedSurfaceRelease( | 138 void OnAcceleratedSurfaceRelease( |
127 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); | 139 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); |
128 #endif | 140 #endif |
129 | 141 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 193 |
182 // Master switch for enabling/disabling GPU acceleration for the current | 194 // Master switch for enabling/disabling GPU acceleration for the current |
183 // browser session. It does not change the acceleration settings for | 195 // browser session. It does not change the acceleration settings for |
184 // existing tabs, just the future ones. | 196 // existing tabs, just the future ones. |
185 static bool gpu_enabled_; | 197 static bool gpu_enabled_; |
186 | 198 |
187 static bool hardware_gpu_enabled_; | 199 static bool hardware_gpu_enabled_; |
188 | 200 |
189 scoped_ptr<BrowserChildProcessHostImpl> process_; | 201 scoped_ptr<BrowserChildProcessHostImpl> process_; |
190 | 202 |
| 203 std::map<int, scoped_refptr<RenderWidgetHelper> > render_widget_helpers_; |
| 204 |
191 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 205 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
192 }; | 206 }; |
193 | 207 |
194 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 208 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
OLD | NEW |