Add support for LayerVisual and DropShadow Composition types. Cleanup. (#390)

* Add support for LayerVisual and DropShadow Composition types. Much cleanup.

Getting ready to actually support DropShadow - we need some Composition types added.
As a result of adding the Composition types, I noticed many small cleanup tasks and included them.

Fix issues caused by update to VS 16.8 release.
Remove NullablesAttributes workaround for .NET Core 3.1 projects.
Now that we are building the .dll projects with .NET Core 3.1, the NullablesAttributes project is redundant and conflicts with the built-in nullables support in .NET Core.
This commit is contained in:
Simeon 2020-11-20 14:37:40 -08:00 коммит произвёл GitHub
Родитель dde5f0b1d0
Коммит 5bb8140bab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
51 изменённых файлов: 843 добавлений и 372 удалений

Просмотреть файл

@ -175,15 +175,12 @@ Global
source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
source\YamlData\YamlData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
source\LottieData\LottieData.projitems*{6221591a-e8f4-4a5e-8f0c-2651c24ad495}*SharedItemsImports = 5
source\NullablesAttributes\NullablesAttributes.projitems*{6221591a-e8f4-4a5e-8f0c-2651c24ad495}*SharedItemsImports = 5
source\NullablesAttributes\NullablesAttributes.projitems*{68317393-f5a5-4b2c-918a-688db2c10f54}*SharedItemsImports = 5
source\WinCompData\WinCompData.projitems*{68317393-f5a5-4b2c-918a-688db2c10f54}*SharedItemsImports = 5
source\NullablesAttributes\NullablesAttributes.projitems*{6ab50ed0-6273-4919-9ade-50195664ef15}*SharedItemsImports = 4
source\DotLottie\DotLottie.projitems*{7012420d-624c-4bd4-a1d2-1c6c1655ed3a}*SharedItemsImports = 13
source\UIData\UIData.projitems*{74601e6c-2dfe-4842-b170-047941abff2c}*SharedItemsImports = 13
source\GenericData\GenericData.projitems*{77bcd724-8555-463b-985f-f8e8110164c4}*SharedItemsImports = 13
source\Lottie\Lottie.projitems*{8ef7bd77-28e9-4998-8dbb-8036f988fe65}*SharedItemsImports = 13
source\NullablesAttributes\NullablesAttributes.projitems*{9a99e690-71d2-4e26-9000-0e0920394dfe}*SharedItemsImports = 5
source\UIData\UIData.projitems*{9a99e690-71d2-4e26-9000-0e0920394dfe}*SharedItemsImports = 5
source\UIDataCodeGen\UIDataCodeGen.projitems*{9b6c0b7f-0d0f-4086-9746-0d34d7667db5}*SharedItemsImports = 5
source\CompMetadata\CompMetadata.projitems*{a262757c-9f1a-4f6e-9188-849f4b709d67}*SharedItemsImports = 5
@ -193,7 +190,6 @@ Global
source\LottieData\LottieData.projitems*{b3db16ee-a821-4474-a188-e64926529bbd}*SharedItemsImports = 13
source\LottieReader\LottieReader.projitems*{bb081e5a-cf3c-490f-8f8e-450a79f6ca33}*SharedItemsImports = 5
source\LottieToWinComp\LottieToWinComp.projitems*{bcedf904-f986-42ec-a22d-e0662777b7f9}*SharedItemsImports = 5
source\NullablesAttributes\NullablesAttributes.projitems*{bcedf904-f986-42ec-a22d-e0662777b7f9}*SharedItemsImports = 5
source\CompMetadata\CompMetadata.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
source\DotLottie\DotLottie.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
source\GenericData\GenericData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
@ -207,7 +203,6 @@ Global
source\WinStorageStreamsData\WinStorageStreamsData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
source\YamlData\YamlData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
source\NullablesAttributes\NullablesAttributes.projitems*{cb587630-3cfd-4bb3-867c-3f5b1ffbc738}*SharedItemsImports = 5
source\YamlData\YamlData.projitems*{cb587630-3cfd-4bb3-867c-3f5b1ffbc738}*SharedItemsImports = 5
source\WinCompData\WinCompData.projitems*{d02870de-7ded-4916-85d4-3175ceedef74}*SharedItemsImports = 13
source\UIDataCodeGen\UIDataCodeGen.projitems*{d02be6c8-14db-4b4f-8600-f3c9b69c104d}*SharedItemsImports = 13

Просмотреть файл

@ -284,6 +284,7 @@ sealed class LottieJsonFileProcessor
("ExpressionAnimation", translationStats.ExpressionAnimationCount.ToString()),
("GeometricClip", translationStats.GeometricClipCount.ToString()),
("InsetClip", translationStats.InsetClipCount.ToString()),
("LayerVisual", translationStats.LayerVisualCount.ToString()),
("LinearEasingFunction", translationStats.LinearEasingFunctionCount.ToString()),
("LinearGradientBrush", translationStats.LinearGradientBrushCount.ToString()),
("PathGeometry", translationStats.PathGeometryCount.ToString()),

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_CompMetadata</DefineConstants>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_LottieData</DefineConstants>

Просмотреть файл

@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_LottieData</DefineConstants>
</PropertyGroup>
<Import Project="..\..\source\LottieData\LottieData.projitems" Label="Shared" />
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.4" />

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_LottieMetadata</DefineConstants>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_LottieReader</DefineConstants>

Просмотреть файл

@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_LottieToWinComp</DefineConstants>
</PropertyGroup>
<Import Project="..\..\source\LottieToWinComp\LottieToWinComp.projitems" Label="Shared" />
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
<ItemGroup>
<ProjectReference Include="..\CompMetadata\CompMetadata.dll.csproj" />

Просмотреть файл

@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_UIData</DefineConstants>
</PropertyGroup>
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
<Import Project="..\..\source\UIData\UIData.projitems" Label="Shared" />
<ItemGroup>

Просмотреть файл

@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_WinCompData</DefineConstants>
</PropertyGroup>
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
<Import Project="..\..\source\WinCompData\WinCompData.projitems" Label="Shared" />
<ItemGroup>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_WinStorageStreamsData</DefineConstants>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_WinUIXamlMediaData</DefineConstants>

Просмотреть файл

@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
<DefineConstants>PUBLIC_YamlData</DefineConstants>
</PropertyGroup>
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
<Import Project="..\..\source\YamlData\YamlData.projitems" Label="Shared" />
</Project>

Просмотреть файл

@ -6,7 +6,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
@ -20,7 +19,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
GenericDataMap(IDictionary<string, GenericDataObject?> items)
{
_items = items.ToDictionary(x => x.Key, x => x.Value);
_items = new Dictionary<string, GenericDataObject?>(items);
}
public static GenericDataMap Create(IDictionary<string, GenericDataObject?> items)

Просмотреть файл

@ -27,7 +27,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
{
}
[return: NotNullIfNotNull("file")]
internal static async Task<AnimatedVisualFactory?> LoadAsync(
StorageFile file,
LottieVisualOptions options)

Просмотреть файл

@ -27,7 +27,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
_inputStream = inputStream;
}
[return: NotNullIfNotNull("inputStream")]
internal static async Task<AnimatedVisualFactory?> LoadAsync(
ImageAssetHandler? imageLoader,
IInputStream inputStream,

Просмотреть файл

@ -135,8 +135,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
target.InterpolationSpace = ColorSpace(source.InterpolationSpace.Value);
}
// Default mapping mode is Relative.
if (source.MappingMode.HasValue && source.MappingMode.Value != Wd.CompositionMappingMode.Relative)
if (source.MappingMode.HasValue)
{
target.MappingMode = MappingMode(source.MappingMode.Value);
}
@ -281,6 +280,25 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
return obj;
}
Wc.LayerVisual GetLayerVisual(Wd.LayerVisual obj)
{
if (GetExisting<Wc.LayerVisual>(obj, out var result))
{
return result;
}
result = CacheAndInitializeVisual(obj, _c.CreateLayerVisual());
if (obj.Shadow != null)
{
result.Shadow = GetCompositionShadow(obj.Shadow);
}
InitializeContainerVisual(obj, result);
StartAnimations(obj, result);
return result;
}
Wc.ShapeVisual GetShapeVisual(Wd.ShapeVisual obj)
{
if (GetExisting<Wc.ShapeVisual>(obj, out var result))
@ -428,8 +446,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
Wd.CompositionObjectType.ContainerVisual => GetContainerVisual((Wd.ContainerVisual)obj),
Wd.CompositionObjectType.CubicBezierEasingFunction => GetCubicBezierEasingFunction((Wd.CubicBezierEasingFunction)obj),
Wd.CompositionObjectType.CompositionSurfaceBrush => GetCompositionSurfaceBrush((Wd.CompositionSurfaceBrush)obj),
Wd.CompositionObjectType.DropShadow => GetDropShadow((Wd.DropShadow)obj),
Wd.CompositionObjectType.ExpressionAnimation => GetExpressionAnimation((Wd.ExpressionAnimation)obj),
Wd.CompositionObjectType.InsetClip => GetInsetClip((Wd.InsetClip)obj),
Wd.CompositionObjectType.LayerVisual => GetLayerVisual((Wd.LayerVisual)obj),
Wd.CompositionObjectType.LinearEasingFunction => GetLinearEasingFunction((Wd.LinearEasingFunction)obj),
Wd.CompositionObjectType.PathKeyFrameAnimation => GetPathKeyFrameAnimation((Wd.PathKeyFrameAnimation)obj),
Wd.CompositionObjectType.ScalarKeyFrameAnimation => GetScalarKeyFrameAnimation((Wd.ScalarKeyFrameAnimation)obj),
@ -514,6 +534,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
obj.Type switch
{
Wd.CompositionObjectType.ContainerVisual => GetContainerVisual((Wd.ContainerVisual)obj),
Wd.CompositionObjectType.LayerVisual => GetLayerVisual((Wd.LayerVisual)obj),
Wd.CompositionObjectType.ShapeVisual => GetShapeVisual((Wd.ShapeVisual)obj),
Wd.CompositionObjectType.SpriteVisual => GetSpriteVisual((Wd.SpriteVisual)obj),
_ => throw new InvalidOperationException(),
@ -605,7 +626,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
result = CacheAndInitializeKeyFrameAnimation(obj, _c.CreateColorKeyFrameAnimation());
if (obj.InterpolationColorSpace != default(Wd.CompositionColorSpace))
if (obj.InterpolationColorSpace != Wd.CompositionColorSpace.Auto)
{
result.InterpolationColorSpace = (Wc.CompositionColorSpace)obj.InterpolationColorSpace;
}
@ -872,29 +893,29 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
}
result = CacheAndInitializeCompositionObject(obj, _c.CreateStepEasingFunction());
if (obj.FinalStep != 1)
if (obj.FinalStep.HasValue)
{
result.FinalStep = obj.FinalStep;
result.FinalStep = obj.FinalStep.Value;
}
if (obj.InitialStep != 0)
if (obj.InitialStep.HasValue)
{
result.InitialStep = obj.InitialStep;
result.InitialStep = obj.InitialStep.Value;
}
if (obj.IsFinalStepSingleFrame)
if (obj.IsFinalStepSingleFrame.HasValue)
{
result.IsFinalStepSingleFrame = obj.IsFinalStepSingleFrame;
result.IsFinalStepSingleFrame = obj.IsFinalStepSingleFrame.Value;
}
if (obj.IsInitialStepSingleFrame)
if (obj.IsInitialStepSingleFrame.HasValue)
{
result.IsInitialStepSingleFrame = obj.IsInitialStepSingleFrame;
result.IsInitialStepSingleFrame = obj.IsInitialStepSingleFrame.Value;
}
if (obj.StepCount != 1)
if (obj.StepCount.HasValue)
{
result.StepCount = obj.StepCount;
result.StepCount = obj.StepCount.Value;
}
StartAnimations(obj, result);
@ -913,6 +934,56 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
return result;
}
Wc.CompositionShadow GetCompositionShadow(Wd.CompositionShadow obj) =>
obj.Type switch
{
Wd.CompositionObjectType.DropShadow => GetDropShadow((Wd.DropShadow)obj),
_ => throw new InvalidOperationException(),
};
Wc.DropShadow GetDropShadow(Wd.DropShadow obj)
{
if (GetExisting<Wc.DropShadow>(obj, out var result))
{
return result;
}
result = CacheAndInitializeCompositionObject(obj, _c.CreateDropShadow());
if (obj.BlurRadius.HasValue)
{
result.BlurRadius = obj.BlurRadius.Value;
}
if (obj.Color.HasValue)
{
result.Color = Color(obj.Color.Value);
}
if (obj.Mask != null)
{
result.Mask = GetCompositionBrush(obj.Mask);
}
if (obj.Offset.HasValue)
{
result.Offset = obj.Offset.Value;
}
if (obj.Opacity.HasValue)
{
result.Opacity = obj.Opacity.Value;
}
if (obj.SourcePolicy.HasValue)
{
result.SourcePolicy = DropShadowSourcePolicy(obj.SourcePolicy.Value);
}
StartAnimations(obj, result);
return result;
}
Wc.CompositionViewBox GetCompositionViewBox(Wd.CompositionViewBox obj)
{
if (GetExisting<Wc.CompositionViewBox>(obj, out var result))
@ -969,24 +1040,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
return result;
}
// If this container has only 1 child, it might be coalescable with its child.
if (obj.Shapes.Count == 1)
{
var child = obj.Shapes[0];
if (obj.Animators.Count == 0)
{
// The container has no animations. It can be replaced with its child as
// long as the child doesn't animate any of the non-default properties and
// the container isn't referenced by an animation.
}
else if (child.Animators.Count == 0 && child.Type == Wd.CompositionObjectType.CompositionContainerShape)
{
// The child has no animations. It can be replaced with its parent as long
// as the parent doesn't animate any of the child's non-default properties
// and the child isn't referenced by an animation.
}
}
result = CacheAndInitializeShape(obj, _c.CreateContainerShape());
var shapeCollection = result.Shapes;
foreach (var child in obj.Shapes)
@ -1082,14 +1135,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
result.StrokeLineJoin = StrokeLineJoin(obj.StrokeLineJoin.Value);
}
if (obj.StrokeDashOffset != 0)
if (obj.StrokeDashOffset.HasValue)
{
result.StrokeDashOffset = obj.StrokeDashOffset;
result.StrokeDashOffset = obj.StrokeDashOffset.Value;
}
if (obj.IsStrokeNonScaling)
if (obj.IsStrokeNonScaling.HasValue)
{
result.IsStrokeNonScaling = obj.IsStrokeNonScaling;
result.IsStrokeNonScaling = obj.IsStrokeNonScaling.Value;
}
var strokeDashArray = result.StrokeDashArray;
@ -1495,6 +1548,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
static Windows.UI.Color Color(Wd.Wui.Color color) =>
Windows.UI.Color.FromArgb(color.A, color.R, color.G, color.B);
static Wc.CompositionDropShadowSourcePolicy DropShadowSourcePolicy(Wd.CompositionDropShadowSourcePolicy value) =>
value switch
{
Wd.CompositionDropShadowSourcePolicy.Default => Wc.CompositionDropShadowSourcePolicy.Default,
Wd.CompositionDropShadowSourcePolicy.InheritFromVisualContent => Wc.CompositionDropShadowSourcePolicy.InheritFromVisualContent,
_ => throw new InvalidOperationException(),
};
static CanvasFilledRegionDetermination FilledRegionDetermination(
Wd.Mgcg.CanvasFilledRegionDetermination value) =>
value switch

