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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // and GPUInfo, we call the callback. | 68 // and GPUInfo, we call the callback. |
69 void EstablishGpuChannel( | 69 void EstablishGpuChannel( |
70 int client_id, const EstablishChannelCallback& callback); | 70 int client_id, const EstablishChannelCallback& callback); |
71 | 71 |
72 typedef base::Callback<void(int32)> CreateCommandBufferCallback; | 72 typedef base::Callback<void(int32)> CreateCommandBufferCallback; |
73 | 73 |
74 // Tells the GPU process to create a new command buffer that draws into the | 74 // Tells the GPU process to create a new command buffer that draws into the |
75 // window associated with the given renderer. | 75 // window associated with the given renderer. |
76 void CreateViewCommandBuffer( | 76 void CreateViewCommandBuffer( |
77 gfx::PluginWindowHandle compositing_surface, | 77 gfx::PluginWindowHandle compositing_surface, |
78 int32 render_view_id, | 78 int surface_id, |
79 int32 client_id, | 79 int client_id, |
80 const GPUCreateCommandBufferConfig& init_params, | 80 const GPUCreateCommandBufferConfig& init_params, |
81 const CreateCommandBufferCallback& callback); | 81 const CreateCommandBufferCallback& callback); |
82 | 82 |
83 // Whether this GPU process is set up to use software rendering. | 83 // Whether this GPU process is set up to use software rendering. |
84 bool software_rendering(); | 84 bool software_rendering(); |
85 | 85 |
86 void ForceShutdown(); | 86 void ForceShutdown(); |
87 | 87 |
88 private: | 88 private: |
89 GpuProcessHost(int host_id); | 89 GpuProcessHost(int host_id); |
90 virtual ~GpuProcessHost(); | 90 virtual ~GpuProcessHost(); |
91 | 91 |
92 bool Init(); | 92 bool Init(); |
93 | 93 |
94 // Post an IPC message to the UI shim's message handler on the UI thread. | 94 // Post an IPC message to the UI shim's message handler on the UI thread. |
95 void RouteOnUIThread(const IPC::Message& message); | 95 void RouteOnUIThread(const IPC::Message& message); |
96 | 96 |
97 virtual void OnProcessLaunched() OVERRIDE; | 97 virtual void OnProcessLaunched() OVERRIDE; |
98 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 98 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
99 | 99 |
100 // Message handlers. | 100 // Message handlers. |
101 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 101 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
102 void OnCommandBufferCreated(const int32 route_id); | 102 void OnCommandBufferCreated(const int32 route_id); |
103 void OnDestroyCommandBuffer( | 103 void OnDestroyCommandBuffer(int32 surface_id); |
104 gfx::PluginWindowHandle window, int32 client_id, int32 render_view_id); | |
105 | 104 |
106 bool LaunchGpuProcess(const std::string& channel_id); | 105 bool LaunchGpuProcess(const std::string& channel_id); |
107 | 106 |
108 void SendOutstandingReplies(); | 107 void SendOutstandingReplies(); |
109 void EstablishChannelError( | 108 void EstablishChannelError( |
110 const EstablishChannelCallback& callback, | 109 const EstablishChannelCallback& callback, |
111 const IPC::ChannelHandle& channel_handle, | 110 const IPC::ChannelHandle& channel_handle, |
112 base::ProcessHandle renderer_process_for_gpu, | 111 base::ProcessHandle renderer_process_for_gpu, |
113 const content::GPUInfo& gpu_info); | 112 const content::GPUInfo& gpu_info); |
114 void CreateCommandBufferError(const CreateCommandBufferCallback& callback, | 113 void CreateCommandBufferError(const CreateCommandBufferCallback& callback, |
115 int32 route_id); | 114 int32 route_id); |
116 | 115 |
117 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 116 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
118 int host_id_; | 117 int host_id_; |
119 | 118 |
120 // These are the channel requests that we have already sent to | 119 // These are the channel requests that we have already sent to |
121 // the GPU process, but haven't heard back about yet. | 120 // the GPU process, but haven't heard back about yet. |
122 std::queue<EstablishChannelCallback> channel_requests_; | 121 std::queue<EstablishChannelCallback> channel_requests_; |
123 | 122 |
124 // The pending create command buffer requests we need to reply to. | 123 // The pending create command buffer requests we need to reply to. |
125 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; | 124 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; |
126 | 125 |
127 #if defined(TOOLKIT_USES_GTK) | 126 #if defined(TOOLKIT_USES_GTK) |
128 typedef std::pair<int32 /* client_id */, | |
129 int32 /* render_view_id */> ViewID; | |
130 | |
131 // Encapsulates surfaces that we lock when creating view command buffers. | 127 // Encapsulates surfaces that we lock when creating view command buffers. |
132 // We release this lock once the command buffer (or associated GPU process) | 128 // We release this lock once the command buffer (or associated GPU process) |
133 // is destroyed. This prevents the browser from destroying the surface | 129 // is destroyed. This prevents the browser from destroying the surface |
134 // while the GPU process is drawing to it. | 130 // while the GPU process is drawing to it. |
135 | 131 |
136 // Multimap is used to simulate reference counting, see comment in | 132 // Multimap is used to simulate reference counting, see comment in |
137 // GpuProcessHostUIShim::CreateViewCommandBuffer. | 133 // GpuProcessHostUIShim::CreateViewCommandBuffer. |
138 class SurfaceRef; | 134 class SurfaceRef; |
139 typedef std::multimap<ViewID, linked_ptr<SurfaceRef> > SurfaceRefMap; | 135 typedef std::multimap<int, linked_ptr<SurfaceRef> > SurfaceRefMap; |
140 SurfaceRefMap surface_refs_; | 136 SurfaceRefMap surface_refs_; |
141 #endif | 137 #endif |
142 | 138 |
143 // Qeueud messages to send when the process launches. | 139 // Qeueud messages to send when the process launches. |
144 std::queue<IPC::Message*> queued_messages_; | 140 std::queue<IPC::Message*> queued_messages_; |
145 | 141 |
146 // The handle for the GPU process or null if it is not known to be launched. | 142 // The handle for the GPU process or null if it is not known to be launched. |
147 base::ProcessHandle gpu_process_; | 143 base::ProcessHandle gpu_process_; |
148 | 144 |
149 // Whether we are running a GPU thread inside the browser process instead | 145 // Whether we are running a GPU thread inside the browser process instead |
150 // of a separate GPU process. | 146 // of a separate GPU process. |
151 bool in_process_; | 147 bool in_process_; |
152 | 148 |
153 bool software_rendering_; | 149 bool software_rendering_; |
154 | 150 |
155 scoped_ptr<GpuMainThread> in_process_gpu_thread_; | 151 scoped_ptr<GpuMainThread> in_process_gpu_thread_; |
156 | 152 |
157 // Master switch for enabling/disabling GPU acceleration for the current | 153 // Master switch for enabling/disabling GPU acceleration for the current |
158 // browser session. It does not change the acceleration settings for | 154 // browser session. It does not change the acceleration settings for |
159 // existing tabs, just the future ones. | 155 // existing tabs, just the future ones. |
160 CONTENT_EXPORT static bool gpu_enabled_; | 156 CONTENT_EXPORT static bool gpu_enabled_; |
161 | 157 |
162 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 158 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
163 }; | 159 }; |
164 | 160 |
165 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 161 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
OLD | NEW |