| 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 CreateArcVideoAcceleratorChannelCallback callback = |
| 863 create_arc_video_accelerator_channel_requests_.front(); |
| 864 create_arc_video_accelerator_channel_requests_.pop(); |
| 865 callback.Run(handle); |
| 866 } |
| 867 |
| 840 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 868 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
| 841 urls_with_live_offscreen_contexts_.insert(url); | 869 urls_with_live_offscreen_contexts_.insert(url); |
| 842 } | 870 } |
| 843 | 871 |
| 844 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 872 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
| 845 gpu::error::ContextLostReason reason, | 873 gpu::error::ContextLostReason reason, |
| 846 const GURL& url) { | 874 const GURL& url) { |
| 847 // TODO(kbr): would be nice to see the "offscreen" flag too. | 875 // TODO(kbr): would be nice to see the "offscreen" flag too. |
| 848 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 876 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
| 849 "reason", reason, | 877 "reason", reason, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 create_command_buffer_requests_.pop(); | 1070 create_command_buffer_requests_.pop(); |
| 1043 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 1071 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
| 1044 } | 1072 } |
| 1045 | 1073 |
| 1046 while (!create_gpu_memory_buffer_requests_.empty()) { | 1074 while (!create_gpu_memory_buffer_requests_.empty()) { |
| 1047 CreateGpuMemoryBufferCallback callback = | 1075 CreateGpuMemoryBufferCallback callback = |
| 1048 create_gpu_memory_buffer_requests_.front(); | 1076 create_gpu_memory_buffer_requests_.front(); |
| 1049 create_gpu_memory_buffer_requests_.pop(); | 1077 create_gpu_memory_buffer_requests_.pop(); |
| 1050 callback.Run(gfx::GpuMemoryBufferHandle()); | 1078 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 1051 } | 1079 } |
| 1080 |
| 1081 while (!create_arc_video_accelerator_channel_requests_.empty()) { |
| 1082 CreateArcVideoAcceleratorChannelCallback callback = |
| 1083 create_arc_video_accelerator_channel_requests_.front(); |
| 1084 create_arc_video_accelerator_channel_requests_.pop(); |
| 1085 callback.Run(IPC::ChannelHandle()); |
| 1086 } |
| 1052 } | 1087 } |
| 1053 | 1088 |
| 1054 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1089 void GpuProcessHost::BlockLiveOffscreenContexts() { |
| 1055 for (std::multiset<GURL>::iterator iter = | 1090 for (std::multiset<GURL>::iterator iter = |
| 1056 urls_with_live_offscreen_contexts_.begin(); | 1091 urls_with_live_offscreen_contexts_.begin(); |
| 1057 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1092 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
| 1058 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1093 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
| 1059 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1094 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
| 1060 } | 1095 } |
| 1061 } | 1096 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1204 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1170 ClientIdToShaderCacheMap::iterator iter = | 1205 ClientIdToShaderCacheMap::iterator iter = |
| 1171 client_id_to_shader_cache_.find(client_id); | 1206 client_id_to_shader_cache_.find(client_id); |
| 1172 // If the cache doesn't exist then this is an off the record profile. | 1207 // If the cache doesn't exist then this is an off the record profile. |
| 1173 if (iter == client_id_to_shader_cache_.end()) | 1208 if (iter == client_id_to_shader_cache_.end()) |
| 1174 return; | 1209 return; |
| 1175 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1210 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1176 } | 1211 } |
| 1177 | 1212 |
| 1178 } // namespace content | 1213 } // namespace content |
| OLD | NEW |