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 11 matching lines...) Expand all Loading... |
22 #include "cc/output/texture_mailbox_deleter.h" | 22 #include "cc/output/texture_mailbox_deleter.h" |
23 #include "cc/output/vulkan_in_process_context_provider.h" | 23 #include "cc/output/vulkan_in_process_context_provider.h" |
24 #include "cc/raster/single_thread_task_graph_runner.h" | 24 #include "cc/raster/single_thread_task_graph_runner.h" |
25 #include "cc/raster/task_graph_runner.h" | 25 #include "cc/raster/task_graph_runner.h" |
26 #include "cc/scheduler/begin_frame_source.h" | 26 #include "cc/scheduler/begin_frame_source.h" |
27 #include "cc/scheduler/delay_based_time_source.h" | 27 #include "cc/scheduler/delay_based_time_source.h" |
28 #include "cc/surfaces/direct_compositor_frame_sink.h" | 28 #include "cc/surfaces/direct_compositor_frame_sink.h" |
29 #include "cc/surfaces/display.h" | 29 #include "cc/surfaces/display.h" |
30 #include "cc/surfaces/display_scheduler.h" | 30 #include "cc/surfaces/display_scheduler.h" |
31 #include "cc/surfaces/surface_manager.h" | 31 #include "cc/surfaces/surface_manager.h" |
32 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" | 32 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or.h" |
33 #include "components/display_compositor/gl_helper.h" | 33 #include "components/viz/display_compositor/gl_helper.h" |
34 #include "components/display_compositor/host_shared_bitmap_manager.h" | 34 #include "components/viz/display_compositor/host_shared_bitmap_manager.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/frame_sink_manager_host.h" | 36 #include "content/browser/compositor/frame_sink_manager_host.h" |
37 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 37 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
38 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 38 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
39 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 39 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
40 #include "content/browser/compositor/reflector_impl.h" | 40 #include "content/browser/compositor/reflector_impl.h" |
41 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 41 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
42 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 42 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
43 #include "content/browser/gpu/gpu_data_manager_impl.h" | 43 #include "content/browser/gpu/gpu_data_manager_impl.h" |
44 #include "content/browser/renderer_host/render_widget_host_impl.h" | 44 #include "content/browser/renderer_host/render_widget_host_impl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
62 #include "ui/gfx/switches.h" | 62 #include "ui/gfx/switches.h" |
63 #include "ui/gl/gl_switches.h" | 63 #include "ui/gl/gl_switches.h" |
64 | 64 |
65 #if defined(USE_AURA) | 65 #if defined(USE_AURA) |
66 #include "content/public/common/service_manager_connection.h" | 66 #include "content/public/common/service_manager_connection.h" |
67 #include "ui/aura/window_tree_host.h" | 67 #include "ui/aura/window_tree_host.h" |
68 #endif | 68 #endif |
69 | 69 |
70 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
71 #include "base/win/windows_version.h" | 71 #include "base/win/windows_version.h" |
72 #include "components/display_compositor/compositor_overlay_candidate_validator_w
in.h" | 72 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_win.h" |
73 #include "content/browser/compositor/software_output_device_win.h" | 73 #include "content/browser/compositor/software_output_device_win.h" |
74 #include "ui/gfx/win/rendering_window_manager.h" | 74 #include "ui/gfx/win/rendering_window_manager.h" |
75 #elif defined(USE_OZONE) | 75 #elif defined(USE_OZONE) |
76 #include "components/display_compositor/compositor_overlay_candidate_validator_o
zone.h" | 76 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_ozone.h" |
77 #include "content/browser/compositor/software_output_device_ozone.h" | 77 #include "content/browser/compositor/software_output_device_ozone.h" |
78 #include "ui/ozone/public/overlay_candidates_ozone.h" | 78 #include "ui/ozone/public/overlay_candidates_ozone.h" |
79 #include "ui/ozone/public/overlay_manager_ozone.h" | 79 #include "ui/ozone/public/overlay_manager_ozone.h" |
80 #include "ui/ozone/public/ozone_platform.h" | 80 #include "ui/ozone/public/ozone_platform.h" |
81 #include "ui/ozone/public/ozone_switches.h" | 81 #include "ui/ozone/public/ozone_switches.h" |
82 #elif defined(USE_X11) | 82 #elif defined(USE_X11) |
83 #include "content/browser/compositor/software_output_device_x11.h" | 83 #include "content/browser/compositor/software_output_device_x11.h" |
84 #elif defined(OS_MACOSX) | 84 #elif defined(OS_MACOSX) |
85 #include "components/display_compositor/compositor_overlay_candidate_validator_m
ac.h" | 85 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_mac.h" |
86 #include "content/browser/compositor/gpu_output_surface_mac.h" | 86 #include "content/browser/compositor/gpu_output_surface_mac.h" |
87 #include "content/browser/compositor/software_output_device_mac.h" | 87 #include "content/browser/compositor/software_output_device_mac.h" |
88 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 88 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
89 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 89 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
90 #include "ui/base/cocoa/remote_layer_api.h" | 90 #include "ui/base/cocoa/remote_layer_api.h" |
91 #include "ui/base/ui_base_switches.h" | 91 #include "ui/base/ui_base_switches.h" |
92 #elif defined(OS_ANDROID) | 92 #elif defined(OS_ANDROID) |
93 #include "components/display_compositor/compositor_overlay_candidate_validator_a
ndroid.h" | 93 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_android.h" |
94 #endif | 94 #endif |
95 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) | 95 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) |
96 #include "gpu/ipc/common/gpu_surface_tracker.h" | 96 #include "gpu/ipc/common/gpu_surface_tracker.h" |
97 #endif | 97 #endif |
98 | 98 |
99 #if BUILDFLAG(ENABLE_VULKAN) | 99 #if BUILDFLAG(ENABLE_VULKAN) |
100 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" | 100 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" |
101 #endif | 101 #endif |
102 | 102 |
103 using cc::ContextProvider; | 103 using cc::ContextProvider; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 new SoftwareOutputDeviceX11(compositor)); | 251 new SoftwareOutputDeviceX11(compositor)); |
252 #elif defined(OS_MACOSX) | 252 #elif defined(OS_MACOSX) |
253 return std::unique_ptr<cc::SoftwareOutputDevice>( | 253 return std::unique_ptr<cc::SoftwareOutputDevice>( |
254 new SoftwareOutputDeviceMac(compositor)); | 254 new SoftwareOutputDeviceMac(compositor)); |
255 #else | 255 #else |
256 NOTREACHED(); | 256 NOTREACHED(); |
257 return std::unique_ptr<cc::SoftwareOutputDevice>(); | 257 return std::unique_ptr<cc::SoftwareOutputDevice>(); |
258 #endif | 258 #endif |
259 } | 259 } |
260 | 260 |
261 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 261 std::unique_ptr<viz::CompositorOverlayCandidateValidator> |
262 CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) { | 262 CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) { |
263 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 263 std::unique_ptr<viz::CompositorOverlayCandidateValidator> validator; |
264 validator; | |
265 #if defined(USE_OZONE) | 264 #if defined(USE_OZONE) |
266 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 265 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
267 if (command_line->HasSwitch(switches::kEnableHardwareOverlays)) { | 266 if (command_line->HasSwitch(switches::kEnableHardwareOverlays)) { |
268 std::string enable_overlay_flag = | 267 std::string enable_overlay_flag = |
269 command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays); | 268 command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays); |
270 std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates = | 269 std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates = |
271 ui::OzonePlatform::GetInstance() | 270 ui::OzonePlatform::GetInstance() |
272 ->GetOverlayManager() | 271 ->GetOverlayManager() |
273 ->CreateOverlayCandidates(widget); | 272 ->CreateOverlayCandidates(widget); |
274 validator.reset( | 273 validator.reset(new viz::CompositorOverlayCandidateValidatorOzone( |
275 new display_compositor::CompositorOverlayCandidateValidatorOzone( | 274 std::move(overlay_candidates), enable_overlay_flag)); |
276 std::move(overlay_candidates), enable_overlay_flag)); | |
277 } | 275 } |
278 #elif defined(OS_MACOSX) | 276 #elif defined(OS_MACOSX) |
279 // Overlays are only supported through the remote layer API. | 277 // Overlays are only supported through the remote layer API. |
280 if (ui::RemoteLayerAPISupported()) { | 278 if (ui::RemoteLayerAPISupported()) { |
281 static bool overlays_disabled_at_command_line = | 279 static bool overlays_disabled_at_command_line = |
282 IsCALayersDisabledFromCommandLine(); | 280 IsCALayersDisabledFromCommandLine(); |
283 const bool ca_layers_disabled = | 281 const bool ca_layers_disabled = |
284 overlays_disabled_at_command_line || | 282 overlays_disabled_at_command_line || |
285 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( | 283 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( |
286 gpu::DISABLE_OVERLAY_CA_LAYERS); | 284 gpu::DISABLE_OVERLAY_CA_LAYERS); |
287 validator.reset( | 285 validator.reset( |
288 new display_compositor::CompositorOverlayCandidateValidatorMac( | 286 new viz::CompositorOverlayCandidateValidatorMac(ca_layers_disabled)); |
289 ca_layers_disabled)); | |
290 } | 287 } |
291 #elif defined(OS_ANDROID) | 288 #elif defined(OS_ANDROID) |
292 validator.reset( | 289 validator.reset(new viz::CompositorOverlayCandidateValidatorAndroid()); |
293 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); | |
294 #elif defined(OS_WIN) | 290 #elif defined(OS_WIN) |
295 validator = base::MakeUnique< | 291 validator = base::MakeUnique<viz::CompositorOverlayCandidateValidatorWin>(); |
296 display_compositor::CompositorOverlayCandidateValidatorWin>(); | |
297 #endif | 292 #endif |
298 | 293 |
299 return validator; | 294 return validator; |
300 } | 295 } |
301 | 296 |
302 static bool ShouldCreateGpuCompositorFrameSink(ui::Compositor* compositor) { | 297 static bool ShouldCreateGpuCompositorFrameSink(ui::Compositor* compositor) { |
303 #if defined(OS_CHROMEOS) | 298 #if defined(OS_CHROMEOS) |
304 // Software fallback does not happen on Chrome OS. | 299 // Software fallback does not happen on Chrome OS. |
305 return true; | 300 return true; |
306 #endif | 301 #endif |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 base::MakeUnique<SoftwareBrowserCompositorOutputSurface>( | 504 base::MakeUnique<SoftwareBrowserCompositorOutputSurface>( |
510 CreateSoftwareOutputDevice(compositor.get()), vsync_callback, | 505 CreateSoftwareOutputDevice(compositor.get()), vsync_callback, |
511 compositor->task_runner()); | 506 compositor->task_runner()); |
512 } else { | 507 } else { |
513 DCHECK(context_provider); | 508 DCHECK(context_provider); |
514 const auto& capabilities = context_provider->ContextCapabilities(); | 509 const auto& capabilities = context_provider->ContextCapabilities(); |
515 if (data->surface_handle == gpu::kNullSurfaceHandle) { | 510 if (data->surface_handle == gpu::kNullSurfaceHandle) { |
516 display_output_surface = | 511 display_output_surface = |
517 base::MakeUnique<OffscreenBrowserCompositorOutputSurface>( | 512 base::MakeUnique<OffscreenBrowserCompositorOutputSurface>( |
518 context_provider, vsync_callback, | 513 context_provider, vsync_callback, |
519 std::unique_ptr< | 514 std::unique_ptr<viz::CompositorOverlayCandidateValidator>()); |
520 display_compositor::CompositorOverlayCandidateValidator>()); | |
521 } else if (capabilities.surfaceless) { | 515 } else if (capabilities.surfaceless) { |
522 #if defined(OS_MACOSX) | 516 #if defined(OS_MACOSX) |
523 display_output_surface = base::MakeUnique<GpuOutputSurfaceMac>( | 517 display_output_surface = base::MakeUnique<GpuOutputSurfaceMac>( |
524 compositor->widget(), context_provider, data->surface_handle, | 518 compositor->widget(), context_provider, data->surface_handle, |
525 vsync_callback, | 519 vsync_callback, |
526 CreateOverlayCandidateValidator(compositor->widget()), | 520 CreateOverlayCandidateValidator(compositor->widget()), |
527 GetGpuMemoryBufferManager()); | 521 GetGpuMemoryBufferManager()); |
528 #else | 522 #else |
529 auto gpu_output_surface = | 523 auto gpu_output_surface = |
530 base::MakeUnique<GpuSurfacelessBrowserCompositorOutputSurface>( | 524 base::MakeUnique<GpuSurfacelessBrowserCompositorOutputSurface>( |
531 context_provider, data->surface_handle, vsync_callback, | 525 context_provider, data->surface_handle, vsync_callback, |
532 CreateOverlayCandidateValidator(compositor->widget()), | 526 CreateOverlayCandidateValidator(compositor->widget()), |
533 GL_TEXTURE_2D, GL_RGB, | 527 GL_TEXTURE_2D, GL_RGB, |
534 display::DisplaySnapshot::PrimaryFormat(), | 528 display::DisplaySnapshot::PrimaryFormat(), |
535 GetGpuMemoryBufferManager()); | 529 GetGpuMemoryBufferManager()); |
536 gpu_vsync_control = gpu_output_surface.get(); | 530 gpu_vsync_control = gpu_output_surface.get(); |
537 display_output_surface = std::move(gpu_output_surface); | 531 display_output_surface = std::move(gpu_output_surface); |
538 #endif | 532 #endif |
539 } else { | 533 } else { |
540 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 534 std::unique_ptr<viz::CompositorOverlayCandidateValidator> validator; |
541 validator; | |
542 #if defined(OS_WIN) | 535 #if defined(OS_WIN) |
543 if (capabilities.dc_layers) | 536 if (capabilities.dc_layers) |
544 validator = CreateOverlayCandidateValidator(compositor->widget()); | 537 validator = CreateOverlayCandidateValidator(compositor->widget()); |
545 #elif !defined(OS_MACOSX) | 538 #elif !defined(OS_MACOSX) |
546 // Overlays are only supported on surfaceless output surfaces on Mac. | 539 // Overlays are only supported on surfaceless output surfaces on Mac. |
547 validator = CreateOverlayCandidateValidator(compositor->widget()); | 540 validator = CreateOverlayCandidateValidator(compositor->widget()); |
548 #endif | 541 #endif |
549 auto gpu_output_surface = | 542 auto gpu_output_surface = |
550 base::MakeUnique<GpuBrowserCompositorOutputSurface>( | 543 base::MakeUnique<GpuBrowserCompositorOutputSurface>( |
551 context_provider, vsync_callback, std::move(validator)); | 544 context_provider, vsync_callback, std::move(validator)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( | 581 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( |
589 compositor->widget()); | 582 compositor->widget()); |
590 #endif | 583 #endif |
591 | 584 |
592 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 585 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
593 compositor->task_runner().get(), | 586 compositor->task_runner().get(), |
594 display_output_surface->capabilities().max_frames_pending)); | 587 display_output_surface->capabilities().max_frames_pending)); |
595 | 588 |
596 // The Display owns and uses the |display_output_surface| created above. | 589 // The Display owns and uses the |display_output_surface| created above. |
597 data->display = base::MakeUnique<cc::Display>( | 590 data->display = base::MakeUnique<cc::Display>( |
598 display_compositor::HostSharedBitmapManager::current(), | 591 viz::HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), |
599 GetGpuMemoryBufferManager(), compositor->GetRendererSettings(), | 592 compositor->GetRendererSettings(), compositor->frame_sink_id(), |
600 compositor->frame_sink_id(), begin_frame_source, | 593 begin_frame_source, std::move(display_output_surface), |
601 std::move(display_output_surface), std::move(scheduler), | 594 std::move(scheduler), |
602 base::MakeUnique<cc::TextureMailboxDeleter>( | 595 base::MakeUnique<cc::TextureMailboxDeleter>( |
603 compositor->task_runner().get())); | 596 compositor->task_runner().get())); |
604 // Note that we are careful not to destroy prior BeginFrameSource objects | 597 // Note that we are careful not to destroy prior BeginFrameSource objects |
605 // until we have reset |data->display|. | 598 // until we have reset |data->display|. |
606 data->synthetic_begin_frame_source = std::move(synthetic_begin_frame_source); | 599 data->synthetic_begin_frame_source = std::move(synthetic_begin_frame_source); |
607 data->gpu_vsync_begin_frame_source = std::move(gpu_vsync_begin_frame_source); | 600 data->gpu_vsync_begin_frame_source = std::move(gpu_vsync_begin_frame_source); |
608 | 601 |
609 // The |delegated_output_surface| is given back to the compositor, it | 602 // The |delegated_output_surface| is given back to the compositor, it |
610 // delegates to the Display as its root surface. Importantly, it shares the | 603 // delegates to the Display as its root surface. Importantly, it shares the |
611 // same ContextProvider as the Display's output surface. | 604 // same ContextProvider as the Display's output surface. |
612 auto compositor_frame_sink = | 605 auto compositor_frame_sink = |
613 vulkan_context_provider | 606 vulkan_context_provider |
614 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 607 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
615 compositor->frame_sink_id(), GetSurfaceManager(), | 608 compositor->frame_sink_id(), GetSurfaceManager(), |
616 data->display.get(), | 609 data->display.get(), |
617 static_cast<scoped_refptr<cc::VulkanContextProvider>>( | 610 static_cast<scoped_refptr<cc::VulkanContextProvider>>( |
618 vulkan_context_provider)) | 611 vulkan_context_provider)) |
619 : base::MakeUnique<cc::DirectCompositorFrameSink>( | 612 : base::MakeUnique<cc::DirectCompositorFrameSink>( |
620 compositor->frame_sink_id(), GetSurfaceManager(), | 613 compositor->frame_sink_id(), GetSurfaceManager(), |
621 data->display.get(), context_provider, | 614 data->display.get(), context_provider, |
622 shared_worker_context_provider_, GetGpuMemoryBufferManager(), | 615 shared_worker_context_provider_, GetGpuMemoryBufferManager(), |
623 display_compositor::HostSharedBitmapManager::current()); | 616 viz::HostSharedBitmapManager::current()); |
624 data->display->Resize(compositor->size()); | 617 data->display->Resize(compositor->size()); |
625 data->display->SetOutputIsSecure(data->output_is_secure); | 618 data->display->SetOutputIsSecure(data->output_is_secure); |
626 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 619 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
627 } | 620 } |
628 | 621 |
629 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 622 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
630 ui::Compositor* source_compositor, | 623 ui::Compositor* source_compositor, |
631 ui::Layer* target_layer) { | 624 ui::Layer* target_layer) { |
632 PerCompositorData* source_data = | 625 PerCompositorData* source_data = |
633 per_compositor_data_[source_compositor].get(); | 626 per_compositor_data_[source_compositor].get(); |
(...skipping 27 matching lines...) Expand all Loading... |
661 gpu::GpuSurfaceTracker::Get()->RemoveSurface(data->surface_handle); | 654 gpu::GpuSurfaceTracker::Get()->RemoveSurface(data->surface_handle); |
662 #endif | 655 #endif |
663 | 656 |
664 per_compositor_data_.erase(it); | 657 per_compositor_data_.erase(it); |
665 if (per_compositor_data_.empty()) { | 658 if (per_compositor_data_.empty()) { |
666 // Destroying the GLHelper may cause some async actions to be cancelled, | 659 // Destroying the GLHelper may cause some async actions to be cancelled, |
667 // causing things to request a new GLHelper. Due to crbug.com/176091 the | 660 // causing things to request a new GLHelper. Due to crbug.com/176091 the |
668 // GLHelper created in this case would be lost/leaked if we just reset() | 661 // GLHelper created in this case would be lost/leaked if we just reset() |
669 // on the |gl_helper_| variable directly. So instead we call reset() on a | 662 // on the |gl_helper_| variable directly. So instead we call reset() on a |
670 // local std::unique_ptr. | 663 // local std::unique_ptr. |
671 std::unique_ptr<display_compositor::GLHelper> helper = | 664 std::unique_ptr<viz::GLHelper> helper = std::move(gl_helper_); |
672 std::move(gl_helper_); | |
673 | 665 |
674 // If there are any observer left at this point, make sure they clean up | 666 // If there are any observer left at this point, make sure they clean up |
675 // before we destroy the GLHelper. | 667 // before we destroy the GLHelper. |
676 for (auto& observer : observer_list_) | 668 for (auto& observer : observer_list_) |
677 observer.OnLostResources(); | 669 observer.OnLostResources(); |
678 | 670 |
679 helper.reset(); | 671 helper.reset(); |
680 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " | 672 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " |
681 "GLHelper to be created."; | 673 "GLHelper to be created."; |
682 } | 674 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 801 } |
810 | 802 |
811 cc::SurfaceManager* GpuProcessTransportFactory::GetSurfaceManager() { | 803 cc::SurfaceManager* GpuProcessTransportFactory::GetSurfaceManager() { |
812 return frame_sink_manager_host_->surface_manager(); | 804 return frame_sink_manager_host_->surface_manager(); |
813 } | 805 } |
814 | 806 |
815 FrameSinkManagerHost* GpuProcessTransportFactory::GetFrameSinkManagerHost() { | 807 FrameSinkManagerHost* GpuProcessTransportFactory::GetFrameSinkManagerHost() { |
816 return frame_sink_manager_host_.get(); | 808 return frame_sink_manager_host_.get(); |
817 } | 809 } |
818 | 810 |
819 display_compositor::GLHelper* GpuProcessTransportFactory::GetGLHelper() { | 811 viz::GLHelper* GpuProcessTransportFactory::GetGLHelper() { |
820 if (!gl_helper_ && !per_compositor_data_.empty()) { | 812 if (!gl_helper_ && !per_compositor_data_.empty()) { |
821 scoped_refptr<cc::ContextProvider> provider = | 813 scoped_refptr<cc::ContextProvider> provider = |
822 SharedMainThreadContextProvider(); | 814 SharedMainThreadContextProvider(); |
823 if (provider.get()) | 815 if (provider.get()) |
824 gl_helper_.reset(new display_compositor::GLHelper( | 816 gl_helper_.reset( |
825 provider->ContextGL(), provider->ContextSupport())); | 817 new viz::GLHelper(provider->ContextGL(), provider->ContextSupport())); |
826 } | 818 } |
827 return gl_helper_.get(); | 819 return gl_helper_.get(); |
828 } | 820 } |
829 | 821 |
830 void GpuProcessTransportFactory::SetGpuChannelEstablishFactory( | 822 void GpuProcessTransportFactory::SetGpuChannelEstablishFactory( |
831 gpu::GpuChannelEstablishFactory* factory) { | 823 gpu::GpuChannelEstablishFactory* factory) { |
832 DCHECK(!gpu_channel_factory_ || !factory); | 824 DCHECK(!gpu_channel_factory_ || !factory); |
833 gpu_channel_factory_ = factory; | 825 gpu_channel_factory_ = factory; |
834 } | 826 } |
835 | 827 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 LOG(ERROR) << "Lost UI shared context."; | 911 LOG(ERROR) << "Lost UI shared context."; |
920 | 912 |
921 // Keep old resources around while we call the observers, but ensure that | 913 // Keep old resources around while we call the observers, but ensure that |
922 // new resources are created if needed. | 914 // new resources are created if needed. |
923 // Kill shared contexts for both threads in tandem so they are always in | 915 // Kill shared contexts for both threads in tandem so they are always in |
924 // the same share group. | 916 // the same share group. |
925 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = | 917 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = |
926 shared_main_thread_contexts_; | 918 shared_main_thread_contexts_; |
927 shared_main_thread_contexts_ = NULL; | 919 shared_main_thread_contexts_ = NULL; |
928 | 920 |
929 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper = | 921 std::unique_ptr<viz::GLHelper> lost_gl_helper = std::move(gl_helper_); |
930 std::move(gl_helper_); | |
931 | 922 |
932 for (auto& observer : observer_list_) | 923 for (auto& observer : observer_list_) |
933 observer.OnLostResources(); | 924 observer.OnLostResources(); |
934 | 925 |
935 // Kill things that use the shared context before killing the shared context. | 926 // Kill things that use the shared context before killing the shared context. |
936 lost_gl_helper.reset(); | 927 lost_gl_helper.reset(); |
937 lost_shared_main_thread_contexts = NULL; | 928 lost_shared_main_thread_contexts = NULL; |
938 } | 929 } |
939 | 930 |
940 scoped_refptr<cc::VulkanInProcessContextProvider> | 931 scoped_refptr<cc::VulkanInProcessContextProvider> |
941 GpuProcessTransportFactory::SharedVulkanContextProvider() { | 932 GpuProcessTransportFactory::SharedVulkanContextProvider() { |
942 if (!shared_vulkan_context_provider_initialized_) { | 933 if (!shared_vulkan_context_provider_initialized_) { |
943 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 934 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
944 switches::kEnableVulkan)) { | 935 switches::kEnableVulkan)) { |
945 shared_vulkan_context_provider_ = | 936 shared_vulkan_context_provider_ = |
946 cc::VulkanInProcessContextProvider::Create(); | 937 cc::VulkanInProcessContextProvider::Create(); |
947 } | 938 } |
948 | 939 |
949 shared_vulkan_context_provider_initialized_ = true; | 940 shared_vulkan_context_provider_initialized_ = true; |
950 } | 941 } |
951 return shared_vulkan_context_provider_; | 942 return shared_vulkan_context_provider_; |
952 } | 943 } |
953 | 944 |
954 } // namespace content | 945 } // namespace content |
OLD | NEW |