OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
33 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" | 33 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" |
34 #include "components/display_compositor/gl_helper.h" | 34 #include "components/display_compositor/gl_helper.h" |
35 #include "content/browser/compositor/browser_compositor_output_surface.h" | 35 #include "content/browser/compositor/browser_compositor_output_surface.h" |
36 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 36 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
37 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 37 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
38 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 38 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
39 #include "content/browser/compositor/reflector_impl.h" | 39 #include "content/browser/compositor/reflector_impl.h" |
40 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 40 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
41 #include "content/browser/compositor/software_output_device_mus.h" | 41 #include "content/browser/compositor/software_output_device_mus.h" |
42 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | |
43 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 42 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
44 #include "content/browser/gpu/gpu_data_manager_impl.h" | 43 #include "content/browser/gpu/gpu_data_manager_impl.h" |
45 #include "content/browser/renderer_host/render_widget_host_impl.h" | 44 #include "content/browser/renderer_host/render_widget_host_impl.h" |
46 #include "content/common/gpu/client/context_provider_command_buffer.h" | 45 #include "content/common/gpu/client/context_provider_command_buffer.h" |
47 #include "content/common/host_shared_bitmap_manager.h" | 46 #include "content/common/host_shared_bitmap_manager.h" |
48 #include "content/public/common/content_switches.h" | 47 #include "content/public/common/content_switches.h" |
49 #include "gpu/GLES2/gl2extchromium.h" | 48 #include "gpu/GLES2/gl2extchromium.h" |
50 #include "gpu/command_buffer/client/gles2_interface.h" | 49 #include "gpu/command_buffer/client/gles2_interface.h" |
51 #include "gpu/command_buffer/client/shared_memory_limits.h" | 50 #include "gpu/command_buffer/client/shared_memory_limits.h" |
52 #include "gpu/command_buffer/common/mailbox.h" | 51 #include "gpu/command_buffer/common/mailbox.h" |
53 #include "gpu/ipc/client/gpu_channel_host.h" | 52 #include "gpu/ipc/client/gpu_channel_host.h" |
| 53 #include "services/shell/runner/common/client_util.h" |
54 #include "third_party/khronos/GLES2/gl2.h" | 54 #include "third_party/khronos/GLES2/gl2.h" |
55 #include "ui/compositor/compositor.h" | 55 #include "ui/compositor/compositor.h" |
56 #include "ui/compositor/compositor_constants.h" | 56 #include "ui/compositor/compositor_constants.h" |
57 #include "ui/compositor/compositor_switches.h" | 57 #include "ui/compositor/compositor_switches.h" |
58 #include "ui/compositor/layer.h" | 58 #include "ui/compositor/layer.h" |
59 #include "ui/gfx/geometry/size.h" | 59 #include "ui/gfx/geometry/size.h" |
60 | 60 |
61 #if defined(MOJO_RUNNER_CLIENT) | 61 #if defined(USE_AURA) |
62 #include "content/browser/compositor/mus_browser_compositor_output_surface.h" | 62 #include "content/browser/compositor/mus_browser_compositor_output_surface.h" |
63 #include "content/public/common/mojo_shell_connection.h" | 63 #include "content/public/common/mojo_shell_connection.h" |
64 #include "services/shell/runner/common/client_util.h" | |
65 #include "services/ui/common/gpu_service.h" | 64 #include "services/ui/common/gpu_service.h" |
66 #endif | 65 #endif |
67 | 66 |
68 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
69 #include "content/browser/compositor/software_output_device_win.h" | 68 #include "content/browser/compositor/software_output_device_win.h" |
70 #include "ui/gfx/win/rendering_window_manager.h" | 69 #include "ui/gfx/win/rendering_window_manager.h" |
71 #elif defined(USE_OZONE) | 70 #elif defined(USE_OZONE) |
72 #include "components/display_compositor/compositor_overlay_candidate_validator_o
zone.h" | 71 #include "components/display_compositor/compositor_overlay_candidate_validator_o
zone.h" |
73 #include "content/browser/compositor/software_output_device_ozone.h" | 72 #include "content/browser/compositor/software_output_device_ozone.h" |
74 #include "ui/ozone/public/overlay_candidates_ozone.h" | 73 #include "ui/ozone/public/overlay_candidates_ozone.h" |
(...skipping 22 matching lines...) Expand all Loading... |
97 #endif | 96 #endif |
98 | 97 |
99 using cc::ContextProvider; | 98 using cc::ContextProvider; |
100 using gpu::gles2::GLES2Interface; | 99 using gpu::gles2::GLES2Interface; |
101 | 100 |
102 namespace { | 101 namespace { |
103 | 102 |
104 const int kNumRetriesBeforeSoftwareFallback = 4; | 103 const int kNumRetriesBeforeSoftwareFallback = 4; |
105 | 104 |
106 bool IsUsingMus() { | 105 bool IsUsingMus() { |
107 #if defined(MOJO_RUNNER_CLIENT) | |
108 return shell::ShellIsRemote(); | 106 return shell::ShellIsRemote(); |
109 #else | |
110 return false; | |
111 #endif | |
112 } | 107 } |
113 | 108 |
114 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon( | 109 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon( |
115 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 110 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
116 gpu::SurfaceHandle surface_handle, | 111 gpu::SurfaceHandle surface_handle, |
117 bool need_alpha_channel, | 112 bool need_alpha_channel, |
118 bool support_locking, | 113 bool support_locking, |
119 content::ContextProviderCommandBuffer* shared_context_provider, | 114 content::ContextProviderCommandBuffer* shared_context_provider, |
120 content::command_buffer_metrics::ContextType type) { | 115 content::command_buffer_metrics::ContextType type) { |
121 DCHECK( | 116 DCHECK( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 193 |
199 // Make sure the lost context callback doesn't try to run during destruction. | 194 // Make sure the lost context callback doesn't try to run during destruction. |
200 callback_factory_.InvalidateWeakPtrs(); | 195 callback_factory_.InvalidateWeakPtrs(); |
201 | 196 |
202 task_graph_runner_->Shutdown(); | 197 task_graph_runner_->Shutdown(); |
203 } | 198 } |
204 | 199 |
205 std::unique_ptr<cc::SoftwareOutputDevice> | 200 std::unique_ptr<cc::SoftwareOutputDevice> |
206 GpuProcessTransportFactory::CreateSoftwareOutputDevice( | 201 GpuProcessTransportFactory::CreateSoftwareOutputDevice( |
207 ui::Compositor* compositor) { | 202 ui::Compositor* compositor) { |
208 #if defined(MOJO_RUNNER_CLIENT) | 203 #if defined(USE_AURA) |
209 if (shell::ShellIsRemote()) { | 204 if (shell::ShellIsRemote()) { |
210 return std::unique_ptr<cc::SoftwareOutputDevice>( | 205 return std::unique_ptr<cc::SoftwareOutputDevice>( |
211 new SoftwareOutputDeviceMus(compositor)); | 206 new SoftwareOutputDeviceMus(compositor)); |
212 } | 207 } |
213 #endif | 208 #endif |
214 | 209 |
215 #if defined(OS_WIN) | 210 #if defined(OS_WIN) |
216 return std::unique_ptr<cc::SoftwareOutputDevice>( | 211 return std::unique_ptr<cc::SoftwareOutputDevice>( |
217 new SoftwareOutputDeviceWin(software_backing_.get(), compositor)); | 212 new SoftwareOutputDeviceWin(software_backing_.get(), compositor)); |
218 #elif defined(USE_OZONE) | 213 #elif defined(USE_OZONE) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 data->display_output_surface = nullptr; | 290 data->display_output_surface = nullptr; |
296 data->begin_frame_source = nullptr; | 291 data->begin_frame_source = nullptr; |
297 } | 292 } |
298 | 293 |
299 #if defined(OS_WIN) | 294 #if defined(OS_WIN) |
300 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 295 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
301 compositor->widget()); | 296 compositor->widget()); |
302 #endif | 297 #endif |
303 | 298 |
304 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); | 299 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); |
305 const bool use_mus = IsUsingMus(); | |
306 const bool create_gpu_output_surface = | 300 const bool create_gpu_output_surface = |
307 ShouldCreateGpuOutputSurface(compositor.get()); | 301 ShouldCreateGpuOutputSurface(compositor.get()); |
308 if (create_gpu_output_surface && !use_vulkan) { | 302 if (create_gpu_output_surface && !use_vulkan) { |
309 base::Closure callback( | 303 gpu::GpuChannelEstablishedCallback callback( |
310 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 304 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
311 callback_factory_.GetWeakPtr(), compositor, | 305 callback_factory_.GetWeakPtr(), compositor, |
312 create_gpu_output_surface, 0)); | 306 create_gpu_output_surface, 0)); |
313 if (!use_mus) { | 307 DCHECK(gpu_channel_factory_); |
314 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(callback); | 308 gpu_channel_factory_->EstablishGpuChannel(callback); |
315 } else { | |
316 #if defined(MOJO_RUNNER_CLIENT) | |
317 ui::GpuService::GetInstance()->EstablishGpuChannel(callback); | |
318 #else | |
319 NOTREACHED(); | |
320 #endif | |
321 } | |
322 } else { | 309 } else { |
323 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); | 310 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0, nullptr); |
324 } | 311 } |
325 } | 312 } |
326 | 313 |
327 void GpuProcessTransportFactory::EstablishedGpuChannel( | 314 void GpuProcessTransportFactory::EstablishedGpuChannel( |
328 base::WeakPtr<ui::Compositor> compositor, | 315 base::WeakPtr<ui::Compositor> compositor, |
329 bool create_gpu_output_surface, | 316 bool create_gpu_output_surface, |
330 int num_attempts) { | 317 int num_attempts, |
| 318 scoped_refptr<gpu::GpuChannelHost> established_channel_host) { |
331 if (!compositor) | 319 if (!compositor) |
332 return; | 320 return; |
333 | 321 |
334 // The widget might have been released in the meantime. | 322 // The widget might have been released in the meantime. |
335 PerCompositorDataMap::iterator it = | 323 PerCompositorDataMap::iterator it = |
336 per_compositor_data_.find(compositor.get()); | 324 per_compositor_data_.find(compositor.get()); |
337 if (it == per_compositor_data_.end()) | 325 if (it == per_compositor_data_.end()) |
338 return; | 326 return; |
339 | 327 |
340 PerCompositorData* data = it->second; | 328 PerCompositorData* data = it->second; |
341 DCHECK(data); | 329 DCHECK(data); |
342 | 330 |
343 if (num_attempts > kNumRetriesBeforeSoftwareFallback) { | 331 if (num_attempts > kNumRetriesBeforeSoftwareFallback) { |
344 #if defined(OS_CHROMEOS) | 332 #if defined(OS_CHROMEOS) |
345 LOG(FATAL) << "Unable to create a UI graphics context, and cannot use " | 333 LOG(FATAL) << "Unable to create a UI graphics context, and cannot use " |
346 << "software compositing on ChromeOS."; | 334 << "software compositing on ChromeOS."; |
347 #endif | 335 #endif |
348 create_gpu_output_surface = false; | 336 create_gpu_output_surface = false; |
349 } | 337 } |
350 | 338 |
351 #if defined(OS_WIN) | 339 #if defined(OS_WIN) |
352 gfx::RenderingWindowManager::GetInstance()->RegisterParent( | 340 gfx::RenderingWindowManager::GetInstance()->RegisterParent( |
353 compositor->widget()); | 341 compositor->widget()); |
354 #endif | 342 #endif |
355 | 343 |
356 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = | 344 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = |
357 SharedVulkanContextProvider(); | 345 SharedVulkanContextProvider(); |
358 const bool use_mus = IsUsingMus(); | |
359 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 346 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
360 if (create_gpu_output_surface && !vulkan_context_provider) { | 347 if (create_gpu_output_surface && !vulkan_context_provider) { |
361 // Try to reuse existing worker context provider. | 348 // Try to reuse existing worker context provider. |
362 if (shared_worker_context_provider_) { | 349 if (shared_worker_context_provider_) { |
363 bool lost; | 350 bool lost; |
364 { | 351 { |
365 // Note: If context is lost, we delete reference after releasing the | 352 // Note: If context is lost, we delete reference after releasing the |
366 // lock. | 353 // lock. |
367 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); | 354 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); |
368 lost = shared_worker_context_provider_->ContextGL() | 355 lost = shared_worker_context_provider_->ContextGL() |
369 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 356 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
370 } | 357 } |
371 if (lost) | 358 if (lost) |
372 shared_worker_context_provider_ = nullptr; | 359 shared_worker_context_provider_ = nullptr; |
373 } | 360 } |
374 | 361 |
375 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 362 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
376 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { | 363 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
377 // We attempted to do EstablishGpuChannel already, so we just use | 364 gpu_channel_host = std::move(established_channel_host); |
378 // GetGpuChannel() instead of EstablishGpuChannelSync(). | |
379 if (!use_mus) { | |
380 gpu_channel_host = | |
381 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); | |
382 } else { | |
383 #if defined(MOJO_RUNNER_CLIENT) | |
384 gpu_channel_host = ui::GpuService::GetInstance()->GetGpuChannel(); | |
385 #else | |
386 NOTREACHED(); | |
387 #endif | |
388 } | |
389 } | |
390 | 365 |
391 if (!gpu_channel_host) { | 366 if (!gpu_channel_host) { |
392 shared_worker_context_provider_ = nullptr; | 367 shared_worker_context_provider_ = nullptr; |
393 } else { | 368 } else { |
394 if (!shared_worker_context_provider_) { | 369 if (!shared_worker_context_provider_) { |
395 bool need_alpha_channel = false; | 370 bool need_alpha_channel = false; |
396 const bool support_locking = true; | 371 const bool support_locking = true; |
397 shared_worker_context_provider_ = | 372 shared_worker_context_provider_ = |
398 CreateContextCommon(gpu_channel_host, gpu::kNullSurfaceHandle, | 373 CreateContextCommon(gpu_channel_host, gpu::kNullSurfaceHandle, |
399 need_alpha_channel, support_locking, nullptr, | 374 need_alpha_channel, support_locking, nullptr, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 419 } |
445 | 420 |
446 bool created_gpu_browser_compositor = | 421 bool created_gpu_browser_compositor = |
447 !!context_provider && !!shared_worker_context_provider_; | 422 !!context_provider && !!shared_worker_context_provider_; |
448 | 423 |
449 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 424 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
450 created_gpu_browser_compositor); | 425 created_gpu_browser_compositor); |
451 | 426 |
452 if (!created_gpu_browser_compositor) { | 427 if (!created_gpu_browser_compositor) { |
453 // Try again. | 428 // Try again. |
454 base::Closure callback( | 429 gpu::GpuChannelEstablishedCallback callback( |
455 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 430 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
456 callback_factory_.GetWeakPtr(), compositor, | 431 callback_factory_.GetWeakPtr(), compositor, |
457 create_gpu_output_surface, num_attempts + 1)); | 432 create_gpu_output_surface, num_attempts + 1)); |
458 if (!use_mus) { | 433 DCHECK(gpu_channel_factory_); |
459 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(callback); | 434 gpu_channel_factory_->EstablishGpuChannel(callback); |
460 } else { | |
461 #if defined(MOJO_RUNNER_CLIENT) | |
462 ui::GpuService::GetInstance()->EstablishGpuChannel(callback); | |
463 #else | |
464 NOTREACHED(); | |
465 #endif | |
466 } | |
467 return; | 435 return; |
468 } | 436 } |
469 } | 437 } |
470 | 438 |
471 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | 439 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; |
472 if (!compositor->GetRendererSettings().disable_display_vsync) { | 440 if (!compositor->GetRendererSettings().disable_display_vsync) { |
473 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( | 441 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( |
474 base::MakeUnique<cc::DelayBasedTimeSource>( | 442 base::MakeUnique<cc::DelayBasedTimeSource>( |
475 compositor->task_runner().get()))); | 443 compositor->task_runner().get()))); |
476 } else { | 444 } else { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( | 491 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( |
524 context_provider, data->surface_handle, | 492 context_provider, data->surface_handle, |
525 compositor->vsync_manager(), begin_frame_source.get(), | 493 compositor->vsync_manager(), begin_frame_source.get(), |
526 CreateOverlayCandidateValidator(compositor->widget()), | 494 CreateOverlayCandidateValidator(compositor->widget()), |
527 GL_TEXTURE_2D, GL_RGB, | 495 GL_TEXTURE_2D, GL_RGB, |
528 BrowserGpuMemoryBufferManager::current())); | 496 BrowserGpuMemoryBufferManager::current())); |
529 #endif | 497 #endif |
530 } else { | 498 } else { |
531 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 499 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
532 validator; | 500 validator; |
| 501 const bool use_mus = IsUsingMus(); |
533 #if !defined(OS_MACOSX) | 502 #if !defined(OS_MACOSX) |
534 // Overlays are only supported on surfaceless output surfaces on Mac. | 503 // Overlays are only supported on surfaceless output surfaces on Mac. |
535 if (!use_mus) | 504 if (!use_mus) |
536 validator = CreateOverlayCandidateValidator(compositor->widget()); | 505 validator = CreateOverlayCandidateValidator(compositor->widget()); |
537 #endif | 506 #endif |
538 if (!use_mus) { | 507 if (!use_mus) { |
539 display_output_surface = | 508 display_output_surface = |
540 base::WrapUnique(new GpuBrowserCompositorOutputSurface( | 509 base::WrapUnique(new GpuBrowserCompositorOutputSurface( |
541 context_provider, compositor->vsync_manager(), | 510 context_provider, compositor->vsync_manager(), |
542 begin_frame_source.get(), std::move(validator))); | 511 begin_frame_source.get(), std::move(validator))); |
543 } else { | 512 } else { |
544 #if defined(MOJO_RUNNER_CLIENT) | 513 #if defined(USE_AURA) |
545 display_output_surface = | 514 display_output_surface = |
546 base::WrapUnique(new MusBrowserCompositorOutputSurface( | 515 base::WrapUnique(new MusBrowserCompositorOutputSurface( |
547 data->surface_handle, context_provider, | 516 data->surface_handle, context_provider, |
548 compositor->vsync_manager(), begin_frame_source.get(), | 517 compositor->vsync_manager(), begin_frame_source.get(), |
549 std::move(validator))); | 518 std::move(validator))); |
550 #else | 519 #else |
551 NOTREACHED(); | 520 NOTREACHED(); |
552 #endif | 521 #endif |
553 } | 522 } |
554 } | 523 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 if (!gl_helper_ && !per_compositor_data_.empty()) { | 734 if (!gl_helper_ && !per_compositor_data_.empty()) { |
766 scoped_refptr<cc::ContextProvider> provider = | 735 scoped_refptr<cc::ContextProvider> provider = |
767 SharedMainThreadContextProvider(); | 736 SharedMainThreadContextProvider(); |
768 if (provider.get()) | 737 if (provider.get()) |
769 gl_helper_.reset(new display_compositor::GLHelper( | 738 gl_helper_.reset(new display_compositor::GLHelper( |
770 provider->ContextGL(), provider->ContextSupport())); | 739 provider->ContextGL(), provider->ContextSupport())); |
771 } | 740 } |
772 return gl_helper_.get(); | 741 return gl_helper_.get(); |
773 } | 742 } |
774 | 743 |
| 744 void GpuProcessTransportFactory::SetGpuChannelEstablishFactory( |
| 745 gpu::GpuChannelEstablishFactory* factory) { |
| 746 DCHECK(!gpu_channel_factory_ || !factory); |
| 747 gpu_channel_factory_ = factory; |
| 748 } |
| 749 |
775 #if defined(OS_MACOSX) | 750 #if defined(OS_MACOSX) |
776 void GpuProcessTransportFactory::SetCompositorSuspendedForRecycle( | 751 void GpuProcessTransportFactory::SetCompositorSuspendedForRecycle( |
777 ui::Compositor* compositor, | 752 ui::Compositor* compositor, |
778 bool suspended) { | 753 bool suspended) { |
779 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); | 754 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); |
780 if (it == per_compositor_data_.end()) | 755 if (it == per_compositor_data_.end()) |
781 return; | 756 return; |
782 PerCompositorData* data = it->second; | 757 PerCompositorData* data = it->second; |
783 DCHECK(data); | 758 DCHECK(data); |
784 if (data->display_output_surface) | 759 if (data->display_output_surface) |
785 data->display_output_surface->SetSurfaceSuspendedForRecycle(suspended); | 760 data->display_output_surface->SetSurfaceSuspendedForRecycle(suspended); |
786 } | 761 } |
787 #endif | 762 #endif |
788 | 763 |
789 scoped_refptr<cc::ContextProvider> | 764 scoped_refptr<cc::ContextProvider> |
790 GpuProcessTransportFactory::SharedMainThreadContextProvider() { | 765 GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
791 if (shared_main_thread_contexts_) | 766 if (shared_main_thread_contexts_) |
792 return shared_main_thread_contexts_; | 767 return shared_main_thread_contexts_; |
793 | 768 |
794 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 769 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
795 return nullptr; | 770 return nullptr; |
796 | 771 |
797 const bool use_mus = IsUsingMus(); | 772 DCHECK(gpu_channel_factory_); |
798 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 773 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = |
799 if (!use_mus) { | 774 gpu_channel_factory_->EstablishGpuChannelSync(); |
800 gpu_channel_host = | |
801 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(); | |
802 } else { | |
803 #if defined(MOJO_RUNNER_CLIENT) | |
804 gpu_channel_host = ui::GpuService::GetInstance()->EstablishGpuChannelSync(); | |
805 #else | |
806 NOTREACHED(); | |
807 #endif | |
808 } | |
809 | |
810 if (!gpu_channel_host) | 775 if (!gpu_channel_host) |
811 return nullptr; | 776 return nullptr; |
812 | 777 |
813 // We need a separate context from the compositor's so that skia and gl_helper | 778 // We need a separate context from the compositor's so that skia and gl_helper |
814 // don't step on each other. | 779 // don't step on each other. |
815 bool need_alpha_channel = false; | 780 bool need_alpha_channel = false; |
816 bool support_locking = false; | 781 bool support_locking = false; |
817 shared_main_thread_contexts_ = CreateContextCommon( | 782 shared_main_thread_contexts_ = CreateContextCommon( |
818 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, need_alpha_channel, | 783 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, need_alpha_channel, |
819 support_locking, nullptr, | 784 support_locking, nullptr, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 shared_vulkan_context_provider_ = | 858 shared_vulkan_context_provider_ = |
894 cc::VulkanInProcessContextProvider::Create(); | 859 cc::VulkanInProcessContextProvider::Create(); |
895 } | 860 } |
896 | 861 |
897 shared_vulkan_context_provider_initialized_ = true; | 862 shared_vulkan_context_provider_initialized_ = true; |
898 } | 863 } |
899 return shared_vulkan_context_provider_; | 864 return shared_vulkan_context_provider_; |
900 } | 865 } |
901 | 866 |
902 } // namespace content | 867 } // namespace content |
OLD | NEW |