Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1260)

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 1532813002: Replace IOSurfaceManager by directly passing IOSurface Mach ports over Chrome IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/gpu/gpu_process_host_ui_shim.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 9 #include <utility>
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #endif 65 #endif
66 66
67 #if defined(USE_OZONE) 67 #if defined(USE_OZONE)
68 #include "ui/ozone/public/ozone_switches.h" 68 #include "ui/ozone/public/ozone_switches.h"
69 #endif 69 #endif
70 70
71 #if defined(USE_X11) && !defined(OS_CHROMEOS) 71 #if defined(USE_X11) && !defined(OS_CHROMEOS)
72 #include "ui/gfx/x/x11_switches.h" 72 #include "ui/gfx/x/x11_switches.h"
73 #endif 73 #endif
74 74
75 #if defined(OS_MACOSX) && !defined(OS_IOS)
76 #include "content/browser/browser_io_surface_manager_mac.h"
77 #include "content/common/child_process_messages.h"
78 #endif
79
80 #if defined(OS_MACOSX) 75 #if defined(OS_MACOSX)
81 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" 76 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h"
82 #endif 77 #endif
83 78
84 namespace content { 79 namespace content {
85 80
86 bool GpuProcessHost::gpu_enabled_ = true; 81 bool GpuProcessHost::gpu_enabled_ = true;
87 bool GpuProcessHost::hardware_gpu_enabled_ = true; 82 bool GpuProcessHost::hardware_gpu_enabled_ = true;
88 int GpuProcessHost::gpu_crash_count_ = 0; 83 int GpuProcessHost::gpu_crash_count_ = 0;
89 int GpuProcessHost::gpu_recent_crash_count_ = 0; 84 int GpuProcessHost::gpu_recent_crash_count_ = 0;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 DCHECK(CalledOnValidThread()); 439 DCHECK(CalledOnValidThread());
445 440
446 SendOutstandingReplies(); 441 SendOutstandingReplies();
447 442
448 // In case we never started, clean up. 443 // In case we never started, clean up.
449 while (!queued_messages_.empty()) { 444 while (!queued_messages_.empty()) {
450 delete queued_messages_.front(); 445 delete queued_messages_.front();
451 queued_messages_.pop(); 446 queued_messages_.pop();
452 } 447 }
453 448
454 #if defined(OS_MACOSX) && !defined(OS_IOS)
455 if (!io_surface_manager_token_.IsZero()) {
456 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken();
457 io_surface_manager_token_.SetZero();
458 }
459 #endif
460
461 // This is only called on the IO thread so no race against the constructor 449 // This is only called on the IO thread so no race against the constructor
462 // for another GpuProcessHost. 450 // for another GpuProcessHost.
463 if (g_gpu_process_hosts[kind_] == this) 451 if (g_gpu_process_hosts[kind_] == this)
464 g_gpu_process_hosts[kind_] = NULL; 452 g_gpu_process_hosts[kind_] = NULL;
465 453
466 // If there are any remaining offscreen contexts at the point the 454 // If there are any remaining offscreen contexts at the point the
467 // GPU process exits, assume something went wrong, and block their 455 // GPU process exits, assume something went wrong, and block their
468 // URLs from accessing client 3D APIs without prompting. 456 // URLs from accessing client 3D APIs without prompting.
469 BlockLiveOffscreenContexts(); 457 BlockLiveOffscreenContexts();
470 458
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 in_process_gpu_thread_->StartWithOptions(options); 549 in_process_gpu_thread_->StartWithOptions(options);
562 550
563 OnProcessLaunched(); // Fake a callback that the process is ready. 551 OnProcessLaunched(); // Fake a callback that the process is ready.
564 } else if (!LaunchGpuProcess(channel_id)) { 552 } else if (!LaunchGpuProcess(channel_id)) {
565 return false; 553 return false;
566 } 554 }
567 555
568 if (!Send(new GpuMsg_Initialize())) 556 if (!Send(new GpuMsg_Initialize()))
569 return false; 557 return false;
570 558
571 #if defined(OS_MACOSX) && !defined(OS_IOS)
572 io_surface_manager_token_ =
573 BrowserIOSurfaceManager::GetInstance()->GenerateGpuProcessToken();
574 // Note: A valid IOSurface manager token needs to be sent to the Gpu process
575 // before any GpuMemoryBuffer allocation requests can be sent.
576 Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_));
577 #endif
578
579 return true; 559 return true;
580 } 560 }
581 561
582 bool GpuProcessHost::SetupMojo() { 562 bool GpuProcessHost::SetupMojo() {
583 DCHECK(!mojo_application_host_); 563 DCHECK(!mojo_application_host_);
584 mojo_application_host_.reset(new MojoApplicationHost); 564 mojo_application_host_.reset(new MojoApplicationHost);
585 return mojo_application_host_->Init(); 565 return mojo_application_host_->Init();
586 } 566 }
587 567
588 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { 568 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { 910 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() {
931 return kind_; 911 return kind_;
932 } 912 }
933 913
934 void GpuProcessHost::ForceShutdown() { 914 void GpuProcessHost::ForceShutdown() {
935 // This is only called on the IO thread so no race against the constructor 915 // This is only called on the IO thread so no race against the constructor
936 // for another GpuProcessHost. 916 // for another GpuProcessHost.
937 if (g_gpu_process_hosts[kind_] == this) 917 if (g_gpu_process_hosts[kind_] == this)
938 g_gpu_process_hosts[kind_] = NULL; 918 g_gpu_process_hosts[kind_] = NULL;
939 919
940 #if defined(OS_MACOSX) && !defined(OS_IOS)
941 if (!io_surface_manager_token_.IsZero()) {
942 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken();
943 io_surface_manager_token_.SetZero();
944 }
945 #endif
946
947 process_->ForceShutdown(); 920 process_->ForceShutdown();
948 } 921 }
949 922
950 void GpuProcessHost::StopGpuProcess() { 923 void GpuProcessHost::StopGpuProcess() {
951 Send(new GpuMsg_Finalize()); 924 Send(new GpuMsg_Finalize());
952 } 925 }
953 926
954 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { 927 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) {
955 if (!(gpu_enabled_ && 928 if (!(gpu_enabled_ &&
956 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && 929 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) &&
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); 1145 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
1173 ClientIdToShaderCacheMap::iterator iter = 1146 ClientIdToShaderCacheMap::iterator iter =
1174 client_id_to_shader_cache_.find(client_id); 1147 client_id_to_shader_cache_.find(client_id);
1175 // If the cache doesn't exist then this is an off the record profile. 1148 // If the cache doesn't exist then this is an off the record profile.
1176 if (iter == client_id_to_shader_cache_.end()) 1149 if (iter == client_id_to_shader_cache_.end())
1177 return; 1150 return;
1178 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); 1151 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader);
1179 } 1152 }
1180 1153
1181 } // namespace content 1154 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/gpu/gpu_process_host_ui_shim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698