| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "cc/base/histograms.h" | 19 #include "cc/base/histograms.h" |
| 20 #include "cc/output/compositor_frame.h" | 20 #include "cc/output/compositor_frame.h" |
| 21 #include "cc/output/output_surface.h" | 21 #include "cc/output/output_surface.h" |
| 22 #include "cc/output/vulkan_in_process_context_provider.h" | 22 #include "cc/output/vulkan_in_process_context_provider.h" |
| 23 #include "cc/raster/single_thread_task_graph_runner.h" | 23 #include "cc/raster/single_thread_task_graph_runner.h" |
| 24 #include "cc/raster/task_graph_runner.h" | 24 #include "cc/raster/task_graph_runner.h" |
| 25 #include "cc/surfaces/onscreen_display_client.h" | 25 #include "cc/surfaces/onscreen_display_client.h" |
| 26 #include "cc/surfaces/surface_display_output_surface.h" | 26 #include "cc/surfaces/surface_display_output_surface.h" |
| 27 #include "cc/surfaces/surface_manager.h" | 27 #include "cc/surfaces/surface_manager.h" |
| 28 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" |
| 28 #include "components/display_compositor/gl_helper.h" | 29 #include "components/display_compositor/gl_helper.h" |
| 29 #include "content/browser/compositor/browser_compositor_output_surface.h" | 30 #include "content/browser/compositor/browser_compositor_output_surface.h" |
| 30 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | |
| 31 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 31 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 32 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 32 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
| 33 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 33 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
| 34 #include "content/browser/compositor/reflector_impl.h" | 34 #include "content/browser/compositor/reflector_impl.h" |
| 35 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 35 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
| 36 #include "content/browser/compositor/software_output_device_mus.h" | 36 #include "content/browser/compositor/software_output_device_mus.h" |
| 37 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 37 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 38 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 38 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 39 #include "content/browser/gpu/gpu_data_manager_impl.h" | 39 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 40 #include "content/browser/renderer_host/render_widget_host_impl.h" | 40 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 #include "ui/gfx/geometry/size.h" | 56 #include "ui/gfx/geometry/size.h" |
| 57 | 57 |
| 58 #if defined(MOJO_RUNNER_CLIENT) | 58 #if defined(MOJO_RUNNER_CLIENT) |
| 59 #include "content/common/mojo/mojo_shell_connection_impl.h" | 59 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 63 #include "content/browser/compositor/software_output_device_win.h" | 63 #include "content/browser/compositor/software_output_device_win.h" |
| 64 #include "ui/gfx/win/rendering_window_manager.h" | 64 #include "ui/gfx/win/rendering_window_manager.h" |
| 65 #elif defined(USE_OZONE) | 65 #elif defined(USE_OZONE) |
| 66 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor_ozone.h" | 66 #include "components/display_compositor/compositor_overlay_candidate_validator_o
zone.h" |
| 67 #include "content/browser/compositor/software_output_device_ozone.h" | 67 #include "content/browser/compositor/software_output_device_ozone.h" |
| 68 #include "ui/ozone/public/overlay_candidates_ozone.h" | 68 #include "ui/ozone/public/overlay_candidates_ozone.h" |
| 69 #include "ui/ozone/public/overlay_manager_ozone.h" | 69 #include "ui/ozone/public/overlay_manager_ozone.h" |
| 70 #include "ui/ozone/public/ozone_platform.h" | 70 #include "ui/ozone/public/ozone_platform.h" |
| 71 #include "ui/ozone/public/ozone_switches.h" | 71 #include "ui/ozone/public/ozone_switches.h" |
| 72 #elif defined(USE_X11) | 72 #elif defined(USE_X11) |
| 73 #include "content/browser/compositor/software_output_device_x11.h" | 73 #include "content/browser/compositor/software_output_device_x11.h" |
| 74 #elif defined(OS_MACOSX) | 74 #elif defined(OS_MACOSX) |
| 75 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor_mac.h" | 75 #include "components/display_compositor/compositor_overlay_candidate_validator_m
ac.h" |
| 76 #include "content/browser/compositor/software_output_device_mac.h" | 76 #include "content/browser/compositor/software_output_device_mac.h" |
| 77 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 77 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 78 #include "ui/base/cocoa/remote_layer_api.h" | 78 #include "ui/base/cocoa/remote_layer_api.h" |
| 79 #include "ui/base/ui_base_switches.h" | 79 #include "ui/base/ui_base_switches.h" |
| 80 #elif defined(OS_ANDROID) | 80 #elif defined(OS_ANDROID) |
| 81 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor_android.h" | 81 #include "components/display_compositor/compositor_overlay_candidate_validator_a
ndroid.h" |
| 82 #endif | 82 #endif |
| 83 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) | 83 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) |
| 84 #include "content/browser/gpu/gpu_surface_tracker.h" | 84 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 #if defined(ENABLE_VULKAN) | 87 #if defined(ENABLE_VULKAN) |
| 88 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" | 88 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" |
| 89 #endif | 89 #endif |
| 90 | 90 |
| 91 using cc::ContextProvider; | 91 using cc::ContextProvider; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 new SoftwareOutputDeviceX11(compositor)); | 200 new SoftwareOutputDeviceX11(compositor)); |
| 201 #elif defined(OS_MACOSX) | 201 #elif defined(OS_MACOSX) |
| 202 return std::unique_ptr<cc::SoftwareOutputDevice>( | 202 return std::unique_ptr<cc::SoftwareOutputDevice>( |
| 203 new SoftwareOutputDeviceMac(compositor)); | 203 new SoftwareOutputDeviceMac(compositor)); |
| 204 #else | 204 #else |
| 205 NOTREACHED(); | 205 NOTREACHED(); |
| 206 return std::unique_ptr<cc::SoftwareOutputDevice>(); | 206 return std::unique_ptr<cc::SoftwareOutputDevice>(); |
| 207 #endif | 207 #endif |
| 208 } | 208 } |
| 209 | 209 |
| 210 std::unique_ptr<BrowserCompositorOverlayCandidateValidator> | 210 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 211 CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) { | 211 CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) { |
| 212 std::unique_ptr<BrowserCompositorOverlayCandidateValidator> validator; | 212 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 213 validator; |
| 213 #if defined(USE_OZONE) | 214 #if defined(USE_OZONE) |
| 214 std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates = | 215 std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates = |
| 215 ui::OzonePlatform::GetInstance() | 216 ui::OzonePlatform::GetInstance() |
| 216 ->GetOverlayManager() | 217 ->GetOverlayManager() |
| 217 ->CreateOverlayCandidates(widget); | 218 ->CreateOverlayCandidates(widget); |
| 218 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 219 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 219 if (overlay_candidates && | 220 if (overlay_candidates && |
| 220 (command_line->HasSwitch(switches::kEnableHardwareOverlays) || | 221 (command_line->HasSwitch(switches::kEnableHardwareOverlays) || |
| 221 command_line->HasSwitch(switches::kOzoneTestSingleOverlaySupport))) { | 222 command_line->HasSwitch(switches::kOzoneTestSingleOverlaySupport))) { |
| 222 validator.reset(new BrowserCompositorOverlayCandidateValidatorOzone( | 223 validator.reset( |
| 223 std::move(overlay_candidates))); | 224 new display_compositor::CompositorOverlayCandidateValidatorOzone( |
| 225 std::move(overlay_candidates))); |
| 224 } | 226 } |
| 225 #elif defined(OS_MACOSX) | 227 #elif defined(OS_MACOSX) |
| 226 // Overlays are only supported through the remote layer API. | 228 // Overlays are only supported through the remote layer API. |
| 227 if (ui::RemoteLayerAPISupported()) { | 229 if (ui::RemoteLayerAPISupported()) { |
| 228 static bool overlays_disabled_at_command_line = | 230 static bool overlays_disabled_at_command_line = |
| 229 IsCALayersDisabledFromCommandLine(); | 231 IsCALayersDisabledFromCommandLine(); |
| 230 const bool ca_layers_disabled = | 232 const bool ca_layers_disabled = |
| 231 overlays_disabled_at_command_line || | 233 overlays_disabled_at_command_line || |
| 232 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( | 234 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( |
| 233 gpu::DISABLE_OVERLAY_CA_LAYERS); | 235 gpu::DISABLE_OVERLAY_CA_LAYERS); |
| 234 validator.reset( | 236 validator.reset( |
| 235 new BrowserCompositorOverlayCandidateValidatorMac(ca_layers_disabled)); | 237 new display_compositor::CompositorOverlayCandidateValidatorMac( |
| 238 ca_layers_disabled)); |
| 236 } | 239 } |
| 237 #elif defined(OS_ANDROID) | 240 #elif defined(OS_ANDROID) |
| 238 validator.reset(new BrowserCompositorOverlayCandidateValidatorAndroid()); | 241 validator.reset( |
| 242 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); |
| 239 #endif | 243 #endif |
| 240 | 244 |
| 241 return validator; | 245 return validator; |
| 242 } | 246 } |
| 243 | 247 |
| 244 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { | 248 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { |
| 245 #if defined(MOJO_RUNNER_CLIENT) | 249 #if defined(MOJO_RUNNER_CLIENT) |
| 246 // Chrome running as a mojo app currently can only use software compositing. | 250 // Chrome running as a mojo app currently can only use software compositing. |
| 247 // TODO(rjkroege): http://crbug.com/548451 | 251 // TODO(rjkroege): http://crbug.com/548451 |
| 248 if (IsRunningInMojoShell()) { | 252 if (IsRunningInMojoShell()) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( | 424 surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( |
| 421 CreateSoftwareOutputDevice(compositor.get()), | 425 CreateSoftwareOutputDevice(compositor.get()), |
| 422 compositor->vsync_manager(), compositor->task_runner().get())); | 426 compositor->vsync_manager(), compositor->task_runner().get())); |
| 423 } else { | 427 } else { |
| 424 DCHECK(context_provider); | 428 DCHECK(context_provider); |
| 425 const auto& capabilities = context_provider->ContextCapabilities(); | 429 const auto& capabilities = context_provider->ContextCapabilities(); |
| 426 if (data->surface_handle == gpu::kNullSurfaceHandle) { | 430 if (data->surface_handle == gpu::kNullSurfaceHandle) { |
| 427 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( | 431 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( |
| 428 context_provider, shared_worker_context_provider_, | 432 context_provider, shared_worker_context_provider_, |
| 429 compositor->vsync_manager(), compositor->task_runner().get(), | 433 compositor->vsync_manager(), compositor->task_runner().get(), |
| 430 std::unique_ptr<BrowserCompositorOverlayCandidateValidator>())); | 434 std::unique_ptr< |
| 435 display_compositor::CompositorOverlayCandidateValidator>())); |
| 431 } else if (capabilities.surfaceless) { | 436 } else if (capabilities.surfaceless) { |
| 432 GLenum target = GL_TEXTURE_2D; | 437 GLenum target = GL_TEXTURE_2D; |
| 433 GLenum format = GL_RGB; | 438 GLenum format = GL_RGB; |
| 434 #if defined(OS_MACOSX) | 439 #if defined(OS_MACOSX) |
| 435 target = GL_TEXTURE_RECTANGLE_ARB; | 440 target = GL_TEXTURE_RECTANGLE_ARB; |
| 436 format = GL_RGBA; | 441 format = GL_RGBA; |
| 437 #endif | 442 #endif |
| 438 surface = | 443 surface = |
| 439 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( | 444 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( |
| 440 context_provider, shared_worker_context_provider_, | 445 context_provider, shared_worker_context_provider_, |
| 441 data->surface_handle, compositor->vsync_manager(), | 446 data->surface_handle, compositor->vsync_manager(), |
| 442 compositor->task_runner().get(), | 447 compositor->task_runner().get(), |
| 443 CreateOverlayCandidateValidator(compositor->widget()), target, | 448 CreateOverlayCandidateValidator(compositor->widget()), target, |
| 444 format, BrowserGpuMemoryBufferManager::current())); | 449 format, BrowserGpuMemoryBufferManager::current())); |
| 445 } else { | 450 } else { |
| 446 std::unique_ptr<BrowserCompositorOverlayCandidateValidator> validator; | 451 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 452 validator; |
| 447 #if !defined(OS_MACOSX) | 453 #if !defined(OS_MACOSX) |
| 448 // Overlays are only supported on surfaceless output surfaces on Mac. | 454 // Overlays are only supported on surfaceless output surfaces on Mac. |
| 449 validator = CreateOverlayCandidateValidator(compositor->widget()); | 455 validator = CreateOverlayCandidateValidator(compositor->widget()); |
| 450 #endif | 456 #endif |
| 451 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface( | 457 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface( |
| 452 context_provider, shared_worker_context_provider_, | 458 context_provider, shared_worker_context_provider_, |
| 453 compositor->vsync_manager(), compositor->task_runner().get(), | 459 compositor->vsync_manager(), compositor->task_runner().get(), |
| 454 std::move(validator))); | 460 std::move(validator))); |
| 455 } | 461 } |
| 456 } | 462 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 shared_vulkan_context_provider_ = | 764 shared_vulkan_context_provider_ = |
| 759 cc::VulkanInProcessContextProvider::Create(); | 765 cc::VulkanInProcessContextProvider::Create(); |
| 760 } | 766 } |
| 761 | 767 |
| 762 shared_vulkan_context_provider_initialized_ = true; | 768 shared_vulkan_context_provider_initialized_ = true; |
| 763 } | 769 } |
| 764 return shared_vulkan_context_provider_; | 770 return shared_vulkan_context_provider_; |
| 765 } | 771 } |
| 766 | 772 |
| 767 } // namespace content | 773 } // namespace content |
| OLD | NEW |