Просмотреть файл

@ -9,7 +9,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
/// <summary>
/// An issue that was discovered while reading or translating a Lottie JSON file.
/// </summary>
public sealed class Issue
sealed class Issue
{
internal Issue(string code, string description)
{

Просмотреть файл

@ -17,7 +17,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
/// <summary>
/// Diagnostics information about a Lottie and its translation.
/// </summary>
public sealed class LottieVisualDiagnostics
sealed class LottieVisualDiagnostics
{
public string FileName { get; internal set; } = string.Empty;

Просмотреть файл

@ -29,7 +29,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
_storageFile = storageFile;
}
[return: NotNullIfNotNull("file")]
internal static async Task<AnimatedVisualFactory?> LoadAsync(
ImageAssetHandler? imageLoader,
StorageFile file,

Просмотреть файл

@ -5,7 +5,6 @@
#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
using Windows.UI.Composition;
@ -24,7 +23,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
_imageLoader = imageLoader;
}
[return: NotNullIfNotNull("uri")]
internal static async Task<AnimatedVisualFactory?> LoadAsync(
ImageAssetHandler? imageLoader,
Uri uri,

Просмотреть файл

@ -16,7 +16,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
/// Relative URIs are made relative to ms-appx:///.
/// </summary>
/// <returns>A Uri or null.</returns>
[return: NotNullIfNotNull("uri")]
public static Uri? StringToUri(string uri)
{
if (!Uri.IsWellFormedUriString(uri, UriKind.RelativeOrAbsolute))

Просмотреть файл

@ -254,7 +254,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
sprite.StrokeBrush = brush;
}
[return: NotNullIfNotNull("shapeFill")]
public static CompositionBrush? TranslateShapeFill(LayerContext context, ShapeFill? shapeFill, CompositeOpacity opacity)
{
if (shapeFill is null)

Просмотреть файл

@ -246,6 +246,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
internal Vector4KeyFrameAnimation CreateVector4KeyFrameAnimation() => _compositor.CreateVector4KeyFrameAnimation();
internal DropShadow CreateDropShadow() => _compositor.CreateDropShadow();
internal InsetClip CreateInsetClip() => _compositor.CreateInsetClip();
internal CompositionGeometricClip CreateGeometricClip() => _compositor.CreateGeometricClip();
@ -254,6 +256,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
internal ContainerVisual CreateContainerVisual() => _compositor.CreateContainerVisual();
internal LayerVisual CreateLayerVisual() => _compositor.CreateLayerVisual();
internal SpriteVisual CreateSpriteVisual() => _compositor.CreateSpriteVisual();
internal ShapeVisual CreateShapeVisualWithChild(CompositionShape child, Sn.Vector2 size)

Просмотреть файл

@ -5,6 +5,8 @@
#nullable enable
using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
#if DEBUG
// For diagnosing issues, give nothing a clip.
@ -29,8 +31,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
return null;
}
var result = context.ObjectFactory.CreateContainerVisual();
#if !NoClipping
// PreComps must clip to their size.
// Create another ContainerVisual to apply clipping to.
@ -55,6 +55,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
#if !NoClipping
layerHasMasks = context.Layer.Masks.Any();
#endif
var result = context.ObjectFactory.CreateContainerVisual();
if (layerHasMasks)
{
var compositedVisual = Masks.TranslateAndApplyMasksForLayer(context, rootNode);
@ -66,6 +68,27 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
result.Children.Add(rootNode);
}
#if DropShadows // Drop shadows are not yet supported.
var dropShadowEffects =
context.Layer.Effects.Where(eff => eff.Type == LottieData.Effect.EffectType.DropShadow).ToArray();
if (dropShadowEffects.Length > 0 && dropShadowEffects.All(eff => eff.Type == LottieData.Effect.EffectType.DropShadow))
{
// TODO - if they're not all drop shadows, ISSUE.
// TODO - ignore if not enabled.
// Create a LayerVisual so we can add a drop shadow.
var layerVisual = context.ObjectFactory.CreateLayerVisual();
var shadow = context.ObjectFactory.CreateDropShadow();
layerVisual.Shadow = shadow;
// TODO - use the correct value.
shadow.Offset = new System.Numerics.Vector3(1);
layerVisual.Children.Add(result);
result = layerVisual;
}
#endif // DropShadows
return new LayerTranslator.FromVisual(result);
}
}

Просмотреть файл

@ -55,6 +55,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
// Find the nodes that are equivalent and point them all to a single canonical representation.
void Canonicalize()
{
CanonicalizeDropShadows();
CanonicalizeInsetClips();
CanonicalizeEllipseGeometries();
CanonicalizeRectangleGeometries();
@ -700,6 +701,26 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
CanonicalizeGrouping(grouping);
}
void CanonicalizeDropShadows()
{
var items = GetCanonicalizableCompositionObjects<DropShadow>(CompositionObjectType.DropShadow);
var grouping =
from item in items
let obj = item.Object
group item.Node by (
obj.BlurRadius,
obj.Color,
obj.Mask,
obj.Offset,
obj.Opacity,
obj.SourcePolicy)
into grouped
select grouped;
CanonicalizeGrouping(grouping);
}
void CanonicalizeInsetClips()
{
var items = GetCanonicalizableCompositionObjects<InsetClip>(CompositionObjectType.InsetClip);

Просмотреть файл

@ -77,14 +77,25 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
switch (node.Object.Type)
{
case CompositionObjectType.CompositionContainerShape:
case CompositionObjectType.ShapeVisual:
foreach (var child in ((IContainShapes)node.Object).Shapes)
{
graph[child].Parent = node.Object;
}
break;
case CompositionObjectType.ShapeVisual:
foreach (var child in ((IContainShapes)node.Object).Shapes)
{
graph[child].Parent = node.Object;
}
// ShapeVisual is also a ContainerVisual.
goto case CompositionObjectType.ContainerVisual;
case CompositionObjectType.ContainerVisual:
case CompositionObjectType.LayerVisual:
case CompositionObjectType.SpriteVisual:
foreach (var child in ((ContainerVisual)node.Object).Children)
{
graph[child].Parent = node.Object;

Просмотреть файл

@ -173,7 +173,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
VisitContainerVisual((ContainerVisual)obj, node);
break;
case CompositionObjectType.CubicBezierEasingFunction:
VisitCubicBezierEasingFunction(node, (CubicBezierEasingFunction)obj);
VisitCubicBezierEasingFunction((CubicBezierEasingFunction)obj, node);
break;
case CompositionObjectType.DropShadow:
VisitDropShadow((DropShadow)obj, node);
break;
case CompositionObjectType.ExpressionAnimation:
VisitExpressionAnimation((ExpressionAnimation)obj, node);
@ -181,6 +184,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
case CompositionObjectType.InsetClip:
VisitInsetClip((InsetClip)obj, node);
break;
case CompositionObjectType.LayerVisual:
VisitLayerVisual((LayerVisual)obj, node);
break;
case CompositionObjectType.LinearEasingFunction:
VisitLinearEasingFunction((LinearEasingFunction)obj, node);
break;
@ -424,6 +430,23 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
return VisitCompositionGeometry(obj, node);
}
bool VisitCompositionShadow(CompositionShadow obj, T node)
{
return VisitCompositionObject(obj, node);
}
bool VisitDropShadow(DropShadow obj, T node)
{
VisitCompositionShadow(obj, node);
if (obj.Mask != null)
{
Reference(node, obj.Mask);
}
return true;
}
bool VisitExpressionAnimation(ExpressionAnimation obj, T node)
{
return VisitCompositionAnimation(obj, node);
@ -444,11 +467,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
return VisitCompositionObject(obj, node);
}
bool VisitCubicBezierEasingFunction(T node, CubicBezierEasingFunction obj)
bool VisitCubicBezierEasingFunction(CubicBezierEasingFunction obj, T node)
{
return VisitCompositionEasingFunction(obj, node);
}
bool VisitLayerVisual(LayerVisual obj, T node)
{
VisitContainerVisual(obj, node);
Reference(node, obj.Shadow);
return true;
}
bool VisitLinearEasingFunction(LinearEasingFunction obj, T node)
{
return VisitCompositionEasingFunction(obj, node);

Просмотреть файл

@ -34,16 +34,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
public static Visual Optimize(Visual root, bool ignoreCommentProperties)
{
// Build the object graph.
var graph = ObjectGraph<ObjectData>.FromCompositionObject(root, includeVertices: true);
// Find the canonical objects in the graph.
Canonicalizer.Canonicalize(graph, ignoreCommentProperties: ignoreCommentProperties);
// Create a copy of the WinCompData objects from the canonical objects.
// The copy is needed so that we can modify the tree without affecting the graph that
// was given to us.
var result = (Visual)new Optimizer(graph).GetCompositionObject(root);
var result = CanonicalizeGraph(root, ignoreCommentProperties);
AssertGraphsAreDisjoint(result, root);
@ -57,9 +48,27 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
// Re-run the property value optimizer because the compactor may have set new properties.
result = PropertyValueOptimizer.OptimizePropertyValues(result);
// The graph compactor may create new CompositionObjects (e.g. BooleanKeyFrameAnimations).
// Re-run the canonicalizer so that the new objects are canonicalized.
result = CanonicalizeGraph(result, ignoreCommentProperties);
return result;
}
static Visual CanonicalizeGraph(Visual root, bool ignoreCommentProperties)
{
// Build the object graph.
var graph = ObjectGraph<ObjectData>.FromCompositionObject(root, includeVertices: true);
// Find the canonical objects in the graph.
Canonicalizer.Canonicalize(graph, ignoreCommentProperties: ignoreCommentProperties);
// Create a copy of the WinCompData objects from the canonical objects.
// The copy is needed so that we can modify the tree without affecting the graph that
// was given to us.
return (Visual)new Optimizer(graph).GetCompositionObject(root);
}
// Asserts that the 2 graphs are disjoint. If this assert ever fires then
// the graph copier is broken - it is reusing an object rather than making
// a copy.
@ -297,6 +306,45 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
return obj;
}
DropShadow GetDropShadow(DropShadow obj)
{
if (GetExisting(obj, out var result))
{
return result;
}
result = CacheAndInitializeCompositionObject(obj, _c.CreateDropShadow());
result.BlurRadius = obj.BlurRadius;
result.Color = obj.Color;
result.Mask = obj.Mask;
result.Offset = obj.Offset;
result.Opacity = obj.Opacity;
result.SourcePolicy = obj.SourcePolicy;
StartAnimationsAndFreeze(obj, result);
return result;
}
LayerVisual GetLayerVisual(LayerVisual obj)
{
if (GetExisting(obj, out var result))
{
return result;
}
result = CacheAndInitializeVisual(obj, _c.CreateLayerVisual());
if (obj.Shadow != null)
{
result.Shadow = GetCompositionShadow(obj.Shadow);
}
InitializeContainerVisual(obj, result);
StartAnimationsAndFreeze(obj, result);
return result;
}
ShapeVisual GetShapeVisual(ShapeVisual obj)
{
if (GetExisting(obj, out var result))
@ -450,8 +498,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
CompositionObjectType.CompositionVisualSurface => GetCompositionVisualSurface((CompositionVisualSurface)obj),
CompositionObjectType.ContainerVisual => GetContainerVisual((ContainerVisual)obj),
CompositionObjectType.CubicBezierEasingFunction => GetCubicBezierEasingFunction((CubicBezierEasingFunction)obj),
CompositionObjectType.DropShadow => GetDropShadow((DropShadow)obj),
CompositionObjectType.ExpressionAnimation => GetExpressionAnimation((ExpressionAnimation)obj),
CompositionObjectType.InsetClip => GetInsetClip((InsetClip)obj),
CompositionObjectType.LayerVisual => GetLayerVisual((LayerVisual)obj),
CompositionObjectType.LinearEasingFunction => GetLinearEasingFunction((LinearEasingFunction)obj),
CompositionObjectType.PathKeyFrameAnimation => GetPathKeyFrameAnimation((PathKeyFrameAnimation)obj),
CompositionObjectType.ScalarKeyFrameAnimation => GetScalarKeyFrameAnimation((ScalarKeyFrameAnimation)obj),
@ -532,10 +582,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
return result;
}
CompositionShadow GetCompositionShadow(CompositionShadow obj) =>
obj.Type switch
{
CompositionObjectType.DropShadow => GetDropShadow((DropShadow)obj),
_ => throw new InvalidOperationException(),
};
Visual GetVisual(Visual obj) =>
obj.Type switch
{
CompositionObjectType.ContainerVisual => GetContainerVisual((ContainerVisual)obj),
CompositionObjectType.LayerVisual => GetLayerVisual((LayerVisual)obj),
CompositionObjectType.ShapeVisual => GetShapeVisual((ShapeVisual)obj),
CompositionObjectType.SpriteVisual => GetSpriteVisual((SpriteVisual)obj),
_ => throw new InvalidOperationException(),
@ -842,30 +900,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
}
result = CacheAndInitializeCompositionObject(obj, _c.CreateStepEasingFunction());
if (obj.FinalStep != 1)
{
result.FinalStep = obj.FinalStep;
}
if (obj.InitialStep != 0)
{
result.InitialStep = obj.InitialStep;
}
if (obj.IsFinalStepSingleFrame)
{
result.IsFinalStepSingleFrame = obj.IsFinalStepSingleFrame;
}
if (obj.IsInitialStepSingleFrame)
{
result.IsInitialStepSingleFrame = obj.IsInitialStepSingleFrame;
}
if (obj.StepCount != 1)
{
result.StepCount = obj.StepCount;
}
result.FinalStep = obj.FinalStep;
result.InitialStep = obj.InitialStep;
result.IsFinalStepSingleFrame = obj.IsFinalStepSingleFrame;
result.IsInitialStepSingleFrame = obj.IsInitialStepSingleFrame;
result.StepCount = obj.StepCount;
StartAnimationsAndFreeze(obj, result);
return result;
@ -1070,40 +1109,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
if (obj.StrokeBrush != null)
{
result.IsStrokeNonScaling = obj.IsStrokeNonScaling;
result.StrokeBrush = GetCompositionBrush(obj.StrokeBrush);
if (obj.StrokeDashCap != CompositionStrokeCap.Flat)
{
result.StrokeDashCap = obj.StrokeDashCap;
}
if (obj.StrokeStartCap != CompositionStrokeCap.Flat)
{
result.StrokeStartCap = obj.StrokeStartCap;
}
if (obj.StrokeEndCap != CompositionStrokeCap.Flat)
{
result.StrokeEndCap = obj.StrokeEndCap;
}
result.StrokeDashCap = obj.StrokeDashCap;
result.StrokeStartCap = obj.StrokeStartCap;
result.StrokeEndCap = obj.StrokeEndCap;
result.StrokeThickness = obj.StrokeThickness;
result.StrokeMiterLimit = obj.StrokeMiterLimit;
if (obj.StrokeLineJoin != CompositionStrokeLineJoin.Miter)
{
result.StrokeLineJoin = obj.StrokeLineJoin;
}
if (obj.StrokeDashOffset != 0)
{
result.StrokeDashOffset = obj.StrokeDashOffset;
}
if (obj.IsStrokeNonScaling)
{
result.IsStrokeNonScaling = obj.IsStrokeNonScaling;
}
result.StrokeLineJoin = obj.StrokeLineJoin;
result.StrokeDashOffset = obj.StrokeDashOffset;
var strokeDashArray = result.StrokeDashArray;
foreach (var strokeDash in obj.StrokeDashArray)

Просмотреть файл

@ -28,6 +28,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
switch (obj.Type)
{
case CompositionObjectType.ContainerVisual:
case CompositionObjectType.LayerVisual:
case CompositionObjectType.SpriteVisual:
case CompositionObjectType.ShapeVisual:
OptimizeVisualProperties((Visual)obj);
@ -40,12 +41,97 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
case CompositionObjectType.CompositionContainerShape:
OptimizeShapeProperties((CompositionShape)obj);
break;
case CompositionObjectType.StepEasingFunction:
OptimizeStepEasingFunctionProperties((StepEasingFunction)obj);
break;
case CompositionObjectType.CompositionLinearGradientBrush:
case CompositionObjectType.CompositionRadialGradientBrush:
OptimizeGradientBrush((CompositionGradientBrush)obj);
break;
}
}
return root;
}
static void OptimizeGradientBrush(CompositionGradientBrush obj)
{
if (obj.AnchorPoint == Vector2.Zero)
{
obj.AnchorPoint = null;
}
if (obj.CenterPoint == Vector2.Zero)
{
obj.CenterPoint = null;
}
if (obj.ExtendMode == CompositionGradientExtendMode.Clamp)
{
obj.ExtendMode = null;
}
if (obj.InterpolationSpace == CompositionColorSpace.Rgb)
{
obj.InterpolationSpace = null;
}
if (obj.MappingMode == CompositionMappingMode.Relative)
{
obj.MappingMode = null;
}
if (obj.Offset == Vector2.Zero)
{
obj.Offset = null;
}
if (obj.RotationAngleInDegrees == 0)
{
obj.RotationAngleInDegrees = null;
}
if (obj.Scale == Vector2.One)
{
obj.Scale = null;
}
if (obj.TransformMatrix == Matrix3x2.Identity)
{
obj.TransformMatrix = null;
}
}
static void OptimizeStepEasingFunctionProperties(StepEasingFunction obj)
{
if (obj.StepCount == 1)
{
obj.StepCount = null;
}
if (obj.IsInitialStepSingleFrame == false)
{
obj.IsInitialStepSingleFrame = null;
}
if (obj.InitialStep == 0)
{
obj.InitialStep = null;
}
if (obj.FinalStep == 1)
{
obj.FinalStep = null;
}
if (obj.IsFinalStepSingleFrame == false)
{
obj.IsFinalStepSingleFrame = null;
}
}
// Remove the centerpoint property if it's redundant, and convert properties to TransformMatrix if possible.
static void OptimizeShapeProperties(CompositionShape obj)
{
@ -104,6 +190,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
OptimizeShapeProperties(sprite);
// Unset properties that are set to their default values.
if (sprite.IsStrokeNonScaling == false)
{
sprite.IsStrokeNonScaling = null;
}
if (sprite.StrokeStartCap == CompositionStrokeCap.Flat)
{
sprite.StrokeStartCap = null;
@ -114,62 +205,154 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
sprite.StrokeDashCap = null;
}
if (sprite.StrokeDashOffset == 0)
{
sprite.StrokeDashOffset = null;
}
if (sprite.StrokeEndCap == CompositionStrokeCap.Flat)
{
sprite.StrokeEndCap = null;
}
var nonDefaultProperties = GetNonDefaultSpriteShapeProperties(sprite);
var nonDefaultGeometryProperties = GetNonDefaultGeometryProperties(sprite.Geometry);
var isTrimmed = (nonDefaultGeometryProperties & (PropertyId.TrimEnd | PropertyId.TrimStart)) != PropertyId.None;
if (sprite.Geometry?.Type == CompositionObjectType.CompositionEllipseGeometry)
if (sprite.StrokeLineJoin == CompositionStrokeLineJoin.Miter)
{
// Remove the StrokeMiterLimit and StrokeLineJoin properties. These properties
// only apply to changes of direction in a path, and never to an ellipse.
if ((nonDefaultProperties & PropertyId.StrokeMiterLimit) != PropertyId.None)
{
sprite.StrokeMiterLimit = null;
sprite.StopAnimation(nameof(sprite.StrokeMiterLimit));
}
if ((nonDefaultProperties & PropertyId.StrokeLineJoin) != PropertyId.None)
{
sprite.StrokeLineJoin = null;
sprite.StopAnimation(nameof(sprite.StrokeLineJoin));
}
sprite.StrokeLineJoin = null;
}
if (sprite.Geometry?.Type == CompositionObjectType.CompositionRectangleGeometry ||
sprite.Geometry?.Type == CompositionObjectType.CompositionRoundedRectangleGeometry ||
sprite.Geometry?.Type == CompositionObjectType.CompositionEllipseGeometry)
if (sprite.StrokeMiterLimit == 1)
{
// TODO - this can also be enabled for path geometries that are closed paths.
// The geometry is closed. If it's not trimmed then the caps are irrelavent.
if (!isTrimmed)
sprite.StrokeMiterLimit = null;
}
if (sprite.StrokeThickness == 1)
{
sprite.StrokeThickness = null;
}
if (sprite.Geometry != null)
{
OptimizeGeometryProperties(sprite.Geometry);
var nonDefaultProperties = GetNonDefaultSpriteShapeProperties(sprite);
var nonDefaultGeometryProperties = GetNonDefaultGeometryProperties(sprite.Geometry);
var isTrimmed = (nonDefaultGeometryProperties & (PropertyId.TrimEnd | PropertyId.TrimStart)) != PropertyId.None;
if (sprite.Geometry.Type == CompositionObjectType.CompositionEllipseGeometry)
{
if ((nonDefaultProperties & PropertyId.StrokeStartCap) != PropertyId.None)
// Remove the StrokeMiterLimit and StrokeLineJoin properties. These properties
// only apply to changes of direction in a path, and never to an ellipse.
if ((nonDefaultProperties & PropertyId.StrokeMiterLimit) != PropertyId.None)
{
sprite.StrokeStartCap = null;
sprite.StopAnimation(nameof(sprite.StrokeStartCap));
sprite.StrokeMiterLimit = null;
sprite.StopAnimation(nameof(sprite.StrokeMiterLimit));
}
if ((nonDefaultProperties & PropertyId.StrokeEndCap) != PropertyId.None)
if ((nonDefaultProperties & PropertyId.StrokeLineJoin) != PropertyId.None)
{
sprite.StrokeEndCap = null;
sprite.StopAnimation(nameof(sprite.StrokeEndCap));
sprite.StrokeLineJoin = null;
sprite.StopAnimation(nameof(sprite.StrokeLineJoin));
}
}
if (sprite.Geometry.Type == CompositionObjectType.CompositionRectangleGeometry ||
sprite.Geometry.Type == CompositionObjectType.CompositionRoundedRectangleGeometry ||
sprite.Geometry.Type == CompositionObjectType.CompositionEllipseGeometry)
{
// TODO - this can also be enabled for path geometries that are closed paths.
// The geometry is closed. If it's not trimmed then the caps are irrelavent.
if (!isTrimmed)
{
if ((nonDefaultProperties & PropertyId.StrokeStartCap) != PropertyId.None)
{
sprite.StrokeStartCap = null;
sprite.StopAnimation(nameof(sprite.StrokeStartCap));
}
if ((nonDefaultProperties & PropertyId.StrokeEndCap) != PropertyId.None)
{
sprite.StrokeEndCap = null;
sprite.StopAnimation(nameof(sprite.StrokeEndCap));
}
}
}
}
}
// Remove the CenterPoint and RotationAxis properties if they're redundant,
// Remove redundant TrimEnd, TrimOffset, and TrimStart properties.
static void OptimizeGeometryProperties(CompositionGeometry obj)
{
// Unset properties that are set to their default values.
if (obj.TrimEnd == 1)
{
obj.TrimEnd = null;
}
if (obj.TrimOffset == 0)
{
obj.TrimOffset = null;
}
if (obj.TrimStart == 0)
{
obj.TrimStart = null;
}
}
// Remove the IsVisible, CenterPoint, and RotationAxis properties if they're redundant,
// and convert properties to TransformMatrix if possible.
static void OptimizeVisualProperties(Visual obj)
{
// Unset properties that are set to their default values.
if (obj.CenterPoint == Vector3.Zero)
{
obj.CenterPoint = null;
}
if (obj.IsVisible == true)
{
obj.IsVisible = null;
}
if (obj.Offset == Vector3.Zero)
{
obj.Offset = null;
}
if (obj.Opacity == 1)
{
obj.Opacity = null;
}
if (obj.RotationAngleInDegrees == 0)
{
obj.RotationAngleInDegrees = null;
}
if (obj.RotationAxis == Vector3.UnitZ)
{
obj.RotationAxis = null;
}
if (obj.Scale == Vector3.One)
{
obj.Scale = null;
}
if (obj.Size == Vector2.Zero)
{
obj.Size = null;
}
if (obj.TransformMatrix == Matrix4x4.Identity)
{
obj.TransformMatrix = null;
}
var nonDefaultProperties = GetNonDefaultVisualProperties(obj);
if (obj.CenterPoint.HasValue &&
((nonDefaultProperties & (PropertyId.RotationAngleInDegrees | PropertyId.Scale)) == PropertyId.None))
{

Просмотреть файл

@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System;
using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
@ -107,12 +109,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
case CompositionObjectType.CubicBezierEasingFunction:
CubicBezierEasingFunctionCount++;
break;
case CompositionObjectType.DropShadow:
DropShadowCount++;
break;
case CompositionObjectType.ExpressionAnimation:
ExpressionAnimationCount++;
break;
case CompositionObjectType.InsetClip:
InsetClipCount++;
break;
case CompositionObjectType.LayerVisual:
LayerVisualCount++;
break;
case CompositionObjectType.LinearEasingFunction:
LinearEasingFunctionCount++;
break;
@ -146,26 +154,28 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
}
}
public int CompositionObjectCount { get; }
public int CompositionPathCount { get; }
public int CanvasGeometryCount { get; }
public int AnimationControllerCount { get; }
public int AnimatorCount { get; }
public int BooleanKeyFrameAnimationCount { get; }
public int CanvasGeometryCount { get; }
public int ColorKeyFrameAnimationCount { get; }
public int ColorBrushCount { get; }
public int ColorGradientStopCount { get; }
public int CompositionObjectCount { get; }
public int CompositionPathCount { get; }
public int ContainerShapeCount { get; }
public int DropShadowCount { get; }
public int EffectBrushCount { get; }
public int EllipseGeometryCount { get; }
@ -202,6 +212,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools
public int InsetClipCount { get; }
public int LayerVisualCount { get; }
public int LinearEasingFunctionCount { get; }
public int PathKeyFrameAnimationCount { get; }

Просмотреть файл

@ -116,6 +116,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen.CSharp
namespaces.Add("Windows.UI");
namespaces.Add($"{_winUiNamespace}.Composition");
if (SourceInfo.LoadedImageSurfaces.Count > 0)
{
// IDynamicAnimatedVisualSource is output in multiple places without
// namespace qualification.
namespaces.Add("Microsoft.UI.Xaml.Controls");
}
// Write out each namespace using.
foreach (var n in namespaces)
{

Просмотреть файл

@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -1154,6 +1156,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
string ColorSpace(CompositionColorSpace value) => _s.ColorSpace(value);
string DropShadowSourcePolicy(CompositionDropShadowSourcePolicy value) => _s.DropShadowSourcePolicy(value);
string ExtendMode(CompositionGradientExtendMode value) => _s.ExtendMode(value);
string MappingMode(CompositionMappingMode value) => _s.MappingMode(value);
@ -1318,6 +1322,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
_currentObjectFactoryNode = null;
}
/// <summary>
/// Combines the calls to <see cref="StartAnimationsOnResult(CodeBuilder, CompositionObject, ObjectData)"/>
/// with <see cref="WriteObjectFactoryEnd(CodeBuilder)"/>.
/// </summary>
void WriteCompositionObjectFactoryEnd(CodeBuilder builder, CompositionObject obj, ObjectData node)
{
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
}
// Writes a factory that just creates an object but doesn't parameterize it before it is returned.
void WriteSimpleObjectFactory(CodeBuilder builder, ObjectData node, string createCallText)
{
@ -1368,54 +1382,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
void WriteSetPropertyStatementDefaultIsFalse(CodeBuilder builder, string propertyName, bool? value, string target = "result")
{
if (value != false)
{
WriteSetPropertyStatement(builder, propertyName, value, target);
}
}
void WriteSetPropertyStatementDefaultIsTrue(CodeBuilder builder, string propertyName, bool? value, string target = "result")
{
if (value != true)
{
WriteSetPropertyStatement(builder, propertyName, value, target);
}
}
void WriteSetPropertyStatementDefaultIsZero(CodeBuilder builder, string propertyName, int? value, string target = "result")
{
if (value != 0)
{
WriteSetPropertyStatement(builder, propertyName, value, target);
}
}
void WriteSetPropertyStatementDefaultIsZero(CodeBuilder builder, string propertyName, float? value, string target = "result")
{
if (value != 0)
{
WriteSetPropertyStatement(builder, propertyName, value, target);
}
}
void WriteSetPropertyStatementDefaultIsOne(CodeBuilder builder, string propertyName, int? value, string target = "result")
{
if (value != 1)
{
WriteSetPropertyStatement(builder, propertyName, value, target);
}
}
void WriteSetPropertyStatementDefaultIsOne(CodeBuilder builder, string propertyName, float? value, string target = "result")
{
if (value != 1)
{
WriteSetPropertyStatement(builder, propertyName, value, target);
}
}
void WriteSetPropertyStatement(CodeBuilder builder, string propertyName, bool? value, string target = "result")
=> WriteSetPropertyStatement(builder, propertyName, value, formatter: Bool, target);
@ -1428,9 +1394,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
void WriteSetPropertyStatement(CodeBuilder builder, string propertyName, CompositionStrokeCap? value, string target = "result")
=> WriteSetPropertyStatement(builder, propertyName, value, formatter: StrokeCap, target);
void WriteSetPropertyStatement(CodeBuilder builder, string propertyName, CompositionStrokeLineJoin? value, string target = "result")
=> WriteSetPropertyStatement(builder, propertyName, value, formatter: StrokeLineJoin, target);
void WriteSetPropertyStatement(CodeBuilder builder, string propertyName, Vector2? value, string target = "result")
=> WriteSetPropertyStatement(builder, propertyName, value, formatter: Vector2, target);
@ -1464,11 +1427,31 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
void WriteSetPropertyStatementDefaultIsNullOrWhitespace(
CodeBuilder builder,
string propertyName,
string? value,
string target = "result")
{
if (!string.IsNullOrWhiteSpace(value))
{
WriteSetPropertyStatement(builder, propertyName, String(value), target);
}
}
void WriteSetPropertyStatement(CodeBuilder builder, string propertyName, string value, string target = "result")
{
builder.WriteLine($"{_s.PropertySet(target, propertyName, value)};");
}
void WriteSetPropertyStatement(CodeBuilder builder, string propertyName, CompositionObject? value, ObjectData callerNode, string target = "result")
{
if (value != null)
{
WriteSetPropertyStatement(builder, propertyName, CallFactoryFromFor(callerNode, value), target);
}
}
void WritePopulateShapesCollection(CodeBuilder builder, IList<CompositionShape> shapes, ObjectData node)
{
switch (shapes.Count)
@ -1659,8 +1642,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
CompositionObjectType.CompositionVisualSurface => GenerateCompositionVisualSurfaceFactory(builder, (CompositionVisualSurface)obj, node),
CompositionObjectType.ContainerVisual => GenerateContainerVisualFactory(builder, (ContainerVisual)obj, node),
CompositionObjectType.CubicBezierEasingFunction => GenerateCubicBezierEasingFunctionFactory(builder, (CubicBezierEasingFunction)obj, node),
CompositionObjectType.DropShadow => GenerateDropShadowFactory(builder, (DropShadow)obj, node),
CompositionObjectType.ExpressionAnimation => GenerateExpressionAnimationFactory(builder, (ExpressionAnimation)obj, node),
CompositionObjectType.InsetClip => GenerateInsetClipFactory(builder, (InsetClip)obj, node),
CompositionObjectType.LayerVisual => GenerateLayerVisualFactory(builder, (LayerVisual)obj, node),
CompositionObjectType.LinearEasingFunction => GenerateLinearEasingFunctionFactory(builder, (LinearEasingFunction)obj, node),
CompositionObjectType.PathKeyFrameAnimation => GeneratePathKeyFrameAnimationFactory(builder, (PathKeyFrameAnimation)obj, node),
CompositionObjectType.ScalarKeyFrameAnimation => GenerateScalarKeyFrameAnimationFactory(builder, (ScalarKeyFrameAnimation)obj, node),
@ -1685,8 +1670,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, nameof(obj.TopInset), obj.TopInset);
WriteSetPropertyStatement(builder, nameof(obj.BottomInset), obj.BottomInset);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
bool GenerateLayerVisualFactory(CodeBuilder builder, LayerVisual obj, ObjectData node)
{
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateLayerVisual()");
InitializeContainerVisual(builder, obj, node);
WriteSetPropertyStatement(builder, nameof(obj.Shadow), obj.Shadow, node);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -1696,13 +1692,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteCreateAssignment(builder, node, $"_c{Deref}CreateGeometricClip()");
InitializeCompositionClip(builder, obj, node);
if (obj.Geometry != null)
{
WriteSetPropertyStatement(builder, "Geometry", CallFactoryFromFor(node, obj.Geometry));
}
WriteSetPropertyStatement(builder, nameof(obj.Geometry), obj.Geometry, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -1715,8 +1707,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, "StartPoint", obj.StartPoint);
WriteSetPropertyStatement(builder, "EndPoint", obj.EndPoint);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -1730,8 +1721,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, "EllipseRadius", obj.EllipseRadius);
WriteSetPropertyStatement(builder, "GradientOriginOffset", obj.GradientOriginOffset);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -1747,18 +1737,36 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
return true;
}
bool GenerateDropShadowFactory(CodeBuilder builder, DropShadow obj, ObjectData node)
{
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateDropShadow();");
InitializeCompositionShadow(builder, obj, node);
WriteSetPropertyStatement(builder, nameof(obj.BlurRadius), obj.BlurRadius);
WriteSetPropertyStatement(builder, nameof(obj.Color), obj.Color, formatter: Color);
WriteSetPropertyStatement(builder, nameof(obj.Mask), obj.Mask, node);
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.Opacity), obj.Opacity);
WriteSetPropertyStatement(builder, nameof(obj.SourcePolicy), obj.SourcePolicy, formatter: DropShadowSourcePolicy);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
bool GenerateStepEasingFunctionFactory(CodeBuilder builder, StepEasingFunction obj, ObjectData node)
{
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateStepEasingFunction()");
InitializeCompositionEasingFunction(builder, obj, node);
WriteSetPropertyStatementDefaultIsOne(builder, nameof(obj.FinalStep), obj.FinalStep);
WriteSetPropertyStatementDefaultIsZero(builder, nameof(obj.InitialStep), obj.InitialStep);
WriteSetPropertyStatementDefaultIsFalse(builder, nameof(obj.IsFinalStepSingleFrame), obj.IsFinalStepSingleFrame);
WriteSetPropertyStatementDefaultIsFalse(builder, nameof(obj.IsInitialStepSingleFrame), obj.IsInitialStepSingleFrame);
WriteSetPropertyStatementDefaultIsOne(builder, nameof(obj.StepCount), obj.StepCount);
WriteSetPropertyStatement(builder, nameof(obj.FinalStep), obj.FinalStep);
WriteSetPropertyStatement(builder, nameof(obj.InitialStep), obj.InitialStep);
WriteSetPropertyStatement(builder, nameof(obj.IsFinalStepSingleFrame), obj.IsFinalStepSingleFrame);
WriteSetPropertyStatement(builder, nameof(obj.IsInitialStepSingleFrame), obj.IsInitialStepSingleFrame);
WriteSetPropertyStatement(builder, nameof(obj.StepCount), obj.StepCount);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -1767,8 +1775,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateContainerVisual()");
InitializeContainerVisual(builder, obj, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -1777,8 +1784,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateExpressionAnimation({String(obj.Expression)})");
InitializeCompositionAnimation(builder, obj, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2046,8 +2052,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
b.WriteLine();
}
// Call the helper and initialize the remaining CompositionShape properties.
WriteMatrixComment(builder, transformMatrix);
builder.WriteLine($"{ConstVar} result = CreateSpriteShape({CallFactoryFromFor(node, obj.Geometry)}, {Matrix3x2(transformMatrix)});");
InitializeCompositionObject(builder, obj, node);
WriteSetPropertyStatement(builder, nameof(obj.CenterPoint), obj.CenterPoint);
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.RotationAngleInDegrees), obj.RotationAngleInDegrees);
WriteSetPropertyStatement(builder, nameof(obj.Scale), obj.Scale);
}
/// <summary>
@ -2073,8 +2085,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
b.WriteLine();
}
// Call the helper and initialize the remaining CompositionShape properties.
WriteMatrixComment(builder, obj.TransformMatrix);
builder.WriteLine($"{ConstVar} result = CreateSpriteShape({CallFactoryFromFor(node, obj.Geometry)}, {Matrix3x2(transformMatrix)}, {CallFactoryFromFor(node, obj.FillBrush)});");
InitializeCompositionObject(builder, obj, node);
WriteSetPropertyStatement(builder, nameof(obj.CenterPoint), obj.CenterPoint);
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.RotationAngleInDegrees), obj.RotationAngleInDegrees);
WriteSetPropertyStatement(builder, nameof(obj.Scale), obj.Scale);
}
// Starts an ExpressionAnimation that uses the shared singleton ExpressionAnimation.
@ -2195,10 +2213,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
{
if (_owner._setCommentProperties)
{
if (!string.IsNullOrWhiteSpace(obj.Comment))
{
WriteSetPropertyStatement(builder, "Comment", String(obj.Comment), localName);
}
WriteSetPropertyStatementDefaultIsNullOrWhitespace(builder, nameof(obj.Comment), obj.Comment, localName);
}
var propertySet = obj.Properties;
@ -2210,10 +2225,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
void InitializeCompositionBrush(CodeBuilder builder, CompositionBrush obj, ObjectData node)
{
void InitializeCompositionBrush(CodeBuilder builder, CompositionBrush obj, ObjectData node) =>
InitializeCompositionObject(builder, obj, node);
void InitializeCompositionEasingFunction(CodeBuilder builder, CompositionEasingFunction obj, ObjectData node) =>
InitializeCompositionObject(builder, obj, node);
void InitializeCompositionShadow(CodeBuilder builder, CompositionShadow obj, ObjectData node) =>
InitializeCompositionObject(builder, obj, node);
}
void InitializeVisual(CodeBuilder builder, Visual obj, ObjectData node)
{
@ -2225,13 +2244,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
WriteSetPropertyStatement(builder, nameof(obj.CenterPoint), obj.CenterPoint);
if (obj.Clip != null)
{
WriteSetPropertyStatement(builder, nameof(obj.Clip), CallFactoryFromFor(node, obj.Clip));
}
WriteSetPropertyStatementDefaultIsTrue(builder, nameof(obj.IsVisible), obj.IsVisible);
WriteSetPropertyStatement(builder, nameof(obj.Clip), obj.Clip, node);
WriteSetPropertyStatement(builder, nameof(obj.IsVisible), obj.IsVisible);
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.Opacity), obj.Opacity);
WriteSetPropertyStatement(builder, nameof(obj.RotationAngleInDegrees), obj.RotationAngleInDegrees);
@ -2267,13 +2281,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, nameof(obj.ExtendMode), obj.ExtendMode, formatter: ExtendMode);
WriteSetPropertyStatement(builder, nameof(obj.InterpolationSpace), obj.InterpolationSpace, formatter: ColorSpace);
// Default MappingMode is Relative
if (obj.MappingMode.HasValue && obj.MappingMode.Value != CompositionMappingMode.Relative)
{
WriteSetPropertyStatement(builder, nameof(obj.MappingMode), MappingMode(obj.MappingMode.Value));
}
WriteSetPropertyStatement(builder, nameof(obj.MappingMode), obj.MappingMode, formatter: MappingMode);
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.RotationAngleInDegrees), obj.RotationAngleInDegrees);
WriteSetPropertyStatement(builder, nameof(obj.Scale), obj.Scale);
@ -2313,7 +2321,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
default:
{
// Multiple children requires the use of a local.
builder.WriteLine($"{ConstVar} children = {_s.PropertyGet("result", "Children")};");
builder.WriteLine($"{ConstVar} children = {_s.PropertyGet("result", nameof(obj.Children))};");
foreach (var child in obj.Children)
{
WriteShortDescriptionComment(builder, child);
@ -2329,9 +2337,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
{
InitializeCompositionObject(builder, obj, node);
WriteSetPropertyStatementDefaultIsOne(builder, nameof(obj.TrimEnd), obj.TrimEnd);
WriteSetPropertyStatementDefaultIsZero(builder, nameof(obj.TrimOffset), obj.TrimOffset);
WriteSetPropertyStatementDefaultIsZero(builder, nameof(obj.TrimStart), obj.TrimStart);
WriteSetPropertyStatement(builder, nameof(obj.TrimEnd), obj.TrimEnd);
WriteSetPropertyStatement(builder, nameof(obj.TrimOffset), obj.TrimOffset);
WriteSetPropertyStatement(builder, nameof(obj.TrimStart), obj.TrimStart);
}
void InitializeCompositionAnimation(CodeBuilder builder, CompositionAnimation obj, ObjectData node)
@ -2343,13 +2351,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
obj.ReferenceParameters.Select(p => new KeyValuePair<string, string>(p.Key, $"{CallFactoryFromFor(node, p.Value)}")));
}
void InitializeCompositionAnimationWithParameters(CodeBuilder builder, CompositionAnimation obj, ObjectData node, IEnumerable<KeyValuePair<string, string>> parameters)
void InitializeCompositionAnimationWithParameters(
CodeBuilder builder,
CompositionAnimation obj,
ObjectData node,
IEnumerable<KeyValuePair<string, string>> parameters)
{
InitializeCompositionObject(builder, obj, node);
if (!string.IsNullOrWhiteSpace(obj.Target))
{
WriteSetPropertyStatement(builder, "Target", String(obj.Target));
}
WriteSetPropertyStatementDefaultIsNullOrWhitespace(builder, nameof(obj.Target), obj.Target);
foreach (var parameter in parameters)
{
@ -2362,7 +2371,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteCreateAssignment(builder, node, $"_c{Deref}Create{animation.Type}()");
Debug.Assert(animation.Duration.Ticks > 0, "Invariant");
WriteSetPropertyStatement(builder, "Duration", TimeSpan(animation.Duration));
WriteSetPropertyStatement(builder, nameof(animation.Duration), TimeSpan(animation.Duration));
InitializeCompositionAnimation(builder, animation, node);
}
@ -2409,8 +2418,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2441,7 +2449,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
if (obj.InterpolationColorSpace != CompositionColorSpace.Auto)
{
WriteSetPropertyStatement(builder, "InterpolationColorSpace", ColorSpace(obj.InterpolationColorSpace));
WriteSetPropertyStatement(builder, nameof(obj.InterpolationColorSpace), ColorSpace(obj.InterpolationColorSpace));
}
}
@ -2463,8 +2471,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2510,8 +2517,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2556,8 +2562,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2602,8 +2607,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2636,8 +2640,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
builder.WriteLine($"result{Deref}InsertKeyFrame({Float(kf.Progress)}, {CallFactoryFromFor(node, valueKeyFrame.Value)}, {CallFactoryFromFor(node, kf.Easing)});");
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2682,8 +2685,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2696,8 +2698,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.Size), obj.Size);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2711,8 +2712,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.Size), obj.Size);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2729,8 +2729,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, nameof(obj.Radius), obj.Radius);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2754,8 +2753,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, createPathGeometryText);
InitializeCompositionGeometry(builder, obj, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
}
return true;
@ -2772,8 +2770,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, createCallText);
InitializeCompositionBrush(builder, obj, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
}
else
{
@ -2790,8 +2787,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateColorGradientStop({Float(obj.Offset)}, {Color(obj.Color)})");
InitializeCompositionObject(builder, obj, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
}
else
{
@ -2809,8 +2805,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteCreateAssignment(builder, node, $"_c{Deref}CreateShapeVisual()");
InitializeContainerVisual(builder, obj, node);
WritePopulateShapesCollection(builder, obj.Shapes, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2820,13 +2815,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteCreateAssignment(builder, node, $"_c{Deref}CreateSpriteVisual()");
InitializeContainerVisual(builder, obj, node);
if (obj.Brush != null)
{
WriteSetPropertyStatement(builder, "Brush", CallFactoryFromFor(node, obj.Brush));
}
WriteSetPropertyStatement(builder, nameof(obj.Brush), obj.Brush, node);
WriteSetPropertyStatement(builder, nameof(obj.Shadow), obj.Shadow, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2836,8 +2828,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteCreateAssignment(builder, node, $"_c{Deref}CreateContainerShape()");
InitializeCompositionShape(builder, obj, node);
WritePopulateShapesCollection(builder, obj.Shapes, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2872,8 +2863,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
throw new InvalidOperationException();
}
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2901,12 +2891,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
{
WriteCallHelperCreateSpriteShapeWithFillBrush(builder, obj, node, obj.TransformMatrix.Value);
}
InitializeCompositionObject(builder, obj, node);
WriteSetPropertyStatement(builder, nameof(obj.CenterPoint), obj.CenterPoint);
WriteSetPropertyStatement(builder, nameof(obj.Offset), obj.Offset);
WriteSetPropertyStatement(builder, nameof(obj.RotationAngleInDegrees), obj.RotationAngleInDegrees);
WriteSetPropertyStatement(builder, nameof(obj.Scale), obj.Scale);
}
else
{
@ -2915,20 +2899,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
}
if (setFillBrush && obj.FillBrush != null)
// The CompositionShape properties are now initialized. Initialize the
// properties that are specific to CompositionSpriteShape properties.
if (setFillBrush)
{
WriteSetPropertyStatement(builder, nameof(obj.FillBrush), CallFactoryFromFor(node, obj.FillBrush));
}
WriteSetPropertyStatementDefaultIsFalse(builder, nameof(obj.IsStrokeNonScaling), obj.IsStrokeNonScaling);
if (obj.StrokeBrush != null)
{
WriteSetPropertyStatement(builder, nameof(obj.StrokeBrush), CallFactoryFromFor(node, obj.StrokeBrush));
WriteSetPropertyStatement(builder, nameof(obj.FillBrush), obj.FillBrush, node);
}
WriteSetPropertyStatement(builder, nameof(obj.IsStrokeNonScaling), obj.IsStrokeNonScaling);
WriteSetPropertyStatement(builder, nameof(obj.StrokeBrush), obj.StrokeBrush, node);
WriteSetPropertyStatement(builder, nameof(obj.StrokeDashCap), obj.StrokeDashCap);
WriteSetPropertyStatementDefaultIsZero(builder, nameof(obj.StrokeDashOffset), obj.StrokeDashOffset);
WriteSetPropertyStatement(builder, nameof(obj.StrokeDashOffset), obj.StrokeDashOffset);
if (obj.StrokeDashArray.Count > 0)
{
@ -2941,12 +2922,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteSetPropertyStatement(builder, nameof(obj.StrokeStartCap), obj.StrokeStartCap);
WriteSetPropertyStatement(builder, nameof(obj.StrokeEndCap), obj.StrokeEndCap);
WriteSetPropertyStatement(builder, nameof(obj.StrokeLineJoin), obj.StrokeLineJoin);
WriteSetPropertyStatementDefaultIsOne(builder, nameof(obj.StrokeMiterLimit), obj.StrokeMiterLimit);
WriteSetPropertyStatementDefaultIsOne(builder, nameof(obj.StrokeThickness), obj.StrokeThickness);
WriteSetPropertyStatement(builder, nameof(obj.StrokeLineJoin), obj.StrokeLineJoin, formatter: StrokeLineJoin);
WriteSetPropertyStatement(builder, nameof(obj.StrokeMiterLimit), obj.StrokeMiterLimit);
WriteSetPropertyStatement(builder, nameof(obj.StrokeThickness), obj.StrokeThickness);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -2993,8 +2973,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
}
InitializeCompositionBrush(builder, obj, node);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
}
return true;
@ -3005,9 +2984,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteObjectFactoryStart(builder, node);
WriteCreateAssignment(builder, node, $"_c{Deref}CreateViewBox()");
InitializeCompositionObject(builder, obj, node);
builder.WriteLine($"result.Size = {Vector2(obj.Size)};");
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteSetPropertyStatement(builder, nameof(obj.Size), obj.Size);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}
@ -3017,16 +2997,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
WriteCreateAssignment(builder, node, $"_c{Deref}CreateVisualSurface()");
InitializeCompositionObject(builder, obj, node);
if (obj.SourceVisual != null)
{
WriteSetPropertyStatement(builder, "SourceVisual", CallFactoryFromFor(node, obj.SourceVisual));
}
WriteSetPropertyStatement(builder, nameof(obj.SourceVisual), obj.SourceVisual, node);
WriteSetPropertyStatement(builder, nameof(obj.SourceSize), obj.SourceSize);
WriteSetPropertyStatement(builder, nameof(obj.SourceOffset), obj.SourceOffset);
WriteSetPropertyStatement(builder, "SourceSize", obj.SourceSize);
WriteSetPropertyStatement(builder, "SourceOffset", obj.SourceOffset);
StartAnimationsOnResult(builder, obj, node);
WriteObjectFactoryEnd(builder);
WriteCompositionObjectFactoryEnd(builder, obj, node);
return true;
}

