OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 g_hosts_by_id.Pointer()->Remove(host_id_); | 164 g_hosts_by_id.Pointer()->Remove(host_id_); |
165 } | 165 } |
166 | 166 |
167 bool GpuProcessHostUIShim::OnControlMessageReceived( | 167 bool GpuProcessHostUIShim::OnControlMessageReceived( |
168 const IPC::Message& message) { | 168 const IPC::Message& message) { |
169 DCHECK(CalledOnValidThread()); | 169 DCHECK(CalledOnValidThread()); |
170 | 170 |
171 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 171 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
172 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 172 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, |
173 OnLogMessage) | 173 OnLogMessage) |
| 174 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 175 OnAcceleratedSurfaceBuffersSwapped) |
| 176 |
174 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) | 177 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) |
175 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) | 178 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) |
176 #endif | 179 #endif |
177 | 180 |
178 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 181 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
179 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | |
180 OnAcceleratedSurfaceBuffersSwapped) | |
181 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceNew, | 182 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceNew, |
182 OnAcceleratedSurfaceNew) | 183 OnAcceleratedSurfaceNew) |
183 #endif | 184 #endif |
184 | 185 |
185 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 186 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
186 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, | 187 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, |
187 OnAcceleratedSurfaceRelease) | 188 OnAcceleratedSurfaceRelease) |
188 #endif | 189 #endif |
| 190 |
189 IPC_MESSAGE_UNHANDLED_ERROR() | 191 IPC_MESSAGE_UNHANDLED_ERROR() |
190 IPC_END_MESSAGE_MAP() | 192 IPC_END_MESSAGE_MAP() |
191 | 193 |
192 return true; | 194 return true; |
193 } | 195 } |
194 | 196 |
195 void GpuProcessHostUIShim::OnLogMessage( | 197 void GpuProcessHostUIShim::OnLogMessage( |
196 int level, | 198 int level, |
197 const std::string& header, | 199 const std::string& header, |
198 const std::string& message) { | 200 const std::string& message) { |
199 DictionaryValue* dict = new DictionaryValue(); | 201 DictionaryValue* dict = new DictionaryValue(); |
200 dict->SetInteger("level", level); | 202 dict->SetInteger("level", level); |
201 dict->SetString("header", header); | 203 dict->SetString("header", header); |
202 dict->SetString("message", message); | 204 dict->SetString("message", message); |
203 GpuDataManager::GetInstance()->AddLogMessage(dict); | 205 GpuDataManager::GetInstance()->AddLogMessage(dict); |
204 } | 206 } |
205 | 207 |
206 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) | 208 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) |
207 | 209 |
208 void GpuProcessHostUIShim::OnResizeView(int32 renderer_id, | 210 void GpuProcessHostUIShim::OnResizeView(int32 renderer_id, |
209 int32 render_view_id, | 211 int32 render_view_id, |
210 int32 command_buffer_route_id, | 212 int32 route_id, |
211 gfx::Size size) { | 213 gfx::Size size) { |
212 // Always respond even if the window no longer exists. The GPU process cannot | 214 // Always respond even if the window no longer exists. The GPU process cannot |
213 // make progress on the resizing command buffer until it receives the | 215 // make progress on the resizing command buffer until it receives the |
214 // response. | 216 // response. |
215 ScopedSendOnIOThread delayed_send( | 217 ScopedSendOnIOThread delayed_send( |
216 host_id_, | 218 host_id_, |
217 new GpuMsg_ResizeViewACK(renderer_id, | 219 new GpuMsg_ResizeViewACK(route_id)); |
218 command_buffer_route_id)); | |
219 | 220 |
220 RenderViewHost* host = RenderViewHost::FromID(renderer_id, render_view_id); | 221 RenderViewHost* host = RenderViewHost::FromID(renderer_id, render_view_id); |
221 if (!host) | 222 if (!host) |
222 return; | 223 return; |
223 | 224 |
224 RenderWidgetHostView* view = host->view(); | 225 RenderWidgetHostView* view = host->view(); |
225 if (!view) | 226 if (!view) |
226 return; | 227 return; |
227 | 228 |
228 gfx::PluginWindowHandle handle = view->GetCompositingSurface(); | 229 gfx::PluginWindowHandle handle = view->GetCompositingSurface(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 306 } |
306 #else // defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 307 #else // defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
307 view->AcceleratedSurfaceNew( | 308 view->AcceleratedSurfaceNew( |
308 params.width, params.height, &surface_id, &surface_handle); | 309 params.width, params.height, &surface_id, &surface_handle); |
309 #endif | 310 #endif |
310 delayed_send.Cancel(); | 311 delayed_send.Cancel(); |
311 Send(new AcceleratedSurfaceMsg_NewACK( | 312 Send(new AcceleratedSurfaceMsg_NewACK( |
312 params.route_id, surface_id, surface_handle)); | 313 params.route_id, surface_id, surface_handle)); |
313 } | 314 } |
314 | 315 |
| 316 #endif |
| 317 |
315 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 318 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
316 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 319 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
317 TRACE_EVENT0("renderer", | 320 TRACE_EVENT0("renderer", |
318 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 321 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
319 | 322 |
320 ScopedSendOnIOThread delayed_send( | 323 ScopedSendOnIOThread delayed_send( |
321 host_id_, | 324 host_id_, |
322 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); | 325 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); |
323 | 326 |
324 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 327 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, |
325 params.render_view_id); | 328 params.render_view_id); |
326 if (!host) | 329 if (!host) |
327 return; | 330 return; |
328 | 331 |
329 RenderWidgetHostView* view = host->view(); | 332 RenderWidgetHostView* view = host->view(); |
330 if (!view) | 333 if (!view) |
331 return; | 334 return; |
332 | 335 |
333 delayed_send.Cancel(); | 336 delayed_send.Cancel(); |
334 | 337 |
335 #if defined (OS_MACOSX) | 338 // View must send ACK message after next composite. |
336 view->AcceleratedSurfaceBuffersSwapped( | 339 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); |
337 // Parameters needed to swap the IOSurface. | |
338 params.window, | |
339 params.surface_id, | |
340 // Parameters needed to formulate an acknowledgment. | |
341 params.renderer_id, | |
342 params.route_id, | |
343 host_id_); | |
344 #else // defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | |
345 // view must send ACK message after next composite | |
346 view->AcceleratedSurfaceBuffersSwapped( | |
347 params.surface_id, params.route_id, host_id_); | |
348 #endif | |
349 } | 340 } |
350 | 341 |
351 #endif | |
352 | |
353 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 342 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
354 | 343 |
355 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( | 344 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( |
356 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { | 345 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { |
357 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 346 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, |
358 params.render_view_id); | 347 params.render_view_id); |
359 if (!host) | 348 if (!host) |
360 return; | 349 return; |
361 RenderWidgetHostView* view = host->view(); | 350 RenderWidgetHostView* view = host->view(); |
362 if (!view) | 351 if (!view) |
363 return; | 352 return; |
364 view->AcceleratedSurfaceRelease(params.identifier); | 353 view->AcceleratedSurfaceRelease(params.identifier); |
365 } | 354 } |
366 | 355 |
367 #endif | 356 #endif |
OLD | NEW |