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