Просмотреть файл

@ -231,13 +231,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
static NodeName NameStepEasingFunction(StepEasingFunction obj)
{
// Recognize 2 common patterns: HoldThenStep and StepThenHold
if (obj.StepCount == 1)
if (!obj.StepCount.HasValue || obj.StepCount.Value == 1)
{
if (obj.IsFinalStepSingleFrame && !obj.IsInitialStepSingleFrame)
if (obj.IsFinalStepSingleFrame == true && obj.IsInitialStepSingleFrame != true)
{
return NodeName.FromNonTypeName("HoldThenStepEasingFunction");
}
else if (obj.IsInitialStepSingleFrame && !obj.IsFinalStepSingleFrame)
else if (obj.IsInitialStepSingleFrame == true && obj.IsFinalStepSingleFrame != true)
{
return NodeName.FromNonTypeName("StepThenHoldEasingFunction");
}
@ -253,7 +253,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
// Replace any disallowed character with underscores.
var cleanName = new string((from ch in name
select char.IsLetterOrDigit(ch) ? ch : '_').ToArray());
select char.IsLetterOrDigit(ch) ? ch : '_').ToArray());
// Remove any duplicated underscores.
cleanName = cleanName.Replace("__", "_");

Просмотреть файл

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Data;
using System.Numerics;
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Mgc;
@ -86,6 +87,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
public abstract string Double(double value);
public string DropShadowSourcePolicy(CompositionDropShadowSourcePolicy value)
{
const string typeName = nameof(CompositionDropShadowSourcePolicy);
return value switch
{
CompositionDropShadowSourcePolicy.Default => $"{typeName}{ScopeResolve}{nameof(CompositionDropShadowSourcePolicy.Default)}",
CompositionDropShadowSourcePolicy.InheritFromVisualContent => $"{typeName}{ScopeResolve}{nameof(CompositionDropShadowSourcePolicy.InheritFromVisualContent)}",
_ => throw new InvalidOperationException(),
};
}
public string ExtendMode(CompositionGradientExtendMode value)
{
const string typeName = nameof(CompositionGradientExtendMode);

Просмотреть файл

@ -299,6 +299,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
case CompositionObjectType.CompositionRoundedRectangleGeometry:
case CompositionObjectType.CompositionViewBox:
case CompositionObjectType.CubicBezierEasingFunction:
case CompositionObjectType.DropShadow:
case CompositionObjectType.ExpressionAnimation:
case CompositionObjectType.InsetClip:
case CompositionObjectType.LinearEasingFunction:
@ -326,6 +327,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen
Category = GetCategory((CompositionSpriteShape)obj);
break;
case CompositionObjectType.ContainerVisual:
case CompositionObjectType.LayerVisual:
Category = IsAnimatedCompositionObject ? CategoryContainerVisualAnimated : CategoryContainerVisual;
break;
case CompositionObjectType.ShapeVisual:

Просмотреть файл

@ -21,6 +21,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
InterpolationColorSpace = other.InterpolationColorSpace;
}
// Default is Auto.
public CompositionColorSpace InterpolationColorSpace { get; set; }
/// <inheritdoc/>

