From ef36add38285b925b645af2184fc1243960c57e1 Mon Sep 17 00:00:00 2001 From: Min Kwon Date: Tue, 15 Apr 2025 16:23:10 -0700 Subject: [PATCH 1/2] add Lottie-Windows-UwpNET.csproj which targets .NET9 + system XAML and will be bundled together with Lottie-Windows-UWP --- Lottie-Windows.sln | 46 +++++++++++++++++ .../Lottie-Windows-UwpNET.csproj | 51 +++++++++++++++++++ source/Lottie/LottieVisualSource.cs | 11 ++++ source/UIData/Tools/Canonicalizer.cs | 18 +++---- source/UIData/Tools/GraphCompactor.cs | 22 ++++---- source/UIData/Tools/PropertyValueOptimizer.cs | 6 ++- source/UIData/Tools/Stats.cs | 2 +- .../CodeGen/InstantiatorGeneratorBase.cs | 14 ++--- source/UIDataCodeGen/CodeGen/NodeNamer.cs | 4 +- .../GraphStatsMonospaceTableFormatter.cs | 6 +-- source/WinCompData/CompositionObject.cs | 31 ++++++----- source/WinCompData/Mgcg/CanvasPathBuilder.cs | 7 ++- 12 files changed, 168 insertions(+), 50 deletions(-) create mode 100644 Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj diff --git a/Lottie-Windows.sln b/Lottie-Windows.sln index 98d1bd1f..a1b9997f 100644 --- a/Lottie-Windows.sln +++ b/Lottie-Windows.sln @@ -171,6 +171,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lottie-Windows-WinUI3", "Lo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LottieSamples", "LottieSamples\LottieSamples.csproj", "{6AB50ED0-6273-4919-9ADE-50195664EF15}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lottie-Windows-UwpNET", "Lottie-Windows\Lottie-Windows-UwpNET\Lottie-Windows-UwpNET.csproj", "{FA1977D8-5C6F-DF3A-0926-C12A1A415024}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution BETA|Any CPU = BETA|Any CPU @@ -615,6 +617,36 @@ Global {6AB50ED0-6273-4919-9ADE-50195664EF15}.Release|x86.ActiveCfg = Release|x86 {6AB50ED0-6273-4919-9ADE-50195664EF15}.Release|x86.Build.0 = Release|x86 {6AB50ED0-6273-4919-9ADE-50195664EF15}.Release|x86.Deploy.0 = Release|x86 + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|Any CPU.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|Any CPU.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|ARM.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|ARM.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|ARM64.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|ARM64.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|x64.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|x64.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|x86.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.BETA|x86.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|ARM.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|ARM.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|ARM64.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|x64.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|x64.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|x86.ActiveCfg = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Debug|x86.Build.0 = Debug|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|Any CPU.Build.0 = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|ARM.ActiveCfg = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|ARM.Build.0 = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|ARM64.ActiveCfg = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|ARM64.Build.0 = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|x64.ActiveCfg = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|x64.Build.0 = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|x86.ActiveCfg = Release|Any CPU + {FA1977D8-5C6F-DF3A-0926-C12A1A415024}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -767,6 +799,20 @@ Global source\WinStorageStreamsData\WinStorageStreamsData.projitems*{e91e3cde-3088-4b12-8472-d2c1c05b7229}*SharedItemsImports = 5 source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{e91e3cde-3088-4b12-8472-d2c1c05b7229}*SharedItemsImports = 5 source\YamlData\YamlData.projitems*{e91e3cde-3088-4b12-8472-d2c1c05b7229}*SharedItemsImports = 5 + source\Animatables\Animatables.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\CompMetadata\CompMetadata.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\DotLottie\DotLottie.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\GenericData\GenericData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\LottieData\LottieData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\LottieMetadata\LottieMetadata.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\LottieReader\LottieReader.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\LottieToWinComp\LottieToWinComp.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\Lottie\Lottie.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\UIData\UIData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\WinCompData\WinCompData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\WinStorageStreamsData\WinStorageStreamsData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 + source\YamlData\YamlData.projitems*{fa1977d8-5c6f-df3a-0926-c12a1a415024}*SharedItemsImports = 5 source\Animatables\Animatables.projitems*{fc89273a-b2da-4625-8a73-ef02a658d65e}*SharedItemsImports = 13 EndGlobalSection EndGlobal diff --git a/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj b/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj new file mode 100644 index 00000000..1a709d66 --- /dev/null +++ b/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj @@ -0,0 +1,51 @@ + + + + net9.0-windows10.0.26100.0 + 10.0.18362.0 + enable + true + en-US + true + true + CommunityToolkit.Uwp.Lottie + UWP Toolkit Windows Animations Lottie XAML + + UWPNET + + none + + + + true + false + True + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/Lottie/LottieVisualSource.cs b/source/Lottie/LottieVisualSource.cs index d33edcde..5a85a73a 100644 --- a/source/Lottie/LottieVisualSource.cs +++ b/source/Lottie/LottieVisualSource.cs @@ -34,6 +34,8 @@ public sealed partial class LottieVisualSource : DependencyObject, IDynamicAnima { #if WINAPPSDK HashSet> _compositionInvalidatedEventTokenTable = new HashSet>(); +#elif UWPNET + HashSet> _compositionInvalidatedEventTokenTable = new HashSet>(); #else EventRegistrationTokenTable>? _compositionInvalidatedEventTokenTable; #endif @@ -162,6 +164,8 @@ public IAsyncAction SetSourceAsync(Uri sourceUri) { #if WINAPPSDK _compositionInvalidatedEventTokenTable.Add(value); +#elif UWPNET + _compositionInvalidatedEventTokenTable.Add(value); #else return EventRegistrationTokenTable> .GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable) @@ -173,6 +177,8 @@ public IAsyncAction SetSourceAsync(Uri sourceUri) { #if WINAPPSDK _compositionInvalidatedEventTokenTable.Remove(value); +#elif UWPNET + _compositionInvalidatedEventTokenTable.Remove(value); #else EventRegistrationTokenTable> .GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable) @@ -230,6 +236,11 @@ void NotifyListenersThatCompositionChanged() { v.Invoke(this, null); } +#elif UWPNET + foreach (var v in _compositionInvalidatedEventTokenTable) + { + v.Invoke(this, null); + } #else EventRegistrationTokenTable> .GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable) diff --git a/source/UIData/Tools/Canonicalizer.cs b/source/UIData/Tools/Canonicalizer.cs index 6dea7110..2933872a 100644 --- a/source/UIData/Tools/Canonicalizer.cs +++ b/source/UIData/Tools/Canonicalizer.cs @@ -146,7 +146,7 @@ from item in items let obj = item.Object where (_ignoreCommentProperties || obj.Comment is null) && obj.Properties.Names.Count == 0 - && obj.Animators.Count == 0 + && obj.Animators.Count() == 0 select (item.Node, obj); } @@ -474,19 +474,19 @@ public bool Equals(ThemeBrushKey? other) // has the same properties and the same animations. var thispAnimators = thisPropertySet.Animators; var otherpAnimators = otherPropertySet.Animators; - if (thispAnimators.Count != otherpAnimators.Count) + if (thispAnimators.Count() != otherpAnimators.Count()) { return false; } - if (thispAnimators.Count != 1) + if (thispAnimators.Count() != 1) { // For now we only handle a single animator. return false; } - var thisAnimator = thispAnimators[0]; - var otherAnimator = otherpAnimators[0]; + var thisAnimator = thispAnimators.ElementAt(0); + var otherAnimator = otherpAnimators.ElementAt(0); if (thisAnimator.AnimatedProperty != otherAnimator.AnimatedProperty) { return false; @@ -566,7 +566,7 @@ from item in nodes var grouping = from item in items let obj = item.obj - where obj.Animators.Count == 0 + where obj.Animators.Count() == 0 group item.Node by CanonicalObject(obj.Surface) into grouped select grouped; @@ -657,15 +657,15 @@ from item in GetCompositionObjects(CompositionObjectTyp let obj = item.Object where (_ignoreCommentProperties || obj.Comment is null) && obj.Properties.Names.Count == 0 - && obj.Animators.Count == 1 - let animator = obj.Animators[0] + && obj.Animators.Count() == 1 + let animator = obj.Animators.ElementAt(0) where animator.AnimatedProperty == "Path" select (Node: item.Node, Object: obj); var grouping = from item in items let obj = item.Object - let animation = CanonicalObject(obj.Animators[0].Animation) + let animation = CanonicalObject(obj.Animators.ElementAt(0).Animation) group item.Node by ( animation, obj.TrimStart, diff --git a/source/UIData/Tools/GraphCompactor.cs b/source/UIData/Tools/GraphCompactor.cs index f7179be2..ddfd992a 100644 --- a/source/UIData/Tools/GraphCompactor.cs +++ b/source/UIData/Tools/GraphCompactor.cs @@ -268,17 +268,17 @@ static bool IsEquivalentContainer(CompositionContainerShape a, CompositionContai return AreAnimatorsEquivalent(a.Animators, b.Animators); } - static bool AreAnimatorsEquivalent(IReadOnlyList a, IReadOnlyList b) + static bool AreAnimatorsEquivalent(IEnumerable a, IEnumerable b) { - if (a.Count != b.Count) + if (a.Count() != b.Count()) { return false; } - for (var i = 0; i < a.Count; i++) + for (var i = 0; i < a.Count(); i++) { - var animatorA = a[i]; - var animatorB = b[i]; + var animatorA = a.ElementAt(i); + var animatorB = b.ElementAt(i); if (animatorA.AnimatedProperty != animatorB.AnimatedProperty) { @@ -311,7 +311,7 @@ n.Object is ContainerVisual container && (GetNonDefaultContainerVisualProperties(container) & (PropertyId.Clip | PropertyId.Size | PropertyId.Children)) == (PropertyId.Clip | PropertyId.Size | PropertyId.Children) && container.Clip?.Type == CompositionObjectType.InsetClip && - container.Animators.Count == 0 && + container.Animators.Count() == 0 && container.Properties.Names.Count == 0 && container.Children.Count == 1 && container.Children[0].Type == CompositionObjectType.ShapeVisual @@ -447,7 +447,7 @@ void PushContainerShapeTransformsDown( var containerProperties = GetNonDefaultShapeProperties(container); - if (container.Animators.Count != 0 || (containerProperties & ~PropertyId.TransformMatrix) != PropertyId.None) + if (container.Animators.Count() != 0 || (containerProperties & ~PropertyId.TransformMatrix) != PropertyId.None) { // Ignore this container if it has animators or anything other than the transform is set. return false; @@ -498,7 +498,7 @@ void ElideStructuralContainerShapes( var container = n.container; var containerProperties = GetNonDefaultShapeProperties(container); - if (container.Animators.Count != 0 || containerProperties != PropertyId.None) + if (container.Animators.Count() != 0 || containerProperties != PropertyId.None) { return false; } @@ -757,7 +757,7 @@ parent.Clip is InsetClip insetClip && insetClip.Scale.HasValue && insetClip.LeftInset.HasValue && insetClip.RightInset.HasValue && insetClip.TopInset.HasValue && insetClip.BottomInset.HasValue && - insetClip.Animators.Count == 0 && + insetClip.Animators.Count() == 0 && parent.Size == shapeVisual.Size && !IsPropertyAnimated(parent, PropertyId.Size) && !IsPropertyAnimated(shapeVisual, PropertyId.Size)) @@ -1353,7 +1353,7 @@ void TransferStructProperty(Func get, Action 0)) + if (anim.Controller is not null && !anim.Controller.IsCustom && (anim.Controller.IsPaused || anim.Controller.Animators.Count() > 0)) { var controller = to.TryGetAnimationController(anim.AnimatedProperty)!; if (anim.Controller.IsPaused) @@ -1425,7 +1425,7 @@ void TransferStructProperty(Func get, Action 0)) + if (anim.Controller is not null && !anim.Controller.IsCustom && (anim.Controller.IsPaused || anim.Controller.Animators.Count() > 0)) { var controller = to.TryGetAnimationController(anim.AnimatedProperty)!; if (anim.Controller.IsPaused) diff --git a/source/UIData/Tools/PropertyValueOptimizer.cs b/source/UIData/Tools/PropertyValueOptimizer.cs index 400fbdf8..dfc21d17 100644 --- a/source/UIData/Tools/PropertyValueOptimizer.cs +++ b/source/UIData/Tools/PropertyValueOptimizer.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Linq; using System.Numerics; using System.Text; using CommunityToolkit.WinUI.Lottie.WinCompData; @@ -171,7 +173,7 @@ static void OptimizeShapeProperties(CompositionShape obj) // Convert the properties to a transform matrix. This can reduce the // number of calls needed to initialize the object, and makes finding // and removing redundant containers easier. - if (obj.Animators.Count == 0) + if (obj.Animators.Count() == 0) { // Get the values for the properties, and the defaults for the properties that are not set. var centerPoint = obj.CenterPoint ?? Vector2.Zero; @@ -394,7 +396,7 @@ static void OptimizeVisualProperties(Visual obj) obj.RotationAngleInDegrees.HasValue && obj.RotationAngleInDegrees.Value != 0 && obj.RotationAxis.HasValue && obj.RotationAxis != Vector3.UnitZ; - if (obj.Animators.Count == 0 && !hasNonStandardRotation) + if (obj.Animators.Count() == 0 && !hasNonStandardRotation) { // Get the values of the properties, and the defaults for properties that are not set. var centerPoint = obj.CenterPoint ?? Vector3.Zero; diff --git a/source/UIData/Tools/Stats.cs b/source/UIData/Tools/Stats.cs index 1771a465..d20823f6 100644 --- a/source/UIData/Tools/Stats.cs +++ b/source/UIData/Tools/Stats.cs @@ -33,7 +33,7 @@ public Stats(CompositionObject? root) foreach (var (_, obj) in objectGraph.CompositionObjectNodes) { - AnimatorCount += obj.Animators.Count; + AnimatorCount += obj.Animators.Count(); CompositionObjectCount++; switch (obj.Type) diff --git a/source/UIDataCodeGen/CodeGen/InstantiatorGeneratorBase.cs b/source/UIDataCodeGen/CodeGen/InstantiatorGeneratorBase.cs index d9e81774..21272e7f 100644 --- a/source/UIDataCodeGen/CodeGen/InstantiatorGeneratorBase.cs +++ b/source/UIDataCodeGen/CodeGen/InstantiatorGeneratorBase.cs @@ -1138,7 +1138,7 @@ internal AnimatedVisualGenerator( node.RequiresStorage = true; } } - else if ((configuration.ImplementCreateAndDestroyMethods && node.Object is CompositionObject obj && obj.Animators.Count > 0) || (node.Object is AnimationController c && c.IsCustom)) + else if ((configuration.ImplementCreateAndDestroyMethods && node.Object is CompositionObject obj && obj.Animators.Count() > 0) || (node.Object is AnimationController c && c.IsCustom)) { // If we are implementing IAnimatedVisual2 interface we need to store all the composition objects that have animators. node.RequiresStorage = true; @@ -1957,10 +1957,10 @@ void StartAnimation(CodeBuilder builder, CompositionObject obj, ObjectData node, var controllerAnimators = controller.Animators; - if (controllerAnimators.Count == 1) + if (controllerAnimators.Count() == 1) { // The controller has only one property being animated. - var controllerAnimator = controllerAnimators[0]; + var controllerAnimator = controllerAnimators.ElementAt(0); if (controllerAnimator.AnimatedProperty == "Progress" && controllerAnimator.Animation is ExpressionAnimation controllerExpressionAnimation && controller.IsPaused) @@ -2970,7 +2970,7 @@ bool GenerateCompositionPathGeometryFactory(CodeBuilder builder, CompositionPath var createPathText = path is null ? string.Empty : CallFactoryFromFor(node, path); var createPathGeometryText = $"_c{Deref}CreatePathGeometry({createPathText})"; - if (obj.Animators.Count == 0 && + if (obj.Animators.Count() == 0 && obj.Properties.Names.Count == 0 && !obj.TrimEnd.HasValue && !obj.TrimOffset.HasValue && @@ -2996,7 +2996,7 @@ bool GenerateCompositionColorBrushFactory(CodeBuilder builder, CompositionColorB ? $"_c{Deref}CreateColorBrush({Color(obj.Color.Value)})" : $"_c{Deref}CreateColorBrush()"; - if (obj.Animators.Count > 0) + if (obj.Animators.Count() > 0) { WriteObjectFactoryStart(builder, node); WriteCreateAssignment(builder, node, createCallText); @@ -3013,7 +3013,7 @@ bool GenerateCompositionColorBrushFactory(CodeBuilder builder, CompositionColorB bool GenerateCompositionColorGradientStopFactory(CodeBuilder builder, CompositionColorGradientStop obj, ObjectData node) { - if (obj.Animators.Count > 0) + if (obj.Animators.Count() > 0) { WriteObjectFactoryStart(builder, node); WriteCreateAssignment(builder, node, $"_c{Deref}CreateColorGradientStop({Float(obj.Offset)}, {Color(obj.Color)})"); @@ -3165,7 +3165,7 @@ bool GenerateCompositionSurfaceBrushFactory(CodeBuilder builder, CompositionSurf var isReachableFromSurfaceNode = node.IsReachableFrom(surfaceNode); - if (obj.Animators.Count == 0 && + if (obj.Animators.Count() == 0 && obj.Properties.Names.Count == 0 && !isReachableFromSurfaceNode) { diff --git a/source/UIDataCodeGen/CodeGen/NodeNamer.cs b/source/UIDataCodeGen/CodeGen/NodeNamer.cs index e153cd60..00c9ae72 100644 --- a/source/UIDataCodeGen/CodeGen/NodeNamer.cs +++ b/source/UIDataCodeGen/CodeGen/NodeNamer.cs @@ -168,7 +168,7 @@ static NodeName NameCompositionColorBrush(CompositionColorBrush obj) { // Color brushes that are not animated get names describing their color. // Optimization ensures there will only be one brush for any one non-animated color. - if (obj.Animators.Count > 0) + if (obj.Animators.Count() > 0) { // Brush is animated. Give it a name based on the colors in the animation. var colorAnimation = obj.Animators.Where(a => a.AnimatedProperty == "Color").First().Animation; @@ -192,7 +192,7 @@ static NodeName NameCompositionColorGradientStop(CompositionColorGradientStop ob { var offsetId = FloatAsId(obj.Offset); - if (obj.Animators.Count > 0) + if (obj.Animators.Count() > 0) { var baseName = $"AnimatedGradientStop_{offsetId}"; diff --git a/source/UIDataCodeGen/CodeGen/Tables/GraphStatsMonospaceTableFormatter.cs b/source/UIDataCodeGen/CodeGen/Tables/GraphStatsMonospaceTableFormatter.cs index abefdaa1..30b19df4 100644 --- a/source/UIDataCodeGen/CodeGen/Tables/GraphStatsMonospaceTableFormatter.cs +++ b/source/UIDataCodeGen/CodeGen/Tables/GraphStatsMonospaceTableFormatter.cs @@ -57,8 +57,8 @@ where o is CompositionObject animatorCounts.referenceParameters, animatorCounts.operations, Row.Separator, - GetCompositionObjectCountRecord(compositionObjects, "Animated brushes", (o) => o is CompositionBrush b && b.Animators.Count > 0), - GetCompositionObjectCountRecord(compositionObjects, "Animated gradient stops", (o) => o is CompositionColorGradientStop s && s.Animators.Count > 0), + GetCompositionObjectCountRecord(compositionObjects, "Animated brushes", (o) => o is CompositionBrush b && b.Animators.Count() > 0), + GetCompositionObjectCountRecord(compositionObjects, "Animated gradient stops", (o) => o is CompositionColorGradientStop s && s.Animators.Count() > 0), GetCompositionObjectCountRecord(compositionObjects, "ExpressionAnimations", (o) => o.Type == CompositionObjectType.ExpressionAnimation), GetCompositionObjectCountRecord(compositionObjects, "PathKeyFrameAnimations", (o) => o.Type == CompositionObjectType.PathKeyFrameAnimation), Row.Separator, @@ -156,7 +156,7 @@ from keyFrame in ((KeyFrameAnimation_)a.Animation).KeyFrames operations += expressionKeyFrames.Sum(e => e.Expression.OperationsCount); // Key frame animations are the animations that are not expression animations. - keyFrames += animators.Count - expressionAnimations.Length; + keyFrames += animators.Count() - expressionAnimations.Length; } return (ColumnData.Create(expressions), ColumnData.Create(keyFrames), ColumnData.Create(referenceParameters), ColumnData.Create(operations)); diff --git a/source/WinCompData/CompositionObject.cs b/source/WinCompData/CompositionObject.cs index f36ae4a5..f55e319d 100644 --- a/source/WinCompData/CompositionObject.cs +++ b/source/WinCompData/CompositionObject.cs @@ -5,6 +5,7 @@ #nullable enable using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -22,7 +23,7 @@ abstract class CompositionObject : IDisposable, IDescribable static readonly Guid s_longDescriptionMetadataKey = new Guid("63514254-2B3E-4794-B01D-9F67D5946A7E"); static readonly Guid s_nameMetadataKey = new Guid("6EB18A31-FA33-43B9-8EE1-57B489DC3404"); - readonly List _animators = new List(); + readonly ArrayList _animators = new ArrayList(); // Null until the first metadata is set. SortedDictionary? _metadata; @@ -183,17 +184,21 @@ public void StopAnimation(string propertyName) for (var i = 0; i < _animators.Count; i++) { - var animatorPropertyName = _animators[i].AnimatedProperty; - - if (animatorPropertyName == propertyName || - animatorPropertyName == rootPropertyName || - animatorPropertyName.StartsWith(subChannelPrefix)) + var temp = _animators[i]; + if (temp != null) { - _animators.RemoveAt(i); - - // Adjust the iteration variable to ensure we don't miss the - // animator just after the one we just removed. - i--; + var animatorPropertyName = ((Animator)temp).AnimatedProperty; + + if (animatorPropertyName == propertyName || + animatorPropertyName == rootPropertyName || + animatorPropertyName.StartsWith(subChannelPrefix)) + { + _animators.RemoveAt(i); + + // Adjust the iteration variable to ensure we don't miss the + // animator just after the one we just removed. + i--; + } } } } @@ -201,10 +206,10 @@ public void StopAnimation(string propertyName) /// /// Gets the animators that are bound to this object. /// - public IReadOnlyList Animators => _animators; + public IEnumerable Animators => _animators.Cast(); public AnimationController? TryGetAnimationController(string target) => - _animators.Where(a => a.AnimatedProperty == target).SingleOrDefault()?.Controller; + _animators.Cast().Where(a => a.AnimatedProperty == target).SingleOrDefault()?.Controller; public abstract CompositionObjectType Type { get; } diff --git a/source/WinCompData/Mgcg/CanvasPathBuilder.cs b/source/WinCompData/Mgcg/CanvasPathBuilder.cs index 11789307..53677ffe 100644 --- a/source/WinCompData/Mgcg/CanvasPathBuilder.cs +++ b/source/WinCompData/Mgcg/CanvasPathBuilder.cs @@ -5,7 +5,9 @@ #nullable enable using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Numerics; using CommunityToolkit.WinUI.Lottie.WinCompData.Mgc; @@ -16,7 +18,8 @@ namespace CommunityToolkit.WinUI.Lottie.WinCompData.Mgcg #endif sealed class CanvasPathBuilder : IDisposable { - readonly List _commands = new List(); + readonly ArrayList _commands = new ArrayList(); + bool _isFilledRegionDeterminationSet; public CanvasPathBuilder(CanvasDevice? device) @@ -59,7 +62,7 @@ public void SetFilledRegionDetermination(CanvasFilledRegionDetermination value) internal CanvasFilledRegionDetermination FilledRegionDetermination { get; private set; } - internal IEnumerable Commands => _commands; + internal IEnumerable Commands => _commands.Cast(); /// public void Dispose() From 0c993690fb072572d3d9d3b60001cdf67806ed23 Mon Sep 17 00:00:00 2001 From: Min Kwon Date: Wed, 16 Apr 2025 14:49:09 -0700 Subject: [PATCH 2/2] remove from csproj --- .../Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj b/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj index 1a709d66..61719a50 100644 --- a/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj +++ b/Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj @@ -23,7 +23,6 @@ true false - True