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> |
| 8 |
7 #include <utility> | 9 #include <utility> |
8 | 10 |
9 #include "base/base64.h" | 11 #include "base/base64.h" |
10 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
11 #include "base/basictypes.h" | |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
17 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
18 #include "base/sha1.h" | 20 #include "base/sha1.h" |
19 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
20 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
| 23 #include "build/build_config.h" |
21 #include "components/tracing/tracing_switches.h" | 24 #include "components/tracing/tracing_switches.h" |
22 #include "content/browser/browser_child_process_host_impl.h" | 25 #include "content/browser/browser_child_process_host_impl.h" |
23 #include "content/browser/gpu/compositor_util.h" | 26 #include "content/browser/gpu/compositor_util.h" |
24 #include "content/browser/gpu/gpu_data_manager_impl.h" | 27 #include "content/browser/gpu/gpu_data_manager_impl.h" |
25 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
26 #include "content/browser/gpu/gpu_surface_tracker.h" | 29 #include "content/browser/gpu/gpu_surface_tracker.h" |
27 #include "content/browser/gpu/shader_disk_cache.h" | 30 #include "content/browser/gpu/shader_disk_cache.h" |
28 #include "content/browser/mojo/mojo_application_host.h" | 31 #include "content/browser/mojo/mojo_application_host.h" |
29 #include "content/browser/renderer_host/render_widget_host_impl.h" | 32 #include "content/browser/renderer_host/render_widget_host_impl.h" |
30 #include "content/common/child_process_host_impl.h" | 33 #include "content/common/child_process_host_impl.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 OnDestroyChannel) | 637 OnDestroyChannel) |
635 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, | 638 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, |
636 OnCacheShader) | 639 OnCacheShader) |
637 | 640 |
638 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 641 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
639 IPC_END_MESSAGE_MAP() | 642 IPC_END_MESSAGE_MAP() |
640 | 643 |
641 return true; | 644 return true; |
642 } | 645 } |
643 | 646 |
644 void GpuProcessHost::OnChannelConnected(int32 peer_pid) { | 647 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { |
645 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); | 648 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); |
646 | 649 |
647 while (!queued_messages_.empty()) { | 650 while (!queued_messages_.empty()) { |
648 Send(queued_messages_.front()); | 651 Send(queued_messages_.front()); |
649 queued_messages_.pop(); | 652 queued_messages_.pop(); |
650 } | 653 } |
651 } | 654 } |
652 | 655 |
653 void GpuProcessHost::EstablishGpuChannel( | 656 void GpuProcessHost::EstablishGpuChannel( |
654 int client_id, | 657 int client_id, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 711 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
709 } | 712 } |
710 } | 713 } |
711 | 714 |
712 void GpuProcessHost::CreateGpuMemoryBuffer( | 715 void GpuProcessHost::CreateGpuMemoryBuffer( |
713 gfx::GpuMemoryBufferId id, | 716 gfx::GpuMemoryBufferId id, |
714 const gfx::Size& size, | 717 const gfx::Size& size, |
715 gfx::BufferFormat format, | 718 gfx::BufferFormat format, |
716 gfx::BufferUsage usage, | 719 gfx::BufferUsage usage, |
717 int client_id, | 720 int client_id, |
718 int32 surface_id, | 721 int32_t surface_id, |
719 const CreateGpuMemoryBufferCallback& callback) { | 722 const CreateGpuMemoryBufferCallback& callback) { |
720 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 723 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
721 | 724 |
722 DCHECK(CalledOnValidThread()); | 725 DCHECK(CalledOnValidThread()); |
723 | 726 |
724 GpuMsg_CreateGpuMemoryBuffer_Params params; | 727 GpuMsg_CreateGpuMemoryBuffer_Params params; |
725 params.id = id; | 728 params.id = id; |
726 params.size = size; | 729 params.size = size; |
727 params.format = format; | 730 params.format = format; |
728 params.usage = usage; | 731 params.usage = usage; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 return shader_prefix_key_; | 1141 return shader_prefix_key_; |
1139 } | 1142 } |
1140 | 1143 |
1141 void GpuProcessHost::LoadedShader(const std::string& key, | 1144 void GpuProcessHost::LoadedShader(const std::string& key, |
1142 const std::string& data) { | 1145 const std::string& data) { |
1143 std::string prefix = GetShaderPrefixKey(); | 1146 std::string prefix = GetShaderPrefixKey(); |
1144 if (!key.compare(0, prefix.length(), prefix)) | 1147 if (!key.compare(0, prefix.length(), prefix)) |
1145 Send(new GpuMsg_LoadedShader(data)); | 1148 Send(new GpuMsg_LoadedShader(data)); |
1146 } | 1149 } |
1147 | 1150 |
1148 void GpuProcessHost::CreateChannelCache(int32 client_id) { | 1151 void GpuProcessHost::CreateChannelCache(int32_t client_id) { |
1149 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); | 1152 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); |
1150 | 1153 |
1151 scoped_refptr<ShaderDiskCache> cache = | 1154 scoped_refptr<ShaderDiskCache> cache = |
1152 ShaderCacheFactory::GetInstance()->Get(client_id); | 1155 ShaderCacheFactory::GetInstance()->Get(client_id); |
1153 if (!cache.get()) | 1156 if (!cache.get()) |
1154 return; | 1157 return; |
1155 | 1158 |
1156 cache->set_host_id(host_id_); | 1159 cache->set_host_id(host_id_); |
1157 | 1160 |
1158 client_id_to_shader_cache_[client_id] = cache; | 1161 client_id_to_shader_cache_[client_id] = cache; |
1159 } | 1162 } |
1160 | 1163 |
1161 void GpuProcessHost::OnDestroyChannel(int32 client_id) { | 1164 void GpuProcessHost::OnDestroyChannel(int32_t client_id) { |
1162 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); | 1165 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel"); |
1163 client_id_to_shader_cache_.erase(client_id); | 1166 client_id_to_shader_cache_.erase(client_id); |
1164 } | 1167 } |
1165 | 1168 |
1166 void GpuProcessHost::OnCacheShader(int32 client_id, | 1169 void GpuProcessHost::OnCacheShader(int32_t client_id, |
1167 const std::string& key, | 1170 const std::string& key, |
1168 const std::string& shader) { | 1171 const std::string& shader) { |
1169 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1172 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1170 ClientIdToShaderCacheMap::iterator iter = | 1173 ClientIdToShaderCacheMap::iterator iter = |
1171 client_id_to_shader_cache_.find(client_id); | 1174 client_id_to_shader_cache_.find(client_id); |
1172 // If the cache doesn't exist then this is an off the record profile. | 1175 // If the cache doesn't exist then this is an off the record profile. |
1173 if (iter == client_id_to_shader_cache_.end()) | 1176 if (iter == client_id_to_shader_cache_.end()) |
1174 return; | 1177 return; |
1175 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1178 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1176 } | 1179 } |
1177 | 1180 |
1178 } // namespace content | 1181 } // namespace content |
OLD | NEW |