Просмотреть файл

@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
{
/// <summary>
/// The masking policy for a <see cref="DropShadow"/>.
/// </summary>
#if PUBLIC_WinCompData
public
#endif
enum CompositionDropShadowSourcePolicy
{
Default = 0,
InheritFromVisualContent = 1,
}
}

Просмотреть файл

@ -16,6 +16,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
{
}
// Default: Vector2.Zero.
public Vector2 Center { get; set; }
public Vector2 Radius { get; set; }

Просмотреть файл

@ -17,25 +17,33 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
{
}
// Default is Vector2.Zero.
public Vector2? AnchorPoint { get; set; }
// Default is Vector2.Zero.
public Vector2? CenterPoint { get; set; }
public IList<CompositionColorGradientStop> ColorStops { get; } = new List<CompositionColorGradientStop>();
// Default is Clamp.
public CompositionGradientExtendMode? ExtendMode { get; set; }
// Default is RGB.
public CompositionColorSpace? InterpolationSpace { get; set; }
// Default is Relative
// Default is Relative.
public CompositionMappingMode? MappingMode { get; set; }
// Default is Vector2.Zero.
public Vector2? Offset { get; set; }
// Default is 0.
public float? RotationAngleInDegrees { get; set; }
// Default is Vector2.One.
public Vector2? Scale { get; set; }
// Default is Matrix3x2.Identity.
public Matrix3x2? TransformMatrix { get; set; }
}
}

