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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 void Cancel() { cancelled_ = true; } | 76 void Cancel() { cancelled_ = true; } |
77 | 77 |
78 private: | 78 private: |
79 int host_id_; | 79 int host_id_; |
80 scoped_ptr<IPC::Message> msg_; | 80 scoped_ptr<IPC::Message> msg_; |
81 bool cancelled_; | 81 bool cancelled_; |
82 }; | 82 }; |
83 | 83 |
| 84 RenderWidgetHostView* GetRenderWidgetHostViewFromID(int render_process_id, |
| 85 int render_widget_id) { |
| 86 content::RenderProcessHost* process = |
| 87 content::RenderProcessHost::FromID(render_process_id); |
| 88 if (!process) |
| 89 return NULL; |
| 90 |
| 91 RenderWidgetHost* host = static_cast<RenderWidgetHost*>( |
| 92 process->GetListenerByID(render_widget_id)); |
| 93 return host ? host->view() : NULL; |
| 94 } |
| 95 |
84 } // namespace | 96 } // namespace |
85 | 97 |
86 RouteToGpuProcessHostUIShimTask::RouteToGpuProcessHostUIShimTask( | 98 RouteToGpuProcessHostUIShimTask::RouteToGpuProcessHostUIShimTask( |
87 int host_id, | 99 int host_id, |
88 const IPC::Message& msg) | 100 const IPC::Message& msg) |
89 : host_id_(host_id), | 101 : host_id_(host_id), |
90 msg_(msg) { | 102 msg_(msg) { |
91 } | 103 } |
92 | 104 |
93 RouteToGpuProcessHostUIShimTask::~RouteToGpuProcessHostUIShimTask() { | 105 RouteToGpuProcessHostUIShimTask::~RouteToGpuProcessHostUIShimTask() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 int32 render_view_id, | 235 int32 render_view_id, |
224 int32 route_id, | 236 int32 route_id, |
225 gfx::Size size) { | 237 gfx::Size size) { |
226 // Always respond even if the window no longer exists. The GPU process cannot | 238 // Always respond even if the window no longer exists. The GPU process cannot |
227 // make progress on the resizing command buffer until it receives the | 239 // make progress on the resizing command buffer until it receives the |
228 // response. | 240 // response. |
229 ScopedSendOnIOThread delayed_send( | 241 ScopedSendOnIOThread delayed_send( |
230 host_id_, | 242 host_id_, |
231 new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); | 243 new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); |
232 | 244 |
233 RenderViewHost* host = RenderViewHost::FromID(renderer_id, render_view_id); | 245 RenderWidgetHostView* view = GetRenderWidgetHostViewFromID(renderer_id, |
234 if (!host) | 246 render_view_id); |
235 return; | |
236 | |
237 RenderWidgetHostView* view = host->view(); | |
238 if (!view) | 247 if (!view) |
239 return; | 248 return; |
240 | 249 |
241 gfx::PluginWindowHandle handle = view->GetCompositingSurface(); | 250 gfx::PluginWindowHandle handle = view->GetCompositingSurface(); |
242 | 251 |
243 // Resize the window synchronously. The GPU process must not issue GL | 252 // Resize the window synchronously. The GPU process must not issue GL |
244 // calls on the command buffer until the window is the size it expects it | 253 // calls on the command buffer until the window is the size it expects it |
245 // to be. | 254 // to be. |
246 #if defined(TOOLKIT_USES_GTK) | 255 #if defined(TOOLKIT_USES_GTK) |
247 GdkWindow* window = reinterpret_cast<GdkWindow*>( | 256 GdkWindow* window = reinterpret_cast<GdkWindow*>( |
(...skipping 22 matching lines...) Expand all Loading... |
270 | 279 |
271 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( | 280 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( |
272 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { | 281 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { |
273 ScopedSendOnIOThread delayed_send( | 282 ScopedSendOnIOThread delayed_send( |
274 host_id_, | 283 host_id_, |
275 new AcceleratedSurfaceMsg_NewACK( | 284 new AcceleratedSurfaceMsg_NewACK( |
276 params.route_id, | 285 params.route_id, |
277 params.surface_id, | 286 params.surface_id, |
278 TransportDIB::DefaultHandleValue())); | 287 TransportDIB::DefaultHandleValue())); |
279 | 288 |
280 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 289 RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( |
281 params.render_view_id); | 290 params.renderer_id, params.render_view_id); |
282 if (!host) | |
283 return; | |
284 | |
285 RenderWidgetHostView* view = host->view(); | |
286 if (!view) | 291 if (!view) |
287 return; | 292 return; |
288 | 293 |
289 uint64 surface_id = params.surface_id; | 294 uint64 surface_id = params.surface_id; |
290 TransportDIB::Handle surface_handle = TransportDIB::DefaultHandleValue(); | 295 TransportDIB::Handle surface_handle = TransportDIB::DefaultHandleValue(); |
291 | 296 |
292 #if defined(OS_MACOSX) | 297 #if defined(OS_MACOSX) |
293 if (params.create_transport_dib) { | 298 if (params.create_transport_dib) { |
294 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 299 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
295 if (shared_memory->CreateAnonymous(params.width * params.height * 4)) { | 300 if (shared_memory->CreateAnonymous(params.width * params.height * 4)) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 334 |
330 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 335 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
331 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 336 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
332 TRACE_EVENT0("renderer", | 337 TRACE_EVENT0("renderer", |
333 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 338 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
334 | 339 |
335 ScopedSendOnIOThread delayed_send( | 340 ScopedSendOnIOThread delayed_send( |
336 host_id_, | 341 host_id_, |
337 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); | 342 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); |
338 | 343 |
339 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 344 RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( |
340 params.render_view_id); | 345 params.renderer_id, params.render_view_id); |
341 if (!host) | |
342 return; | |
343 | |
344 RenderWidgetHostView* view = host->view(); | |
345 if (!view) | 346 if (!view) |
346 return; | 347 return; |
347 | 348 |
348 delayed_send.Cancel(); | 349 delayed_send.Cancel(); |
349 | 350 |
350 // View must send ACK message after next composite. | 351 // View must send ACK message after next composite. |
351 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); | 352 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); |
352 } | 353 } |
353 | 354 |
354 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( | 355 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( |
355 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { | 356 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { |
356 TRACE_EVENT0("renderer", | 357 TRACE_EVENT0("renderer", |
357 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); | 358 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); |
358 | 359 |
359 ScopedSendOnIOThread delayed_send( | 360 ScopedSendOnIOThread delayed_send( |
360 host_id_, | 361 host_id_, |
361 new AcceleratedSurfaceMsg_PostSubBufferACK(params.route_id)); | 362 new AcceleratedSurfaceMsg_PostSubBufferACK(params.route_id)); |
362 | 363 |
363 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 364 RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( |
364 params.render_view_id); | 365 params.renderer_id, params.render_view_id); |
365 if (!host) | |
366 return; | |
367 | |
368 RenderWidgetHostView* view = host->view(); | |
369 if (!view) | 366 if (!view) |
370 return; | 367 return; |
371 | 368 |
372 delayed_send.Cancel(); | 369 delayed_send.Cancel(); |
373 | 370 |
374 // View must send ACK message after next composite. | 371 // View must send ACK message after next composite. |
375 view->AcceleratedSurfacePostSubBuffer(params, host_id_); | 372 view->AcceleratedSurfacePostSubBuffer(params, host_id_); |
376 } | 373 } |
377 | 374 |
378 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 375 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
379 | 376 |
380 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( | 377 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( |
381 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { | 378 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { |
382 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 379 RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( |
383 params.render_view_id); | 380 params.renderer_id, params.render_view_id); |
384 if (!host) | |
385 return; | |
386 RenderWidgetHostView* view = host->view(); | |
387 if (!view) | 381 if (!view) |
388 return; | 382 return; |
389 view->AcceleratedSurfaceRelease(params.identifier); | 383 view->AcceleratedSurfaceRelease(params.identifier); |
390 } | 384 } |
391 | 385 |
392 #endif | 386 #endif |
OLD | NEW |