2018-11-07 12:24:35 -08:00
|
|
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
2016-10-24 16:14:37 -07:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
#ifndef SHELL_PLATFORM_ANDROID_VSYNC_WAITER_ANDROID_H_
|
|
|
|
|
#define SHELL_PLATFORM_ANDROID_VSYNC_WAITER_ANDROID_H_
|
|
|
|
|
|
2017-03-22 15:42:51 -07:00
|
|
|
#include <jni.h>
|
2019-02-21 23:02:32 -08:00
|
|
|
|
2018-07-16 12:04:05 -07:00
|
|
|
#include <memory>
|
2019-02-21 23:02:32 -08:00
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
#include "flutter/fml/macros.h"
|
2016-10-24 16:14:37 -07:00
|
|
|
#include "flutter/shell/common/vsync_waiter.h"
|
|
|
|
|
|
2019-04-09 17:10:46 -07:00
|
|
|
namespace flutter {
|
2016-10-24 16:14:37 -07:00
|
|
|
|
2018-04-13 13:48:15 -07:00
|
|
|
class VsyncWaiterAndroid final : public VsyncWaiter {
|
2016-10-24 16:14:37 -07:00
|
|
|
public:
|
2018-04-13 13:48:15 -07:00
|
|
|
static bool Register(JNIEnv* env);
|
|
|
|
|
|
2019-04-09 12:44:42 -07:00
|
|
|
VsyncWaiterAndroid(flutter::TaskRunners task_runners);
|
2017-03-22 15:42:51 -07:00
|
|
|
|
2016-10-24 16:14:37 -07:00
|
|
|
~VsyncWaiterAndroid() override;
|
|
|
|
|
|
2018-12-12 10:28:44 -08:00
|
|
|
float GetDisplayRefreshRate() const override;
|
|
|
|
|
|
2016-10-24 16:14:37 -07:00
|
|
|
private:
|
2019-04-09 17:10:46 -07:00
|
|
|
// |VsyncWaiter|
|
2018-04-13 13:48:15 -07:00
|
|
|
void AwaitVSync() override;
|
2016-10-24 16:14:37 -07:00
|
|
|
|
2019-02-21 23:02:32 -08:00
|
|
|
static void OnNativeVsync(JNIEnv* env,
|
|
|
|
|
jclass jcaller,
|
|
|
|
|
jlong frameTimeNanos,
|
|
|
|
|
jlong frameTargetTimeNanos,
|
|
|
|
|
jlong java_baton);
|
|
|
|
|
|
|
|
|
|
static void ConsumePendingCallback(jlong java_baton,
|
|
|
|
|
fml::TimePoint frame_start_time,
|
|
|
|
|
fml::TimePoint frame_target_time);
|
|
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiterAndroid);
|
2016-10-24 16:14:37 -07:00
|
|
|
};
|
|
|
|
|
|
2019-04-09 17:10:46 -07:00
|
|
|
} // namespace flutter
|
2016-10-24 16:14:37 -07:00
|
|
|
|
|
|
|
|
#endif // SHELL_PLATFORM_ANDROID_ASYNC_WAITER_ANDROID_H_
|