| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 628 |
| 629 OnProcessLaunched(); // Fake a callback that the process is ready. | 629 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 630 } else if (!LaunchGpuProcess(&gpu_preferences)) { | 630 } else if (!LaunchGpuProcess(&gpu_preferences)) { |
| 631 return false; | 631 return false; |
| 632 } | 632 } |
| 633 | 633 |
| 634 process_->child_channel() | 634 process_->child_channel() |
| 635 ->GetAssociatedInterfaceSupport() | 635 ->GetAssociatedInterfaceSupport() |
| 636 ->GetRemoteAssociatedInterface(&gpu_main_ptr_); | 636 ->GetRemoteAssociatedInterface(&gpu_main_ptr_); |
| 637 ui::mojom::GpuServiceRequest request(&gpu_service_ptr_); | 637 ui::mojom::GpuServiceRequest request(&gpu_service_ptr_); |
| 638 gpu_main_ptr_->CreateGpuService(std::move(request), | 638 gpu_main_ptr_->CreateGpuService( |
| 639 gpu_host_binding_.CreateInterfacePtrAndBind(), | 639 std::move(request), gpu_host_binding_.CreateInterfacePtrAndBind(), |
| 640 gpu_preferences); | 640 gpu_preferences, activity_flags_.CloneHandle()); |
| 641 | 641 |
| 642 #if defined(USE_OZONE) | 642 #if defined(USE_OZONE) |
| 643 // Ozone needs to send the primary DRM device to GPU process as early as | 643 // Ozone needs to send the primary DRM device to GPU process as early as |
| 644 // possible to ensure the latter always has a valid device. crbug.com/608839 | 644 // possible to ensure the latter always has a valid device. crbug.com/608839 |
| 645 ui::OzonePlatform::GetInstance() | 645 ui::OzonePlatform::GetInstance() |
| 646 ->GetGpuPlatformSupportHost() | 646 ->GetGpuPlatformSupportHost() |
| 647 ->OnGpuProcessLaunched( | 647 ->OnGpuProcessLaunched( |
| 648 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 648 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 649 base::Bind(&SendGpuProcessMessageByHostId, host_id_)); | 649 base::Bind(&SendGpuProcessMessageByHostId, host_id_)); |
| 650 #endif | 650 #endif |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 857 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
| 858 base::TimeTicks::Now() - init_start_time_); | 858 base::TimeTicks::Now() - init_start_time_); |
| 859 } | 859 } |
| 860 | 860 |
| 861 void GpuProcessHost::OnProcessLaunchFailed(int error_code) { | 861 void GpuProcessHost::OnProcessLaunchFailed(int error_code) { |
| 862 // TODO(wfh): do something more useful with this error code. | 862 // TODO(wfh): do something more useful with this error code. |
| 863 RecordProcessCrash(); | 863 RecordProcessCrash(); |
| 864 } | 864 } |
| 865 | 865 |
| 866 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 866 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
| 867 // If the GPU process crashed while compiling a shader, we may have invalid |
| 868 // cached binaries. Completely clear the shader cache to force shader binaries |
| 869 // to be re-created. |
| 870 if (activity_flags_.IsFlagSet( |
| 871 gpu::ActivityFlagsBase::FLAG_LOADING_PROGRAM_BINARY)) { |
| 872 for (auto cache_key : client_id_to_shader_cache_) { |
| 873 // This call will temporarily extend the lifetime of the cache (kept |
| 874 // alive in the factory), and may drop loads of cached shader binaries if |
| 875 // it takes a while to complete. As we are intentionally dropping all |
| 876 // binaries, this behavior is fine. |
| 877 GetShaderCacheFactorySingleton()->ClearByClientId( |
| 878 cache_key.first, base::Time(), base::Time::Max(), base::Bind([] {})); |
| 879 } |
| 880 } |
| 867 SendOutstandingReplies(); | 881 SendOutstandingReplies(); |
| 868 RecordProcessCrash(); | 882 RecordProcessCrash(); |
| 869 GpuDataManagerImpl::GetInstance()->ProcessCrashed( | 883 GpuDataManagerImpl::GetInstance()->ProcessCrashed( |
| 870 process_->GetTerminationStatus(true /* known_dead */, NULL)); | 884 process_->GetTerminationStatus(true /* known_dead */, NULL)); |
| 871 } | 885 } |
| 872 | 886 |
| 873 void GpuProcessHost::DidInitialize(const gpu::GPUInfo& gpu_info) { | 887 void GpuProcessHost::DidInitialize(const gpu::GPUInfo& gpu_info) { |
| 874 // TODO(sad): This should call OnInitialized(). | 888 // TODO(sad): This should call OnInitialized(). |
| 875 } | 889 } |
| 876 | 890 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 GetShaderCacheFactorySingleton()->Get(client_id); | 1225 GetShaderCacheFactorySingleton()->Get(client_id); |
| 1212 if (!cache.get()) | 1226 if (!cache.get()) |
| 1213 return; | 1227 return; |
| 1214 | 1228 |
| 1215 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); | 1229 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); |
| 1216 | 1230 |
| 1217 client_id_to_shader_cache_[client_id] = cache; | 1231 client_id_to_shader_cache_[client_id] = cache; |
| 1218 } | 1232 } |
| 1219 | 1233 |
| 1220 } // namespace content | 1234 } // namespace content |
| OLD | NEW |