Просмотреть файл

@ -31,8 +31,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
CompositionVisualSurface,
ContainerVisual,
CubicBezierEasingFunction,
DropShadow,
ExpressionAnimation,
InsetClip,
LayerVisual,
LinearEasingFunction,
PathKeyFrameAnimation,
ScalarKeyFrameAnimation,

Просмотреть файл

@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
{
/// <summary>
/// Data representation of Windows.UI.Composition.CompositionShadow.
/// </summary>
[MetaData.UapVersion(3)]
#if PUBLIC_WinCompData
public
#endif
abstract class CompositionShadow : CompositionObject
{
private protected CompositionShadow()
{
}
}
}

Просмотреть файл

@ -22,11 +22,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
public CompositionGeometry? Geometry { get; set; }
public bool IsStrokeNonScaling { get; set; }
// Default is false.
public bool? IsStrokeNonScaling { get; set; }
public CompositionBrush? StrokeBrush { get; set; }
public float StrokeDashOffset { get; set; }
// Default is 0.
public float? StrokeDashOffset { get; set; }
public List<float> StrokeDashArray { get; } = new List<float>();

Просмотреть файл

@ -31,6 +31,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
public CubicBezierEasingFunction CreateCubicBezierEasingFunction(System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2) => new CubicBezierEasingFunction(controlPoint1, controlPoint2);
public DropShadow CreateDropShadow() => new DropShadow();
public CompositionEffectFactory CreateEffectFactory(GraphicsEffectBase graphicsEffect) => new CompositionEffectFactory(graphicsEffect);
public CompositionEllipseGeometry CreateEllipseGeometry() => new CompositionEllipseGeometry();
@ -41,6 +43,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
public InsetClip CreateInsetClip() => new InsetClip();
public LayerVisual CreateLayerVisual() => new LayerVisual();
public LinearEasingFunction CreateLinearEasingFunction() => new LinearEasingFunction();
public CompositionLinearGradientBrush CreateLinearGradientBrush() => new CompositionLinearGradientBrush();

