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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 | 699 |
700 void GpuProcessHost::EstablishGpuChannel( | 700 void GpuProcessHost::EstablishGpuChannel( |
701 int client_id, | 701 int client_id, |
702 bool share_context, | 702 bool share_context, |
703 const EstablishChannelCallback& callback) { | 703 const EstablishChannelCallback& callback) { |
704 DCHECK(CalledOnValidThread()); | 704 DCHECK(CalledOnValidThread()); |
705 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); | 705 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); |
706 | 706 |
707 // If GPU features are already blacklisted, no need to establish the channel. | 707 // If GPU features are already blacklisted, no need to establish the channel. |
708 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 708 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
709 callback.Run(IPC::ChannelHandle(), GPUInfo()); | 709 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
710 return; | 710 return; |
711 } | 711 } |
712 | 712 |
713 if (Send(new GpuMsg_EstablishChannel(client_id, share_context))) { | 713 if (Send(new GpuMsg_EstablishChannel(client_id, share_context))) { |
714 channel_requests_.push(callback); | 714 channel_requests_.push(callback); |
715 } else { | 715 } else { |
716 callback.Run(IPC::ChannelHandle(), GPUInfo()); | 716 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
717 } | 717 } |
718 | 718 |
719 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 719 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
720 switches::kDisableGpuShaderDiskCache)) { | 720 switches::kDisableGpuShaderDiskCache)) { |
721 CreateChannelCache(client_id, gpu::kDefaultMaxProgramCacheMemoryBytes); | 721 CreateChannelCache(client_id, gpu::kDefaultMaxProgramCacheMemoryBytes); |
722 } | 722 } |
723 } | 723 } |
724 | 724 |
725 void GpuProcessHost::CreateViewCommandBuffer( | 725 void GpuProcessHost::CreateViewCommandBuffer( |
726 const gfx::GLSurfaceHandle& compositing_surface, | 726 const gfx::GLSurfaceHandle& compositing_surface, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 return; | 786 return; |
787 } | 787 } |
788 EstablishChannelCallback callback = channel_requests_.front(); | 788 EstablishChannelCallback callback = channel_requests_.front(); |
789 channel_requests_.pop(); | 789 channel_requests_.pop(); |
790 | 790 |
791 // Currently if any of the GPU features are blacklisted, we don't establish a | 791 // Currently if any of the GPU features are blacklisted, we don't establish a |
792 // GPU channel. | 792 // GPU channel. |
793 if (!channel_handle.name.empty() && | 793 if (!channel_handle.name.empty() && |
794 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 794 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
795 Send(new GpuMsg_CloseChannel(channel_handle)); | 795 Send(new GpuMsg_CloseChannel(channel_handle)); |
796 callback.Run(IPC::ChannelHandle(), GPUInfo()); | 796 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
797 RouteOnUIThread(GpuHostMsg_OnLogMessage( | 797 RouteOnUIThread(GpuHostMsg_OnLogMessage( |
798 logging::LOG_WARNING, | 798 logging::LOG_WARNING, |
799 "WARNING", | 799 "WARNING", |
800 "Hardware acceleration is unavailable.")); | 800 "Hardware acceleration is unavailable.")); |
801 return; | 801 return; |
802 } | 802 } |
803 | 803 |
804 callback.Run(channel_handle, | 804 callback.Run(channel_handle, |
805 GpuDataManagerImpl::GetInstance()->GetGPUInfo()); | 805 GpuDataManagerImpl::GetInstance()->GetGPUInfo()); |
806 } | 806 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); | 1183 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); |
1184 return true; | 1184 return true; |
1185 } | 1185 } |
1186 | 1186 |
1187 void GpuProcessHost::SendOutstandingReplies() { | 1187 void GpuProcessHost::SendOutstandingReplies() { |
1188 valid_ = false; | 1188 valid_ = false; |
1189 // First send empty channel handles for all EstablishChannel requests. | 1189 // First send empty channel handles for all EstablishChannel requests. |
1190 while (!channel_requests_.empty()) { | 1190 while (!channel_requests_.empty()) { |
1191 EstablishChannelCallback callback = channel_requests_.front(); | 1191 EstablishChannelCallback callback = channel_requests_.front(); |
1192 channel_requests_.pop(); | 1192 channel_requests_.pop(); |
1193 callback.Run(IPC::ChannelHandle(), GPUInfo()); | 1193 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
1194 } | 1194 } |
1195 | 1195 |
1196 while (!create_command_buffer_requests_.empty()) { | 1196 while (!create_command_buffer_requests_.empty()) { |
1197 CreateCommandBufferCallback callback = | 1197 CreateCommandBufferCallback callback = |
1198 create_command_buffer_requests_.front(); | 1198 create_command_buffer_requests_.front(); |
1199 create_command_buffer_requests_.pop(); | 1199 create_command_buffer_requests_.pop(); |
1200 callback.Run(MSG_ROUTING_NONE); | 1200 callback.Run(MSG_ROUTING_NONE); |
1201 } | 1201 } |
1202 } | 1202 } |
1203 | 1203 |
1204 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1204 void GpuProcessHost::BlockLiveOffscreenContexts() { |
1205 for (std::multiset<GURL>::iterator iter = | 1205 for (std::multiset<GURL>::iterator iter = |
1206 urls_with_live_offscreen_contexts_.begin(); | 1206 urls_with_live_offscreen_contexts_.begin(); |
1207 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1207 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
1208 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1208 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
1209 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1209 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
1210 } | 1210 } |
1211 } | 1211 } |
1212 | 1212 |
1213 std::string GpuProcessHost::GetShaderPrefixKey() { | 1213 std::string GpuProcessHost::GetShaderPrefixKey() { |
1214 if (shader_prefix_key_.empty()) { | 1214 if (shader_prefix_key_.empty()) { |
1215 GPUInfo info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); | 1215 gpu::GPUInfo info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); |
1216 | 1216 |
1217 std::string in_str = GetContentClient()->GetProduct() + "-" + | 1217 std::string in_str = GetContentClient()->GetProduct() + "-" + |
1218 info.gl_vendor + "-" + info.gl_renderer + "-" + | 1218 info.gl_vendor + "-" + info.gl_renderer + "-" + |
1219 info.driver_version + "-" + info.driver_vendor; | 1219 info.driver_version + "-" + info.driver_vendor; |
1220 | 1220 |
1221 base::Base64Encode(base::SHA1HashString(in_str), &shader_prefix_key_); | 1221 base::Base64Encode(base::SHA1HashString(in_str), &shader_prefix_key_); |
1222 } | 1222 } |
1223 | 1223 |
1224 return shader_prefix_key_; | 1224 return shader_prefix_key_; |
1225 } | 1225 } |
(...skipping 30 matching lines...) Expand all Loading... |
1256 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1256 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1257 ClientIdToShaderCacheMap::iterator iter = | 1257 ClientIdToShaderCacheMap::iterator iter = |
1258 client_id_to_shader_cache_.find(client_id); | 1258 client_id_to_shader_cache_.find(client_id); |
1259 // If the cache doesn't exist then this is an off the record profile. | 1259 // If the cache doesn't exist then this is an off the record profile. |
1260 if (iter == client_id_to_shader_cache_.end()) | 1260 if (iter == client_id_to_shader_cache_.end()) |
1261 return; | 1261 return; |
1262 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1262 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1263 } | 1263 } |
1264 | 1264 |
1265 } // namespace content | 1265 } // namespace content |
OLD | NEW |