Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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/display/types/display_snapshot.h" | 59 #include "ui/display/types/display_snapshot.h" |
| 60 #include "ui/gfx/geometry/size.h" | 60 #include "ui/gfx/geometry/size.h" |
| 61 #include "ui/gfx/switches.h" | 61 #include "ui/gfx/switches.h" |
| 62 #include "ui/gl/gl_switches.h" | 62 #include "ui/gl/gl_switches.h" |
| 63 | 63 |
| 64 #if defined(USE_AURA) | 64 #if defined(USE_AURA) |
| 65 #include "content/browser/compositor/mus_browser_compositor_output_surface.h" | |
| 66 #include "content/public/common/service_manager_connection.h" | 65 #include "content/public/common/service_manager_connection.h" |
| 67 #include "ui/aura/window_tree_host.h" | 66 #include "ui/aura/window_tree_host.h" |
| 68 #endif | 67 #endif |
| 69 | 68 |
| 70 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
| 71 #include "base/win/windows_version.h" | 70 #include "base/win/windows_version.h" |
| 72 #include "components/display_compositor/compositor_overlay_candidate_validator_w in.h" | 71 #include "components/display_compositor/compositor_overlay_candidate_validator_w in.h" |
| 73 #include "content/browser/compositor/software_output_device_win.h" | 72 #include "content/browser/compositor/software_output_device_win.h" |
| 74 #include "ui/gfx/win/rendering_window_manager.h" | 73 #include "ui/gfx/win/rendering_window_manager.h" |
| 75 #elif defined(USE_OZONE) | 74 #elif defined(USE_OZONE) |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 103 using cc::ContextProvider; | 102 using cc::ContextProvider; |
| 104 using gpu::gles2::GLES2Interface; | 103 using gpu::gles2::GLES2Interface; |
| 105 | 104 |
| 106 namespace { | 105 namespace { |
| 107 | 106 |
| 108 const int kNumRetriesBeforeSoftwareFallback = 4; | 107 const int kNumRetriesBeforeSoftwareFallback = 4; |
| 109 // The client_id used here should not conflict with the client_id generated | 108 // The client_id used here should not conflict with the client_id generated |
| 110 // from RenderWidgetHostImpl. | 109 // from RenderWidgetHostImpl. |
| 111 constexpr uint32_t kDefaultClientId = 0u; | 110 constexpr uint32_t kDefaultClientId = 0u; |
| 112 | 111 |
| 113 bool IsUsingMus() { | |
| 114 return service_manager::ServiceManagerIsRemote(); | |
| 115 } | |
| 116 | |
| 117 bool IsGpuVSyncSignalSupported() { | 112 bool IsGpuVSyncSignalSupported() { |
| 118 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
| 119 // TODO(stanisc): http://crbug.com/467617 Limit to Windows 8+ for now because | 114 // TODO(stanisc): http://crbug.com/467617 Limit to Windows 8+ for now because |
| 120 // of locking issue caused by waiting for VSync on Win7. | 115 // of locking issue caused by waiting for VSync on Win7. |
| 121 return base::win::GetVersion() >= base::win::VERSION_WIN8 && | 116 return base::win::GetVersion() >= base::win::VERSION_WIN8 && |
| 122 base::FeatureList::IsEnabled(features::kD3DVsync); | 117 base::FeatureList::IsEnabled(features::kD3DVsync); |
| 123 #else | 118 #else |
| 124 return false; | 119 return false; |
| 125 #endif // defined(OS_WIN) | 120 #endif // defined(OS_WIN) |
| 126 } | 121 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 #endif | 286 #endif |
| 292 | 287 |
| 293 return validator; | 288 return validator; |
| 294 } | 289 } |
| 295 | 290 |
| 296 static bool ShouldCreateGpuCompositorFrameSink(ui::Compositor* compositor) { | 291 static bool ShouldCreateGpuCompositorFrameSink(ui::Compositor* compositor) { |
| 297 #if defined(OS_CHROMEOS) | 292 #if defined(OS_CHROMEOS) |
| 298 // Software fallback does not happen on Chrome OS. | 293 // Software fallback does not happen on Chrome OS. |
| 299 return true; | 294 return true; |
| 300 #endif | 295 #endif |
| 301 if (IsUsingMus()) | |
| 302 return true; | |
| 303 | |
| 304 #if defined(OS_WIN) | 296 #if defined(OS_WIN) |
| 305 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && | 297 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && |
| 306 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) | 298 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) |
| 307 return false; | 299 return false; |
| 308 #endif | 300 #endif |
| 309 | 301 |
| 310 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); | 302 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); |
| 311 } | 303 } |
| 312 | 304 |
| 313 void GpuProcessTransportFactory::CreateCompositorFrameSink( | 305 void GpuProcessTransportFactory::CreateCompositorFrameSink( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 // The widget might have been released in the meantime. | 346 // The widget might have been released in the meantime. |
| 355 PerCompositorDataMap::iterator it = | 347 PerCompositorDataMap::iterator it = |
| 356 per_compositor_data_.find(compositor.get()); | 348 per_compositor_data_.find(compositor.get()); |
| 357 if (it == per_compositor_data_.end()) | 349 if (it == per_compositor_data_.end()) |
| 358 return; | 350 return; |
| 359 | 351 |
| 360 PerCompositorData* data = it->second.get(); | 352 PerCompositorData* data = it->second.get(); |
| 361 DCHECK(data); | 353 DCHECK(data); |
| 362 | 354 |
| 363 if (num_attempts > kNumRetriesBeforeSoftwareFallback) { | 355 if (num_attempts > kNumRetriesBeforeSoftwareFallback) { |
| 364 bool fatal = IsUsingMus(); | 356 bool fatal = false; |
| 365 #if defined(OS_CHROMEOS) | 357 #if defined(OS_CHROMEOS) |
| 366 fatal = true; | 358 fatal = true; |
| 367 #endif | 359 #endif |
| 368 LOG_IF(FATAL, fatal) << "Unable to create a UI graphics context, and " | 360 LOG_IF(FATAL, fatal) << "Unable to create a UI graphics context, and " |
| 369 << "cannot use software compositing on ChromeOS."; | 361 << "cannot use software compositing on ChromeOS."; |
| 370 create_gpu_output_surface = false; | 362 create_gpu_output_surface = false; |
| 371 } | 363 } |
| 372 | 364 |
| 373 bool support_stencil = false; | 365 bool support_stencil = false; |
| 374 #if defined(OS_CHROMEOS) | 366 #if defined(OS_CHROMEOS) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 } | 421 } |
| 430 | 422 |
| 431 // The |context_provider| is used for both the browser compositor and the | 423 // The |context_provider| is used for both the browser compositor and the |
| 432 // display compositor. It shares resources with the worker context, so if | 424 // display compositor. It shares resources with the worker context, so if |
| 433 // we failed to make a worker context, just start over and try again. | 425 // we failed to make a worker context, just start over and try again. |
| 434 if (shared_worker_context_provider_) { | 426 if (shared_worker_context_provider_) { |
| 435 // For mus, we create an offscreen context for a mus window, and we will | 427 // For mus, we create an offscreen context for a mus window, and we will |
| 436 // use CommandBufferProxyImpl::TakeFrontBuffer() to take the context's | 428 // use CommandBufferProxyImpl::TakeFrontBuffer() to take the context's |
| 437 // front buffer into a mailbox, insert a sync token, and send the | 429 // front buffer into a mailbox, insert a sync token, and send the |
| 438 // mailbox+sync to the ui service process. | 430 // mailbox+sync to the ui service process. |
| 439 gpu::SurfaceHandle surface_handle = | 431 gpu::SurfaceHandle surface_handle = data->surface_handle; |
| 440 IsUsingMus() ? gpu::kNullSurfaceHandle : data->surface_handle; | 432 bool need_alpha_channel = false; |
| 441 bool need_alpha_channel = IsUsingMus(); | |
| 442 bool support_locking = false; | 433 bool support_locking = false; |
| 443 context_provider = CreateContextCommon( | 434 context_provider = CreateContextCommon( |
| 444 std::move(gpu_channel_host), surface_handle, need_alpha_channel, | 435 std::move(gpu_channel_host), surface_handle, need_alpha_channel, |
| 445 support_stencil, support_locking, | 436 support_stencil, support_locking, |
| 446 shared_worker_context_provider_.get(), | 437 shared_worker_context_provider_.get(), |
| 447 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); | 438 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); |
| 448 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is | 439 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is |
| 449 // fixed. Tracking time in BindToCurrentThread. | 440 // fixed. Tracking time in BindToCurrentThread. |
| 450 tracked_objects::ScopedTracker tracking_profile( | 441 tracked_objects::ScopedTracker tracking_profile( |
| 451 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 442 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 CreateOverlayCandidateValidator(compositor->widget()), | 521 CreateOverlayCandidateValidator(compositor->widget()), |
| 531 GL_TEXTURE_2D, GL_RGB, | 522 GL_TEXTURE_2D, GL_RGB, |
| 532 display::DisplaySnapshot::PrimaryFormat(), | 523 display::DisplaySnapshot::PrimaryFormat(), |
| 533 GetGpuMemoryBufferManager()); | 524 GetGpuMemoryBufferManager()); |
| 534 gpu_vsync_control = gpu_output_surface.get(); | 525 gpu_vsync_control = gpu_output_surface.get(); |
| 535 display_output_surface = std::move(gpu_output_surface); | 526 display_output_surface = std::move(gpu_output_surface); |
| 536 #endif | 527 #endif |
| 537 } else { | 528 } else { |
| 538 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 529 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 539 validator; | 530 validator; |
| 540 const bool use_mus = IsUsingMus(); | |
| 541 #if !defined(OS_MACOSX) | 531 #if !defined(OS_MACOSX) |
| 542 // Overlays are only supported on surfaceless output surfaces on Mac. | 532 // Overlays are only supported on surfaceless output surfaces on Mac. |
| 543 if (!use_mus) | 533 validator = CreateOverlayCandidateValidator(compositor->widget()); |
| 544 validator = CreateOverlayCandidateValidator(compositor->widget()); | |
| 545 #endif | 534 #endif |
| 546 if (!use_mus) { | 535 auto gpu_output_surface = |
| 547 auto gpu_output_surface = | 536 base::MakeUnique<GpuBrowserCompositorOutputSurface>( |
| 548 base::MakeUnique<GpuBrowserCompositorOutputSurface>( | 537 context_provider, vsync_callback, std::move(validator)); |
| 549 context_provider, vsync_callback, std::move(validator)); | 538 gpu_vsync_control = gpu_output_surface.get(); |
| 550 gpu_vsync_control = gpu_output_surface.get(); | 539 display_output_surface = std::move(gpu_output_surface); |
| 551 display_output_surface = std::move(gpu_output_surface); | |
| 552 } else { | |
| 553 #if defined(USE_AURA) | |
| 554 aura::WindowTreeHost* host = | |
| 555 aura::WindowTreeHost::GetForAcceleratedWidget( | |
| 556 compositor->widget()); | |
| 557 auto mus_output_surface = | |
| 558 base::MakeUnique<MusBrowserCompositorOutputSurface>( | |
| 559 host->window(), context_provider, GetGpuMemoryBufferManager(), | |
| 560 vsync_callback, std::move(validator)); | |
| 561 // We use the ExternalBeginFrameSource provided by the output surface | |
| 562 // instead of our own synthetic one. | |
| 563 begin_frame_source = mus_output_surface->GetBeginFrameSource(); | |
|
stanisc
2017/03/28 18:14:23
Now that this line of code is removed it doesn't m
| |
| 564 DCHECK(begin_frame_source); | |
| 565 display_output_surface = std::move(mus_output_surface); | |
| 566 #else | |
| 567 NOTREACHED(); | |
| 568 #endif | |
| 569 } | |
| 570 } | 540 } |
| 571 } | 541 } |
| 572 } | 542 } |
| 573 | 543 |
| 574 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source; | 544 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source; |
| 575 std::unique_ptr<GpuVSyncBeginFrameSource> gpu_vsync_begin_frame_source; | 545 std::unique_ptr<GpuVSyncBeginFrameSource> gpu_vsync_begin_frame_source; |
| 576 | 546 |
| 577 if (!begin_frame_source) { | 547 if (!begin_frame_source) { |
|
stanisc
2017/03/28 18:14:23
With the mus case removed above begin_frame_source
| |
| 578 if (!compositor->GetRendererSettings().disable_display_vsync) { | 548 if (!compositor->GetRendererSettings().disable_display_vsync) { |
| 579 if (gpu_vsync_control && IsGpuVSyncSignalSupported()) { | 549 if (gpu_vsync_control && IsGpuVSyncSignalSupported()) { |
| 580 gpu_vsync_begin_frame_source = | 550 gpu_vsync_begin_frame_source = |
| 581 base::MakeUnique<GpuVSyncBeginFrameSource>(gpu_vsync_control); | 551 base::MakeUnique<GpuVSyncBeginFrameSource>(gpu_vsync_control); |
| 582 begin_frame_source = gpu_vsync_begin_frame_source.get(); | 552 begin_frame_source = gpu_vsync_begin_frame_source.get(); |
| 583 } else { | 553 } else { |
| 584 synthetic_begin_frame_source = | 554 synthetic_begin_frame_source = |
| 585 base::MakeUnique<cc::DelayBasedBeginFrameSource>( | 555 base::MakeUnique<cc::DelayBasedBeginFrameSource>( |
| 586 base::MakeUnique<cc::DelayBasedTimeSource>( | 556 base::MakeUnique<cc::DelayBasedTimeSource>( |
| 587 compositor->task_runner().get())); | 557 compositor->task_runner().get())); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 952 shared_vulkan_context_provider_ = | 922 shared_vulkan_context_provider_ = |
| 953 cc::VulkanInProcessContextProvider::Create(); | 923 cc::VulkanInProcessContextProvider::Create(); |
| 954 } | 924 } |
| 955 | 925 |
| 956 shared_vulkan_context_provider_initialized_ = true; | 926 shared_vulkan_context_provider_initialized_ = true; |
| 957 } | 927 } |
| 958 return shared_vulkan_context_provider_; | 928 return shared_vulkan_context_provider_; |
| 959 } | 929 } |
| 960 | 930 |
| 961 } // namespace content | 931 } // namespace content |
| OLD | NEW |