Просмотреть файл

@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Numerics;
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Wui;
namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
{
/// <summary>
/// Data representation of Windows.UI.Composition.CompositionShadow.
/// </summary>
[MetaData.UapVersion(3)]
#if PUBLIC_WinCompData
public
#endif
sealed class DropShadow : CompositionShadow
{
internal DropShadow()
{
}
// Defaults to 9.0F
public float? BlurRadius { get; set; }
// Defaults to black.
public Color? Color { get; set; }
// Opacity mask.
public CompositionBrush? Mask { get; set; }
public Vector3? Offset { get; set; }
public float? Opacity { get; set; }
public CompositionDropShadowSourcePolicy? SourcePolicy { get; set; }
public override CompositionObjectType Type => CompositionObjectType.DropShadow;
}
}

Просмотреть файл

@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
{
[MetaData.UapVersion(3)]
#if PUBLIC_WinCompData
public
#endif
sealed class LayerVisual : ContainerVisual
{
internal LayerVisual()
{
}
public CompositionShadow? Shadow { get; set; }
/// <inheritdoc/>
public override CompositionObjectType Type => CompositionObjectType.LayerVisual;
}
}

Просмотреть файл

@ -18,6 +18,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
public CompositionBrush? Brush { get; set; }
public CompositionShadow? Shadow { get; set; }
/// <inheritdoc/>
public override CompositionObjectType Type => CompositionObjectType.SpriteVisual;
}

