Skip to content

Commit

Permalink
Syncing content from committish ea1a4b2489560b61b03f50a3df798dd0358740ff
Browse files Browse the repository at this point in the history
  • Loading branch information
reunion-maestro-bot committed Nov 21, 2024
1 parent ff21f9b commit 6909712
Show file tree
Hide file tree
Showing 1,784 changed files with 10,072 additions and 7,836 deletions.
76 changes: 61 additions & 15 deletions src/UpdateMockWinAppSDKPackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,70 @@
<Import Project="Directory.Build.props" />
<Import Project="$(NugetPackageDirectory)\MUXCustomBuildTasks.$(MuxCustomBuildTasksPackageVersion)\build\MUXCustomBuildTasks.targets" />
<Import Project="Directory.Build.targets" />
<PropertyGroup>
<!-- OutDir doesn't contain the project name since this is only a partial project. We'll add it manually. -->
<OutDir>$([System.IO.Path]::GetFullPath("$(OutDir)UpdateMockWinAppSDKPackage\"))</OutDir>
<MockPackagePath>$(ProjectRoot)PackageStore\Microsoft.WindowsAppSDK.999.0.0-mock-$(WinUIVersion)-$(Platform)-$(Configuration).nupkg</MockPackagePath>
</PropertyGroup>
<Target Name="Rebuild" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<CallTarget Targets="Clean" />
<CallTarget Targets="Build" />
</Target>
<Target Name="Publish" />
<Target Name="Clean" Condition="'$(BuildingInsideVisualStudio)' == 'true'" />
<Target Name="Clean" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<ItemGroup>
<OutDirFiles Include="$(OutDir)**\*" />
</ItemGroup>
<Delete Files="$(MockPackagePath)" />
<Delete Files="@(OutDirFiles)" />
<RemoveDir Directories="$(OutDir)" />
</Target>
<Target Name="Build" Condition="'$(BuildingInsideVisualStudio)' == 'true'" DependsOnTargets="CheckIfUpdateIsRequired" />
<Target Name="CheckIfUpdateIsRequired">
<Target Name="SetProperties">
<PropertyGroup>
<PackagesDirectory>$(ProjectRoot)packages\</PackagesDirectory>
<TempPackagesDirectory>$(OutDir)packages\</TempPackagesDirectory>
<MicrosoftWindowsSDKBuildToolsPackageName>Microsoft.Windows.SDK.BuildTools</MicrosoftWindowsSDKBuildToolsPackageName>
<MicrosoftWindowsSDKBuildToolsTempPackagesDir>$(TempPackagesDirectory)$(MicrosoftWindowsSDKBuildToolsPackageName).$(MicrosoftWindowsSDKBuildToolsNugetPackageVersion)</MicrosoftWindowsSDKBuildToolsTempPackagesDir>
<WASDKPackageCppDirectoryName>Microsoft.WindowsAppSDK.$(WindowsAppSdkPackageVersion)</WASDKPackageCppDirectoryName>
<WASDKPackageCSharpDirectoryName>microsoft.windowsappsdk\$(WindowsAppSdkPackageVersion)</WASDKPackageCSharpDirectoryName>
<BuildMockPackageScriptPath>$(ProjectRoot)scripts\buildMockWinAppSdkPackage.ps1</BuildMockPackageScriptPath>
<BuildMockPackageScriptParams>$(ProjectRoot) $(Platform) $(Configuration) $(WinUIVersion) 999.0.0-mock $(TempPackagesDirectory)</BuildMockPackageScriptParams>
</PropertyGroup>
<RunPowershellScript Path="$(BuildMockPackageScriptPath)" Parameters="$(BuildMockPackageScriptParams) -Fake">
<Output TaskParameter="ExitCode" PropertyName="FakeScriptRunExitCode"/>
</RunPowershellScript>
<PropertyGroup>
<UpdateIsRequired Condition="'$(FakeScriptRunExitCode)' == '1'">true</UpdateIsRequired>
</PropertyGroup>
</Target>
<Target Name="UpdateMockWinAppSDKPackage" Condition="'$(UpdateIsRequired)' == 'true'" AfterTargets="Build">
<Target Name="CopyDependencies" DependsOnTargets="SetProperties">
<!-- First we'll create the package themselves and extract them to a temp folder using the Powershell script.
Microsoft.Windows.SDK.BuildTools is a package we depend on that needs to be in the packages directory
for dependency resolution. -->
<PropertyGroup>
<MicrosoftWindowsSDKBuildToolsPackageName>Microsoft.Windows.SDK.BuildTools</MicrosoftWindowsSDKBuildToolsPackageName>
<MicrosoftWindowsSDKBuildToolsTempPackagesDir>$(TempPackagesDirectory)$(MicrosoftWindowsSDKBuildToolsPackageName).$(MicrosoftWindowsSDKBuildToolsNugetPackageVersion)</MicrosoftWindowsSDKBuildToolsTempPackagesDir>
<WebView2PackageName>Microsoft.Web.WebView2</WebView2PackageName>
<WebView2TempPackagesDir>$(TempPackagesDirectory)$(WebView2PackageName).$(WebView2Version)</WebView2TempPackagesDir>
</PropertyGroup>
<ItemGroup>
<MicrosoftWindowsSDKBuildToolsFile Include="$(PackagesDirectory)$(MicrosoftWindowsSDKBuildToolsPackageName).$(MicrosoftWindowsSDKBuildToolsNugetPackageVersion)\**\*" />
<WebView2File Include="$(PackagesDirectory)$(WebView2PackageName).$(WebView2Version)\**\*" />
</ItemGroup>
<Message Text="Copying $(MicrosoftWindowsSDKBuildToolsPackageName), which is a package we depend on for WinAppSDK package creation." Condition="!Exists('$(MicrosoftWindowsSDKBuildToolsTempPackagesDir)')" />
<Copy SourceFiles="@(MicrosoftWindowsSDKBuildToolsFile)" DestinationFiles="@(MicrosoftWindowsSDKBuildToolsFile->'$(MicrosoftWindowsSDKBuildToolsTempPackagesDir)\%(RecursiveDir)\%(Filename)%(Extension)')" Condition="!Exists('$(MicrosoftWindowsSDKBuildToolsTempPackagesDir)')" />
<RunPowershellScript Path="$(ProjectRoot)scripts\buildMockWinAppSdkPackage.ps1" Parameters="$(ProjectRoot) $(Platform) $(Configuration) $(WinUIVersion) 999.0.0-mock $(TempPackagesDirectory)" />
<!-- Next we'll install the packages. Visual Studio complains if we completely delete and regenerate in-use NuGet package folders,
<Message Text="Copying $(WebView2PackageName), which is a package we depend on for WinAppSDK package creation." Condition="!Exists('$(WebView2TempPackagesDir)')" />
<Copy SourceFiles="@(WebView2File)" DestinationFiles="@(WebView2File->'$(WebView2TempPackagesDir)\%(RecursiveDir)\%(Filename)%(Extension)')" Condition="!Exists('$(WebView2TempPackagesDir)')" />
</Target>
<Target Name="CheckIfUpdateIsRequired" DependsOnTargets="CopyDependencies">
<!-- We'll only check whether an update is required if the nupkg already exists. Otherwise, we know we need to create it. -->
<RunPowershellScript Path="$(BuildMockPackageScriptPath)" Parameters="$(BuildMockPackageScriptParams) -Fake" Condition="Exists('$(MockPackagePath)')">
<Output TaskParameter="ExitCode" PropertyName="FakeScriptRunExitCode"/>
</RunPowershellScript>
<PropertyGroup>
<UpdateIsRequired Condition="'$(FakeScriptRunExitCode)' == '1' or !Exists('$(MockPackagePath)')">true</UpdateIsRequired>
</PropertyGroup>
</Target>
<Target Name="UpdateMockWinAppSDKPackage" Condition="'$(UpdateIsRequired)' == 'true'" AfterTargets="Build" DependsOnTargets="CopyDependencies">
<!-- We first need to clear the AppXContents directory for the WindowsAppSDK mock package staging ground, since otherwise a Clean will delete files we need. -->
<PropertyGroup>
<WASDKPackageCppDirectoryName>Microsoft.WindowsAppSDK.$(WindowsAppSdkPackageVersion)</WASDKPackageCppDirectoryName>
<WASDKPackageCSharpDirectoryName>microsoft.windowsappsdk\$(WindowsAppSdkPackageVersion)</WASDKPackageCSharpDirectoryName>
</PropertyGroup>
<!-- Now we can build the mock WindowsAppSDK package. -->
<RunPowershellScript Path="$(BuildMockPackageScriptPath)" Parameters="$(BuildMockPackageScriptParams)" />
<!-- Finally, we'll install the packages. Visual Studio complains if we completely delete and regenerate in-use NuGet package folders,
so instead of that, if the package folders already exist, we'll just copy over all of the lib, runtimes, and MSIX files.
This ensures that the newest built files get used correctly without breaking any Visual Studio NuGet integration. -->
<ItemGroup>
Expand All @@ -91,6 +119,23 @@
</ItemGroup>
<Copy SourceFiles="@(WASDKPackageTempFileToCopy)" DestinationFolder="%(CppTargetDirectory)%(RecursiveDir)" />
<Copy SourceFiles="@(WASDKPackageTempFileToCopy)" DestinationFolder="%(CSharpTargetDirectory)%(RecursiveDir)" />

<!-- This project needs an output file that changes when the mock WinAppSDK package is updated
so that other projects that depend on this one will know to rebuild. -->
<Touch Files="$(OutDir).MockWinAppSdkPackageUpdated" AlwaysCreate="true" />

<ItemGroup>
<FileWrites Include="$(MockPackagePath)" />
<FileWrites Include="$(OutDir)**\*" />
</ItemGroup>
</Target>
<ItemGroup>
<Content Include="$(OutDir).MockWinAppSdkPackageUpdated" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Target Name="GetUpdatedMarkerFilePath" Returns="@(UpdatedMarkerFilePath)">
<ItemGroup>
<UpdatedMarkerFilePath Include="$(OutDir).MockWinAppSdkPackageUpdated" />
</ItemGroup>
</Target>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'" />
Expand All @@ -109,6 +154,7 @@
<!-- Define targets required for MSBuild's project-to-project protocol -->
<Target Name="GetNativeManifest" />
<Target Name="GetCopyToOutputDirectoryItems" />
<Target Name="GetCopyToPublishDirectoryItems" />
<Target Name="GetTargetPathWithTargetPlatformMoniker" />
<Target Name="GetPackagingOutputs" />
</Project>
19 changes: 19 additions & 0 deletions src/UpdateMockWinAppSDKPackageBeforeBuilding.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectReference Include="$(ProjectRoot)UpdateMockWinAppSDKPackage.csproj" ReferenceOutputAssembly="false" Condition="'$(BuildingInsideVisualStudio)' == 'true'" />
</ItemGroup>

<Target Name="EnsureBuildAfterUpdatingMockWinAppSDK" BeforeTargets="Build" Condition="'$(BuildingInsideVisualStudio)' == 'true'" />
<Target Name="GetMockWinAppSDKUpdatedMarkerFilePath" BeforeTargets="EnsureBuildAfterUpdatingMockWinAppSDK" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<MSBuild Projects="$(ProjectRoot)UpdateMockWinAppSDKPackage.csproj" Targets="GetUpdatedMarkerFilePath">
<Output TaskParameter="TargetOutputs" ItemName="UpdatedMarkerFilePath" />
</MSBuild>
</Target>
<Target Name="AddMockWinAppSDKUpdatedMarkerFilePathToContent" AfterTargets="EnsureBuildAfterUpdatingMockWinAppSDK" Condition="'$(BuildingInsideVisualStudio)' == 'true'" Inputs="@(UpdatedMarkerFilePath)" Outputs="@(UpdatedMarkerFilePath->'$(OutDir)%(Filename)%(Extension)')">
<ItemGroup>
<Content Include="@(UpdatedMarkerFilePath)" />
</ItemGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/controls/dev/AnimatedIcon/TestUI/AnimatedIconHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace MUXControlsTestApp
{
public sealed class AnimatedIconHost : Button
public sealed partial class AnimatedIconHost : Button
{
Border m_iconPresenter;
TextBlock m_transitionTextBlock;
Expand Down
4 changes: 2 additions & 2 deletions src/controls/dev/AnimatedIcon/TestUI/BrightnessSun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace AnimatedVisuals
// Frame rate: 25 fps
// Frame count: 40
// Duration: 1600.0 mS
sealed class BrightnessSun
sealed partial class BrightnessSun
: Microsoft.UI.Xaml.Controls.IAnimatedVisualSource, Microsoft.UI.Xaml.Controls.IAnimatedVisualSource2
{
// Animation duration: 1.600 seconds.
Expand Down Expand Up @@ -127,7 +127,7 @@ public void SetScalarProperty(string propertyName, double value)
{
}

sealed class BrightnessSun_AnimatedVisual : Microsoft.UI.Xaml.Controls.IAnimatedVisual
sealed partial class BrightnessSun_AnimatedVisual : Microsoft.UI.Xaml.Controls.IAnimatedVisual
{
const long c_durationTicks = 16000000;
readonly Compositor _c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace MUXControlsTestApp
{
class ColorToSolidColorBrushConverter : IValueConverter
partial class ColorToSolidColorBrushConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace MUXControlsTestApp
{
class DoubleToStringConverter : IValueConverter
partial class DoubleToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace MUXControlsTestApp
{
class MockIAnimatedIconSource2 : IAnimatedVisualSource2
partial class MockIAnimatedIconSource2 : IAnimatedVisualSource2
{
Dictionary<string, double> markers = new Dictionary<string, double>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace MUXControlsTestApp
{
public sealed class ToggleAnimatedIconHost : CheckBox
public sealed partial class ToggleAnimatedIconHost : CheckBox
{
Border m_iconPresenter;
TextBlock m_transitionTextBlock;
Expand Down
59 changes: 40 additions & 19 deletions src/controls/dev/AnimatedVisualPlayer/AnimatedVisualPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,25 +323,31 @@ AnimatedVisualPlayer::AnimatedVisualPlayer()

// Subscribe to suspending, resuming, and visibility events so we can pause the animation if it's
// definitely not visible.
m_suspendingRevoker = winrt::Application::Current().Suspending(winrt::auto_revoke, [weakThis{ get_weak() }](
// Previously we used get_weak() here, but we found the potential to hit a
// refcounting problem where in some scenarios the outer object gets
// an extra Release() in this process.
auto weakThis {winrt::make_weak(static_cast<winrt::AnimatedVisualPlayer>(*this))};
m_suspendingRevoker = winrt::Application::Current().Suspending(winrt::auto_revoke, [weakThis](
auto const& /*sender*/,
auto const& /*e*/)
{
if (auto strongThis = weakThis.get())
{
strongThis->OnHiding();
AnimatedVisualPlayer* rawThis = winrt::get_self<AnimatedVisualPlayer>(strongThis);
rawThis->OnHiding();
}
});

m_resumingRevoker = winrt::Application::Current().Resuming(winrt::auto_revoke, [weakThis{ get_weak() }](
m_resumingRevoker = winrt::Application::Current().Resuming(winrt::auto_revoke, [weakThis](
auto const& /*sender*/,
auto const& /*e*/)
{
if (auto strongThis = weakThis.get())
{
if (winrt::CoreWindow::GetForCurrentThread().Visible())
{
strongThis->OnUnhiding();
AnimatedVisualPlayer* rawThis = winrt::get_self<AnimatedVisualPlayer>(strongThis);
rawThis->OnUnhiding();
}
}
});
Expand Down Expand Up @@ -398,27 +404,31 @@ void AnimatedVisualPlayer::OnLoaded(winrt::IInspectable const& /*sender*/, winrt
m_isUnloaded = false;
}


m_xamlRootChangedRevoker = this->XamlRoot().Changed(winrt::auto_revoke, [weakThis{ get_weak() }](
// Previously we used get_weak() here, but we found the potential to hit a
// refcounting problem where in some scenarios the outer object gets
// an extra Release() in this process.
auto weakThis {winrt::make_weak(static_cast<winrt::AnimatedVisualPlayer>(*this))};
m_xamlRootChangedRevoker = this->XamlRoot().Changed(winrt::auto_revoke, [weakThis](
auto const& /*sender*/,
auto const& args)
{
if (auto strongThis = weakThis.get())
{
auto xamlRoot = strongThis->XamlRoot();
AnimatedVisualPlayer* rawThis = winrt::get_self<AnimatedVisualPlayer>(strongThis);
auto xamlRoot = rawThis->XamlRoot();
bool hostVisibility = xamlRoot.IsHostVisible();
if (hostVisibility != strongThis->m_isHostVisible)
if (hostVisibility != rawThis->m_isHostVisible)
{
strongThis->m_isHostVisible = hostVisibility;
rawThis->m_isHostVisible = hostVisibility;
if (hostVisibility)
{
// Transition from invisible to visible.
strongThis->OnUnhiding();
rawThis->OnUnhiding();
}
else
{
// Transition from visible to invisible.
strongThis->OnHiding();
rawThis->OnHiding();
}

}
Expand Down Expand Up @@ -832,29 +842,35 @@ void AnimatedVisualPlayer::DestroyAnimations() {

// Call RequestCommit to make sure that previous compositor calls complete before destroying animations.
// RequestCommitAsync is available only for RS4+
// Previously we used get_weak() here, but we found the potential to hit a
// refcounting problem where in some scenarios the outer object gets
// an extra Release() in this process.
auto weakThis {winrt::make_weak(static_cast<winrt::AnimatedVisualPlayer>(*this))};
m_rootVisual.Compositor().RequestCommitAsync().Completed(
[me_weak = get_weak(), createAnimationsCounter = m_createAnimationsCounter](auto, auto) {
auto me = me_weak.get();
[weakThis, createAnimationsCounter = m_createAnimationsCounter](auto, auto) {
auto strongThis = weakThis.get();

if (!me)
if (!strongThis)
{
return;
}

AnimatedVisualPlayer* rawThis = winrt::get_self<AnimatedVisualPlayer>(strongThis);

// Check if there was any CreateAnimations call after DestroyAnimations.
// We should not destroy animations in this case,
// they will be destroyed by the following DestroyAnimations call.
if (createAnimationsCounter != me->m_createAnimationsCounter) {
if (createAnimationsCounter != rawThis->m_createAnimationsCounter) {
return;
}

// Check if current animated visual supports destroyig animations.
if (const auto& animatedVisual = me->m_animatedVisual.get())
if (const auto& animatedVisual = rawThis->m_animatedVisual.get())
{
if (const auto& animatedVisual2 = animatedVisual.try_as<winrt::IAnimatedVisual2>())
{
animatedVisual2.DestroyAnimations();
me->m_isAnimationsCreated = false;
rawThis->m_isAnimationsCreated = false;
}
}
}
Expand Down Expand Up @@ -884,14 +900,19 @@ void AnimatedVisualPlayer::OnSourcePropertyChanged(
if (auto newDynamicSource = newSource.try_as<winrt::IDynamicAnimatedVisualSource>())
{
// Connect to the update notifications of the new source.
// Previously we used get_weak() here, but we found the potential to hit a
// refcounting problem where in some scenarios the outer object gets
// an extra Release() in this process.
auto weakThis {winrt::make_weak(static_cast<winrt::AnimatedVisualPlayer>(*this))};
m_dynamicAnimatedVisualInvalidatedRevoker
= newDynamicSource.AnimatedVisualInvalidated(winrt::auto_revoke, [weakThis{ get_weak() }](
= newDynamicSource.AnimatedVisualInvalidated(winrt::auto_revoke, [weakThis](
auto const& /*sender*/,
auto const& /*e*/)
{
if (auto strongThis = weakThis.get())
{
strongThis->UpdateContent();
AnimatedVisualPlayer* rawThis = winrt::get_self<AnimatedVisualPlayer>(strongThis);
rawThis->UpdateContent();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace MUXControlsTestApp
{
public class FallbackGrid : Microsoft.UI.Xaml.Controls.Grid
public partial class FallbackGrid : Microsoft.UI.Xaml.Controls.Grid
{
internal const int RectangleWidth = 100;
internal const int RectangleHeight = 100;
Expand Down
4 changes: 2 additions & 2 deletions src/controls/dev/AnimatedVisualPlayer/TestUI/LottieLogo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace AnimatedVisuals
// Frame rate: 30 fps
// Frame count: 179
// Duration: 5966.7 mS
public sealed class LottieLogo
public sealed partial class LottieLogo
: Microsoft.UI.Xaml.Controls.IAnimatedVisualSource
{
// Animation duration: 5.967 seconds.
Expand Down Expand Up @@ -131,7 +131,7 @@ public void SetScalarProperty(string propertyName, double value)
{
}

sealed class LottieLogo_AnimatedVisual : Microsoft.UI.Xaml.Controls.IAnimatedVisual2
sealed partial class LottieLogo_AnimatedVisual : Microsoft.UI.Xaml.Controls.IAnimatedVisual2
{
const long c_durationTicks = 59666666;
readonly Compositor _c;
Expand Down
Loading

0 comments on commit 6909712

Please sign in to comment.