Chromium Code Reviews| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 return NULL; | 454 return NULL; |
| 455 } | 455 } |
| 456 | 456 |
| 457 GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) | 457 GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) |
| 458 : host_id_(host_id), | 458 : host_id_(host_id), |
| 459 valid_(true), | 459 valid_(true), |
| 460 in_process_(false), | 460 in_process_(false), |
| 461 swiftshader_rendering_(false), | 461 swiftshader_rendering_(false), |
| 462 kind_(kind), | 462 kind_(kind), |
| 463 process_launched_(false), | 463 process_launched_(false), |
| 464 initialized_(false) { | 464 initialized_(false), |
| 465 gpu_host_binding_(this) { | |
| 465 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 466 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 466 switches::kSingleProcess) || | 467 switches::kSingleProcess) || |
| 467 base::CommandLine::ForCurrentProcess()->HasSwitch( | 468 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 468 switches::kInProcessGPU)) { | 469 switches::kInProcessGPU)) { |
| 469 in_process_ = true; | 470 in_process_ = true; |
| 470 } | 471 } |
| 471 | 472 |
| 472 // If the 'single GPU process' policy ever changes, we still want to maintain | 473 // If the 'single GPU process' policy ever changes, we still want to maintain |
| 473 // it for 'gpu thread' mode and only create one instance of host and thread. | 474 // it for 'gpu thread' mode and only create one instance of host and thread. |
| 474 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); | 475 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 in_process_gpu_thread_->StartWithOptions(options); | 613 in_process_gpu_thread_->StartWithOptions(options); |
| 613 | 614 |
| 614 OnProcessLaunched(); // Fake a callback that the process is ready. | 615 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 615 } else if (!LaunchGpuProcess(&gpu_preferences)) { | 616 } else if (!LaunchGpuProcess(&gpu_preferences)) { |
| 616 return false; | 617 return false; |
| 617 } | 618 } |
| 618 | 619 |
| 619 process_->child_channel() | 620 process_->child_channel() |
| 620 ->GetAssociatedInterfaceSupport() | 621 ->GetAssociatedInterfaceSupport() |
| 621 ->GetRemoteAssociatedInterface(&gpu_main_ptr_); | 622 ->GetRemoteAssociatedInterface(&gpu_main_ptr_); |
| 622 | 623 ui::mojom::GpuServiceRequest request(&gpu_service_ptr_); |
| 623 if (!Send(new GpuMsg_Initialize(gpu_preferences))) | 624 gpu_main_ptr_->CreateGpuService(std::move(request), |
| 624 return false; | 625 gpu_host_binding_.CreateInterfacePtrAndBind(), |
| 626 gpu_preferences); | |
| 625 | 627 |
| 626 #if defined(USE_OZONE) | 628 #if defined(USE_OZONE) |
| 627 // Ozone needs to send the primary DRM device to GPU process as early as | 629 // Ozone needs to send the primary DRM device to GPU process as early as |
| 628 // possible to ensure the latter always has a valid device. crbug.com/608839 | 630 // possible to ensure the latter always has a valid device. crbug.com/608839 |
| 629 ui::OzonePlatform::GetInstance() | 631 ui::OzonePlatform::GetInstance() |
| 630 ->GetGpuPlatformSupportHost() | 632 ->GetGpuPlatformSupportHost() |
| 631 ->OnGpuProcessLaunched( | 633 ->OnGpuProcessLaunched( |
| 632 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 634 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 633 base::Bind(&SendGpuProcessMessageByHostId, host_id_)); | 635 base::Bind(&SendGpuProcessMessageByHostId, host_id_)); |
| 634 #endif | 636 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 DCHECK(CalledOnValidThread()); | 671 DCHECK(CalledOnValidThread()); |
| 670 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 672 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 671 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 673 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
| 672 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 674 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
| 673 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, | 675 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
| 674 OnGpuMemoryBufferCreated) | 676 OnGpuMemoryBufferCreated) |
| 675 #if defined(OS_ANDROID) | 677 #if defined(OS_ANDROID) |
| 676 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck, | 678 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck, |
| 677 OnDestroyingVideoSurfaceAck) | 679 OnDestroyingVideoSurfaceAck) |
| 678 #endif | 680 #endif |
| 679 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | |
| 680 OnDidCreateOffscreenContext) | |
| 681 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | |
| 682 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | |
| 683 OnDidDestroyOffscreenContext) | |
| 684 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel) | |
| 685 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader) | |
| 686 #if defined(OS_WIN) | |
| 687 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, | |
| 688 OnAcceleratedSurfaceCreatedChildWindow) | |
| 689 #endif | |
| 690 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); | 681 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); |
| 691 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 682 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
| 692 IPC_END_MESSAGE_MAP() | 683 IPC_END_MESSAGE_MAP() |
| 693 | 684 |
| 694 return true; | 685 return true; |
| 695 } | 686 } |
| 696 | 687 |
| 697 #if defined(OS_WIN) | 688 #if defined(OS_WIN) |
| 698 void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( | 689 void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( |
| 699 gpu::SurfaceHandle parent_handle, | 690 gpu::SurfaceHandle parent_handle, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 RecordProcessCrash(); | 947 RecordProcessCrash(); |
| 957 } | 948 } |
| 958 | 949 |
| 959 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 950 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
| 960 SendOutstandingReplies(); | 951 SendOutstandingReplies(); |
| 961 RecordProcessCrash(); | 952 RecordProcessCrash(); |
| 962 GpuDataManagerImpl::GetInstance()->ProcessCrashed( | 953 GpuDataManagerImpl::GetInstance()->ProcessCrashed( |
| 963 process_->GetTerminationStatus(true /* known_dead */, NULL)); | 954 process_->GetTerminationStatus(true /* known_dead */, NULL)); |
| 964 } | 955 } |
| 965 | 956 |
| 957 void GpuProcessHost::DidInitialize(const gpu::GPUInfo& gpu_info) { | |
| 958 // TODO(sad): This should call OnInitialized(). | |
| 959 } | |
| 960 | |
| 961 void GpuProcessHost::DidCreateOffscreenContext(const GURL& url) { | |
| 962 OnDidCreateOffscreenContext(url); | |
|
sadrul
2017/01/21 05:35:56
Note that I have deliberately kept the old ipc-mes
| |
| 963 } | |
| 964 | |
| 965 void GpuProcessHost::DidDestroyOffscreenContext(const GURL& url) { | |
| 966 OnDidDestroyOffscreenContext(url); | |
| 967 } | |
| 968 | |
| 969 void GpuProcessHost::DidDestroyChannel(int32_t client_id) { | |
| 970 OnDestroyChannel(client_id); | |
| 971 } | |
| 972 | |
| 973 void GpuProcessHost::DidLoseContext(bool offscreen, | |
| 974 gpu::error::ContextLostReason reason, | |
| 975 const GURL& active_url) { | |
| 976 OnDidLoseContext(offscreen, reason, active_url); | |
| 977 } | |
| 978 | |
| 979 void GpuProcessHost::SetChildSurface(gpu::SurfaceHandle parent, | |
| 980 gpu::SurfaceHandle child) { | |
| 981 #if defined(OS_WIN) | |
| 982 OnAcceleratedSurfaceCreatedChildWindow(parent, child); | |
| 983 #endif | |
| 984 } | |
| 985 | |
| 986 void GpuProcessHost::StoreShaderToDisk(int32_t client_id, | |
| 987 const std::string& key, | |
| 988 const std::string& shader) { | |
| 989 OnCacheShader(client_id, key, shader); | |
| 990 } | |
| 991 | |
| 966 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { | 992 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { |
| 967 return kind_; | 993 return kind_; |
| 968 } | 994 } |
| 969 | 995 |
| 970 void GpuProcessHost::ForceShutdown() { | 996 void GpuProcessHost::ForceShutdown() { |
| 971 // This is only called on the IO thread so no race against the constructor | 997 // This is only called on the IO thread so no race against the constructor |
| 972 // for another GpuProcessHost. | 998 // for another GpuProcessHost. |
| 973 if (g_gpu_process_hosts[kind_] == this) | 999 if (g_gpu_process_hosts[kind_] == this) |
| 974 g_gpu_process_hosts[kind_] = NULL; | 1000 g_gpu_process_hosts[kind_] = NULL; |
| 975 | 1001 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1236 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1211 ClientIdToShaderCacheMap::iterator iter = | 1237 ClientIdToShaderCacheMap::iterator iter = |
| 1212 client_id_to_shader_cache_.find(client_id); | 1238 client_id_to_shader_cache_.find(client_id); |
| 1213 // If the cache doesn't exist then this is an off the record profile. | 1239 // If the cache doesn't exist then this is an off the record profile. |
| 1214 if (iter == client_id_to_shader_cache_.end()) | 1240 if (iter == client_id_to_shader_cache_.end()) |
| 1215 return; | 1241 return; |
| 1216 iter->second->Cache(GetShaderPrefixKey(shader) + ":" + key, shader); | 1242 iter->second->Cache(GetShaderPrefixKey(shader) + ":" + key, shader); |
| 1217 } | 1243 } |
| 1218 | 1244 |
| 1219 } // namespace content | 1245 } // namespace content |
| OLD | NEW |