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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 559 } |
560 | 560 |
561 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 561 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
562 DCHECK(CalledOnValidThread()); | 562 DCHECK(CalledOnValidThread()); |
563 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 563 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
564 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 564 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
565 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 565 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
566 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 566 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
567 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) | 567 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) |
568 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) | 568 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) |
| 569 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
| 570 OnGpuMemoryBufferCreated) |
569 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 571 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
570 OnDidCreateOffscreenContext) | 572 OnDidCreateOffscreenContext) |
571 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 573 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
572 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 574 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
573 OnDidDestroyOffscreenContext) | 575 OnDidDestroyOffscreenContext) |
574 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 576 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
575 OnGpuMemoryUmaStatsReceived) | 577 OnGpuMemoryUmaStatsReceived) |
576 #if defined(OS_MACOSX) | 578 #if defined(OS_MACOSX) |
577 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 579 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
578 OnAcceleratedSurfaceBuffersSwapped) | 580 OnAcceleratedSurfaceBuffersSwapped) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 void GpuProcessHost::DeleteImage(int client_id, | 666 void GpuProcessHost::DeleteImage(int client_id, |
665 int image_id, | 667 int image_id, |
666 int sync_point) { | 668 int sync_point) { |
667 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteImage"); | 669 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteImage"); |
668 | 670 |
669 DCHECK(CalledOnValidThread()); | 671 DCHECK(CalledOnValidThread()); |
670 | 672 |
671 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); | 673 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); |
672 } | 674 } |
673 | 675 |
| 676 void GpuProcessHost::CreateGpuMemoryBuffer( |
| 677 const gfx::GpuMemoryBufferHandle& handle, |
| 678 const gfx::Size& size, |
| 679 unsigned internalformat, |
| 680 unsigned usage, |
| 681 const CreateGpuMemoryBufferCallback& callback) { |
| 682 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
| 683 |
| 684 DCHECK(CalledOnValidThread()); |
| 685 |
| 686 if (Send(new GpuMsg_CreateGpuMemoryBuffer( |
| 687 handle, size, internalformat, usage))) { |
| 688 create_gpu_memory_buffer_requests_.push(callback); |
| 689 } else { |
| 690 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 691 } |
| 692 } |
| 693 |
| 694 void GpuProcessHost::DestroyGpuMemoryBuffer( |
| 695 const gfx::GpuMemoryBufferHandle& handle, |
| 696 int sync_point) { |
| 697 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
| 698 |
| 699 DCHECK(CalledOnValidThread()); |
| 700 |
| 701 Send(new GpuMsg_DestroyGpuMemoryBuffer(handle, sync_point)); |
| 702 } |
| 703 |
674 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 704 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
675 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 705 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
676 initialized_ = result; | 706 initialized_ = result; |
677 | 707 |
678 if (!initialized_) | 708 if (!initialized_) |
679 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 709 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
680 else if (!in_process_) | 710 else if (!in_process_) |
681 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 711 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
682 } | 712 } |
683 | 713 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); | 767 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); |
738 | 768 |
739 if (create_image_requests_.empty()) | 769 if (create_image_requests_.empty()) |
740 return; | 770 return; |
741 | 771 |
742 CreateImageCallback callback = create_image_requests_.front(); | 772 CreateImageCallback callback = create_image_requests_.front(); |
743 create_image_requests_.pop(); | 773 create_image_requests_.pop(); |
744 callback.Run(size); | 774 callback.Run(size); |
745 } | 775 } |
746 | 776 |
| 777 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 778 const gfx::GpuMemoryBufferHandle& handle) { |
| 779 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 780 |
| 781 if (create_gpu_memory_buffer_requests_.empty()) |
| 782 return; |
| 783 |
| 784 CreateGpuMemoryBufferCallback callback = |
| 785 create_gpu_memory_buffer_requests_.front(); |
| 786 create_gpu_memory_buffer_requests_.pop(); |
| 787 callback.Run(handle); |
| 788 } |
| 789 |
747 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 790 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
748 urls_with_live_offscreen_contexts_.insert(url); | 791 urls_with_live_offscreen_contexts_.insert(url); |
749 } | 792 } |
750 | 793 |
751 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 794 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
752 gpu::error::ContextLostReason reason, | 795 gpu::error::ContextLostReason reason, |
753 const GURL& url) { | 796 const GURL& url) { |
754 // TODO(kbr): would be nice to see the "offscreen" flag too. | 797 // TODO(kbr): would be nice to see the "offscreen" flag too. |
755 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 798 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
756 "reason", reason, | 799 "reason", reason, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1112 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1070 ClientIdToShaderCacheMap::iterator iter = | 1113 ClientIdToShaderCacheMap::iterator iter = |
1071 client_id_to_shader_cache_.find(client_id); | 1114 client_id_to_shader_cache_.find(client_id); |
1072 // If the cache doesn't exist then this is an off the record profile. | 1115 // If the cache doesn't exist then this is an off the record profile. |
1073 if (iter == client_id_to_shader_cache_.end()) | 1116 if (iter == client_id_to_shader_cache_.end()) |
1074 return; | 1117 return; |
1075 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1118 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1076 } | 1119 } |
1077 | 1120 |
1078 } // namespace content | 1121 } // namespace content |
OLD | NEW |