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