| 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> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 82 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 83 #include "ui/gfx/x/x11_switches.h" // nogncheck | 83 #include "ui/gfx/x/x11_switches.h" // nogncheck |
| 84 #endif | 84 #endif |
| 85 | 85 |
| 86 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 86 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 87 #include "content/browser/gpu/gpu_surface_tracker.h" | 87 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 88 #endif | 88 #endif |
| 89 | 89 |
| 90 #if defined(MOJO_SHELL_CLIENT) |
| 91 #include "services/shell/runner/common/client_util.h" |
| 92 #endif |
| 93 |
| 90 namespace content { | 94 namespace content { |
| 91 | 95 |
| 92 bool GpuProcessHost::gpu_enabled_ = true; | 96 bool GpuProcessHost::gpu_enabled_ = true; |
| 93 bool GpuProcessHost::hardware_gpu_enabled_ = true; | 97 bool GpuProcessHost::hardware_gpu_enabled_ = true; |
| 94 int GpuProcessHost::gpu_crash_count_ = 0; | 98 int GpuProcessHost::gpu_crash_count_ = 0; |
| 95 int GpuProcessHost::gpu_recent_crash_count_ = 0; | 99 int GpuProcessHost::gpu_recent_crash_count_ = 0; |
| 96 bool GpuProcessHost::crashed_before_ = false; | 100 bool GpuProcessHost::crashed_before_ = false; |
| 97 int GpuProcessHost::swiftshader_crash_count_ = 0; | 101 int GpuProcessHost::swiftshader_crash_count_ = 0; |
| 98 | 102 |
| 99 namespace { | 103 namespace { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return true; | 306 return true; |
| 303 } | 307 } |
| 304 | 308 |
| 305 host->ForceShutdown(); | 309 host->ForceShutdown(); |
| 306 return false; | 310 return false; |
| 307 } | 311 } |
| 308 | 312 |
| 309 // static | 313 // static |
| 310 GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, | 314 GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, |
| 311 CauseForGpuLaunch cause) { | 315 CauseForGpuLaunch cause) { |
| 316 #if defined(MOJO_SHELL_CLIENT) |
| 317 DCHECK(!shell::ShellIsRemote()); |
| 318 #endif |
| 312 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 319 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 313 | 320 |
| 314 // Don't grant further access to GPU if it is not allowed. | 321 // Don't grant further access to GPU if it is not allowed. |
| 315 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); | 322 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
| 316 DCHECK(gpu_data_manager); | 323 DCHECK(gpu_data_manager); |
| 317 if (!gpu_data_manager->GpuAccessAllowed(NULL)) | 324 if (!gpu_data_manager->GpuAccessAllowed(NULL)) |
| 318 return NULL; | 325 return NULL; |
| 319 | 326 |
| 320 if (g_gpu_process_hosts[kind] && ValidateHost(g_gpu_process_hosts[kind])) | 327 if (g_gpu_process_hosts[kind] && ValidateHost(g_gpu_process_hosts[kind])) |
| 321 return g_gpu_process_hosts[kind]; | 328 return g_gpu_process_hosts[kind]; |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1180 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1174 ClientIdToShaderCacheMap::iterator iter = | 1181 ClientIdToShaderCacheMap::iterator iter = |
| 1175 client_id_to_shader_cache_.find(client_id); | 1182 client_id_to_shader_cache_.find(client_id); |
| 1176 // If the cache doesn't exist then this is an off the record profile. | 1183 // If the cache doesn't exist then this is an off the record profile. |
| 1177 if (iter == client_id_to_shader_cache_.end()) | 1184 if (iter == client_id_to_shader_cache_.end()) |
| 1178 return; | 1185 return; |
| 1179 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1186 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1180 } | 1187 } |
| 1181 | 1188 |
| 1182 } // namespace content | 1189 } // namespace content |
| OLD | NEW |