| 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 17 matching lines...) Expand all Loading... |
| 28 #include "content/gpu/gpu_child_thread.h" | 28 #include "content/gpu/gpu_child_thread.h" |
| 29 #include "content/gpu/gpu_process.h" | 29 #include "content/gpu/gpu_process.h" |
| 30 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 30 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
| 33 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
| 34 #include "content/public/browser/render_widget_host_view.h" | 34 #include "content/public/browser/render_widget_host_view.h" |
| 35 #include "content/public/common/content_client.h" | 35 #include "content/public/common/content_client.h" |
| 36 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 37 #include "content/public/common/result_codes.h" | 37 #include "content/public/common/result_codes.h" |
| 38 #include "gpu/command_buffer/common/constants.h" | |
| 39 #include "gpu/command_buffer/service/gpu_switches.h" | 38 #include "gpu/command_buffer/service/gpu_switches.h" |
| 40 #include "ipc/ipc_channel_handle.h" | 39 #include "ipc/ipc_channel_handle.h" |
| 41 #include "ipc/ipc_switches.h" | 40 #include "ipc/ipc_switches.h" |
| 42 #include "ui/base/latency_info.h" | 41 #include "ui/base/latency_info.h" |
| 43 #include "ui/gl/gl_switches.h" | 42 #include "ui/gl/gl_switches.h" |
| 44 | 43 |
| 45 | 44 |
| 46 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 47 #include "base/win/windows_version.h" | 46 #include "base/win/windows_version.h" |
| 48 #include "content/common/sandbox_win.h" | 47 #include "content/common/sandbox_win.h" |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 715 } |
| 717 | 716 |
| 718 if (Send(new GpuMsg_EstablishChannel(client_id, share_context))) { | 717 if (Send(new GpuMsg_EstablishChannel(client_id, share_context))) { |
| 719 channel_requests_.push(callback); | 718 channel_requests_.push(callback); |
| 720 } else { | 719 } else { |
| 721 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 720 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| 722 } | 721 } |
| 723 | 722 |
| 724 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 723 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 725 switches::kDisableGpuShaderDiskCache)) { | 724 switches::kDisableGpuShaderDiskCache)) { |
| 726 CreateChannelCache(client_id, gpu::kDefaultMaxProgramCacheMemoryBytes); | 725 CreateChannelCache(client_id); |
| 727 } | 726 } |
| 728 } | 727 } |
| 729 | 728 |
| 730 void GpuProcessHost::CreateViewCommandBuffer( | 729 void GpuProcessHost::CreateViewCommandBuffer( |
| 731 const gfx::GLSurfaceHandle& compositing_surface, | 730 const gfx::GLSurfaceHandle& compositing_surface, |
| 732 int surface_id, | 731 int surface_id, |
| 733 int client_id, | 732 int client_id, |
| 734 const GPUCreateCommandBufferConfig& init_params, | 733 const GPUCreateCommandBufferConfig& init_params, |
| 735 const CreateCommandBufferCallback& callback) { | 734 const CreateCommandBufferCallback& callback) { |
| 736 TRACE_EVENT0("gpu", "GpuProcessHost::CreateViewCommandBuffer"); | 735 TRACE_EVENT0("gpu", "GpuProcessHost::CreateViewCommandBuffer"); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 return shader_prefix_key_; | 1245 return shader_prefix_key_; |
| 1247 } | 1246 } |
| 1248 | 1247 |
| 1249 void GpuProcessHost::LoadedShader(const std::string& key, | 1248 void GpuProcessHost::LoadedShader(const std::string& key, |
| 1250 const std::string& data) { | 1249 const std::string& data) { |
| 1251 std::string prefix = GetShaderPrefixKey(); | 1250 std::string prefix = GetShaderPrefixKey(); |
| 1252 if (!key.compare(0, prefix.length(), prefix)) | 1251 if (!key.compare(0, prefix.length(), prefix)) |
| 1253 Send(new GpuMsg_LoadedShader(data)); | 1252 Send(new GpuMsg_LoadedShader(data)); |
| 1254 } | 1253 } |
| 1255 | 1254 |
| 1256 void GpuProcessHost::CreateChannelCache(int32 client_id, size_t cache_size) { | 1255 void GpuProcessHost::CreateChannelCache(int32 client_id) { |
| 1257 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); | 1256 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); |
| 1258 | 1257 |
| 1259 scoped_refptr<ShaderDiskCache> cache = | 1258 scoped_refptr<ShaderDiskCache> cache = |
| 1260 ShaderCacheFactory::GetInstance()->Get(client_id); | 1259 ShaderCacheFactory::GetInstance()->Get(client_id); |
| 1261 if (!cache.get()) | 1260 if (!cache.get()) |
| 1262 return; | 1261 return; |
| 1263 | 1262 |
| 1264 cache->set_max_cache_size(cache_size); | |
| 1265 cache->set_host_id(host_id_); | 1263 cache->set_host_id(host_id_); |
| 1266 | 1264 |
| 1267 client_id_to_shader_cache_[client_id] = cache; | 1265 client_id_to_shader_cache_[client_id] = cache; |
| 1268 } | 1266 } |
| 1269 | 1267 |
| 1270 void GpuProcessHost::OnDestroyChannel(int32 client_id) { | 1268 void GpuProcessHost::OnDestroyChannel(int32 client_id) { |
| 1271 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); | 1269 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); |
| 1272 client_id_to_shader_cache_.erase(client_id); | 1270 client_id_to_shader_cache_.erase(client_id); |
| 1273 } | 1271 } |
| 1274 | 1272 |
| 1275 void GpuProcessHost::OnCacheShader(int32 client_id, | 1273 void GpuProcessHost::OnCacheShader(int32 client_id, |
| 1276 const std::string& key, | 1274 const std::string& key, |
| 1277 const std::string& shader) { | 1275 const std::string& shader) { |
| 1278 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1276 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1279 ClientIdToShaderCacheMap::iterator iter = | 1277 ClientIdToShaderCacheMap::iterator iter = |
| 1280 client_id_to_shader_cache_.find(client_id); | 1278 client_id_to_shader_cache_.find(client_id); |
| 1281 // If the cache doesn't exist then this is an off the record profile. | 1279 // If the cache doesn't exist then this is an off the record profile. |
| 1282 if (iter == client_id_to_shader_cache_.end()) | 1280 if (iter == client_id_to_shader_cache_.end()) |
| 1283 return; | 1281 return; |
| 1284 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1282 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1285 } | 1283 } |
| 1286 | 1284 |
| 1287 } // namespace content | 1285 } // namespace content |
| OLD | NEW |