mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This removes most of the remaining FLUTTER_NOLINT comments and opts these files back into linter enforcement. I've filed https://github.com/flutter/flutter/issues/68273 to require that all FLUTTER_NOLINT comments be followed by a GitHub issue URL describing the problem to be fixed.
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/shell/common/vsync_waiter_fallback.h"
|
|
|
|
#include "flutter/fml/logging.h"
|
|
|
|
namespace flutter {
|
|
namespace {
|
|
|
|
static fml::TimePoint SnapToNextTick(fml::TimePoint value,
|
|
fml::TimePoint tick_phase,
|
|
fml::TimeDelta tick_interval) {
|
|
fml::TimeDelta offset = (tick_phase - value) % tick_interval;
|
|
if (offset != fml::TimeDelta::Zero())
|
|
offset = offset + tick_interval;
|
|
return value + offset;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
VsyncWaiterFallback::VsyncWaiterFallback(TaskRunners task_runners)
|
|
: VsyncWaiter(std::move(task_runners)), phase_(fml::TimePoint::Now()) {}
|
|
|
|
VsyncWaiterFallback::~VsyncWaiterFallback() = default;
|
|
|
|
// |VsyncWaiter|
|
|
void VsyncWaiterFallback::AwaitVSync() {
|
|
constexpr fml::TimeDelta kSingleFrameInterval =
|
|
fml::TimeDelta::FromSecondsF(1.0 / 60.0);
|
|
|
|
auto next =
|
|
SnapToNextTick(fml::TimePoint::Now(), phase_, kSingleFrameInterval);
|
|
|
|
FireCallback(next, next + kSingleFrameInterval);
|
|
}
|
|
|
|
} // namespace flutter
|