mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-05-21 18:20:41 +00:00
Refactoring
This commit is contained in:
@@ -31,6 +31,7 @@ swift_library(
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
|
||||
"//submodules/TelegramUI/Components/DCTAnimationCacheImpl:DCTAnimationCacheImpl",
|
||||
"//submodules/TelegramUI/Components/VideoAnimationCache:VideoAnimationCache",
|
||||
"//submodules/TelegramUI/Components/LottieAnimationCache:LottieAnimationCache",
|
||||
"//submodules/rlottie:RLottieBinding",
|
||||
|
||||
@@ -3,6 +3,7 @@ import UIKit
|
||||
|
||||
import Display
|
||||
import AnimationCache
|
||||
import DCTAnimationCacheImpl
|
||||
import SwiftSignalKit
|
||||
import VideoAnimationCache
|
||||
import LottieAnimationCache
|
||||
@@ -50,7 +51,7 @@ public final class ViewController: UIViewController {
|
||||
let basePath = NSTemporaryDirectory() + "/animation-cache"
|
||||
let _ = try? FileManager.default.removeItem(atPath: basePath)
|
||||
let _ = try? FileManager.default.createDirectory(at: URL(fileURLWithPath: basePath), withIntermediateDirectories: true)
|
||||
self.cache = AnimationCacheImpl(basePath: basePath, allocateTempFile: {
|
||||
self.cache = DCTAnimationCacheImpl(basePath: basePath, allocateTempFile: {
|
||||
return basePath + "/\(Int64.random(in: 0 ... Int64.max))"
|
||||
})
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ swift_library(
|
||||
"//submodules/TelegramUI/Components/EntityKeyboard:EntityKeyboard",
|
||||
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer",
|
||||
"//submodules/TelegramUI/Components/DCTMultiAnimationRendererImpl:DCTMultiAnimationRendererImpl",
|
||||
"//submodules/TelegramUI/Components/EmojiTextAttachmentView:EmojiTextAttachmentView",
|
||||
"//submodules/Components/ComponentDisplayAdapters:ComponentDisplayAdapters",
|
||||
"//submodules/TextFormat:TextFormat",
|
||||
|
||||
@@ -20,6 +20,7 @@ import EntityKeyboard
|
||||
import ComponentDisplayAdapters
|
||||
import AnimationCache
|
||||
import MultiAnimationRenderer
|
||||
import DCTMultiAnimationRendererImpl
|
||||
import EmojiTextAttachmentView
|
||||
import TextFormat
|
||||
import GZip
|
||||
@@ -504,8 +505,8 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
|
||||
self.reactionsLocked = reactionsLocked
|
||||
|
||||
self.animationCache = animationCache
|
||||
self.animationRenderer = MultiAnimationRendererImpl()
|
||||
(self.animationRenderer as? MultiAnimationRendererImpl)?.useYuvA = context.sharedContext.immediateExperimentalUISettings.compressedEmojiCache
|
||||
self.animationRenderer = DCTMultiAnimationRendererImpl()
|
||||
(self.animationRenderer as? DCTMultiAnimationRendererImpl)?.useYuvA = context.sharedContext.immediateExperimentalUISettings.compressedEmojiCache
|
||||
|
||||
self.backgroundMaskNode = ASDisplayNode()
|
||||
var backgroundGlassParams: ReactionContextBackgroundNode.GlassParams?
|
||||
@@ -3341,7 +3342,7 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
|
||||
if let currentItemNode = currentItemNode {
|
||||
itemNode = currentItemNode
|
||||
} else {
|
||||
let animationRenderer = MultiAnimationRendererImpl()
|
||||
let animationRenderer = DCTMultiAnimationRendererImpl()
|
||||
itemNode = ReactionNode(context: context, theme: theme, item: reaction, icon: .none, animationCache: animationCache, animationRenderer: animationRenderer, loopIdle: false, isLocked: false)
|
||||
}
|
||||
self.itemNode = itemNode
|
||||
|
||||
@@ -283,6 +283,8 @@ swift_library(
|
||||
"//submodules/TelegramUI/Components/LottieAnimationCache:LottieAnimationCache",
|
||||
"//submodules/TelegramUI/Components/VideoAnimationCache:VideoAnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer",
|
||||
"//submodules/TelegramUI/Components/DCTAnimationCacheImpl:DCTAnimationCacheImpl",
|
||||
"//submodules/TelegramUI/Components/DCTMultiAnimationRendererImpl:DCTMultiAnimationRendererImpl",
|
||||
"//submodules/TelegramUI/Components/ChatInputPanelContainer:ChatInputPanelContainer",
|
||||
"//submodules/TelegramUI/Components/TextNodeWithEntities:TextNodeWithEntities",
|
||||
"//submodules/TelegramUI/Components/EmojiSuggestionsComponent:EmojiSuggestionsComponent",
|
||||
|
||||
@@ -11,10 +11,6 @@ swift_library(
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/CryptoUtils:CryptoUtils",
|
||||
"//submodules/ManagedFile:ManagedFile",
|
||||
"//submodules/TelegramUI/Components/AnimationCache/ImageDCT:ImageDCT",
|
||||
"//third-party/subcodec:SubcodecObjC",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "DCTAnimationCacheImpl",
|
||||
module_name = "DCTAnimationCacheImpl",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/CryptoUtils:CryptoUtils",
|
||||
"//submodules/ManagedFile:ManagedFile",
|
||||
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
|
||||
"//submodules/TelegramUI/Components/AnimationCache/ImageDCT:ImageDCT",
|
||||
"//third-party/subcodec:SubcodecObjC",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
+1558
File diff suppressed because it is too large
Load Diff
+1
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AnimationCache
|
||||
import ImageDCT
|
||||
import Accelerate
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "DCTMultiAnimationRendererImpl",
|
||||
module_name = "DCTMultiAnimationRendererImpl",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
+1078
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@ swift_library(
|
||||
"//submodules/TelegramUI/Components/LottieAnimationCache:LottieAnimationCache",
|
||||
"//submodules/TelegramUI/Components/VideoAnimationCache:VideoAnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer",
|
||||
"//submodules/TelegramUI/Components/DCTMultiAnimationRendererImpl:DCTMultiAnimationRendererImpl",
|
||||
"//submodules/ShimmerEffect:ShimmerEffect",
|
||||
"//submodules/TelegramUIPreferences",
|
||||
"//submodules/TelegramUI/Components/Utils/GenerateStickerPlaceholderImage",
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@ import AnimationCache
|
||||
import LottieAnimationCache
|
||||
import VideoAnimationCache
|
||||
import MultiAnimationRenderer
|
||||
import DCTMultiAnimationRendererImpl
|
||||
import ShimmerEffect
|
||||
import TextFormat
|
||||
import TelegramUIPreferences
|
||||
@@ -817,7 +818,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
|
||||
let isThumbnailCancelled = Atomic<Bool>(value: false)
|
||||
self.loadDisposable = arguments.renderer.loadFirstFrame(target: self, cache: arguments.cache, itemId: file.resource.id.stringRepresentation, size: arguments.pixelSize, fetch: animationCacheFetchFile(postbox: arguments.context.postbox, userLocation: arguments.userLocation, userContentType: .sticker, resource: .media(media: .standalone(media: file), resource: file.resource), type: AnimationCacheAnimationType(file: file), keyframeOnly: true, customColor: isTemplate ? .white : nil), completion: { [weak self] result, isFinal in
|
||||
if !result {
|
||||
MultiAnimationRendererImpl.firstFrameQueue.async {
|
||||
DCTMultiAnimationRendererImpl.firstFrameQueue.async {
|
||||
let image = generateStickerPlaceholderImage(data: file.immediateThumbnailData, size: pointSize, scale: min(2.0, UIScreenScale), imageSize: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0), backgroundColor: nil, foregroundColor: placeholderColor)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
@@ -28,6 +28,7 @@ swift_library(
|
||||
"//submodules/TelegramUI/Components/LottieAnimationCache:LottieAnimationCache",
|
||||
"//submodules/TelegramUI/Components/VideoAnimationCache:VideoAnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer",
|
||||
"//submodules/TelegramUI/Components/DCTMultiAnimationRendererImpl:DCTMultiAnimationRendererImpl",
|
||||
"//submodules/TelegramUI/Components/EmojiTextAttachmentView:EmojiTextAttachmentView",
|
||||
"//submodules/TelegramUI/Components/EmojiStatusComponent:EmojiStatusComponent",
|
||||
"//submodules/TelegramUI/Components/LottieComponent",
|
||||
|
||||
@@ -8,6 +8,7 @@ import Postbox
|
||||
import SwiftSignalKit
|
||||
import MultiAnimationRenderer
|
||||
import AnimationCache
|
||||
import DCTMultiAnimationRendererImpl
|
||||
import AccountContext
|
||||
import TelegramUIPreferences
|
||||
import GenerateStickerPlaceholderImage
|
||||
@@ -277,7 +278,7 @@ public final class InlineFileIconLayer: MultiAnimationRenderTarget {
|
||||
size: arguments.pixelSize,
|
||||
fetch: animationCacheFetchFile(postbox: arguments.context.postbox, userLocation: arguments.userLocation, userContentType: .sticker, resource: .media(media: .standalone(media: file), resource: file.resource), type: AnimationCacheAnimationType(file: file), keyframeOnly: true, customColor: isTemplate ? .white : nil), completion: { [weak self] result, isFinal in
|
||||
if !result {
|
||||
MultiAnimationRendererImpl.firstFrameQueue.async {
|
||||
DCTMultiAnimationRendererImpl.firstFrameQueue.async {
|
||||
let image = generateStickerPlaceholderImage(data: file.immediateThumbnailData, size: pointSize, scale: min(2.0, UIScreenScale), imageSize: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0), backgroundColor: nil, foregroundColor: placeholderColor)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
@@ -1,44 +1,4 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
load(
|
||||
"@build_bazel_rules_apple//apple:resources.bzl",
|
||||
"apple_resource_bundle",
|
||||
"apple_resource_group",
|
||||
)
|
||||
load("//build-system/bazel-utils:plist_fragment.bzl",
|
||||
"plist_fragment",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "MultiAnimationRendererMetalResources",
|
||||
srcs = glob([
|
||||
"Resources/**/*.metal",
|
||||
]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
name = "WallpaperBackgroundNodeBundleInfoPlist",
|
||||
extension = "plist",
|
||||
template =
|
||||
"""
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.telegram.MultiAnimationRenderer</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>MultiAnimationRenderer</string>
|
||||
"""
|
||||
)
|
||||
|
||||
apple_resource_bundle(
|
||||
name = "MultiAnimationRendererBundle",
|
||||
infoplists = [
|
||||
":WallpaperBackgroundNodeBundleInfoPlist",
|
||||
],
|
||||
resources = [
|
||||
":MultiAnimationRendererMetalResources",
|
||||
],
|
||||
)
|
||||
|
||||
swift_library(
|
||||
name = "MultiAnimationRenderer",
|
||||
@@ -46,9 +6,6 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
data = [
|
||||
":MultiAnimationRendererBundle",
|
||||
],
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
typedef struct {
|
||||
packed_float2 position;
|
||||
packed_float2 texCoord;
|
||||
} Vertex;
|
||||
|
||||
typedef struct {
|
||||
float4 position[[position]];
|
||||
float2 texCoord;
|
||||
} Varyings;
|
||||
|
||||
vertex Varyings multiAnimationVertex(
|
||||
unsigned int vid[[vertex_id]],
|
||||
constant Vertex *verticies[[buffer(0)]],
|
||||
constant uint2 &resolution[[buffer(1)]],
|
||||
constant uint2 &slotSize[[buffer(2)]],
|
||||
constant uint2 &slotPosition[[buffer(3)]]
|
||||
) {
|
||||
Varyings out;
|
||||
constant Vertex &v = verticies[vid];
|
||||
|
||||
out.position = float4(float2(v.position), 0.0, 1.0);
|
||||
out.texCoord = v.texCoord;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment half4 multiAnimationFragment(
|
||||
Varyings in[[stage_in]],
|
||||
texture2d<float, access::sample> textureY[[texture(0)]],
|
||||
texture2d<float, access::sample> textureU[[texture(1)]],
|
||||
texture2d<float, access::sample> textureV[[texture(2)]],
|
||||
texture2d<float, access::sample> textureA[[texture(3)]]
|
||||
) {
|
||||
constexpr sampler s(address::clamp_to_edge, filter::linear);
|
||||
|
||||
half y = textureY.sample(s, in.texCoord).r;
|
||||
half u = textureU.sample(s, in.texCoord).r - 0.5;
|
||||
half v = textureV.sample(s, in.texCoord).r - 0.5;
|
||||
half a = textureA.sample(s, in.texCoord).r;
|
||||
|
||||
half4 out = half4(1.5748 * v + y, -0.1873 * v + y, 1.8556 * u + y, a);
|
||||
return half4(out.b, out.g, out.r, out.a);
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
|
||||
+15
-1087
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,8 @@ swift_library(
|
||||
"//submodules/TelegramUI/Components/TelegramUIDeclareEncodables",
|
||||
"//submodules/TelegramUI/Components/AnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer",
|
||||
"//submodules/TelegramUI/Components/DCTAnimationCacheImpl:DCTAnimationCacheImpl",
|
||||
"//submodules/TelegramUI/Components/DCTMultiAnimationRendererImpl:DCTMultiAnimationRendererImpl",
|
||||
"//submodules/TelegramUI/Components/TelegramAccountAuxiliaryMethods",
|
||||
"//submodules/TelegramUI/Components/PeerSelectionController",
|
||||
"//submodules/TelegramUI/Components/ContextMenuScreen",
|
||||
|
||||
+4
-2
@@ -27,6 +27,8 @@ import ManagedFile
|
||||
import TelegramUIDeclareEncodables
|
||||
import AnimationCache
|
||||
import MultiAnimationRenderer
|
||||
import DCTAnimationCacheImpl
|
||||
import DCTMultiAnimationRendererImpl
|
||||
import TelegramUIDeclareEncodables
|
||||
import TelegramAccountAuxiliaryMethods
|
||||
import PeerSelectionController
|
||||
@@ -105,14 +107,14 @@ private final class ShareControllerAccountContextExtension: ShareControllerAccou
|
||||
self.stateManager = stateManager
|
||||
self.engineData = TelegramEngine.EngineData(accountPeerId: stateManager.accountPeerId, postbox: stateManager.postbox)
|
||||
let cacheStorageBox = stateManager.postbox.mediaBox.cacheStorageBox
|
||||
self.animationCache = AnimationCacheImpl(basePath: stateManager.postbox.mediaBox.basePath + "/animation-cache", allocateTempFile: {
|
||||
self.animationCache = DCTAnimationCacheImpl(basePath: stateManager.postbox.mediaBox.basePath + "/animation-cache", allocateTempFile: {
|
||||
return TempBox.shared.tempFile(fileName: "file").path
|
||||
}, updateStorageStats: { path, size in
|
||||
if let pathData = path.data(using: .utf8) {
|
||||
cacheStorageBox.update(id: pathData, size: size)
|
||||
}
|
||||
})
|
||||
self.animationRenderer = MultiAnimationRendererImpl()
|
||||
self.animationRenderer = DCTMultiAnimationRendererImpl()
|
||||
self.contentSettings = contentSettings
|
||||
self.appConfiguration = appConfiguration
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import FetchManagerImpl
|
||||
import InAppPurchaseManager
|
||||
import AnimationCache
|
||||
import MultiAnimationRenderer
|
||||
import DCTAnimationCacheImpl
|
||||
import DCTMultiAnimationRendererImpl
|
||||
import AppBundle
|
||||
import DirectMediaImageCache
|
||||
|
||||
@@ -317,15 +319,15 @@ public final class AccountContextImpl: AccountContext {
|
||||
self.cachedGroupCallContexts = AccountGroupCallContextCacheImpl()
|
||||
|
||||
let cacheStorageBox = self.account.postbox.mediaBox.cacheStorageBox
|
||||
self.animationCache = AnimationCacheImpl(basePath: self.account.postbox.mediaBox.basePath + "/animation-cache", allocateTempFile: {
|
||||
self.animationCache = DCTAnimationCacheImpl(basePath: self.account.postbox.mediaBox.basePath + "/animation-cache", allocateTempFile: {
|
||||
return TempBox.shared.tempFile(fileName: "file").path
|
||||
}, updateStorageStats: { path, size in
|
||||
if let pathData = path.data(using: .utf8) {
|
||||
cacheStorageBox.update(id: pathData, size: size)
|
||||
}
|
||||
})
|
||||
self.animationRenderer = MultiAnimationRendererImpl()
|
||||
(self.animationRenderer as? MultiAnimationRendererImpl)?.useYuvA = sharedContext.immediateExperimentalUISettings.compressedEmojiCache
|
||||
self.animationRenderer = DCTMultiAnimationRendererImpl()
|
||||
(self.animationRenderer as? DCTMultiAnimationRendererImpl)?.useYuvA = sharedContext.immediateExperimentalUISettings.compressedEmojiCache
|
||||
|
||||
let updatedLimitsConfiguration = account.postbox.preferencesView(keys: [PreferencesKeys.limitsConfiguration])
|
||||
|> map { preferences -> LimitsConfiguration in
|
||||
@@ -496,7 +498,7 @@ public final class AccountContextImpl: AccountContext {
|
||||
guard let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.experimentalUISettings]?.get(ExperimentalUISettings.self) else {
|
||||
return
|
||||
}
|
||||
(self.animationRenderer as? MultiAnimationRendererImpl)?.useYuvA = settings.compressedEmojiCache
|
||||
(self.animationRenderer as? DCTMultiAnimationRendererImpl)?.useYuvA = settings.compressedEmojiCache
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user