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