| 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 #include "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 channel_requests_.push(callback); | 396 channel_requests_.push(callback); |
| 397 } else { | 397 } else { |
| 398 EstablishChannelError( | 398 EstablishChannelError( |
| 399 callback, IPC::ChannelHandle(), | 399 callback, IPC::ChannelHandle(), |
| 400 base::kNullProcessHandle, content::GPUInfo()); | 400 base::kNullProcessHandle, content::GPUInfo()); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 void GpuProcessHost::CreateViewCommandBuffer( | 404 void GpuProcessHost::CreateViewCommandBuffer( |
| 405 gfx::PluginWindowHandle compositing_surface, | 405 gfx::PluginWindowHandle compositing_surface, |
| 406 int32 render_view_id, | 406 int surface_id, |
| 407 int32 client_id, | 407 int client_id, |
| 408 const GPUCreateCommandBufferConfig& init_params, | 408 const GPUCreateCommandBufferConfig& init_params, |
| 409 const CreateCommandBufferCallback& callback) { | 409 const CreateCommandBufferCallback& callback) { |
| 410 DCHECK(CalledOnValidThread()); | 410 DCHECK(CalledOnValidThread()); |
| 411 | 411 |
| 412 #if defined(TOOLKIT_USES_GTK) | 412 #if defined(TOOLKIT_USES_GTK) |
| 413 ViewID view_id(client_id, render_view_id); | |
| 414 | |
| 415 // There should only be one such command buffer (for the compositor). In | 413 // There should only be one such command buffer (for the compositor). In |
| 416 // practice, if the GPU process lost a context, GraphicsContext3D with | 414 // practice, if the GPU process lost a context, GraphicsContext3D with |
| 417 // associated command buffer and view surface will not be gone until new | 415 // associated command buffer and view surface will not be gone until new |
| 418 // one is in place and all layers are reattached. | 416 // one is in place and all layers are reattached. |
| 419 linked_ptr<SurfaceRef> surface_ref; | 417 linked_ptr<SurfaceRef> surface_ref; |
| 420 SurfaceRefMap::iterator it = surface_refs_.find(view_id); | 418 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
| 421 if (it != surface_refs_.end()) | 419 if (it != surface_refs_.end()) |
| 422 surface_ref = (*it).second; | 420 surface_ref = (*it).second; |
| 423 else | 421 else |
| 424 surface_ref.reset(new SurfaceRef(compositing_surface)); | 422 surface_ref.reset(new SurfaceRef(compositing_surface)); |
| 425 #endif // defined(TOOLKIT_USES_GTK) | 423 #endif // defined(TOOLKIT_USES_GTK) |
| 426 | 424 |
| 427 if (compositing_surface != gfx::kNullPluginWindow && | 425 if (compositing_surface != gfx::kNullPluginWindow && |
| 428 Send(new GpuMsg_CreateViewCommandBuffer( | 426 Send(new GpuMsg_CreateViewCommandBuffer( |
| 429 compositing_surface, render_view_id, client_id, init_params))) { | 427 compositing_surface, surface_id, client_id, init_params))) { |
| 430 create_command_buffer_requests_.push(callback); | 428 create_command_buffer_requests_.push(callback); |
| 431 #if defined(TOOLKIT_USES_GTK) | 429 #if defined(TOOLKIT_USES_GTK) |
| 432 surface_refs_.insert(std::pair<ViewID, linked_ptr<SurfaceRef> >( | 430 surface_refs_.insert(std::make_pair(surface_id, surface_ref)); |
| 433 view_id, surface_ref)); | |
| 434 #endif | 431 #endif |
| 435 } else { | 432 } else { |
| 436 CreateCommandBufferError(callback, MSG_ROUTING_NONE); | 433 CreateCommandBufferError(callback, MSG_ROUTING_NONE); |
| 437 } | 434 } |
| 438 } | 435 } |
| 439 | 436 |
| 440 void GpuProcessHost::OnChannelEstablished( | 437 void GpuProcessHost::OnChannelEstablished( |
| 441 const IPC::ChannelHandle& channel_handle) { | 438 const IPC::ChannelHandle& channel_handle) { |
| 442 // The GPU process should have launched at this point and this object should | 439 // The GPU process should have launched at this point and this object should |
| 443 // have been notified of its process handle. | 440 // have been notified of its process handle. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 471 CreateCommandBufferCallback callback = | 468 CreateCommandBufferCallback callback = |
| 472 create_command_buffer_requests_.front(); | 469 create_command_buffer_requests_.front(); |
| 473 create_command_buffer_requests_.pop(); | 470 create_command_buffer_requests_.pop(); |
| 474 if (route_id == MSG_ROUTING_NONE) | 471 if (route_id == MSG_ROUTING_NONE) |
| 475 CreateCommandBufferError(callback, route_id); | 472 CreateCommandBufferError(callback, route_id); |
| 476 else | 473 else |
| 477 callback.Run(route_id); | 474 callback.Run(route_id); |
| 478 } | 475 } |
| 479 } | 476 } |
| 480 | 477 |
| 481 void GpuProcessHost::OnDestroyCommandBuffer( | 478 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
| 482 gfx::PluginWindowHandle window, int32 client_id, | |
| 483 int32 render_view_id) { | |
| 484 #if defined(TOOLKIT_USES_GTK) | 479 #if defined(TOOLKIT_USES_GTK) |
| 485 ViewID view_id(client_id, render_view_id); | 480 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
| 486 SurfaceRefMap::iterator it = surface_refs_.find(view_id); | |
| 487 if (it != surface_refs_.end()) | 481 if (it != surface_refs_.end()) |
| 488 surface_refs_.erase(it); | 482 surface_refs_.erase(it); |
| 489 #endif // defined(TOOLKIT_USES_GTK) | 483 #endif // defined(TOOLKIT_USES_GTK) |
| 490 } | 484 } |
| 491 | 485 |
| 492 void GpuProcessHost::OnProcessLaunched() { | 486 void GpuProcessHost::OnProcessLaunched() { |
| 493 // Send the GPU process handle to the UI thread before it has to | 487 // Send the GPU process handle to the UI thread before it has to |
| 494 // respond to any requests to establish a GPU channel. The response | 488 // respond to any requests to establish a GPU channel. The response |
| 495 // to such requests require that the GPU process handle be known. | 489 // to such requests require that the GPU process handle be known. |
| 496 | 490 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 const IPC::ChannelHandle& channel_handle, | 620 const IPC::ChannelHandle& channel_handle, |
| 627 base::ProcessHandle renderer_process_for_gpu, | 621 base::ProcessHandle renderer_process_for_gpu, |
| 628 const content::GPUInfo& gpu_info) { | 622 const content::GPUInfo& gpu_info) { |
| 629 callback.Run(channel_handle, renderer_process_for_gpu, gpu_info); | 623 callback.Run(channel_handle, renderer_process_for_gpu, gpu_info); |
| 630 } | 624 } |
| 631 | 625 |
| 632 void GpuProcessHost::CreateCommandBufferError( | 626 void GpuProcessHost::CreateCommandBufferError( |
| 633 const CreateCommandBufferCallback& callback, int32 route_id) { | 627 const CreateCommandBufferCallback& callback, int32 route_id) { |
| 634 callback.Run(route_id); | 628 callback.Run(route_id); |
| 635 } | 629 } |
| OLD | NEW |