Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 gpu::GpuChannelEstablishedCallback callback( 429 gpu::GpuChannelEstablishedCallback callback(
430 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, 430 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
431 callback_factory_.GetWeakPtr(), compositor, 431 callback_factory_.GetWeakPtr(), compositor,
432 create_gpu_output_surface, num_attempts + 1)); 432 create_gpu_output_surface, num_attempts + 1));
433 DCHECK(gpu_channel_factory_); 433 DCHECK(gpu_channel_factory_);
434 gpu_channel_factory_->EstablishGpuChannel(callback); 434 gpu_channel_factory_->EstablishGpuChannel(callback);
435 return; 435 return;
436 } 436 }
437 } 437 }
438 438
439 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; 439 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source;
440 if (!compositor->GetRendererSettings().disable_display_vsync) { 440 if (!compositor->GetRendererSettings().disable_display_vsync) {
441 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( 441 synthetic_begin_frame_source = new cc::DelayBasedBeginFrameSource(
442 base::MakeUnique<cc::DelayBasedTimeSource>( 442 base::MakeUnique<cc::DelayBasedTimeSource>(
443 compositor->task_runner().get()))); 443 compositor->task_runner().get()));
444 } else { 444 } else {
445 begin_frame_source.reset(new cc::BackToBackBeginFrameSource( 445 synthetic_begin_frame_source = new cc::BackToBackBeginFrameSource(
446 base::MakeUnique<cc::DelayBasedTimeSource>( 446 base::MakeUnique<cc::DelayBasedTimeSource>(
447 compositor->task_runner().get()))); 447 compositor->task_runner().get()));
448 } 448 }
449 std::unique_ptr<cc::BeginFrameSource> begin_frame_source(
450 synthetic_begin_frame_source);
449 451
450 BrowserCompositorOutputSurface::UpdateVSyncParametersCallback vsync_callback = 452 BrowserCompositorOutputSurface::UpdateVSyncParametersCallback vsync_callback =
451 base::Bind(&ui::Compositor::SetDisplayVSyncParameters, compositor); 453 base::Bind(&ui::Compositor::SetDisplayVSyncParameters, compositor);
452 454
453 std::unique_ptr<BrowserCompositorOutputSurface> display_output_surface; 455 std::unique_ptr<BrowserCompositorOutputSurface> display_output_surface;
454 #if defined(ENABLE_VULKAN) 456 #if defined(ENABLE_VULKAN)
455 std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface; 457 std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface;
456 if (vulkan_context_provider) { 458 if (vulkan_context_provider) {
457 vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface( 459 vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface(
458 vulkan_context_provider, vsync_callback)); 460 vulkan_context_provider, vsync_callback));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // Overlays are only supported on surfaceless output surfaces on Mac. 505 // Overlays are only supported on surfaceless output surfaces on Mac.
504 if (!use_mus) 506 if (!use_mus)
505 validator = CreateOverlayCandidateValidator(compositor->widget()); 507 validator = CreateOverlayCandidateValidator(compositor->widget());
506 #endif 508 #endif
507 if (!use_mus) { 509 if (!use_mus) {
508 display_output_surface = 510 display_output_surface =
509 base::MakeUnique<GpuBrowserCompositorOutputSurface>( 511 base::MakeUnique<GpuBrowserCompositorOutputSurface>(
510 context_provider, vsync_callback, std::move(validator)); 512 context_provider, vsync_callback, std::move(validator));
511 } else { 513 } else {
512 #if defined(USE_AURA) 514 #if defined(USE_AURA)
515 std::unique_ptr<MusBrowserCompositorOutputSurface> mus_output_surface;
513 if (compositor->window()) { 516 if (compositor->window()) {
514 // TODO(mfomitchev): Remove this clause once we complete the switch 517 // TODO(mfomitchev): Remove this clause once we complete the switch
515 // to Aura-Mus. 518 // to Aura-Mus.
516 display_output_surface = 519 mus_output_surface =
517 base::MakeUnique<MusBrowserCompositorOutputSurface>( 520 base::MakeUnique<MusBrowserCompositorOutputSurface>(
518 compositor->window(), context_provider, 521 compositor->window(), context_provider,
519 GetGpuMemoryBufferManager(), vsync_callback, 522 GetGpuMemoryBufferManager(), vsync_callback,
520 std::move(validator)); 523 std::move(validator));
521 } else { 524 } else {
522 aura::WindowTreeHost* host = 525 aura::WindowTreeHost* host =
523 aura::WindowTreeHost::GetForAcceleratedWidget( 526 aura::WindowTreeHost::GetForAcceleratedWidget(
524 compositor->widget()); 527 compositor->widget());
525 display_output_surface = 528 mus_output_surface =
526 base::MakeUnique<MusBrowserCompositorOutputSurface>( 529 base::MakeUnique<MusBrowserCompositorOutputSurface>(
527 host->window(), context_provider, 530 host->window(), context_provider,
528 GetGpuMemoryBufferManager(), vsync_callback, 531 GetGpuMemoryBufferManager(), vsync_callback,
529 std::move(validator)); 532 std::move(validator));
530 } 533 }
534 // We use the ExternalBeginFrameSource provided by the output surface
535 // instead of our own synthetic one.
536 begin_frame_source.reset(new cc::DelegatingBeginFrameSource(
537 mus_output_surface->GetBeginFrameSource()));
538 synthetic_begin_frame_source = nullptr;
539 display_output_surface = std::move(mus_output_surface);
531 #else 540 #else
532 NOTREACHED(); 541 NOTREACHED();
533 #endif 542 #endif
534 } 543 }
535 } 544 }
536 } 545 }
537 } 546 }
538 547
539 data->display_output_surface = display_output_surface.get(); 548 data->display_output_surface = display_output_surface.get();
540 data->begin_frame_source = begin_frame_source.get(); 549 if (synthetic_begin_frame_source)
550 data->begin_frame_source = synthetic_begin_frame_source;
541 if (data->reflector) 551 if (data->reflector)
542 data->reflector->OnSourceSurfaceReady(data->display_output_surface); 552 data->reflector->OnSourceSurfaceReady(data->display_output_surface);
543 553
544 #if defined(OS_WIN) 554 #if defined(OS_WIN)
545 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( 555 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild(
546 compositor->widget()); 556 compositor->widget());
547 #endif 557 #endif
548 558
549 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 559 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
550 begin_frame_source.get(), compositor->task_runner().get(), 560 compositor->task_runner().get(),
551 display_output_surface->capabilities().max_frames_pending)); 561 display_output_surface->capabilities().max_frames_pending));
552 562
553 // The Display owns and uses the |display_output_surface| created above. 563 // The Display owns and uses the |display_output_surface| created above.
554 data->display = base::MakeUnique<cc::Display>( 564 data->display = base::MakeUnique<cc::Display>(
555 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), 565 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(),
556 compositor->GetRendererSettings(), compositor->frame_sink_id(), 566 compositor->GetRendererSettings(), compositor->frame_sink_id(),
557 std::move(begin_frame_source), std::move(display_output_surface), 567 std::move(begin_frame_source), std::move(display_output_surface),
558 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( 568 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>(
559 compositor->task_runner().get())); 569 compositor->task_runner().get()));
560 570
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 shared_vulkan_context_provider_ = 890 shared_vulkan_context_provider_ =
881 cc::VulkanInProcessContextProvider::Create(); 891 cc::VulkanInProcessContextProvider::Create();
882 } 892 }
883 893
884 shared_vulkan_context_provider_initialized_ = true; 894 shared_vulkan_context_provider_initialized_ = true;
885 } 895 }
886 return shared_vulkan_context_provider_; 896 return shared_vulkan_context_provider_;
887 } 897 }
888 898
889 } // namespace content 899 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698