| 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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 | 281 |
| 282 host->ForceShutdown(); | 282 host->ForceShutdown(); |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 | 285 |
| 286 // static | 286 // static |
| 287 GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, | 287 GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, |
| 288 CauseForGpuLaunch cause) { | 288 CauseForGpuLaunch cause) { |
| 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 289 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 290 | 290 |
| 291 // Don't grant further access to GPU if it is not allowed. | 291 // Don't grant further access to GPU if it is not allowed. |
| 292 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); | 292 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
| 293 DCHECK(gpu_data_manager); | 293 DCHECK(gpu_data_manager); |
| 294 if (!gpu_data_manager->GpuAccessAllowed(NULL)) | 294 if (!gpu_data_manager->GpuAccessAllowed(NULL)) |
| 295 return NULL; | 295 return NULL; |
| 296 | 296 |
| 297 if (g_gpu_process_hosts[kind] && ValidateHost(g_gpu_process_hosts[kind])) | 297 if (g_gpu_process_hosts[kind] && ValidateHost(g_gpu_process_hosts[kind])) |
| 298 return g_gpu_process_hosts[kind]; | 298 return g_gpu_process_hosts[kind]; |
| 299 | 299 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 GpuMainThreadFactoryFunction g_gpu_main_thread_factory = NULL; | 354 GpuMainThreadFactoryFunction g_gpu_main_thread_factory = NULL; |
| 355 | 355 |
| 356 void GpuProcessHost::RegisterGpuMainThreadFactory( | 356 void GpuProcessHost::RegisterGpuMainThreadFactory( |
| 357 GpuMainThreadFactoryFunction create) { | 357 GpuMainThreadFactoryFunction create) { |
| 358 g_gpu_main_thread_factory = create; | 358 g_gpu_main_thread_factory = create; |
| 359 } | 359 } |
| 360 | 360 |
| 361 // static | 361 // static |
| 362 GpuProcessHost* GpuProcessHost::FromID(int host_id) { | 362 GpuProcessHost* GpuProcessHost::FromID(int host_id) { |
| 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 363 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 364 | 364 |
| 365 for (int i = 0; i < GPU_PROCESS_KIND_COUNT; ++i) { | 365 for (int i = 0; i < GPU_PROCESS_KIND_COUNT; ++i) { |
| 366 GpuProcessHost* host = g_gpu_process_hosts[i]; | 366 GpuProcessHost* host = g_gpu_process_hosts[i]; |
| 367 if (host && host->host_id_ == host_id && ValidateHost(host)) | 367 if (host && host->host_id_ == host_id && ValidateHost(host)) |
| 368 return host; | 368 return host; |
| 369 } | 369 } |
| 370 | 370 |
| 371 return NULL; | 371 return NULL; |
| 372 } | 372 } |
| 373 | 373 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1090 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1091 ClientIdToShaderCacheMap::iterator iter = | 1091 ClientIdToShaderCacheMap::iterator iter = |
| 1092 client_id_to_shader_cache_.find(client_id); | 1092 client_id_to_shader_cache_.find(client_id); |
| 1093 // If the cache doesn't exist then this is an off the record profile. | 1093 // If the cache doesn't exist then this is an off the record profile. |
| 1094 if (iter == client_id_to_shader_cache_.end()) | 1094 if (iter == client_id_to_shader_cache_.end()) |
| 1095 return; | 1095 return; |
| 1096 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1096 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 } // namespace content | 1099 } // namespace content |
| OLD | NEW |