| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 #if defined(USE_OZONE) | 64 #if defined(USE_OZONE) |
| 65 #include "ui/ozone/public/ozone_switches.h" | 65 #include "ui/ozone/public/ozone_switches.h" |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 68 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 69 #include "ui/gfx/x/x11_switches.h" | 69 #include "ui/gfx/x/x11_switches.h" |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 73 #include "content/browser/browser_io_surface_manager_mac.h" | |
| 74 #include "content/common/child_process_messages.h" | |
| 75 #endif | |
| 76 | |
| 77 #if defined(OS_MACOSX) | 72 #if defined(OS_MACOSX) |
| 78 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" | 73 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" |
| 79 #endif | 74 #endif |
| 80 | 75 |
| 81 namespace content { | 76 namespace content { |
| 82 | 77 |
| 83 bool GpuProcessHost::gpu_enabled_ = true; | 78 bool GpuProcessHost::gpu_enabled_ = true; |
| 84 bool GpuProcessHost::hardware_gpu_enabled_ = true; | 79 bool GpuProcessHost::hardware_gpu_enabled_ = true; |
| 85 int GpuProcessHost::gpu_crash_count_ = 0; | 80 int GpuProcessHost::gpu_crash_count_ = 0; |
| 86 int GpuProcessHost::gpu_recent_crash_count_ = 0; | 81 int GpuProcessHost::gpu_recent_crash_count_ = 0; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 DCHECK(CalledOnValidThread()); | 436 DCHECK(CalledOnValidThread()); |
| 442 | 437 |
| 443 SendOutstandingReplies(); | 438 SendOutstandingReplies(); |
| 444 | 439 |
| 445 // In case we never started, clean up. | 440 // In case we never started, clean up. |
| 446 while (!queued_messages_.empty()) { | 441 while (!queued_messages_.empty()) { |
| 447 delete queued_messages_.front(); | 442 delete queued_messages_.front(); |
| 448 queued_messages_.pop(); | 443 queued_messages_.pop(); |
| 449 } | 444 } |
| 450 | 445 |
| 451 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 452 if (!io_surface_manager_token_.IsZero()) { | |
| 453 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); | |
| 454 io_surface_manager_token_.SetZero(); | |
| 455 } | |
| 456 #endif | |
| 457 | |
| 458 // This is only called on the IO thread so no race against the constructor | 446 // This is only called on the IO thread so no race against the constructor |
| 459 // for another GpuProcessHost. | 447 // for another GpuProcessHost. |
| 460 if (g_gpu_process_hosts[kind_] == this) | 448 if (g_gpu_process_hosts[kind_] == this) |
| 461 g_gpu_process_hosts[kind_] = NULL; | 449 g_gpu_process_hosts[kind_] = NULL; |
| 462 | 450 |
| 463 // If there are any remaining offscreen contexts at the point the | 451 // If there are any remaining offscreen contexts at the point the |
| 464 // GPU process exits, assume something went wrong, and block their | 452 // GPU process exits, assume something went wrong, and block their |
| 465 // URLs from accessing client 3D APIs without prompting. | 453 // URLs from accessing client 3D APIs without prompting. |
| 466 BlockLiveOffscreenContexts(); | 454 BlockLiveOffscreenContexts(); |
| 467 | 455 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 in_process_gpu_thread_->StartWithOptions(options); | 546 in_process_gpu_thread_->StartWithOptions(options); |
| 559 | 547 |
| 560 OnProcessLaunched(); // Fake a callback that the process is ready. | 548 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 561 } else if (!LaunchGpuProcess(channel_id)) { | 549 } else if (!LaunchGpuProcess(channel_id)) { |
| 562 return false; | 550 return false; |
| 563 } | 551 } |
| 564 | 552 |
| 565 if (!Send(new GpuMsg_Initialize())) | 553 if (!Send(new GpuMsg_Initialize())) |
| 566 return false; | 554 return false; |
| 567 | 555 |
| 568 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 569 io_surface_manager_token_ = | |
| 570 BrowserIOSurfaceManager::GetInstance()->GenerateGpuProcessToken(); | |
| 571 // Note: A valid IOSurface manager token needs to be sent to the Gpu process | |
| 572 // before any GpuMemoryBuffer allocation requests can be sent. | |
| 573 Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_)); | |
| 574 #endif | |
| 575 | |
| 576 return true; | 556 return true; |
| 577 } | 557 } |
| 578 | 558 |
| 579 bool GpuProcessHost::SetupMojo() { | 559 bool GpuProcessHost::SetupMojo() { |
| 580 DCHECK(!mojo_application_host_); | 560 DCHECK(!mojo_application_host_); |
| 581 mojo_application_host_.reset(new MojoApplicationHost); | 561 mojo_application_host_.reset(new MojoApplicationHost); |
| 582 return mojo_application_host_->Init(); | 562 return mojo_application_host_->Init(); |
| 583 } | 563 } |
| 584 | 564 |
| 585 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { | 565 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { | 907 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { |
| 928 return kind_; | 908 return kind_; |
| 929 } | 909 } |
| 930 | 910 |
| 931 void GpuProcessHost::ForceShutdown() { | 911 void GpuProcessHost::ForceShutdown() { |
| 932 // This is only called on the IO thread so no race against the constructor | 912 // This is only called on the IO thread so no race against the constructor |
| 933 // for another GpuProcessHost. | 913 // for another GpuProcessHost. |
| 934 if (g_gpu_process_hosts[kind_] == this) | 914 if (g_gpu_process_hosts[kind_] == this) |
| 935 g_gpu_process_hosts[kind_] = NULL; | 915 g_gpu_process_hosts[kind_] = NULL; |
| 936 | 916 |
| 937 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 938 if (!io_surface_manager_token_.IsZero()) { | |
| 939 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); | |
| 940 io_surface_manager_token_.SetZero(); | |
| 941 } | |
| 942 #endif | |
| 943 | |
| 944 process_->ForceShutdown(); | 917 process_->ForceShutdown(); |
| 945 } | 918 } |
| 946 | 919 |
| 947 void GpuProcessHost::StopGpuProcess() { | 920 void GpuProcessHost::StopGpuProcess() { |
| 948 Send(new GpuMsg_Finalize()); | 921 Send(new GpuMsg_Finalize()); |
| 949 } | 922 } |
| 950 | 923 |
| 951 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { | 924 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { |
| 952 if (!(gpu_enabled_ && | 925 if (!(gpu_enabled_ && |
| 953 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && | 926 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1142 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1170 ClientIdToShaderCacheMap::iterator iter = | 1143 ClientIdToShaderCacheMap::iterator iter = |
| 1171 client_id_to_shader_cache_.find(client_id); | 1144 client_id_to_shader_cache_.find(client_id); |
| 1172 // If the cache doesn't exist then this is an off the record profile. | 1145 // If the cache doesn't exist then this is an off the record profile. |
| 1173 if (iter == client_id_to_shader_cache_.end()) | 1146 if (iter == client_id_to_shader_cache_.end()) |
| 1174 return; | 1147 return; |
| 1175 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1148 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1176 } | 1149 } |
| 1177 | 1150 |
| 1178 } // namespace content | 1151 } // namespace content |
| OLD | NEW |