| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 DCHECK(CalledOnValidThread()); | 675 DCHECK(CalledOnValidThread()); |
| 676 process_->GetHost()->AddFilter(filter); | 676 process_->GetHost()->AddFilter(filter); |
| 677 } | 677 } |
| 678 | 678 |
| 679 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 679 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 680 DCHECK(CalledOnValidThread()); | 680 DCHECK(CalledOnValidThread()); |
| 681 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 681 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 682 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 682 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
| 683 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, | 683 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
| 684 OnGpuMemoryBufferCreated) | 684 OnGpuMemoryBufferCreated) |
| 685 #if defined(OS_ANDROID) | |
| 686 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck, | |
| 687 OnDestroyingVideoSurfaceAck) | |
| 688 #endif | |
| 689 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); | 685 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); |
| 690 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 686 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
| 691 IPC_END_MESSAGE_MAP() | 687 IPC_END_MESSAGE_MAP() |
| 692 | 688 |
| 693 return true; | 689 return true; |
| 694 } | 690 } |
| 695 | 691 |
| 696 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { | 692 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { |
| 697 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); | 693 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); |
| 698 | 694 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 766 |
| 771 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); | 767 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); |
| 772 } | 768 } |
| 773 | 769 |
| 774 #if defined(OS_ANDROID) | 770 #if defined(OS_ANDROID) |
| 775 void GpuProcessHost::SendDestroyingVideoSurface(int surface_id, | 771 void GpuProcessHost::SendDestroyingVideoSurface(int surface_id, |
| 776 const base::Closure& done_cb) { | 772 const base::Closure& done_cb) { |
| 777 TRACE_EVENT0("gpu", "GpuProcessHost::SendDestroyingVideoSurface"); | 773 TRACE_EVENT0("gpu", "GpuProcessHost::SendDestroyingVideoSurface"); |
| 778 DCHECK(send_destroying_video_surface_done_cb_.is_null()); | 774 DCHECK(send_destroying_video_surface_done_cb_.is_null()); |
| 779 DCHECK(!done_cb.is_null()); | 775 DCHECK(!done_cb.is_null()); |
| 780 if (Send(new GpuMsg_DestroyingVideoSurface(surface_id))) { | 776 send_destroying_video_surface_done_cb_ = done_cb; |
| 781 send_destroying_video_surface_done_cb_ = done_cb; | 777 gpu_service_ptr_->DestroyingVideoSurface( |
| 782 } else { | 778 surface_id, base::Bind(&GpuProcessHost::OnDestroyingVideoSurfaceAck, |
| 783 done_cb.Run(); | 779 weak_ptr_factory_.GetWeakPtr())); |
| 784 } | |
| 785 } | 780 } |
| 786 #endif | 781 #endif |
| 787 | 782 |
| 788 void GpuProcessHost::OnInitialized( | 783 void GpuProcessHost::OnInitialized( |
| 789 bool result, | 784 bool result, |
| 790 const gpu::GPUInfo& gpu_info, | 785 const gpu::GPUInfo& gpu_info, |
| 791 const gpu::GpuFeatureInfo& gpu_feature_info) { | 786 const gpu::GpuFeatureInfo& gpu_feature_info) { |
| 792 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 787 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
| 793 initialized_ = result; | 788 initialized_ = result; |
| 794 gpu_info_ = gpu_info; | 789 gpu_info_ = gpu_info; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 807 mojo::ScopedMessagePipeHandle channel_handle) { | 802 mojo::ScopedMessagePipeHandle channel_handle) { |
| 808 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); | 803 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); |
| 809 DCHECK(!channel_requests_.empty()); | 804 DCHECK(!channel_requests_.empty()); |
| 810 DCHECK(channel_requests_.front().Equals(callback)); | 805 DCHECK(channel_requests_.front().Equals(callback)); |
| 811 channel_requests_.pop(); | 806 channel_requests_.pop(); |
| 812 | 807 |
| 813 // Currently if any of the GPU features are blacklisted, we don't establish a | 808 // Currently if any of the GPU features are blacklisted, we don't establish a |
| 814 // GPU channel. | 809 // GPU channel. |
| 815 if (channel_handle.is_valid() && | 810 if (channel_handle.is_valid() && |
| 816 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { | 811 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { |
| 817 Send(new GpuMsg_CloseChannel(client_id)); | 812 gpu_service_ptr_->CloseChannel(client_id); |
| 818 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 813 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| 819 RouteOnUIThread( | 814 RouteOnUIThread( |
| 820 GpuHostMsg_OnLogMessage(logging::LOG_WARNING, "WARNING", | 815 GpuHostMsg_OnLogMessage(logging::LOG_WARNING, "WARNING", |
| 821 "Hardware acceleration is unavailable.")); | 816 "Hardware acceleration is unavailable.")); |
| 822 return; | 817 return; |
| 823 } | 818 } |
| 824 | 819 |
| 825 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_); | 820 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_); |
| 826 } | 821 } |
| 827 | 822 |
| 828 void GpuProcessHost::OnGpuMemoryBufferCreated( | 823 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 829 const gfx::GpuMemoryBufferHandle& handle) { | 824 const gfx::GpuMemoryBufferHandle& handle) { |
| 830 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 825 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 831 | 826 |
| 832 if (create_gpu_memory_buffer_requests_.empty()) | 827 if (create_gpu_memory_buffer_requests_.empty()) |
| 833 return; | 828 return; |
| 834 | 829 |
| 835 CreateGpuMemoryBufferCallback callback = | 830 CreateGpuMemoryBufferCallback callback = |
| 836 create_gpu_memory_buffer_requests_.front(); | 831 create_gpu_memory_buffer_requests_.front(); |
| 837 create_gpu_memory_buffer_requests_.pop(); | 832 create_gpu_memory_buffer_requests_.pop(); |
| 838 callback.Run(handle); | 833 callback.Run(handle); |
| 839 } | 834 } |
| 840 | 835 |
| 841 #if defined(OS_ANDROID) | 836 #if defined(OS_ANDROID) |
| 842 void GpuProcessHost::OnDestroyingVideoSurfaceAck(int surface_id) { | 837 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { |
| 843 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); | 838 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); |
| 844 if (!send_destroying_video_surface_done_cb_.is_null()) | 839 if (!send_destroying_video_surface_done_cb_.is_null()) |
| 845 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 840 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
| 846 } | 841 } |
| 847 #endif | 842 #endif |
| 848 | 843 |
| 849 void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) { | 844 void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) { |
| 850 // Activate the trial in the browser process to match its state in the | 845 // Activate the trial in the browser process to match its state in the |
| 851 // GPU process. This is done by calling FindFullName which finalizes the group | 846 // GPU process. This is done by calling FindFullName which finalizes the group |
| 852 // and activates the trial. | 847 // and activates the trial. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 &prefix); | 1188 &prefix); |
| 1194 return prefix; | 1189 return prefix; |
| 1195 } | 1190 } |
| 1196 | 1191 |
| 1197 void GpuProcessHost::LoadedShader(const std::string& key, | 1192 void GpuProcessHost::LoadedShader(const std::string& key, |
| 1198 const std::string& data) { | 1193 const std::string& data) { |
| 1199 std::string prefix = GetShaderPrefixKey(data); | 1194 std::string prefix = GetShaderPrefixKey(data); |
| 1200 bool prefix_ok = !key.compare(0, prefix.length(), prefix); | 1195 bool prefix_ok = !key.compare(0, prefix.length(), prefix); |
| 1201 UMA_HISTOGRAM_BOOLEAN("GPU.ShaderLoadPrefixOK", prefix_ok); | 1196 UMA_HISTOGRAM_BOOLEAN("GPU.ShaderLoadPrefixOK", prefix_ok); |
| 1202 if (prefix_ok) | 1197 if (prefix_ok) |
| 1203 Send(new GpuMsg_LoadedShader(data)); | 1198 gpu_service_ptr_->LoadedShader(data); |
| 1204 } | 1199 } |
| 1205 | 1200 |
| 1206 void GpuProcessHost::CreateChannelCache(int32_t client_id) { | 1201 void GpuProcessHost::CreateChannelCache(int32_t client_id) { |
| 1207 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); | 1202 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); |
| 1208 | 1203 |
| 1209 scoped_refptr<gpu::ShaderDiskCache> cache = | 1204 scoped_refptr<gpu::ShaderDiskCache> cache = |
| 1210 GetShaderCacheFactorySingleton()->Get(client_id); | 1205 GetShaderCacheFactorySingleton()->Get(client_id); |
| 1211 if (!cache.get()) | 1206 if (!cache.get()) |
| 1212 return; | 1207 return; |
| 1213 | 1208 |
| 1214 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); | 1209 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); |
| 1215 | 1210 |
| 1216 client_id_to_shader_cache_[client_id] = cache; | 1211 client_id_to_shader_cache_[client_id] = cache; |
| 1217 } | 1212 } |
| 1218 | 1213 |
| 1219 } // namespace content | 1214 } // namespace content |
| OLD | NEW |