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/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 return result; | 471 return result; |
472 } | 472 } |
473 | 473 |
474 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 474 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
475 DCHECK(CalledOnValidThread()); | 475 DCHECK(CalledOnValidThread()); |
476 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 476 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
477 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 477 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
478 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 478 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
479 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 479 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
480 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) | 480 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) |
| 481 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) |
481 #if defined(OS_MACOSX) | 482 #if defined(OS_MACOSX) |
482 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 483 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
483 OnAcceleratedSurfaceBuffersSwapped) | 484 OnAcceleratedSurfaceBuffersSwapped) |
484 #endif | 485 #endif |
485 #if defined(OS_WIN) | 486 #if defined(OS_WIN) |
486 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 487 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
487 OnAcceleratedSurfaceBuffersSwapped) | 488 OnAcceleratedSurfaceBuffersSwapped) |
488 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, | 489 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, |
489 OnAcceleratedSurfacePostSubBuffer) | 490 OnAcceleratedSurfacePostSubBuffer) |
490 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, | 491 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 compositing_surface, surface_id, client_id, init_params))) { | 560 compositing_surface, surface_id, client_id, init_params))) { |
560 create_command_buffer_requests_.push(callback); | 561 create_command_buffer_requests_.push(callback); |
561 #if defined(TOOLKIT_GTK) | 562 #if defined(TOOLKIT_GTK) |
562 surface_refs_.insert(std::make_pair(surface_id, surface_ref)); | 563 surface_refs_.insert(std::make_pair(surface_id, surface_ref)); |
563 #endif | 564 #endif |
564 } else { | 565 } else { |
565 CreateCommandBufferError(callback, MSG_ROUTING_NONE); | 566 CreateCommandBufferError(callback, MSG_ROUTING_NONE); |
566 } | 567 } |
567 } | 568 } |
568 | 569 |
| 570 void GpuProcessHost::CreateImage( |
| 571 gfx::PluginWindowHandle window, |
| 572 int client_id, |
| 573 int image_id, |
| 574 const CreateImageCallback& callback) { |
| 575 TRACE_EVENT0("gpu", "GpuProcessHostUIShim::CreateImage"); |
| 576 |
| 577 DCHECK(CalledOnValidThread()); |
| 578 |
| 579 if (Send(new GpuMsg_CreateImage(window, client_id, image_id))) { |
| 580 create_image_requests_.push(callback); |
| 581 } else { |
| 582 CreateImageError(callback, gfx::Size()); |
| 583 } |
| 584 } |
| 585 |
| 586 void GpuProcessHost::DeleteImage( |
| 587 int client_id, |
| 588 int image_id, |
| 589 int sync_point) { |
| 590 TRACE_EVENT0("gpu", "GpuProcessHostUIShim::DeleteImage"); |
| 591 |
| 592 DCHECK(CalledOnValidThread()); |
| 593 |
| 594 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); |
| 595 } |
| 596 |
569 void GpuProcessHost::OnInitialized(bool result) { | 597 void GpuProcessHost::OnInitialized(bool result) { |
570 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 598 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
571 } | 599 } |
572 | 600 |
573 void GpuProcessHost::OnChannelEstablished( | 601 void GpuProcessHost::OnChannelEstablished( |
574 const IPC::ChannelHandle& channel_handle) { | 602 const IPC::ChannelHandle& channel_handle) { |
575 TRACE_EVENT0("gpu", "GpuProcessHostUIShim::OnChannelEstablished"); | 603 TRACE_EVENT0("gpu", "GpuProcessHostUIShim::OnChannelEstablished"); |
576 | 604 |
577 EstablishChannelCallback callback = channel_requests_.front(); | 605 EstablishChannelCallback callback = channel_requests_.front(); |
578 channel_requests_.pop(); | 606 channel_requests_.pop(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { | 642 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
615 TRACE_EVENT0("gpu", "GpuProcessHostUIShim::OnDestroyCommandBuffer"); | 643 TRACE_EVENT0("gpu", "GpuProcessHostUIShim::OnDestroyCommandBuffer"); |
616 | 644 |
617 #if defined(TOOLKIT_GTK) | 645 #if defined(TOOLKIT_GTK) |
618 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); | 646 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
619 if (it != surface_refs_.end()) | 647 if (it != surface_refs_.end()) |
620 surface_refs_.erase(it); | 648 surface_refs_.erase(it); |
621 #endif // defined(TOOLKIT_GTK) | 649 #endif // defined(TOOLKIT_GTK) |
622 } | 650 } |
623 | 651 |
| 652 void GpuProcessHost::OnImageCreated(const gfx::Size size) { |
| 653 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); |
| 654 |
| 655 if (!create_image_requests_.empty()) { |
| 656 CreateImageCallback callback = create_image_requests_.front(); |
| 657 create_image_requests_.pop(); |
| 658 callback.Run(size); |
| 659 } |
| 660 } |
| 661 |
624 #if defined(OS_MACOSX) | 662 #if defined(OS_MACOSX) |
625 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 663 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
626 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 664 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
627 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 665 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
628 | 666 |
629 gfx::PluginWindowHandle handle = | 667 gfx::PluginWindowHandle handle = |
630 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); | 668 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); |
631 // Compositor window is always gfx::kNullPluginWindow. | 669 // Compositor window is always gfx::kNullPluginWindow. |
632 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no | 670 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
633 // plugin windows. | 671 // plugin windows. |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 const IPC::ChannelHandle& channel_handle, | 945 const IPC::ChannelHandle& channel_handle, |
908 base::ProcessHandle renderer_process_for_gpu, | 946 base::ProcessHandle renderer_process_for_gpu, |
909 const content::GPUInfo& gpu_info) { | 947 const content::GPUInfo& gpu_info) { |
910 callback.Run(channel_handle, gpu_info); | 948 callback.Run(channel_handle, gpu_info); |
911 } | 949 } |
912 | 950 |
913 void GpuProcessHost::CreateCommandBufferError( | 951 void GpuProcessHost::CreateCommandBufferError( |
914 const CreateCommandBufferCallback& callback, int32 route_id) { | 952 const CreateCommandBufferCallback& callback, int32 route_id) { |
915 callback.Run(route_id); | 953 callback.Run(route_id); |
916 } | 954 } |
| 955 |
| 956 void GpuProcessHost::CreateImageError( |
| 957 const CreateImageCallback& callback, const gfx::Size size) { |
| 958 callback.Run(size); |
| 959 } |
OLD | NEW |