Просмотреть файл

@ -20,19 +20,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
}
// Default is 1.
public int StepCount { get; set; }
public int? StepCount { get; set; }
// Default is false.
public bool IsInitialStepSingleFrame { get; set; }
public bool? IsInitialStepSingleFrame { get; set; }
// Default is 0.
public int InitialStep { get; set; }
public int? InitialStep { get; set; }
// Default is 1.
public int FinalStep { get; set; }
public int? FinalStep { get; set; }
// Default is false.
public bool IsFinalStepSingleFrame { get; set; }
public bool? IsFinalStepSingleFrame { get; set; }
/// <inheritdoc/>
public override CompositionObjectType Type => CompositionObjectType.StepEasingFunction;

Просмотреть файл

@ -25,6 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
// overridden.
public CompositionBorderMode? BorderMode { get; set; }
// Defaults to Vector3.Zero.
public Vector3? CenterPoint { get; set; }
public CompositionClip? Clip { get; set; }
@ -32,7 +33,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
// Defaults to true.
public bool? IsVisible { get; set; }
// Defaults to 0.
// Defaults to Vector3.Zero.
public Vector3? Offset { get; set; }
// Defaults to 1.
@ -41,13 +42,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData
// Defaults to 0.
public float? RotationAngleInDegrees { get; set; }
// Defaults to Vector3.UnitZ.
public Vector3? RotationAxis { get; set; }
// Defaults to 1.
// Defaults to Vector3.One.
public Vector3? Scale { get; set; }
// Defaults to Vector2.Zero.
public Vector2? Size { get; set; }
// Defaults to Matrix4x4.Identity.
public Matrix4x4? TransformMatrix { get; set; }
}
}

