forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vsync_waiter.h
43 lines (29 loc) · 1.05 KB
/
vsync_waiter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_COMMON_VSYNC_WAITER_H_
#define FLUTTER_SHELL_COMMON_VSYNC_WAITER_H_
#include <functional>
#include <memory>
#include <mutex>
#include "flutter/common/task_runners.h"
#include "lib/fxl/time/time_point.h"
namespace shell {
class VsyncWaiter {
public:
using Callback = std::function<void(fxl::TimePoint frame_start_time,
fxl::TimePoint frame_target_time)>;
virtual ~VsyncWaiter();
void AsyncWaitForVsync(Callback callback);
protected:
const blink::TaskRunners task_runners_;
std::mutex callback_mutex_;
Callback callback_;
VsyncWaiter(blink::TaskRunners task_runners);
virtual void AwaitVSync() = 0;
void FireCallback(fxl::TimePoint frame_start_time,
fxl::TimePoint frame_target_time);
FXL_DISALLOW_COPY_AND_ASSIGN(VsyncWaiter);
};
} // namespace shell
#endif // FLUTTER_SHELL_COMMON_VSYNC_WAITER_H_