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/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/sha1.h" | 17 #include "base/sha1.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "content/browser/browser_child_process_host_impl.h" | 19 #include "content/browser/browser_child_process_host_impl.h" |
20 #include "content/browser/gpu/gpu_data_manager_impl.h" | 20 #include "content/browser/gpu/gpu_data_manager_impl.h" |
21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
22 #include "content/browser/gpu/gpu_surface_tracker.h" | 22 #include "content/browser/gpu/gpu_surface_tracker.h" |
23 #include "content/browser/gpu/shader_disk_cache.h" | 23 #include "content/browser/gpu/shader_disk_cache_impl.h" |
24 #include "content/browser/renderer_host/render_widget_helper.h" | 24 #include "content/browser/renderer_host/render_widget_helper.h" |
25 #include "content/browser/renderer_host/render_widget_host_impl.h" | 25 #include "content/browser/renderer_host/render_widget_host_impl.h" |
26 #include "content/common/child_process_host_impl.h" | 26 #include "content/common/child_process_host_impl.h" |
27 #include "content/common/gpu/gpu_messages.h" | 27 #include "content/common/gpu/gpu_messages.h" |
28 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
29 #include "content/gpu/gpu_child_thread.h" | 29 #include "content/gpu/gpu_child_thread.h" |
30 #include "content/gpu/gpu_process.h" | 30 #include "content/gpu/gpu_process.h" |
31 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 31 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/content_browser_client.h" | 33 #include "content/public/browser/content_browser_client.h" |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 const std::string& data) { | 1263 const std::string& data) { |
1264 std::string prefix = GetShaderPrefixKey(); | 1264 std::string prefix = GetShaderPrefixKey(); |
1265 if (!key.compare(0, prefix.length(), prefix)) | 1265 if (!key.compare(0, prefix.length(), prefix)) |
1266 Send(new GpuMsg_LoadedShader(data)); | 1266 Send(new GpuMsg_LoadedShader(data)); |
1267 } | 1267 } |
1268 | 1268 |
1269 void GpuProcessHost::CreateChannelCache(int32 client_id, size_t cache_size) { | 1269 void GpuProcessHost::CreateChannelCache(int32 client_id, size_t cache_size) { |
1270 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); | 1270 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); |
1271 | 1271 |
1272 scoped_refptr<ShaderDiskCache> cache = | 1272 scoped_refptr<ShaderDiskCache> cache = |
1273 ShaderCacheFactory::GetInstance()->Get(client_id); | 1273 ShaderCacheFactoryImpl::GetInstance()->Get(client_id); |
1274 if (!cache) | 1274 if (!cache) |
1275 return; | 1275 return; |
1276 | 1276 |
1277 cache->set_max_cache_size(cache_size); | 1277 cache->set_max_cache_size(cache_size); |
1278 cache->set_host_id(host_id_); | 1278 cache->set_host_id(host_id_); |
1279 | 1279 |
1280 client_id_to_shader_cache_[client_id] = cache; | 1280 client_id_to_shader_cache_[client_id] = cache; |
1281 } | 1281 } |
1282 | 1282 |
1283 void GpuProcessHost::OnDestroyChannel(int32 client_id) { | 1283 void GpuProcessHost::OnDestroyChannel(int32 client_id) { |
1284 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); | 1284 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); |
1285 client_id_to_shader_cache_.erase(client_id); | 1285 client_id_to_shader_cache_.erase(client_id); |
1286 } | 1286 } |
1287 | 1287 |
1288 void GpuProcessHost::OnCacheShader(int32 client_id, | 1288 void GpuProcessHost::OnCacheShader(int32 client_id, |
1289 const std::string& key, | 1289 const std::string& key, |
1290 const std::string& shader) { | 1290 const std::string& shader) { |
1291 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1291 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1292 ClientIdToShaderCacheMap::iterator iter = | 1292 ClientIdToShaderCacheMap::iterator iter = |
1293 client_id_to_shader_cache_.find(client_id); | 1293 client_id_to_shader_cache_.find(client_id); |
1294 // If the cache doesn't exist then this is an off the record profile. | 1294 // If the cache doesn't exist then this is an off the record profile. |
1295 if (iter == client_id_to_shader_cache_.end()) | 1295 if (iter == client_id_to_shader_cache_.end()) |
1296 return; | 1296 return; |
1297 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1297 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1298 } | 1298 } |
1299 | 1299 |
1300 } // namespace content | 1300 } // namespace content |
OLD | NEW |