Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,63 @@
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",
module_name = "MultiAnimationRenderer",
srcs = glob([
"Sources/**/*.swift",
]),
data = [
":MultiAnimationRendererBundle",
],
copts = [
"-warnings-as-errors",
],
deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Display:Display",
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
],
visibility = [
"//visibility:public",
],
)
@@ -0,0 +1,46 @@
#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);
}