diff --git a/Tests/LottieMetalTest/LottieSwift/Sources/Private/Utility/Extensions/CGFloatExtensions.swift b/Tests/LottieMetalTest/LottieSwift/Sources/Private/Utility/Extensions/CGFloatExtensions.swift index 939725a331..bd7d6f32e8 100644 --- a/Tests/LottieMetalTest/LottieSwift/Sources/Private/Utility/Extensions/CGFloatExtensions.swift +++ b/Tests/LottieMetalTest/LottieSwift/Sources/Private/Utility/Extensions/CGFloatExtensions.swift @@ -8,6 +8,53 @@ import Foundation import QuartzCore +private func fma(_ a: CGFloat, _ b: CGFloat, _ c: CGFloat) -> CGFloat { + return a * b + c +} + +private func eval_poly(_ t: CGFloat, _ b: CGFloat) -> CGFloat { + return b; +} + +private func eval_poly(_ t: CGFloat, _ m: CGFloat, _ b: CGFloat) -> CGFloat { + return eval_poly(t, fma(m, t, b)) +} + +private func eval_poly(_ t: CGFloat, _ m: CGFloat, _ b: CGFloat, _ c: CGFloat) -> CGFloat { + return eval_poly(t, fma(m, t, b), c) +} + +private func eval_poly(_ t: CGFloat, _ m: CGFloat, _ b: CGFloat, _ c: CGFloat, _ d: CGFloat) -> CGFloat { + return eval_poly(t, fma(m, t, b), c, d) +} + +private func cubic_solver(_ A: CGFloat, _ B: CGFloat, _ C: CGFloat, _ D: CGFloat) -> CGFloat { + var t = -D + + for _ in 0 ..< 8 { + let f = eval_poly(t, A, B, C, D) // f = At^3 + Bt^2 + Ct + D + if (abs(f) <= 0.00005) { + break; + } + let fp = eval_poly(t, 3.0 * A, 2.0 * B, C) // f' = 3At^2 + 2Bt + C + let fpp = eval_poly(t, 3.0 * A + 3.0 * A, 2.0 * B) // f'' = 6At + 2B + + let numer = 2.0 * fp * f + let denom = fma(2 * fp, fp, -(f * fpp)) + + t -= numer / denom + } + + if t < 0.0 { + t = 0.0 + } + if t > 1.0 { + t = 1.0 + } + + return t +} + extension CGFloat { // MARK: Internal @@ -90,7 +137,9 @@ extension CGFloat { } fileprivate static func SolveCubic(_ a: CGFloat, _ b: CGFloat, _ c: CGFloat, _ d: CGFloat) -> CGFloat { - if a == 0 { + return cubic_solver(a, b, c, d) + + /*if a == 0 { return SolveQuadratic(b, c, d) } if d == 0 { @@ -151,6 +200,6 @@ extension CGFloat { } } - return -1; + return -1;*/ } } diff --git a/Tests/LottieMetalTest/Sources/ViewController.swift b/Tests/LottieMetalTest/Sources/ViewController.swift index 40c709ef88..34393712aa 100644 --- a/Tests/LottieMetalTest/Sources/ViewController.swift +++ b/Tests/LottieMetalTest/Sources/ViewController.swift @@ -78,7 +78,7 @@ private final class ReferenceCompareTest { } var continueFromName: String? - //continueFromName = "1048388279864393866.json" + //continueFromName = "5089561049196134821.json" let _ = await processAnimationFolderAsync(basePath: bundlePath, path: "", stopOnFailure: !testNonReference, process: { path, name, alwaysDraw in if let continueFromNameValue = continueFromName { @@ -119,7 +119,7 @@ public final class ViewController: UIViewController { self.view.layer.addSublayer(MetalEngine.shared.rootLayer) - if !"".isEmpty { + if "".isEmpty { if #available(iOS 13.0, *) { self.test = ReferenceCompareTest(view: self.view, testNonReference: false) } diff --git a/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift b/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift index f1c5f4e417..f0ad22f2c8 100644 --- a/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift +++ b/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift @@ -967,12 +967,14 @@ final class ChatSendMessageContextScreenComponent: Component { standaloneReactionAnimation = DirectAnimatedStickerNode() effectiveScale = 1.4 #else - if "".isEmpty { + standaloneReactionAnimation = DirectAnimatedStickerNode() + effectiveScale = 1.4 + /*if "".isEmpty { standaloneReactionAnimation = DirectAnimatedStickerNode() effectiveScale = 1.4 } else { standaloneReactionAnimation = LottieMetalAnimatedStickerNode() - } + }*/ #endif standaloneReactionAnimation.isUserInteractionEnabled = false diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift index 6804e647b0..4dfd11293e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift @@ -986,12 +986,14 @@ open class ChatMessageItemView: ListViewItemNode, ChatMessageItemNodeProtocol { additionalAnimationNode = DirectAnimatedStickerNode() effectiveScale = 1.4 #else - if "".isEmpty { + additionalAnimationNode = DirectAnimatedStickerNode() + effectiveScale = 1.4 + /*if "".isEmpty { additionalAnimationNode = DirectAnimatedStickerNode() effectiveScale = 1.4 } else { additionalAnimationNode = LottieMetalAnimatedStickerNode() - } + }*/ #endif additionalAnimationNode.updateLayout(size: animationSize) additionalAnimationNode.setup(source: source, width: Int(animationSize.width * effectiveScale), height: Int(animationSize.height * effectiveScale), playbackMode: .once, mode: .direct(cachePathPrefix: pathPrefix))