Skip to content

Commit

Permalink
feat(composition): Implement CompositionCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed605 committed Sep 5, 2023
1 parent 2def209 commit 56c39cf
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 33 deletions.
26 changes: 26 additions & 0 deletions src/Uno.UI.Composition/Composition/CompositionCapabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;

namespace Windows.UI.Composition
{
public partial class CompositionCapabilities
{
private Compositor? _compositor;

internal CompositionCapabilities(Compositor? compositor) => _compositor = compositor;

public static CompositionCapabilities GetForCurrentView() => new CompositionCapabilities(Compositor.Current);

public partial bool AreEffectsSupported();

public partial bool AreEffectsFast();

TypedEventHandler<CompositionCapabilities, object>? Changed;
}
}
18 changes: 18 additions & 0 deletions src/Uno.UI.Composition/Composition/CompositionCapabilities.skia.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;

namespace Windows.UI.Composition
{
public partial class CompositionCapabilities
{
public partial bool AreEffectsSupported() => true;

public partial bool AreEffectsFast() => _compositor?.IsSoftwareRenderer is not true;
}
}
4 changes: 4 additions & 0 deletions src/Uno.UI.Composition/Composition/Compositor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ namespace Windows.UI.Composition
{
public partial class Compositor : global::System.IDisposable
{
internal static Compositor? Current;

public Compositor() { Current = this; }

public ContainerVisual CreateContainerVisual()
=> new ContainerVisual(this);

Expand Down
2 changes: 2 additions & 0 deletions src/Uno.UI.Composition/Composition/Compositor.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public partial class Compositor
{
private bool _isDirty;

internal bool? IsSoftwareRenderer { get; set; }

internal void RenderRootVisual(SKSurface surface, ContainerVisual rootVisual)
{
if (rootVisual is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,26 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.UI.Composition
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || false || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented]
#endif
public partial class CompositionCapabilities
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
internal CompositionCapabilities()
{
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || false || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool AreEffectsSupported()
public partial bool AreEffectsSupported()
{
throw new global::System.NotImplementedException("The member bool CompositionCapabilities.AreEffectsSupported() is not implemented. For more information, visit https://aka.platform.uno/notimplemented#m=bool%20CompositionCapabilities.AreEffectsSupported%28%29");
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || false || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool AreEffectsFast()
public partial bool AreEffectsFast()
{
throw new global::System.NotImplementedException("The member bool CompositionCapabilities.AreEffectsFast() is not implemented. For more information, visit https://aka.platform.uno/notimplemented#m=bool%20CompositionCapabilities.AreEffectsFast%28%29");
}
#endif
// Forced skipping of method Windows.UI.Composition.CompositionCapabilities.Changed.add
// Forced skipping of method Windows.UI.Composition.CompositionCapabilities.Changed.remove
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Composition.CompositionCapabilities GetForCurrentView()
{
throw new global::System.NotImplementedException("The member CompositionCapabilities CompositionCapabilities.GetForCurrentView() is not implemented. For more information, visit https://aka.platform.uno/notimplemented#m=CompositionCapabilities%20CompositionCapabilities.GetForCurrentView%28%29");
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Composition.CompositionCapabilities, object> Changed
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Composition.CompositionCapabilities", "event TypedEventHandler<CompositionCapabilities, object> CompositionCapabilities.Changed");
}
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Composition.CompositionCapabilities", "event TypedEventHandler<CompositionCapabilities, object> CompositionCapabilities.Changed");
}
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ protected override bool OnDrawn(Context cr)
if (_host.RootElement?.Visual is { } rootVisual)
{
WUX.Window.Current.Compositor.RenderRootVisual(_surface, rootVisual);

if (WUX.Window.Current.Compositor.IsSoftwareRenderer is null)
WUX.Window.Current.Compositor.IsSoftwareRenderer = true;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI.Runtime.Skia.Wpf/Rendering/SoftwareWpfRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public void Render(DrawingContext drawingContext)
if (_host.RootElement?.Visual is { } rootVisual)
{
rootVisual.Compositor.RenderRootVisual(surface, rootVisual);

if (rootVisual.Compositor.IsSoftwareRenderer is null)
rootVisual.Compositor.IsSoftwareRenderer = true;
}
}

Expand Down

0 comments on commit 56c39cf

Please sign in to comment.