Refactor type of deadline in the method NotifyIdle to fml::TimePoint (flutter/engine#30737)
This commit is contained in:
@@ -205,7 +205,7 @@ bool RuntimeController::ReportTimings(std::vector<int64_t> timings) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RuntimeController::NotifyIdle(int64_t deadline) {
|
||||
bool RuntimeController::NotifyIdle(fml::TimePoint deadline) {
|
||||
std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
|
||||
if (!root_isolate) {
|
||||
return false;
|
||||
@@ -213,12 +213,12 @@ bool RuntimeController::NotifyIdle(int64_t deadline) {
|
||||
|
||||
tonic::DartState::Scope scope(root_isolate);
|
||||
|
||||
Dart_NotifyIdle(deadline);
|
||||
Dart_NotifyIdle(deadline.ToEpochDelta().ToMicroseconds());
|
||||
|
||||
// Idle notifications being in isolate scope are part of the contract.
|
||||
if (idle_notification_callback_) {
|
||||
TRACE_EVENT0("flutter", "EmbedderIdleNotification");
|
||||
idle_notification_callback_(deadline);
|
||||
idle_notification_callback_(deadline.ToEpochDelta().ToMicroseconds());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -350,13 +350,12 @@ class RuntimeController : public PlatformConfigurationClient {
|
||||
/// @bug The `deadline` argument must be converted to `std::chrono`
|
||||
/// instead of a raw integer.
|
||||
///
|
||||
/// @param[in] deadline The deadline measures in microseconds against the
|
||||
/// system's monotonic time. The clock can be accessed via
|
||||
/// `Dart_TimelineGetMicros`.
|
||||
/// @param[in] deadline The deadline is used by the VM to determine if the
|
||||
/// corresponding sweep can be performed within the deadline.
|
||||
///
|
||||
/// @return If the idle notification was forwarded to the running isolate.
|
||||
///
|
||||
virtual bool NotifyIdle(int64_t deadline);
|
||||
virtual bool NotifyIdle(fml::TimePoint deadline);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Returns if the root isolate is running. The isolate must be
|
||||
|
||||
@@ -168,8 +168,9 @@ void Animator::BeginFrame(
|
||||
if (notify_idle_task_id == self->notify_idle_task_id_ &&
|
||||
!self->frame_scheduled_) {
|
||||
TRACE_EVENT0("flutter", "BeginFrame idle callback");
|
||||
self->delegate_.OnAnimatorNotifyIdle(Dart_TimelineGetMicros() +
|
||||
100000);
|
||||
self->delegate_.OnAnimatorNotifyIdle(
|
||||
FxlToDartOrEarlier(fml::TimePoint::Now() +
|
||||
fml::TimeDelta::FromMicroseconds(100000)));
|
||||
}
|
||||
},
|
||||
kNotifyIdleTaskWaitTime);
|
||||
@@ -274,8 +275,7 @@ void Animator::AwaitVSync() {
|
||||
}
|
||||
});
|
||||
if (has_rendered_) {
|
||||
delegate_.OnAnimatorNotifyIdle(
|
||||
dart_frame_deadline_.ToEpochDelta().ToMicroseconds());
|
||||
delegate_.OnAnimatorNotifyIdle(dart_frame_deadline_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Animator final {
|
||||
virtual void OnAnimatorBeginFrame(fml::TimePoint frame_target_time,
|
||||
uint64_t frame_number) = 0;
|
||||
|
||||
virtual void OnAnimatorNotifyIdle(int64_t deadline) = 0;
|
||||
virtual void OnAnimatorNotifyIdle(fml::TimePoint deadline) = 0;
|
||||
|
||||
virtual void OnAnimatorDraw(
|
||||
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
|
||||
|
||||
@@ -23,7 +23,7 @@ class FakeAnimatorDelegate : public Animator::Delegate {
|
||||
void OnAnimatorBeginFrame(fml::TimePoint frame_target_time,
|
||||
uint64_t frame_number) override {}
|
||||
|
||||
void OnAnimatorNotifyIdle(int64_t deadline) override {
|
||||
void OnAnimatorNotifyIdle(fml::TimePoint deadline) override {
|
||||
notify_idle_called_ = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -252,8 +252,9 @@ void Engine::ReportTimings(std::vector<int64_t> timings) {
|
||||
runtime_controller_->ReportTimings(std::move(timings));
|
||||
}
|
||||
|
||||
void Engine::NotifyIdle(int64_t deadline) {
|
||||
auto trace_event = std::to_string(deadline - Dart_TimelineGetMicros());
|
||||
void Engine::NotifyIdle(fml::TimePoint deadline) {
|
||||
auto trace_event = std::to_string(deadline.ToEpochDelta().ToMicroseconds() -
|
||||
Dart_TimelineGetMicros());
|
||||
TRACE_EVENT1("flutter", "Engine::NotifyIdle", "deadline_now_delta",
|
||||
trace_event.c_str());
|
||||
runtime_controller_->NotifyIdle(deadline);
|
||||
|
||||
@@ -539,15 +539,12 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
|
||||
/// collection, just gives the Dart VM more hints about opportune
|
||||
/// moments to perform collections.
|
||||
///
|
||||
// TODO(chinmaygarde): This should just use fml::TimePoint instead of having
|
||||
// to remember that the unit is microseconds (which is no used anywhere else
|
||||
// in the engine).
|
||||
///
|
||||
/// @param[in] deadline The deadline as a timepoint in microseconds measured
|
||||
/// against the system monotonic clock. Use
|
||||
/// `Dart_TimelineGetMicros()`, for consistency.
|
||||
/// @param[in] deadline The deadline is used by the VM to determine if the
|
||||
/// corresponding sweep can be performed within the
|
||||
/// deadline.
|
||||
///
|
||||
void NotifyIdle(int64_t deadline);
|
||||
void NotifyIdle(fml::TimePoint deadline);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Dart code cannot fully measure the time it takes for a
|
||||
|
||||
@@ -71,7 +71,7 @@ class MockRuntimeController : public RuntimeController {
|
||||
MOCK_METHOD3(LoadDartDeferredLibraryError,
|
||||
void(intptr_t, const std::string, bool));
|
||||
MOCK_CONST_METHOD0(GetDartVM, DartVM*());
|
||||
MOCK_METHOD1(NotifyIdle, bool(int64_t));
|
||||
MOCK_METHOD1(NotifyIdle, bool(fml::TimePoint));
|
||||
};
|
||||
|
||||
std::unique_ptr<PlatformMessage> MakePlatformMessage(
|
||||
|
||||
@@ -1091,7 +1091,7 @@ void Shell::OnAnimatorBeginFrame(fml::TimePoint frame_target_time,
|
||||
}
|
||||
|
||||
// |Animator::Delegate|
|
||||
void Shell::OnAnimatorNotifyIdle(int64_t deadline) {
|
||||
void Shell::OnAnimatorNotifyIdle(fml::TimePoint deadline) {
|
||||
FML_DCHECK(is_setup_);
|
||||
FML_DCHECK(task_runners_.GetUITaskRunner()->RunsTasksOnCurrentThread());
|
||||
|
||||
|
||||
@@ -574,7 +574,7 @@ class Shell final : public PlatformView::Delegate,
|
||||
uint64_t frame_number) override;
|
||||
|
||||
// |Animator::Delegate|
|
||||
void OnAnimatorNotifyIdle(int64_t deadline) override;
|
||||
void OnAnimatorNotifyIdle(fml::TimePoint deadline) override;
|
||||
|
||||
// |Animator::Delegate|
|
||||
void OnAnimatorDraw(
|
||||
|
||||
@@ -152,7 +152,7 @@ void ShellTest::SetViewportMetrics(Shell* shell, double width, double height) {
|
||||
latch.Wait();
|
||||
}
|
||||
|
||||
void ShellTest::NotifyIdle(Shell* shell, int64_t deadline) {
|
||||
void ShellTest::NotifyIdle(Shell* shell, fml::TimePoint deadline) {
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
shell->GetTaskRunners().GetUITaskRunner()->PostTask(
|
||||
[&latch, engine = shell->weak_engine_, deadline]() {
|
||||
|
||||
@@ -73,7 +73,7 @@ class ShellTest : public FixtureTest {
|
||||
std::function<void(std::shared_ptr<ContainerLayer> root)>;
|
||||
|
||||
static void SetViewportMetrics(Shell* shell, double width, double height);
|
||||
static void NotifyIdle(Shell* shell, int64_t deadline);
|
||||
static void NotifyIdle(Shell* shell, fml::TimePoint deadline);
|
||||
|
||||
static void PumpOneFrame(Shell* shell,
|
||||
double width = 1,
|
||||
|
||||
Reference in New Issue
Block a user