mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-08 01:40:09 +00:00
Fix fps
This commit is contained in:
parent
f192fbf16b
commit
e69e0a33dd
@ -807,6 +807,12 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
||||||
|
if #available(iOS 15.0, *) {
|
||||||
|
if let scrollDisplayLink = self.scroller.value(forKey: "_scrollHeartbeat") as? CADisplayLink {
|
||||||
|
let _ = scrollDisplayLink
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.isDragging = false
|
self.isDragging = false
|
||||||
if decelerate {
|
if decelerate {
|
||||||
self.lastContentOffsetTimestamp = CACurrentMediaTime()
|
self.lastContentOffsetTimestamp = CACurrentMediaTime()
|
||||||
@ -886,6 +892,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
|||||||
|
|
||||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
self.updateScrollViewDidScroll(scrollView, synchronous: self.defaultToSynchronousTransactionWhileScrolling)
|
self.updateScrollViewDidScroll(scrollView, synchronous: self.defaultToSynchronousTransactionWhileScrolling)
|
||||||
|
scrollView.fixScrollDisplayLink()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var generalAccumulatedDeltaY: CGFloat = 0.0
|
private var generalAccumulatedDeltaY: CGFloat = 0.0
|
||||||
|
|||||||
@ -48,3 +48,9 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView);
|
|||||||
@property (nonatomic, copy) UIInterfaceOrientationMask (^ _Nullable supportedOrientations)(void);
|
@property (nonatomic, copy) UIInterfaceOrientationMask (^ _Nullable supportedOrientations)(void);
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface UIScrollView (FrameRateRangeOverride)
|
||||||
|
|
||||||
|
- (void)fixScrollDisplayLink;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|||||||
@ -43,6 +43,7 @@ static const void *inputAccessoryHeightProviderKey = &inputAccessoryHeightProvid
|
|||||||
static const void *interactiveTransitionGestureRecognizerTestKey = &interactiveTransitionGestureRecognizerTestKey;
|
static const void *interactiveTransitionGestureRecognizerTestKey = &interactiveTransitionGestureRecognizerTestKey;
|
||||||
static const void *UIViewControllerHintWillBePresentedInPreviewingContextKey = &UIViewControllerHintWillBePresentedInPreviewingContextKey;
|
static const void *UIViewControllerHintWillBePresentedInPreviewingContextKey = &UIViewControllerHintWillBePresentedInPreviewingContextKey;
|
||||||
static const void *disablesInteractiveModalDismissKey = &disablesInteractiveModalDismissKey;
|
static const void *disablesInteractiveModalDismissKey = &disablesInteractiveModalDismissKey;
|
||||||
|
static const void *forceFullRefreshRateKey = &forceFullRefreshRateKey;
|
||||||
|
|
||||||
static bool notyfyingShiftState = false;
|
static bool notyfyingShiftState = false;
|
||||||
|
|
||||||
@ -99,14 +100,41 @@ static bool notyfyingShiftState = false;
|
|||||||
@implementation CADisplayLink (FrameRateRangeOverride)
|
@implementation CADisplayLink (FrameRateRangeOverride)
|
||||||
|
|
||||||
- (void)_65087dc8_setPreferredFrameRateRange:(CAFrameRateRange)range API_AVAILABLE(ios(15.0)) {
|
- (void)_65087dc8_setPreferredFrameRateRange:(CAFrameRateRange)range API_AVAILABLE(ios(15.0)) {
|
||||||
|
if ([self associatedObjectForKey:forceFullRefreshRateKey] != nil) {
|
||||||
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
|
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
|
||||||
range = CAFrameRateRangeMake(maxFps, maxFps, maxFps);
|
range = CAFrameRateRangeMake(maxFps, maxFps, maxFps);
|
||||||
|
}
|
||||||
|
|
||||||
[self _65087dc8_setPreferredFrameRateRange:range];
|
[self _65087dc8_setPreferredFrameRateRange:range];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation UIScrollView (FrameRateRangeOverride)
|
||||||
|
|
||||||
|
- (void)fixScrollDisplayLink {
|
||||||
|
static NSString *scrollHeartbeatKey = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
scrollHeartbeatKey = [NSString stringWithFormat:@"_%@", @"scrollHeartbeat"];
|
||||||
|
});
|
||||||
|
|
||||||
|
id value = [self valueForKey:scrollHeartbeatKey];
|
||||||
|
if ([value isKindOfClass:[CADisplayLink class]]) {
|
||||||
|
CADisplayLink *displayLink = (CADisplayLink *)value;
|
||||||
|
if ([displayLink associatedObjectForKey:forceFullRefreshRateKey] == nil) {
|
||||||
|
[displayLink setAssociatedObject:@true forKey:forceFullRefreshRateKey];
|
||||||
|
|
||||||
|
if (@available(iOS 15.0, *)) {
|
||||||
|
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
|
||||||
|
[displayLink setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation UIViewController (Navigation)
|
@implementation UIViewController (Navigation)
|
||||||
|
|
||||||
+ (void)load
|
+ (void)load
|
||||||
|
|||||||
@ -216,6 +216,10 @@
|
|||||||
animationWithKeyPath:event];
|
animationWithKeyPath:event];
|
||||||
theAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
|
theAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
|
||||||
theAnimation.fromValue = [[self presentationLayer] valueForKey:event];
|
theAnimation.fromValue = [[self presentationLayer] valueForKey:event];
|
||||||
|
if (@available(iOS 15.0, *)) {
|
||||||
|
float maxFps = UIScreen.mainScreen.maximumFramesPerSecond;
|
||||||
|
[theAnimation setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
|
||||||
|
}
|
||||||
return theAnimation;
|
return theAnimation;
|
||||||
}
|
}
|
||||||
return [super actionForKey:event];
|
return [super actionForKey:event];
|
||||||
|
|||||||
@ -363,6 +363,10 @@ static NSString * const kCompContainerAnimationKey = @"play";
|
|||||||
} else {
|
} else {
|
||||||
NSTimeInterval duration = (ABS(toEndFrame.floatValue - fromStartFrame.floatValue) / _sceneModel.framerate.floatValue);
|
NSTimeInterval duration = (ABS(toEndFrame.floatValue - fromStartFrame.floatValue) / _sceneModel.framerate.floatValue);
|
||||||
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"currentFrame"];
|
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"currentFrame"];
|
||||||
|
if (@available(iOS 15.0, *)) {
|
||||||
|
float maxFps = UIScreen.mainScreen.maximumFramesPerSecond;
|
||||||
|
[animation setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
|
||||||
|
}
|
||||||
animation.speed = _animationSpeed;
|
animation.speed = _animationSpeed;
|
||||||
animation.fromValue = fromStartFrame;
|
animation.fromValue = fromStartFrame;
|
||||||
animation.toValue = toEndFrame;
|
animation.toValue = toEndFrame;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user