Flutter Engine
The Flutter Engine
vsync_waiter_ios.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_VSYNC_WAITER_IOS_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_VSYNC_WAITER_IOS_H_
7
8#include <QuartzCore/CADisplayLink.h>
9
10#include "flutter/fml/macros.h"
11#include "flutter/shell/common/variable_refresh_rate_reporter.h"
12#include "flutter/shell/common/vsync_waiter.h"
13
14@interface DisplayLinkManager : NSObject
15
16// Whether the max refresh rate on iPhone Pro-motion devices are enabled.
17// This reflects the value of `CADisableMinimumFrameDurationOnPhone` in the
18// info.plist file.
19//
20// Note on iPads that support Pro-motion, the max refresh rate is always enabled.
21@property(class, nonatomic, readonly) BOOL maxRefreshRateEnabledOnIPhone;
22
23//------------------------------------------------------------------------------
24/// @brief The display refresh rate used for reporting purposes. The engine does not care
25/// about this for frame scheduling. It is only used by tools for instrumentation. The
26/// engine uses the duration field of the link per frame for frame scheduling.
27///
28/// @attention Do not use the this call in frame scheduling. It is only meant for reporting.
29///
30/// @return The refresh rate in frames per second.
31///
32@property(class, nonatomic, readonly) double displayRefreshRate;
33
34@end
35
36@interface VSyncClient : NSObject
37
38//------------------------------------------------------------------------------
39/// @brief Default value is YES. Vsync client will pause vsync callback after receiving
40/// a vsync signal. Setting this property to NO can avoid this and vsync client
41/// will trigger vsync callback continuously.
42///
43///
44/// @param allowPauseAfterVsync Allow vsync client to pause after receiving a vsync signal.
45///
46@property(nonatomic, assign) BOOL allowPauseAfterVsync;
47
48- (instancetype)initWithTaskRunner:(fml::RefPtr<fml::TaskRunner>)task_runner
50
51- (void)await;
52
53- (void)pause;
54
55//------------------------------------------------------------------------------
56/// @brief Call invalidate before releasing this object to remove from runloops.
57///
58- (void)invalidate;
59
60- (void)setMaxRefreshRate:(double)refreshRate;
61
62@end
63
64namespace flutter {
65
67 public:
68 explicit VsyncWaiterIOS(const flutter::TaskRunners& task_runners);
69
70 ~VsyncWaiterIOS() override;
71
72 // |VariableRefreshRateReporter|
73 double GetRefreshRate() const override;
74
75 // |VsyncWaiter|
76 // Made public for testing.
77 void AwaitVSync() override;
78
79 private:
80 VSyncClient* client_;
81 double max_refresh_rate_;
82
84};
85
86} // namespace flutter
87
88#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_VSYNC_WAITER_IOS_H_
std::function< void(std::unique_ptr< FrameTimingsRecorder >)> Callback
Definition: vsync_waiter.h:26
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
double displayRefreshRate
The display refresh rate used for reporting purposes. The engine does not care about this for frame s...
int BOOL
Definition: windows_types.h:37