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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 614 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
615 DCHECK(CalledOnValidThread()); | 615 DCHECK(CalledOnValidThread()); |
616 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 616 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
617 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 617 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
618 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 618 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
619 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 619 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
620 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, | 620 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
621 OnGpuMemoryBufferCreated) | 621 OnGpuMemoryBufferCreated) |
622 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 622 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
623 OnDidCreateOffscreenContext) | 623 OnDidCreateOffscreenContext) |
| 624 IPC_MESSAGE_HANDLER(GpuHostMsg_ArcVideoAcceleratorChannelCreated, |
| 625 OnArcVideoAcceleratorChannelCreated) |
624 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 626 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
625 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 627 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
626 OnDidDestroyOffscreenContext) | 628 OnDidDestroyOffscreenContext) |
627 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 629 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
628 OnGpuMemoryUmaStatsReceived) | 630 OnGpuMemoryUmaStatsReceived) |
629 #if defined(OS_MACOSX) | 631 #if defined(OS_MACOSX) |
630 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 632 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
631 OnAcceleratedSurfaceBuffersSwapped(message)) | 633 OnAcceleratedSurfaceBuffersSwapped(message)) |
632 #endif | 634 #endif |
633 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, | 635 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 765 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
764 int client_id, | 766 int client_id, |
765 const gpu::SyncToken& sync_token) { | 767 const gpu::SyncToken& sync_token) { |
766 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); | 768 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
767 | 769 |
768 DCHECK(CalledOnValidThread()); | 770 DCHECK(CalledOnValidThread()); |
769 | 771 |
770 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); | 772 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); |
771 } | 773 } |
772 | 774 |
| 775 void GpuProcessHost::CreateArcVideoAcceleratorChannel( |
| 776 const CreateArcVideoAcceleratorChannelCallback& callback) { |
| 777 DCHECK(CalledOnValidThread()); |
| 778 |
| 779 if (Send(new GpuMsg_CreateArcVideoAcceleratorChannel())) { |
| 780 create_arc_video_accelerator_channel_requests_.push(callback); |
| 781 } else { |
| 782 callback.Run(IPC::ChannelHandle()); |
| 783 } |
| 784 } |
| 785 |
773 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 786 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
774 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 787 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
775 initialized_ = result; | 788 initialized_ = result; |
776 | 789 |
777 if (!initialized_) | 790 if (!initialized_) |
778 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 791 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
779 else if (!in_process_) | 792 else if (!in_process_) |
780 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 793 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
781 } | 794 } |
782 | 795 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 843 |
831 if (create_gpu_memory_buffer_requests_.empty()) | 844 if (create_gpu_memory_buffer_requests_.empty()) |
832 return; | 845 return; |
833 | 846 |
834 CreateGpuMemoryBufferCallback callback = | 847 CreateGpuMemoryBufferCallback callback = |
835 create_gpu_memory_buffer_requests_.front(); | 848 create_gpu_memory_buffer_requests_.front(); |
836 create_gpu_memory_buffer_requests_.pop(); | 849 create_gpu_memory_buffer_requests_.pop(); |
837 callback.Run(handle); | 850 callback.Run(handle); |
838 } | 851 } |
839 | 852 |
| 853 void GpuProcessHost::OnArcVideoAcceleratorChannelCreated( |
| 854 const IPC::ChannelHandle& handle) { |
| 855 if (create_arc_video_accelerator_channel_requests_.empty()) { |
| 856 RouteOnUIThread( |
| 857 GpuHostMsg_OnLogMessage(logging::LOG_WARNING, "WARNING", |
| 858 "Received a ArcVideoAcceleratorChannelCreated " |
| 859 "message but no requests in queue.")); |
| 860 return; |
| 861 } |
| 862 |
| 863 CreateArcVideoAcceleratorChannelCallback callback = |
| 864 create_arc_video_accelerator_channel_requests_.front(); |
| 865 create_arc_video_accelerator_channel_requests_.pop(); |
| 866 callback.Run(handle); |
| 867 } |
| 868 |
840 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 869 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
841 urls_with_live_offscreen_contexts_.insert(url); | 870 urls_with_live_offscreen_contexts_.insert(url); |
842 } | 871 } |
843 | 872 |
844 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 873 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
845 gpu::error::ContextLostReason reason, | 874 gpu::error::ContextLostReason reason, |
846 const GURL& url) { | 875 const GURL& url) { |
847 // TODO(kbr): would be nice to see the "offscreen" flag too. | 876 // TODO(kbr): would be nice to see the "offscreen" flag too. |
848 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 877 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
849 "reason", reason, | 878 "reason", reason, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 create_command_buffer_requests_.pop(); | 1071 create_command_buffer_requests_.pop(); |
1043 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 1072 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
1044 } | 1073 } |
1045 | 1074 |
1046 while (!create_gpu_memory_buffer_requests_.empty()) { | 1075 while (!create_gpu_memory_buffer_requests_.empty()) { |
1047 CreateGpuMemoryBufferCallback callback = | 1076 CreateGpuMemoryBufferCallback callback = |
1048 create_gpu_memory_buffer_requests_.front(); | 1077 create_gpu_memory_buffer_requests_.front(); |
1049 create_gpu_memory_buffer_requests_.pop(); | 1078 create_gpu_memory_buffer_requests_.pop(); |
1050 callback.Run(gfx::GpuMemoryBufferHandle()); | 1079 callback.Run(gfx::GpuMemoryBufferHandle()); |
1051 } | 1080 } |
| 1081 |
| 1082 while (!create_arc_video_accelerator_channel_requests_.empty()) { |
| 1083 CreateArcVideoAcceleratorChannelCallback callback = |
| 1084 create_arc_video_accelerator_channel_requests_.front(); |
| 1085 create_arc_video_accelerator_channel_requests_.pop(); |
| 1086 callback.Run(IPC::ChannelHandle()); |
| 1087 } |
1052 } | 1088 } |
1053 | 1089 |
1054 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1090 void GpuProcessHost::BlockLiveOffscreenContexts() { |
1055 for (std::multiset<GURL>::iterator iter = | 1091 for (std::multiset<GURL>::iterator iter = |
1056 urls_with_live_offscreen_contexts_.begin(); | 1092 urls_with_live_offscreen_contexts_.begin(); |
1057 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1093 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
1058 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1094 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
1059 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1095 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
1060 } | 1096 } |
1061 } | 1097 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1205 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1170 ClientIdToShaderCacheMap::iterator iter = | 1206 ClientIdToShaderCacheMap::iterator iter = |
1171 client_id_to_shader_cache_.find(client_id); | 1207 client_id_to_shader_cache_.find(client_id); |
1172 // If the cache doesn't exist then this is an off the record profile. | 1208 // If the cache doesn't exist then this is an off the record profile. |
1173 if (iter == client_id_to_shader_cache_.end()) | 1209 if (iter == client_id_to_shader_cache_.end()) |
1174 return; | 1210 return; |
1175 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1211 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1176 } | 1212 } |
1177 | 1213 |
1178 } // namespace content | 1214 } // namespace content |
OLD | NEW |