| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 gpu::GpuChannelEstablishedCallback callback( | 438 gpu::GpuChannelEstablishedCallback callback( |
| 439 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 439 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 440 callback_factory_.GetWeakPtr(), compositor, | 440 callback_factory_.GetWeakPtr(), compositor, |
| 441 create_gpu_output_surface, num_attempts + 1)); | 441 create_gpu_output_surface, num_attempts + 1)); |
| 442 DCHECK(gpu_channel_factory_); | 442 DCHECK(gpu_channel_factory_); |
| 443 gpu_channel_factory_->EstablishGpuChannel(callback); | 443 gpu_channel_factory_->EstablishGpuChannel(callback); |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | 448 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source; |
| 449 if (!compositor->GetRendererSettings().disable_display_vsync) { | 449 if (!compositor->GetRendererSettings().disable_display_vsync) { |
| 450 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( | 450 synthetic_begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( |
| 451 base::MakeUnique<cc::DelayBasedTimeSource>( | 451 base::MakeUnique<cc::DelayBasedTimeSource>( |
| 452 compositor->task_runner().get()))); | 452 compositor->task_runner().get()))); |
| 453 } else { | 453 } else { |
| 454 begin_frame_source.reset(new cc::BackToBackBeginFrameSource( | 454 synthetic_begin_frame_source.reset(new cc::BackToBackBeginFrameSource( |
| 455 base::MakeUnique<cc::DelayBasedTimeSource>( | 455 base::MakeUnique<cc::DelayBasedTimeSource>( |
| 456 compositor->task_runner().get()))); | 456 compositor->task_runner().get()))); |
| 457 } | 457 } |
| 458 cc::BeginFrameSource* begin_frame_source = synthetic_begin_frame_source.get(); |
| 458 | 459 |
| 459 BrowserCompositorOutputSurface::UpdateVSyncParametersCallback vsync_callback = | 460 BrowserCompositorOutputSurface::UpdateVSyncParametersCallback vsync_callback = |
| 460 base::Bind(&ui::Compositor::SetDisplayVSyncParameters, compositor); | 461 base::Bind(&ui::Compositor::SetDisplayVSyncParameters, compositor); |
| 461 | 462 |
| 462 std::unique_ptr<BrowserCompositorOutputSurface> display_output_surface; | 463 std::unique_ptr<BrowserCompositorOutputSurface> display_output_surface; |
| 463 #if defined(ENABLE_VULKAN) | 464 #if defined(ENABLE_VULKAN) |
| 464 std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface; | 465 std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface; |
| 465 if (vulkan_context_provider) { | 466 if (vulkan_context_provider) { |
| 466 vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface( | 467 vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface( |
| 467 vulkan_context_provider, vsync_callback)); | 468 vulkan_context_provider, vsync_callback)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 // Overlays are only supported on surfaceless output surfaces on Mac. | 513 // Overlays are only supported on surfaceless output surfaces on Mac. |
| 513 if (!use_mus) | 514 if (!use_mus) |
| 514 validator = CreateOverlayCandidateValidator(compositor->widget()); | 515 validator = CreateOverlayCandidateValidator(compositor->widget()); |
| 515 #endif | 516 #endif |
| 516 if (!use_mus) { | 517 if (!use_mus) { |
| 517 display_output_surface = | 518 display_output_surface = |
| 518 base::MakeUnique<GpuBrowserCompositorOutputSurface>( | 519 base::MakeUnique<GpuBrowserCompositorOutputSurface>( |
| 519 context_provider, vsync_callback, std::move(validator)); | 520 context_provider, vsync_callback, std::move(validator)); |
| 520 } else { | 521 } else { |
| 521 #if defined(USE_AURA) | 522 #if defined(USE_AURA) |
| 523 std::unique_ptr<MusBrowserCompositorOutputSurface> mus_output_surface; |
| 522 if (compositor->window()) { | 524 if (compositor->window()) { |
| 523 // TODO(mfomitchev): Remove this clause once we complete the switch | 525 // TODO(mfomitchev): Remove this clause once we complete the switch |
| 524 // to Aura-Mus. | 526 // to Aura-Mus. |
| 525 display_output_surface = | 527 mus_output_surface = |
| 526 base::MakeUnique<MusBrowserCompositorOutputSurface>( | 528 base::MakeUnique<MusBrowserCompositorOutputSurface>( |
| 527 compositor->window(), context_provider, | 529 compositor->window(), context_provider, |
| 528 GetGpuMemoryBufferManager(), vsync_callback, | 530 GetGpuMemoryBufferManager(), vsync_callback, |
| 529 std::move(validator)); | 531 std::move(validator)); |
| 530 } else { | 532 } else { |
| 531 aura::WindowTreeHost* host = | 533 aura::WindowTreeHost* host = |
| 532 aura::WindowTreeHost::GetForAcceleratedWidget( | 534 aura::WindowTreeHost::GetForAcceleratedWidget( |
| 533 compositor->widget()); | 535 compositor->widget()); |
| 534 display_output_surface = | 536 mus_output_surface = |
| 535 base::MakeUnique<MusBrowserCompositorOutputSurface>( | 537 base::MakeUnique<MusBrowserCompositorOutputSurface>( |
| 536 host->window(), context_provider, | 538 host->window(), context_provider, |
| 537 GetGpuMemoryBufferManager(), vsync_callback, | 539 GetGpuMemoryBufferManager(), vsync_callback, |
| 538 std::move(validator)); | 540 std::move(validator)); |
| 539 } | 541 } |
| 542 // We use the ExternalBeginFrameSource provided by the output surface |
| 543 // instead of our own synthetic one. |
| 544 synthetic_begin_frame_source.reset(); |
| 545 begin_frame_source = mus_output_surface->GetBeginFrameSource(); |
| 546 DCHECK(begin_frame_source); |
| 547 display_output_surface = std::move(mus_output_surface); |
| 540 #else | 548 #else |
| 541 NOTREACHED(); | 549 NOTREACHED(); |
| 542 #endif | 550 #endif |
| 543 } | 551 } |
| 544 } | 552 } |
| 545 } | 553 } |
| 546 } | 554 } |
| 547 | 555 |
| 548 data->display_output_surface = display_output_surface.get(); | 556 data->display_output_surface = display_output_surface.get(); |
| 549 if (data->reflector) | 557 if (data->reflector) |
| 550 data->reflector->OnSourceSurfaceReady(data->display_output_surface); | 558 data->reflector->OnSourceSurfaceReady(data->display_output_surface); |
| 551 | 559 |
| 552 #if defined(OS_WIN) | 560 #if defined(OS_WIN) |
| 553 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( | 561 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( |
| 554 compositor->widget()); | 562 compositor->widget()); |
| 555 #endif | 563 #endif |
| 556 | 564 |
| 557 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 565 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 558 compositor->task_runner().get(), | 566 compositor->task_runner().get(), |
| 559 display_output_surface->capabilities().max_frames_pending)); | 567 display_output_surface->capabilities().max_frames_pending)); |
| 560 | 568 |
| 561 // The Display owns and uses the |display_output_surface| created above. | 569 // The Display owns and uses the |display_output_surface| created above. |
| 562 data->display = base::MakeUnique<cc::Display>( | 570 data->display = base::MakeUnique<cc::Display>( |
| 563 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), | 571 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), |
| 564 compositor->GetRendererSettings(), compositor->frame_sink_id(), | 572 compositor->GetRendererSettings(), compositor->frame_sink_id(), |
| 565 begin_frame_source.get(), std::move(display_output_surface), | 573 begin_frame_source, std::move(display_output_surface), |
| 566 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( | 574 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( |
| 567 compositor->task_runner().get())); | 575 compositor->task_runner().get())); |
| 568 // Note that we are careful not to destroy a prior |data->begin_frame_source| | 576 // Note that we are careful not to destroy a prior |data->begin_frame_source| |
| 569 // until we have reset |data->display|. | 577 // until we have reset |data->display|. |
| 570 data->begin_frame_source = std::move(begin_frame_source); | 578 data->begin_frame_source = std::move(synthetic_begin_frame_source); |
| 571 | 579 |
| 572 // The |delegated_output_surface| is given back to the compositor, it | 580 // The |delegated_output_surface| is given back to the compositor, it |
| 573 // delegates to the Display as its root surface. Importantly, it shares the | 581 // delegates to the Display as its root surface. Importantly, it shares the |
| 574 // same ContextProvider as the Display's output surface. | 582 // same ContextProvider as the Display's output surface. |
| 575 auto compositor_frame_sink = | 583 auto compositor_frame_sink = |
| 576 vulkan_context_provider | 584 vulkan_context_provider |
| 577 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 585 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 578 compositor->frame_sink_id(), surface_manager_.get(), | 586 compositor->frame_sink_id(), surface_manager_.get(), |
| 579 data->display.get(), | 587 data->display.get(), |
| 580 static_cast<scoped_refptr<cc::VulkanContextProvider>>( | 588 static_cast<scoped_refptr<cc::VulkanContextProvider>>( |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 shared_vulkan_context_provider_ = | 904 shared_vulkan_context_provider_ = |
| 897 cc::VulkanInProcessContextProvider::Create(); | 905 cc::VulkanInProcessContextProvider::Create(); |
| 898 } | 906 } |
| 899 | 907 |
| 900 shared_vulkan_context_provider_initialized_ = true; | 908 shared_vulkan_context_provider_initialized_ = true; |
| 901 } | 909 } |
| 902 return shared_vulkan_context_provider_; | 910 return shared_vulkan_context_provider_; |
| 903 } | 911 } |
| 904 | 912 |
| 905 } // namespace content | 913 } // namespace content |
| OLD | NEW |