Просмотреть файл

@ -17,6 +17,7 @@
<Compile Include="$(MSBuildThisFileDirectory)CompositionColorGradientStop.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionColorSpace.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionContainerShape.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionDropShadowSourcePolicy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionEasingFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionEffectBrush.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionEffectFactory.cs" />
@ -37,6 +38,7 @@
<Compile Include="$(MSBuildThisFileDirectory)CompositionRadialGradientBrush.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionRectangleGeometry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionRoundedRectangleGeometry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionShadow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionShape.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionSpriteShape.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompositionStrokeCap.cs" />
@ -47,6 +49,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Compositor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ContainerVisual.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CubicBezierEasingFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DropShadow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExpressionAnimation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expressions\Boolean.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expressions\Color.cs" />
@ -66,6 +69,7 @@
<Compile Include="$(MSBuildThisFileDirectory)KeyFrameAnimation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)KeyFrameAnimation_.cs" />
<Compile Include="$(MSBuildThisFileDirectory)KeyFrameType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LayerVisual.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LinearEasingFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MetaData\PropertySetValueType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MetaData\UapVersionAttribute.cs" />

Просмотреть файл

@ -11,7 +11,7 @@ echo Compiling all .cs files under %1
set cscPath="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe"
:: WinUI local copy. Needed because we can't mock IDynamicAnimatedVisualSource in C# due to the use of WinRT events.
set winuiWinmdPath="%homedrive%%homepath%\.nuget\packages\microsoft.ui.xaml\2.2.190917002\lib\uap10.0\Microsoft.UI.Xaml.winmd"
set winuiWinmdPath="%homedrive%%homepath%\.nuget\packages\microsoft.ui.xaml\2.4.3\lib\uap10.0\Microsoft.UI.Xaml.winmd"
for /r "%1" %%F in (*.cs) do @%cscPath% /noconfig @CompileDirectory.rsp /reference:%winuiWinmdPath% "%%F" /out:"%%~dpnF.dll" & del "%%~dpnF.dll"