Skip to content

Add Lottie-Windows-UwpNET.csproj #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Lottie-Windows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
50 changes: 50 additions & 0 deletions Lottie-Windows/Lottie-Windows-UwpNET/Lottie-Windows-UwpNET.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<Nullable>enable</Nullable>
<UseUwp>true</UseUwp>
<DefaultLanguage>en-US</DefaultLanguage>
<IsAotCompatible>true</IsAotCompatible>
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
<PackageId>CommunityToolkit.Uwp.Lottie</PackageId>
<PackageTags>UWP Toolkit Windows Animations Lottie XAML</PackageTags>

<DefineConstants>UWPNET</DefineConstants>
<!--
Turn off debugging information for now. It is causing errors with winmd generation because
the build system is creating CommunityToolkit.WinUI.Lottie.compile.pdb but the winmdexp
task expects the name without the "compile." in it.
-->
<DebugType>none</DebugType>
</PropertyGroup>

<PropertyGroup>
<CsWinRTComponent>true</CsWinRTComponent>
<CsWinRTGenerateProjection>false</CsWinRTGenerateProjection>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.7" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
<PackageReference Include="Win2D.uwp" Version="1.28.2" />
</ItemGroup>

<Import Project="..\Lottie-Windows.props" />
<Import Project="..\..\source\Animatables\Animatables.projitems" Label="Shared" />
<Import Project="..\..\source\DotLottie\DotLottie.projitems" Label="Shared" />
<Import Project="..\..\source\CompMetadata\CompMetadata.projitems" Label="Shared" />
<Import Project="..\..\source\GenericData\GenericData.projitems" Label="Shared" />
<Import Project="..\..\source\Lottie\Lottie.projitems" Label="Shared" />
<Import Project="..\..\source\LottieData\LottieData.projitems" Label="Shared" />
<Import Project="..\..\source\LottieMetadata\LottieMetadata.projitems" Label="Shared" />
<Import Project="..\..\source\LottieReader\LottieReader.projitems" Label="Shared" />
<Import Project="..\..\source\LottieToWinComp\LottieToWinComp.projitems" Label="Shared" />
<Import Project="..\..\source\UIData\UIData.projitems" Label="Shared" />
<Import Project="..\..\source\WinCompData\WinCompData.projitems" Label="Shared" />
<Import Project="..\..\source\WinStorageStreamsData\WinStorageStreamsData.projitems" Label="Shared" />
<Import Project="..\..\source\WinUIXamlMediaData\WinUIXamlMediaData.projitems" Label="Shared" />
<Import Project="..\..\source\YamlData\YamlData.projitems" Label="Shared" />

</Project>
11 changes: 11 additions & 0 deletions source/Lottie/LottieVisualSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public sealed partial class LottieVisualSource : DependencyObject, IDynamicAnima
{
#if WINAPPSDK
HashSet<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>> _compositionInvalidatedEventTokenTable = new HashSet<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>();
#elif UWPNET
HashSet<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>> _compositionInvalidatedEventTokenTable = new HashSet<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>();
#else
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>? _compositionInvalidatedEventTokenTable;
#endif
Expand Down Expand Up @@ -162,6 +164,8 @@ public IAsyncAction SetSourceAsync(Uri sourceUri)
{
#if WINAPPSDK
_compositionInvalidatedEventTokenTable.Add(value);
#elif UWPNET
_compositionInvalidatedEventTokenTable.Add(value);
#else
return EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>
.GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable)
Expand All @@ -173,6 +177,8 @@ public IAsyncAction SetSourceAsync(Uri sourceUri)
{
#if WINAPPSDK
_compositionInvalidatedEventTokenTable.Remove(value);
#elif UWPNET
_compositionInvalidatedEventTokenTable.Remove(value);
#else
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>
.GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable)
Expand Down Expand Up @@ -230,6 +236,11 @@ void NotifyListenersThatCompositionChanged()
{
v.Invoke(this, null);
}
#elif UWPNET
foreach (var v in _compositionInvalidatedEventTokenTable)
{
v.Invoke(this, null);
}
#else
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>
.GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable)
Expand Down
18 changes: 9 additions & 9 deletions source/UIData/Tools/Canonicalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<ICompositionSurface>(obj.Surface) into grouped
select grouped;

Expand Down Expand Up @@ -657,15 +657,15 @@ from item in GetCompositionObjects<CompositionPathGeometry>(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<PathKeyFrameAnimation>(obj.Animators[0].Animation)
let animation = CanonicalObject<PathKeyFrameAnimation>(obj.Animators.ElementAt(0).Animation)
group item.Node by (
animation,
obj.TrimStart,
Expand Down
22 changes: 11 additions & 11 deletions source/UIData/Tools/GraphCompactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,17 @@ static bool IsEquivalentContainer(CompositionContainerShape a, CompositionContai
return AreAnimatorsEquivalent(a.Animators, b.Animators);
}

static bool AreAnimatorsEquivalent(IReadOnlyList<CompositionObject.Animator> a, IReadOnlyList<CompositionObject.Animator> b)
static bool AreAnimatorsEquivalent(IEnumerable<CompositionObject.Animator> a, IEnumerable<CompositionObject.Animator> 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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -1353,7 +1353,7 @@ void TransferStructProperty<T>(Func<CompositionShape, T?> get, Action<Compositio
to.StartAnimation(anim.AnimatedProperty, anim.Animation, anim.Controller);
}

if (anim.Controller is not null && !anim.Controller.IsCustom && (anim.Controller.IsPaused || anim.Controller.Animators.Count > 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)
Expand Down Expand Up @@ -1425,7 +1425,7 @@ void TransferStructProperty<T>(Func<ContainerVisual, T?> get, Action<ContainerVi
to.StartAnimation(anim.AnimatedProperty, anim.Animation, anim.Controller);
}

if (anim.Controller is not null && !anim.Controller.IsCustom && (anim.Controller.IsPaused || anim.Controller.Animators.Count > 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)
Expand Down
6 changes: 4 additions & 2 deletions source/UIData/Tools/PropertyValueOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/UIData/Tools/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading