| 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 597 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 598 DCHECK(CalledOnValidThread()); | 598 DCHECK(CalledOnValidThread()); |
| 599 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 599 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 600 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 600 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
| 601 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 601 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
| 602 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 602 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
| 603 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, | 603 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
| 604 OnGpuMemoryBufferCreated) | 604 OnGpuMemoryBufferCreated) |
| 605 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 605 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
| 606 OnDidCreateOffscreenContext) | 606 OnDidCreateOffscreenContext) |
| 607 #if defined(OS_CHROMEOS) | |
| 608 IPC_MESSAGE_HANDLER(GpuHostMsg_ArcVideoAcceleratorChannelCreated, | |
| 609 OnArcVideoAcceleratorChannelCreated) | |
| 610 #endif | |
| 611 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 607 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
| 612 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 608 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
| 613 OnDidDestroyOffscreenContext) | 609 OnDidDestroyOffscreenContext) |
| 614 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 610 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 615 OnGpuMemoryUmaStatsReceived) | 611 OnGpuMemoryUmaStatsReceived) |
| 616 #if defined(OS_MACOSX) | 612 #if defined(OS_MACOSX) |
| 617 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 613 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 618 OnAcceleratedSurfaceBuffersSwapped(message)) | 614 OnAcceleratedSurfaceBuffersSwapped(message)) |
| 619 #endif | 615 #endif |
| 620 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, | 616 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 778 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 783 int client_id, | 779 int client_id, |
| 784 const gpu::SyncToken& sync_token) { | 780 const gpu::SyncToken& sync_token) { |
| 785 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); | 781 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
| 786 | 782 |
| 787 DCHECK(CalledOnValidThread()); | 783 DCHECK(CalledOnValidThread()); |
| 788 | 784 |
| 789 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); | 785 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); |
| 790 } | 786 } |
| 791 | 787 |
| 792 #if defined(OS_CHROMEOS) | |
| 793 void GpuProcessHost::CreateArcVideoAcceleratorChannel( | |
| 794 const CreateArcVideoAcceleratorChannelCallback& callback) { | |
| 795 DCHECK(CalledOnValidThread()); | |
| 796 | |
| 797 if (Send(new GpuMsg_CreateArcVideoAcceleratorChannel())) { | |
| 798 create_arc_video_accelerator_channel_requests_.push(callback); | |
| 799 } else { | |
| 800 callback.Run(IPC::ChannelHandle()); | |
| 801 } | |
| 802 } | |
| 803 #endif | |
| 804 | |
| 805 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 788 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
| 806 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 789 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
| 807 initialized_ = result; | 790 initialized_ = result; |
| 808 gpu_info_ = gpu_info; | 791 gpu_info_ = gpu_info; |
| 809 | 792 |
| 810 if (!initialized_) | 793 if (!initialized_) |
| 811 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 794 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
| 812 else if (!in_process_) | 795 else if (!in_process_) |
| 813 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 796 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 814 } | 797 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 | 845 |
| 863 if (create_gpu_memory_buffer_requests_.empty()) | 846 if (create_gpu_memory_buffer_requests_.empty()) |
| 864 return; | 847 return; |
| 865 | 848 |
| 866 CreateGpuMemoryBufferCallback callback = | 849 CreateGpuMemoryBufferCallback callback = |
| 867 create_gpu_memory_buffer_requests_.front(); | 850 create_gpu_memory_buffer_requests_.front(); |
| 868 create_gpu_memory_buffer_requests_.pop(); | 851 create_gpu_memory_buffer_requests_.pop(); |
| 869 callback.Run(handle); | 852 callback.Run(handle); |
| 870 } | 853 } |
| 871 | 854 |
| 872 #if defined(OS_CHROMEOS) | |
| 873 void GpuProcessHost::OnArcVideoAcceleratorChannelCreated( | |
| 874 const IPC::ChannelHandle& handle) { | |
| 875 if (create_arc_video_accelerator_channel_requests_.empty()) { | |
| 876 RouteOnUIThread( | |
| 877 GpuHostMsg_OnLogMessage(logging::LOG_WARNING, "WARNING", | |
| 878 "Received a ArcVideoAcceleratorChannelCreated " | |
| 879 "message but no requests in queue.")); | |
| 880 return; | |
| 881 } | |
| 882 | |
| 883 CreateArcVideoAcceleratorChannelCallback callback = | |
| 884 create_arc_video_accelerator_channel_requests_.front(); | |
| 885 create_arc_video_accelerator_channel_requests_.pop(); | |
| 886 callback.Run(handle); | |
| 887 } | |
| 888 #endif | |
| 889 | |
| 890 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 855 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
| 891 urls_with_live_offscreen_contexts_.insert(url); | 856 urls_with_live_offscreen_contexts_.insert(url); |
| 892 } | 857 } |
| 893 | 858 |
| 894 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 859 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
| 895 gpu::error::ContextLostReason reason, | 860 gpu::error::ContextLostReason reason, |
| 896 const GURL& url) { | 861 const GURL& url) { |
| 897 // TODO(kbr): would be nice to see the "offscreen" flag too. | 862 // TODO(kbr): would be nice to see the "offscreen" flag too. |
| 898 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 863 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
| 899 "reason", reason, | 864 "reason", reason, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 create_command_buffer_requests_.pop(); | 1050 create_command_buffer_requests_.pop(); |
| 1086 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 1051 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
| 1087 } | 1052 } |
| 1088 | 1053 |
| 1089 while (!create_gpu_memory_buffer_requests_.empty()) { | 1054 while (!create_gpu_memory_buffer_requests_.empty()) { |
| 1090 CreateGpuMemoryBufferCallback callback = | 1055 CreateGpuMemoryBufferCallback callback = |
| 1091 create_gpu_memory_buffer_requests_.front(); | 1056 create_gpu_memory_buffer_requests_.front(); |
| 1092 create_gpu_memory_buffer_requests_.pop(); | 1057 create_gpu_memory_buffer_requests_.pop(); |
| 1093 callback.Run(gfx::GpuMemoryBufferHandle()); | 1058 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 1094 } | 1059 } |
| 1095 | |
| 1096 #if defined(OS_CHROMEOS) | |
| 1097 while (!create_arc_video_accelerator_channel_requests_.empty()) { | |
| 1098 CreateArcVideoAcceleratorChannelCallback callback = | |
| 1099 create_arc_video_accelerator_channel_requests_.front(); | |
| 1100 create_arc_video_accelerator_channel_requests_.pop(); | |
| 1101 callback.Run(IPC::ChannelHandle()); | |
| 1102 } | |
| 1103 #endif | |
| 1104 } | 1060 } |
| 1105 | 1061 |
| 1106 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1062 void GpuProcessHost::BlockLiveOffscreenContexts() { |
| 1107 for (std::multiset<GURL>::iterator iter = | 1063 for (std::multiset<GURL>::iterator iter = |
| 1108 urls_with_live_offscreen_contexts_.begin(); | 1064 urls_with_live_offscreen_contexts_.begin(); |
| 1109 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1065 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
| 1110 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1066 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
| 1111 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1067 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
| 1112 } | 1068 } |
| 1113 } | 1069 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1177 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1222 ClientIdToShaderCacheMap::iterator iter = | 1178 ClientIdToShaderCacheMap::iterator iter = |
| 1223 client_id_to_shader_cache_.find(client_id); | 1179 client_id_to_shader_cache_.find(client_id); |
| 1224 // If the cache doesn't exist then this is an off the record profile. | 1180 // If the cache doesn't exist then this is an off the record profile. |
| 1225 if (iter == client_id_to_shader_cache_.end()) | 1181 if (iter == client_id_to_shader_cache_.end()) |
| 1226 return; | 1182 return; |
| 1227 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1183 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1228 } | 1184 } |
| 1229 | 1185 |
| 1230 } // namespace content | 1186 } // namespace content |
| OLD | NEW |