Skip to content

Commit 60e5a9e

Browse files
Win2D pipeline brushes (#3112)
* Added extensions and Win2D helpers * Added PipelineBuilder type * Added acrylic and tiles brushes * Added XamlCompositionBrush type * Added Win2D/Composition effects * Added pipeline brush * Minor code styling tweaks * Switched composition cache to ConditionalWeakTable<TKey, TValue> * Minor performance improvements * More code switched to ConditionalWeakTable<TKey, TValue> * Fixed missing file header * Added empty PipelineBrush sample page * Fixed an incorrect namespace * Implemented PipelineBrush sample * Fixed incorrect extensions namespaces * Reordered using directives * Code refactoring, added LuminanceToAlpha pipeline effect * Added C# sample code * Reordered a using statement * Renamed some public APIs * More API refactoring * Removed unused API * Reordered a using statement * Added support for repeated effects in a pipeline * Animation delegates changed to TimeSpan params * Added effects setter APIs * Removed unnecessary remarks * Added generic parameter to effect setters * Added generic parameter to effect animations * Added overloads to set/animate a color effect * Fixed some XML docs * Added check for composition capabilities in brushes * BackdropSaturationBrush switched to pipeline * Removed unnecessary using directives * Added pipeline invert effect * BackdropInvertBrush switched to pipeline * Reordered using directives * BackdropBlurBrush switched to pipeline * Added sepia effect APIs * BackdropSepiaBrush switched to pipeline * Added HDR color pipeline initialization APIs * Minor code refactoring * More code refactoring * More code refactoring * Added exposure effect * Added grayscale effect * Minor code refactoring and bug fixes * Switched to ValueTask<T> to reduce allocations, new APIs * Removed unnecessary APIs * Streamlined prebuilt acrylic pipelines * Added support for live updates in the acrylic brush * Code refactoring to keep the style consistent * Added support for noiseless acrylic effects * Code refactoring * Added XML remarks with Win2D reference links * Renamed the TintEffect type * Added TintEffect * Added TemperatureAndTintEffect * Added HueRotationEffect * Aadded missing capability check * Removed unnecessary APIs, code refactoring * Removed an unnecessary resize step * Win2DImageHelper class renamed to SurfaceLoader * Unified SurfaceLoader APIs in the .Media package * Added sample page for the AcrylicBrush * Updated AcrylicBrush icon * Added bindings for the AcrylicBrush sample * Added dependency property to the TilesBrush * Added sample page for the TilesBrush * Fixed two XML comments * Updated tile texture * Added new brushes to the readme * Minor code refactoring * Added support for device lost in SurfaceLoader.Instance * Updated tile brush texture * Added opacity to tile brush sample * Updated the PipelineBrush sample page icon * Fixed PipelineBrush sample page shallow copy * Update Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TilesBrush/TilesBrushXaml.bind Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> * Removed unnecessary CU badges * Update Microsoft.Toolkit.Uwp.UI.Media/Brushes/AcrylicBrush.cs Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> * Added missing effects to shallow copy * Moved brushes to .Media namespace * Fixed crash in pipeline sample page * Switched BlendEffect.Mode to use proxy enum * Minor code refactoring * Added unicorn to PipelineBrush sample * Fixed code URLs for brushes * Fixed documentation URLs to brushes * Fix StyleCop Issues with namespaces in Brushes * Fixed uppercase acronym in public property * Added DpiMode property to TilesBrush Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]>
1 parent c51e301 commit 60e5a9e

File tree

75 files changed

+4336
-463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4336
-463
lines changed
216 KB
Loading
359 KB
Loading

Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
</ItemGroup>
136136
<ItemGroup>
137137
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
138+
<Content Include="Assets\BrushAssets\TileTexture.png" />
139+
<Content Include="Assets\BrushAssets\NoiseTexture.png" />
138140
<Content Include="Assets\mslogo.png" />
139141
<Content Include="Assets\NotificationAssets\Cloudy-Square.png" />
140142
<Content Include="Assets\NotificationAssets\Cloudy.png" />
@@ -269,8 +271,11 @@
269271
<Content Include="Icons\More.png" />
270272
<Content Include="Icons\Notifications.png" />
271273
<Content Include="Icons\Services.png" />
274+
<Content Include="SamplePages\TilesBrush\TilesBrush.png" />
272275
<Content Include="SamplePages\Eyedropper\Eyedropper.png" />
273276
<Content Include="SamplePages\OnDevice\OnDevice.png" />
277+
<Content Include="SamplePages\AcrylicBrush\AcrylicBrush.png" />
278+
<Content Include="SamplePages\PipelineBrush\PipelineBrush.png" />
274279
<Content Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelper.png" />
275280
<Content Include="SamplePages\ImageCropper\ImageCropper.png" />
276281
<Content Include="SamplePages\StaggeredLayout\StaggeredLayout.png" />
@@ -511,6 +516,9 @@
511516
</Content>
512517
<Content Include="SamplePages\Weibo Service\WeiboCode.bind" />
513518
<Compile Include="Common\TextBlockHyperlinkBehavior.cs" />
519+
<Compile Include="SamplePages\TilesBrush\TilesBrushPage.xaml.cs">
520+
<DependentUpon>TilesBrushPage.xaml</DependentUpon>
521+
</Compile>
514522
<Compile Include="SamplePages\Eyedropper\EyedropperPage.xaml.cs">
515523
<DependentUpon>EyedropperPage.xaml</DependentUpon>
516524
</Compile>
@@ -529,6 +537,12 @@
529537
<Compile Include="SamplePages\OnDevice\OnDevicePage.xaml.cs">
530538
<DependentUpon>OnDevicePage.xaml</DependentUpon>
531539
</Compile>
540+
<Compile Include="SamplePages\AcrylicBrush\AcrylicBrushPage.xaml.cs">
541+
<DependentUpon>AcrylicBrushPage.xaml</DependentUpon>
542+
</Compile>
543+
<Compile Include="SamplePages\PipelineBrush\PipelineBrushPage.xaml.cs">
544+
<DependentUpon>PipelineBrushPage.xaml</DependentUpon>
545+
</Compile>
532546
<Compile Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelperPage.xaml.cs">
533547
<DependentUpon>RemoteDeviceHelperPage.xaml</DependentUpon>
534548
</Compile>
@@ -584,9 +598,12 @@
584598
<Content Include="SamplePages\Eyedropper\EyedropperXaml.bind" />
585599
<Content Include="SamplePages\Eyedropper\EyedropperCode.bind" />
586600
<Content Include="SamplePages\TokenizingTextBox\TokenizingTextBoxCode.bind" />
601+
<Content Include="SamplePages\PipelineBrush\PipelineBrushXaml.bind" />
602+
<Content Include="SamplePages\PipelineBrush\PipelineBrushCode.bind" />
603+
<Content Include="SamplePages\AcrylicBrush\AcrylicBrushXaml.bind" />
604+
<Content Include="SamplePages\TilesBrush\TilesBrushXaml.bind" />
587605
<Content Include="SamplePages\IconExtensions\IconExtensionsXaml.bind" />
588606
<Content Include="SamplePages\WrapLayout\WrapLayout.bind" />
589-
<Content Include="SamplePages\StaggeredLayout\StaggeredLayout.bind" />
590607
<Content Include="SamplePages\ObservableGroup\ObservableGroup.bind" />
591608
<Content Include="SamplePages\Triggers\CompareStateTrigger.bind" />
592609
<Content Include="SamplePages\Triggers\IsEqualStateTrigger.bind" />
@@ -979,6 +996,10 @@
979996
<SubType>Designer</SubType>
980997
<Generator>MSBuild:Compile</Generator>
981998
</Page>
999+
<Page Include="SamplePages\TilesBrush\TilesBrushPage.xaml">
1000+
<Generator>MSBuild:Compile</Generator>
1001+
<SubType>Designer</SubType>
1002+
</Page>
9821003
<Page Include="SamplePages\Eyedropper\EyedropperPage.xaml">
9831004
<SubType>Designer</SubType>
9841005
<Generator>MSBuild:Compile</Generator>
@@ -1006,6 +1027,14 @@
10061027
<Generator>MSBuild:Compile</Generator>
10071028
<SubType>Designer</SubType>
10081029
</Page>
1030+
<Page Include="SamplePages\AcrylicBrush\AcrylicBrushPage.xaml">
1031+
<Generator>MSBuild:Compile</Generator>
1032+
<SubType>Designer</SubType>
1033+
</Page>
1034+
<Page Include="SamplePages\PipelineBrush\PipelineBrushPage.xaml">
1035+
<SubType>Designer</SubType>
1036+
<Generator>MSBuild:Compile</Generator>
1037+
</Page>
10091038
<Page Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelperPage.xaml">
10101039
<SubType>Designer</SubType>
10111040
<Generator>MSBuild:Compile</Generator>
24.7 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Page
2+
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.AcrylicBrushPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:brushes="using:Microsoft.Toolkit.Uwp.UI.Media"
8+
mc:Ignorable="d">
9+
10+
<!-- Shallow Copy -->
11+
<Grid>
12+
<Rectangle>
13+
<Rectangle.Fill>
14+
<brushes:AcrylicBrush />
15+
</Rectangle.Fill>
16+
</Rectangle>
17+
</Grid>
18+
</Page>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Windows.UI.Xaml.Controls;
6+
7+
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
8+
{
9+
/// <summary>
10+
/// A page that shows how to use the acrylic brushe.
11+
/// </summary>
12+
public sealed partial class AcrylicBrushPage : Page
13+
{
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="AcrylicBrushPage"/> class.
16+
/// </summary>
17+
public AcrylicBrushPage()
18+
{
19+
this.InitializeComponent();
20+
}
21+
}
22+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Page
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:brushes="using:Microsoft.Toolkit.Uwp.UI.Media"
7+
xmlns:effects="using:Microsoft.Toolkit.Uwp.UI.Media.Effects"
8+
mc:Ignorable="d">
9+
10+
<Grid>
11+
<Image Source="ms-appx:///Assets/Photos/BigFourSummerHeat.jpg"/>
12+
<Grid>
13+
<Grid.ColumnDefinitions>
14+
<ColumnDefinition Width="*" />
15+
<ColumnDefinition Width="*" />
16+
</Grid.ColumnDefinitions>
17+
<ProgressRing IsActive="True" Grid.ColumnSpan="2"
18+
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" Width="200" Height="200"/>
19+
<Border BorderBrush="Black" BorderThickness="1"
20+
Grid.Column="2"
21+
Height="400">
22+
<Border.Background>
23+
<brushes:AcrylicBrush Source="@[Source:Enum:AcrylicBackgroundSource.Backdrop]"
24+
Tint="@[Tint:Brush:DarkCyan]"
25+
TintMix="@[TintMix:DoubleSlider:0.2:0.0-1.0]"
26+
BlurAmount="@[BlurAmount:DoubleSlider:12:0.0-32.0]"
27+
TextureUri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
28+
</Border.Background>
29+
</Border>
30+
</Grid>
31+
</Grid>
32+
</Page>
23 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Defines a brush like the one shown in the XAML code, but via C# code.
2+
using Microsoft.Toolkit.Uwp.UI.Media;
3+
using Microsoft.Toolkit.Uwp.UI.Media.Effects;
4+
using Windows.UI.Xaml.Media;
5+
6+
Brush brush =
7+
PipelineBuilder
8+
.FromBackdrop()
9+
.LuminanceToAlpha()
10+
.Opacity(0.4f)
11+
.Blend(
12+
PipelineBuilder.FromBackdrop(),
13+
BlendEffectMode.Multiply)
14+
.Blur(16)
15+
.Shade("#FF222222".ToColor(), 0.4f)
16+
.Blend(
17+
PipelineBuilder.FromTiles("/Assets/BrushAssets/NoiseTexture.png"),
18+
BlendEffectMode.Overlay,
19+
Placement.Background)
20+
.AsBrush();
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<Page
2+
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.PipelineBrushPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media"
8+
xmlns:effects="using:Microsoft.Toolkit.Uwp.UI.Media.Effects"
9+
mc:Ignorable="d">
10+
11+
<!--Shallow copy-->
12+
<Grid>
13+
<Image Source="ms-appx:///Assets/Photos/BigFourSummerHeat.jpg"/>
14+
<Grid>
15+
<Grid.ColumnDefinitions>
16+
<ColumnDefinition Width="*" />
17+
<ColumnDefinition Width="*" />
18+
</Grid.ColumnDefinitions>
19+
<ProgressRing IsActive="True" Grid.ColumnSpan="2"
20+
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" Width="200" Height="200"/>
21+
<Border>
22+
<Border.Background>
23+
<media:PipelineBrush>
24+
<media:PipelineBrush.Effects>
25+
<effects:AcrylicEffect/>
26+
<effects:BlendEffect>
27+
<effects:BlendEffect.Input>
28+
<effects:BackdropEffect Source="Backdrop"/>
29+
</effects:BlendEffect.Input>
30+
</effects:BlendEffect>
31+
<effects:BlurEffect/>
32+
<effects:ExposureEffect/>
33+
<effects:GrayscaleEffect/>
34+
<effects:HueRotationEffect/>
35+
</media:PipelineBrush.Effects>
36+
</media:PipelineBrush>
37+
</Border.Background>
38+
</Border>
39+
<Border>
40+
<Border.Background>
41+
<media:PipelineBrush>
42+
<media:PipelineBrush.Effects>
43+
<effects:AcrylicEffect/>
44+
<effects:HueRotationEffect/>
45+
<effects:BlendEffect>
46+
<effects:BlendEffect.Input>
47+
<effects:ImageEffect Uri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
48+
</effects:BlendEffect.Input>
49+
</effects:BlendEffect>
50+
<effects:InvertEffect/>
51+
<effects:LuminanceToAlphaEffect/>
52+
<effects:OpacityEffect/>
53+
<effects:SaturationEffect/>
54+
<effects:SepiaEffect/>
55+
</media:PipelineBrush.Effects>
56+
</media:PipelineBrush>
57+
</Border.Background>
58+
</Border>
59+
<Border>
60+
<Border.Background>
61+
<media:PipelineBrush>
62+
<media:PipelineBrush.Effects>
63+
<effects:AcrylicEffect/>
64+
<effects:SepiaEffect/>
65+
<effects:ShadeEffect/>
66+
<effects:BlendEffect>
67+
<effects:BlendEffect.Input>
68+
<effects:SolidColorEffect/>
69+
</effects:BlendEffect.Input>
70+
</effects:BlendEffect>
71+
<effects:TemperatureAndTintEffect/>
72+
<effects:BlendEffect>
73+
<effects:BlendEffect.Input>
74+
<effects:TileEffect Uri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
75+
</effects:BlendEffect.Input>
76+
</effects:BlendEffect>
77+
<effects:TintEffect/>
78+
</media:PipelineBrush.Effects>
79+
</media:PipelineBrush>
80+
</Border.Background>
81+
</Border>
82+
</Grid>
83+
</Grid>
84+
</Page>

0 commit comments

Comments
 (0)