Chromium Code Reviews| 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 process_->GetHost()->AddFilter(filter); | 609 process_->GetHost()->AddFilter(filter); |
| 610 } | 610 } |
| 611 | 611 |
| 612 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 612 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 613 DCHECK(CalledOnValidThread()); | 613 DCHECK(CalledOnValidThread()); |
| 614 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 614 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 615 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 615 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
| 616 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 616 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
| 617 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, | 617 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
| 618 OnGpuMemoryBufferCreated) | 618 OnGpuMemoryBufferCreated) |
| 619 #if defined(OS_ANDROID) | |
| 620 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceHandled, | |
| 621 OnDestroyingVideoSurfaceHandled) | |
| 622 #endif | |
| 619 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 623 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
| 620 OnDidCreateOffscreenContext) | 624 OnDidCreateOffscreenContext) |
| 621 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 625 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
| 622 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 626 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
| 623 OnDidDestroyOffscreenContext) | 627 OnDidDestroyOffscreenContext) |
| 624 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 628 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 625 OnGpuMemoryUmaStatsReceived) | 629 OnGpuMemoryUmaStatsReceived) |
| 626 #if defined(OS_MACOSX) | 630 #if defined(OS_MACOSX) |
| 627 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 631 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 628 OnAcceleratedSurfaceBuffersSwapped(message)) | 632 OnAcceleratedSurfaceBuffersSwapped(message)) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 785 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 782 int client_id, | 786 int client_id, |
| 783 const gpu::SyncToken& sync_token) { | 787 const gpu::SyncToken& sync_token) { |
| 784 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); | 788 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
| 785 | 789 |
| 786 DCHECK(CalledOnValidThread()); | 790 DCHECK(CalledOnValidThread()); |
| 787 | 791 |
| 788 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); | 792 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); |
| 789 } | 793 } |
| 790 | 794 |
| 795 #if defined(OS_ANDROID) | |
| 796 void GpuProcessHost::DestroyingVideoSurface(int surface_id, | |
| 797 const base::Closure& done_cb) { | |
| 798 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyingVideoSurface"); | |
|
no sievers
2016/04/19 23:30:17
DCHECK(destroying_video_surface_request_.is_null()
watk
2016/04/22 02:48:55
Done.
| |
| 799 if (Send(new GpuMsg_DestroyingVideoSurface(surface_id))) { | |
| 800 destroying_video_surface_request_ = done_cb; | |
| 801 } else { | |
| 802 done_cb.Run(); | |
| 803 } | |
| 804 } | |
| 805 #endif | |
| 806 | |
| 791 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 807 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
| 792 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 808 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
| 793 initialized_ = result; | 809 initialized_ = result; |
| 794 gpu_info_ = gpu_info; | 810 gpu_info_ = gpu_info; |
| 795 | 811 |
| 796 if (!initialized_) | 812 if (!initialized_) |
| 797 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 813 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
| 798 else if (!in_process_) | 814 else if (!in_process_) |
| 799 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 815 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 800 } | 816 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 | 850 |
| 835 if (create_gpu_memory_buffer_requests_.empty()) | 851 if (create_gpu_memory_buffer_requests_.empty()) |
| 836 return; | 852 return; |
| 837 | 853 |
| 838 CreateGpuMemoryBufferCallback callback = | 854 CreateGpuMemoryBufferCallback callback = |
| 839 create_gpu_memory_buffer_requests_.front(); | 855 create_gpu_memory_buffer_requests_.front(); |
| 840 create_gpu_memory_buffer_requests_.pop(); | 856 create_gpu_memory_buffer_requests_.pop(); |
| 841 callback.Run(handle); | 857 callback.Run(handle); |
| 842 } | 858 } |
| 843 | 859 |
| 860 #if defined(OS_ANDROID) | |
| 861 void GpuProcessHost::OnDestroyingVideoSurfaceHandled(int surface_id) { | |
| 862 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceHandled"); | |
| 863 if (!destroying_video_surface_request_.is_null()) | |
| 864 base::ResetAndReturn(&destroying_video_surface_request_).Run(); | |
| 865 } | |
| 866 #endif | |
| 867 | |
| 844 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 868 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
| 845 urls_with_live_offscreen_contexts_.insert(url); | 869 urls_with_live_offscreen_contexts_.insert(url); |
| 846 } | 870 } |
| 847 | 871 |
| 848 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 872 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
| 849 gpu::error::ContextLostReason reason, | 873 gpu::error::ContextLostReason reason, |
| 850 const GURL& url) { | 874 const GURL& url) { |
| 851 // TODO(kbr): would be nice to see the "offscreen" flag too. | 875 // TODO(kbr): would be nice to see the "offscreen" flag too. |
| 852 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 876 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
| 853 "reason", reason, | 877 "reason", reason, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1037 channel_requests_.pop(); | 1061 channel_requests_.pop(); |
| 1038 request.callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 1062 request.callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| 1039 } | 1063 } |
| 1040 | 1064 |
| 1041 while (!create_gpu_memory_buffer_requests_.empty()) { | 1065 while (!create_gpu_memory_buffer_requests_.empty()) { |
| 1042 CreateGpuMemoryBufferCallback callback = | 1066 CreateGpuMemoryBufferCallback callback = |
| 1043 create_gpu_memory_buffer_requests_.front(); | 1067 create_gpu_memory_buffer_requests_.front(); |
| 1044 create_gpu_memory_buffer_requests_.pop(); | 1068 create_gpu_memory_buffer_requests_.pop(); |
| 1045 callback.Run(gfx::GpuMemoryBufferHandle()); | 1069 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 1046 } | 1070 } |
| 1071 | |
| 1072 if (!destroying_video_surface_request_.is_null()) | |
| 1073 base::ResetAndReturn(&destroying_video_surface_request_).Run(); | |
| 1047 } | 1074 } |
| 1048 | 1075 |
| 1049 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1076 void GpuProcessHost::BlockLiveOffscreenContexts() { |
| 1050 for (std::multiset<GURL>::iterator iter = | 1077 for (std::multiset<GURL>::iterator iter = |
| 1051 urls_with_live_offscreen_contexts_.begin(); | 1078 urls_with_live_offscreen_contexts_.begin(); |
| 1052 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1079 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
| 1053 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1080 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
| 1054 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1081 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
| 1055 } | 1082 } |
| 1056 } | 1083 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1164 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1191 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1165 ClientIdToShaderCacheMap::iterator iter = | 1192 ClientIdToShaderCacheMap::iterator iter = |
| 1166 client_id_to_shader_cache_.find(client_id); | 1193 client_id_to_shader_cache_.find(client_id); |
| 1167 // If the cache doesn't exist then this is an off the record profile. | 1194 // If the cache doesn't exist then this is an off the record profile. |
| 1168 if (iter == client_id_to_shader_cache_.end()) | 1195 if (iter == client_id_to_shader_cache_.end()) |
| 1169 return; | 1196 return; |
| 1170 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1197 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1171 } | 1198 } |
| 1172 | 1199 |
| 1173 } // namespace content | 1200 } // namespace content |
| OLD | NEW |