diff --git components/input/fling_scheduler_base.h components/input/fling_scheduler_base.h index 6e331ee24bddf..ab6c61c2e57ac 100644 --- components/input/fling_scheduler_base.h +++ components/input/fling_scheduler_base.h @@ -5,9 +5,14 @@ #ifndef COMPONENTS_INPUT_FLING_SCHEDULER_BASE_H_ #define COMPONENTS_INPUT_FLING_SCHEDULER_BASE_H_ +#include "base/memory/raw_ptr.h" #include "components/input/fling_controller.h" #include "components/viz/common/frame_sinks/begin_frame_source.h" +namespace ui { +class Compositor; +} + namespace input { class FlingSchedulerBase : public FlingControllerSchedulerClient { @@ -19,6 +24,13 @@ class FlingSchedulerBase : public FlingControllerSchedulerClient { // in Viz currently, but in future we would want to migrate browser's // implementations to use this to progress flings. virtual void SetBeginFrameSource(viz::BeginFrameSource* begin_frame_source) {} + + void SetCompositor(ui::Compositor* compositor) { + compositor_ = compositor; + } + + protected: + raw_ptr compositor_ = nullptr; }; } // namespace input diff --git components/input/render_input_router.h components/input/render_input_router.h index f9b608527a252..ec64323db09be 100644 --- components/input/render_input_router.h +++ components/input/render_input_router.h @@ -68,6 +68,7 @@ class COMPONENT_EXPORT(INPUT) RenderInputRouter InputRouter* input_router() { return input_router_.get(); } RenderInputRouterDelegate* delegate() { return delegate_; } + input::FlingSchedulerBase* fling_scheduler() { return fling_scheduler_.get(); } void SetForceEnableZoom(bool); void SetDeviceScaleFactor(float device_scale_factor); diff --git content/browser/renderer_host/input/fling_scheduler.cc content/browser/renderer_host/input/fling_scheduler.cc index 477389a1cb1d3..b7b7edbfbdf5d 100644 --- content/browser/renderer_host/input/fling_scheduler.cc +++ content/browser/renderer_host/input/fling_scheduler.cc @@ -98,6 +98,9 @@ void FlingScheduler::ProgressFlingOnBeginFrameIfneeded( } ui::Compositor* FlingScheduler::GetCompositor() { + if (compositor_) { + return compositor_; + } if (!host_->GetView()) { return nullptr; } diff --git content/browser/renderer_host/render_widget_host_impl.cc content/browser/renderer_host/render_widget_host_impl.cc index 52f772876a887..fb14424865660 100644 --- content/browser/renderer_host/render_widget_host_impl.cc +++ content/browser/renderer_host/render_widget_host_impl.cc @@ -3759,6 +3759,11 @@ void RenderWidgetHostImpl::StopFling() { GetRenderInputRouter()->StopFling(); } +void RenderWidgetHostImpl::SetCompositorForFlingScheduler( + ui::Compositor* compositor) { + GetRenderInputRouter()->fling_scheduler()->SetCompositor(compositor); +} + void RenderWidgetHostImpl::SetScreenOrientationForTesting( uint16_t angle, display::mojom::ScreenOrientation type) { diff --git content/browser/renderer_host/render_widget_host_impl.h content/browser/renderer_host/render_widget_host_impl.h index 0bc94f2246a93..20fbaaf347d58 100644 --- content/browser/renderer_host/render_widget_host_impl.h +++ content/browser/renderer_host/render_widget_host_impl.h @@ -848,6 +848,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl void ProgressFlingIfNeeded(base::TimeTicks current_time); void StopFling(); + void SetCompositorForFlingScheduler(ui::Compositor* compositor); RenderWidgetHostViewBase* GetRenderWidgetHostViewBase();