Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterTimeConverter.mm
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_MACOS_FRAMEWORK_SOURCE_FLUTTER_TIME_CONVERTER_MM_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTER_TIME_CONVERTER_MM_
7
8#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTimeConverter.h"
9#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
10
11@interface FlutterTimeConverter () {
13}
14@end
15
16@implementation FlutterTimeConverter
17
18- (instancetype)initWithEngine:(FlutterEngine*)engine {
19 self = [super init];
20 if (self) {
22 }
23 return self;
24}
25
26- (uint64_t)CAMediaTimeToEngineTime:(CFTimeInterval)time {
28 if (!engine) {
29 return 0;
30 }
31 return (time - CACurrentMediaTime()) * NSEC_PER_SEC + engine.embedderAPI.GetCurrentTime();
32}
33
34- (CFTimeInterval)engineTimeToCAMediaTime:(uint64_t)time {
36 if (!engine) {
37 return 0;
38 }
39 return (static_cast<int64_t>(time) - static_cast<int64_t>(engine.embedderAPI.GetCurrentTime())) /
40 static_cast<double>(NSEC_PER_SEC) +
41 CACurrentMediaTime();
42}
43
44@end
45
46#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTER_TIME_CONVERTER_MM_-
FlutterEngine engine
Definition main.cc:68
FlutterEngineProcTable & embedderAPI()
Converts between the time representation used by Flutter Engine and CAMediaTime.
__weak FlutterEngine * _engine
fml::scoped_nsobject< FlutterEngine > _engine
FlutterEngineGetCurrentTimeFnPtr GetCurrentTime
Definition embedder.h:3350
#define NSEC_PER_SEC
Definition timerfd.cc:35
#define GetCurrentTime()