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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/sha1.h" | 16 #include "base/sha1.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "content/browser/browser_child_process_host_impl.h" | 18 #include "content/browser/browser_child_process_host_impl.h" |
19 #include "content/browser/gpu/gpu_data_manager_impl.h" | 19 #include "content/browser/gpu/gpu_data_manager_impl.h" |
20 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 20 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
21 #include "content/browser/gpu/gpu_surface_tracker.h" | 21 #include "content/browser/gpu/gpu_surface_tracker.h" |
22 #include "content/browser/gpu/shader_disk_cache.h" | 22 #include "content/browser/gpu/shader_disk_cache_impl.h" |
23 #include "content/browser/renderer_host/render_widget_helper.h" | 23 #include "content/browser/renderer_host/render_widget_helper.h" |
24 #include "content/browser/renderer_host/render_widget_host_impl.h" | 24 #include "content/browser/renderer_host/render_widget_host_impl.h" |
25 #include "content/common/child_process_host_impl.h" | 25 #include "content/common/child_process_host_impl.h" |
26 #include "content/common/gpu/gpu_messages.h" | 26 #include "content/common/gpu/gpu_messages.h" |
27 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
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/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
32 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 const std::string& data) { | 1125 const std::string& data) { |
1126 std::string prefix = GetShaderPrefixKey(); | 1126 std::string prefix = GetShaderPrefixKey(); |
1127 if (!key.compare(0, prefix.length(), prefix)) | 1127 if (!key.compare(0, prefix.length(), prefix)) |
1128 Send(new GpuMsg_LoadedShader(data)); | 1128 Send(new GpuMsg_LoadedShader(data)); |
1129 } | 1129 } |
1130 | 1130 |
1131 void GpuProcessHost::CreateChannelCache(int32 client_id, size_t cache_size) { | 1131 void GpuProcessHost::CreateChannelCache(int32 client_id, size_t cache_size) { |
1132 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); | 1132 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); |
1133 | 1133 |
1134 scoped_refptr<ShaderDiskCache> cache = | 1134 scoped_refptr<ShaderDiskCache> cache = |
1135 ShaderCacheFactory::GetInstance()->Get(client_id); | 1135 ShaderCacheFactoryImpl::GetInstance()->Get(client_id); |
1136 if (!cache) | 1136 if (!cache) |
1137 return; | 1137 return; |
1138 | 1138 |
1139 cache->set_max_cache_size(cache_size); | 1139 cache->set_max_cache_size(cache_size); |
1140 cache->set_host_id(host_id_); | 1140 cache->set_host_id(host_id_); |
1141 | 1141 |
1142 client_id_to_shader_cache_[client_id] = cache; | 1142 client_id_to_shader_cache_[client_id] = cache; |
1143 } | 1143 } |
1144 | 1144 |
1145 void GpuProcessHost::OnDestroyChannel(int32 client_id) { | 1145 void GpuProcessHost::OnDestroyChannel(int32 client_id) { |
1146 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); | 1146 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); |
1147 client_id_to_shader_cache_.erase(client_id); | 1147 client_id_to_shader_cache_.erase(client_id); |
1148 } | 1148 } |
1149 | 1149 |
1150 void GpuProcessHost::OnCacheShader(int32 client_id, | 1150 void GpuProcessHost::OnCacheShader(int32 client_id, |
1151 const std::string& key, | 1151 const std::string& key, |
1152 const std::string& shader) { | 1152 const std::string& shader) { |
1153 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1153 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1154 ClientIdToShaderCacheMap::iterator iter = | 1154 ClientIdToShaderCacheMap::iterator iter = |
1155 client_id_to_shader_cache_.find(client_id); | 1155 client_id_to_shader_cache_.find(client_id); |
1156 // If the cache doesn't exist then this is an off the record profile. | 1156 // If the cache doesn't exist then this is an off the record profile. |
1157 if (iter == client_id_to_shader_cache_.end()) | 1157 if (iter == client_id_to_shader_cache_.end()) |
1158 return; | 1158 return; |
1159 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1159 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1160 } | 1160 } |
1161 | 1161 |
1162 } // namespace content | 1162 } // namespace content |
OLD | NEW |