5#ifndef FLUTTER_SHELL_COMMON_ANIMATOR_H_
6#define FLUTTER_SHELL_COMMON_ANIMATOR_H_
10#include "flutter/common/task_runners.h"
11#include "flutter/flow/frame_timings.h"
12#include "flutter/fml/memory/ref_ptr.h"
13#include "flutter/fml/memory/weak_ptr.h"
14#include "flutter/fml/synchronization/semaphore.h"
15#include "flutter/fml/time/time_point.h"
16#include "flutter/shell/common/pipeline.h"
17#include "flutter/shell/common/rasterizer.h"
18#include "flutter/shell/common/vsync_waiter.h"
35 uint64_t frame_number) = 0;
45 std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) = 0;
50 std::unique_ptr<VsyncWaiter> waiter);
86 void Render(int64_t view_id,
87 std::unique_ptr<flutter::LayerTree> layer_tree,
88 float device_pixel_ratio);
121 void BeginFrame(std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder);
124 bool CanReuseLastLayerTrees();
126 void DrawLastLayerTrees(
127 std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder);
132 void ScheduleMaybeClearTraceFlowIds();
136 std::shared_ptr<VsyncWaiter> waiter_;
138 std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder_;
139 std::unordered_map<int64_t, std::unique_ptr<LayerTreeTask>>
141 uint64_t frame_request_number_ = 1;
143 std::shared_ptr<FramePipeline> layer_tree_pipeline_;
146 bool regenerate_layer_trees_ =
false;
147 bool frame_scheduled_ =
false;
148 std::deque<uint64_t> trace_flow_ids_;
149 bool has_rendered_ =
false;
virtual void OnAnimatorNotifyIdle(fml::TimeDelta deadline)=0
virtual void OnAnimatorBeginFrame(fml::TimePoint frame_target_time, uint64_t frame_number)=0
virtual void OnAnimatorDrawLastLayerTrees(std::unique_ptr< FrameTimingsRecorder > frame_timings_recorder)=0
virtual void OnAnimatorUpdateLatestFrameTargetTime(fml::TimePoint frame_target_time)=0
virtual void OnAnimatorDraw(std::shared_ptr< FramePipeline > pipeline)=0
void ScheduleSecondaryVsyncCallback(uintptr_t id, const fml::closure &callback)
Schedule a secondary callback to be executed right after the main VsyncWaiter::AsyncWaitForVsync call...
void Render(int64_t view_id, std::unique_ptr< flutter::LayerTree > layer_tree, float device_pixel_ratio)
Tells the Animator that this frame needs to render another view.
Animator(Delegate &delegate, const TaskRunners &task_runners, std::unique_ptr< VsyncWaiter > waiter)
void EnqueueTraceFlowId(uint64_t trace_flow_id)
void RequestFrame(bool regenerate_layer_trees=true)
const std::weak_ptr< VsyncWaiter > GetVsyncWaiter() const
void OnAllViewsRendered()
Tells the Animator that all views that should render for this frame have been rendered.
A traditional counting semaphore. Waits decrement the counter and Signal increments it.
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
std::function< void()> closure