forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unoplatform#16403 from ramezgerges/composition_thr…
…ead_architecture Skia Composition refactoring
- Loading branch information
Showing
29 changed files
with
432 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...Shared/Windows_UI_Xaml_Media/BrushesTests/CompositionNineGridBrush_Source_Changes.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using Microsoft.UI.Composition; | ||
using Uno.UI.Samples.Controls; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Hosting; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Media.Imaging; | ||
|
||
namespace UITests.Windows_UI_Xaml_Media.BrushesTests | ||
{ | ||
[Sample("Brushes")] | ||
public sealed partial class CompositionNineGridBrush_Source_Changes : Page | ||
{ | ||
public CompositionNineGridBrush_Source_Changes() | ||
{ | ||
var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; | ||
|
||
var onlineSource = new Image | ||
{ | ||
Width = 100, | ||
Height = 100, | ||
Stretch = Stretch.UniformToFill, | ||
Source = new BitmapImage(new Uri("ms-appx:///Assets/test_image_100_100.png")) | ||
}; | ||
|
||
var online = new Border | ||
{ | ||
Width = 200, | ||
Height = 200 | ||
}; | ||
|
||
var offline = new Grid | ||
{ | ||
Width = 200, | ||
Height = 200 | ||
}; | ||
|
||
var visualSurface = compositor.CreateVisualSurface(); | ||
visualSurface.SourceVisual = ElementCompositionPreview.GetElementVisual(onlineSource); | ||
visualSurface.SourceSize = new(200, 200); | ||
|
||
var onlineBrush = compositor.CreateSurfaceBrush(visualSurface); | ||
var onlineNineGridBrush = compositor.CreateNineGridBrush(); | ||
onlineNineGridBrush.Source = onlineBrush; | ||
onlineNineGridBrush.SetInsets(35); | ||
|
||
online.Background = new TestBrush(onlineNineGridBrush); | ||
|
||
var surface = Microsoft.UI.Xaml.Media.LoadedImageSurface.StartLoadFromUri(new Uri("ms-appx:///Assets/test_image_100_100.png")); | ||
|
||
surface.LoadCompleted += new Windows.Foundation.TypedEventHandler<Microsoft.UI.Xaml.Media.LoadedImageSurface, LoadedImageSourceLoadCompletedEventArgs>((s, o) => | ||
{ | ||
if (o.Status == Microsoft.UI.Xaml.Media.LoadedImageSourceLoadStatus.Success) | ||
{ | ||
var offlineBrush = compositor.CreateSurfaceBrush(surface); | ||
|
||
var offlineNineGridBrush = compositor.CreateNineGridBrush(); | ||
offlineNineGridBrush.Source = offlineBrush; | ||
offlineNineGridBrush.SetInsets(35); | ||
|
||
offline.Background = new TestBrush(offlineNineGridBrush); | ||
|
||
this.Content = new StackPanel | ||
{ | ||
Children = | ||
{ | ||
onlineSource, | ||
// we need to put the children in borders to work around our limited implementation of RenderTargetBitmap | ||
// not taking the offsets of the Visuals into account. This way, the Child will not have any offset | ||
// relative to its parent (the border) | ||
new Border | ||
{ | ||
Child = online | ||
}, | ||
new Border | ||
{ | ||
Child = offline | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
} | ||
|
||
private class TestBrush : Microsoft.UI.Xaml.Media.XamlCompositionBrushBase | ||
{ | ||
private CompositionBrush Brush; | ||
|
||
public TestBrush(CompositionBrush brush) => Brush = brush; | ||
|
||
protected override void OnConnected() => CompositionBrush = Brush; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.