Browse Source
* Init DirectComposition support * Use Win8.1 as a minimum dcomp target, avoid hacks with render timer * Refactor transparency supprot a little * Cleanups * Restore old hack as I don't know how to remove it yetpull/13394/head
committed by
GitHub
20 changed files with 752 additions and 192 deletions
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using System.Numerics; |
|||
using System.Threading; |
|||
using Avalonia.OpenGL.Egl; |
|||
using Avalonia.Reactive; |
|||
using MicroCom.Runtime; |
|||
|
|||
namespace Avalonia.Win32.DComposition; |
|||
|
|||
internal class DirectCompositedWindow : IDisposable |
|||
{ |
|||
private readonly DirectCompositionShared _shared; |
|||
public EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo WindowInfo { get; } |
|||
private readonly IDCompositionVisual _container; |
|||
private readonly IDCompositionTarget _target; |
|||
private readonly IDCompositionDevice2 _device; |
|||
|
|||
public void Dispose() |
|||
{ |
|||
lock (_shared.SyncRoot) |
|||
{ |
|||
_container.Dispose(); |
|||
_target.Dispose(); |
|||
_device.Dispose(); |
|||
} |
|||
} |
|||
|
|||
public DirectCompositedWindow(EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info, DirectCompositionShared shared) |
|||
{ |
|||
WindowInfo = info; |
|||
_shared = shared; |
|||
_device = shared.Device.CloneReference(); |
|||
|
|||
using var desktopTarget = shared.Device.CreateTargetForHwnd(WindowInfo.Handle, false); |
|||
_target = desktopTarget.QueryInterface<IDCompositionTarget>(); |
|||
|
|||
using var container = shared.Device.CreateVisual(); |
|||
_container = container.CloneReference(); |
|||
|
|||
_target.SetRoot(container); |
|||
} |
|||
|
|||
public void SetSurface(IDCompositionSurface surface) => _container.SetContent(surface); |
|||
|
|||
public IDisposable BeginTransaction() |
|||
{ |
|||
Monitor.Enter(_shared.SyncRoot); |
|||
return Disposable.Create(() => |
|||
{ |
|||
_device.Commit(); |
|||
Monitor.Exit(_shared.SyncRoot); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,173 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using Avalonia.OpenGL.Egl; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Win32.DirectX; |
|||
using Avalonia.Win32.Interop; |
|||
using MicroCom.Runtime; |
|||
|
|||
namespace Avalonia.Win32.DComposition; |
|||
|
|||
internal class DirectCompositedWindowSurface : IDirect3D11TexturePlatformSurface, IDisposable, ICompositionEffectsSurface |
|||
{ |
|||
private readonly EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo _info; |
|||
private readonly DirectCompositionShared _shared; |
|||
private DirectCompositedWindow? _window; |
|||
private BlurEffect _blurEffect; |
|||
|
|||
public DirectCompositedWindowSurface(DirectCompositionShared shared, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info) |
|||
{ |
|||
_shared = shared; |
|||
_info = info; |
|||
} |
|||
|
|||
public IDirect3D11TextureRenderTarget CreateRenderTarget(IPlatformGraphicsContext context, IntPtr d3dDevice) |
|||
{ |
|||
_window ??= new DirectCompositedWindow(_info, _shared); |
|||
SetBlur(_blurEffect); |
|||
|
|||
return new DirectCompositedWindowRenderTarget(context, d3dDevice, _shared, _window); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_window?.Dispose(); |
|||
_window = null; |
|||
} |
|||
|
|||
// TODO: we can implement BlurEffect.GaussianBlur in with IDCompositionDevice3.CreateGaussianBlurEffect.
|
|||
public bool IsBlurSupported(BlurEffect effect) => effect == BlurEffect.None; |
|||
|
|||
public void SetBlur(BlurEffect enable) |
|||
{ |
|||
_blurEffect = enable; |
|||
// _window?.SetBlur(enable);
|
|||
} |
|||
} |
|||
|
|||
internal class DirectCompositedWindowRenderTarget : IDirect3D11TextureRenderTarget |
|||
{ |
|||
private static readonly Guid IID_ID3D11Texture2D = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); |
|||
|
|||
private readonly IPlatformGraphicsContext _context; |
|||
private readonly DirectCompositedWindow _window; |
|||
private readonly IDCompositionVirtualSurface _surface; |
|||
private bool _lost; |
|||
private PixelSize _size; |
|||
private readonly IUnknown _d3dDevice; |
|||
|
|||
public DirectCompositedWindowRenderTarget( |
|||
IPlatformGraphicsContext context, IntPtr d3dDevice, |
|||
DirectCompositionShared shared, DirectCompositedWindow window) |
|||
{ |
|||
_d3dDevice = MicroComRuntime.CreateProxyFor<IUnknown>(d3dDevice, false).CloneReference(); |
|||
|
|||
_context = context; |
|||
_window = window; |
|||
|
|||
using (var surfaceFactory = shared.Device.CreateSurfaceFactory(_d3dDevice)) |
|||
{ |
|||
_surface = surfaceFactory.CreateVirtualSurface(1, 1, DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM, |
|||
DXGI_ALPHA_MODE.DXGI_ALPHA_MODE_PREMULTIPLIED); |
|||
} |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_surface.Dispose(); |
|||
_d3dDevice.Dispose(); |
|||
} |
|||
|
|||
public bool IsCorrupted => _context.IsLost || _lost; |
|||
|
|||
public unsafe IDirect3D11TextureRenderTargetRenderSession BeginDraw() |
|||
{ |
|||
if (IsCorrupted) |
|||
throw new RenderTargetCorruptedException(); |
|||
var transaction = _window.BeginTransaction(); |
|||
bool needsEndDraw = false; |
|||
try |
|||
{ |
|||
var size = _window.WindowInfo.Size; |
|||
var scale = _window.WindowInfo.Scaling; |
|||
if (_size != size) |
|||
{ |
|||
_surface.Resize((ushort)size.Width, (ushort)size.Height); |
|||
_size = size; |
|||
} |
|||
|
|||
_window.SetSurface(_surface); |
|||
|
|||
void* pTexture; |
|||
UnmanagedMethods.POINT off; |
|||
try |
|||
{ |
|||
var rect = new UnmanagedMethods.RECT { right = size.Width, bottom = size.Height }; |
|||
var iid = IID_ID3D11Texture2D; |
|||
off = _surface.BeginDraw(&rect, &iid, &pTexture); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
_lost = true; |
|||
throw new RenderTargetCorruptedException(e); |
|||
} |
|||
|
|||
needsEndDraw = true; |
|||
var offset = new PixelPoint(off.X, off.Y); |
|||
using var texture = MicroComRuntime.CreateProxyFor<IUnknown>(pTexture, true); |
|||
|
|||
var session = new Session(_surface, texture, transaction, size, offset, scale); |
|||
transaction = null; |
|||
return session; |
|||
} |
|||
finally |
|||
{ |
|||
if (transaction != null) |
|||
{ |
|||
if (needsEndDraw) |
|||
_surface.EndDraw(); |
|||
transaction.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private class Session : IDirect3D11TextureRenderTargetRenderSession |
|||
{ |
|||
private readonly IDisposable _transaction; |
|||
private readonly PixelSize _size; |
|||
private readonly PixelPoint _offset; |
|||
private readonly double _scaling; |
|||
private readonly IDCompositionSurface _surfaceInterop; |
|||
private readonly IUnknown _texture; |
|||
|
|||
public Session(IDCompositionSurface surfaceInterop, IUnknown texture, IDisposable transaction, |
|||
PixelSize size, PixelPoint offset, double scaling) |
|||
{ |
|||
_transaction = transaction; |
|||
_size = size; |
|||
_offset = offset; |
|||
_scaling = scaling; |
|||
_surfaceInterop = surfaceInterop.CloneReference(); |
|||
_texture = texture.CloneReference(); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
try |
|||
{ |
|||
_texture.Dispose(); |
|||
_surfaceInterop.EndDraw(); |
|||
_surfaceInterop.Dispose(); |
|||
} |
|||
finally |
|||
{ |
|||
_transaction.Dispose(); |
|||
} |
|||
} |
|||
|
|||
public IntPtr D3D11Texture2D => _texture.GetNativeIntPtr(); |
|||
public PixelSize Size => _size; |
|||
public PixelPoint Offset => _offset; |
|||
public double Scaling => _scaling; |
|||
} |
|||
} |
|||
@ -0,0 +1,129 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Diagnostics; |
|||
using System.Runtime.InteropServices; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Logging; |
|||
using Avalonia.MicroCom; |
|||
using Avalonia.OpenGL.Egl; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.Win32.Interop; |
|||
using Avalonia.Win32.WinRT; |
|||
using Avalonia.Win32.WinRT.Composition; |
|||
using MicroCom.Runtime; |
|||
|
|||
namespace Avalonia.Win32.DComposition; |
|||
|
|||
internal class DirectCompositionConnection : IRenderTimer, IWindowsSurfaceFactory |
|||
{ |
|||
private static readonly Guid IID_IDCompositionDesktopDevice = Guid.Parse("5f4633fe-1e08-4cb8-8c75-ce24333f5602"); |
|||
|
|||
public event Action<TimeSpan>? Tick; |
|||
public bool RunsInBackground => true; |
|||
|
|||
private readonly DirectCompositionShared _shared; |
|||
|
|||
public DirectCompositionConnection(DirectCompositionShared shared) |
|||
{ |
|||
_shared = shared; |
|||
} |
|||
|
|||
private static bool TryCreateAndRegisterCore() |
|||
{ |
|||
var tcs = new TaskCompletionSource<bool>(); |
|||
var th = new Thread(() => |
|||
{ |
|||
DirectCompositionConnection connect; |
|||
try |
|||
{ |
|||
var result = NativeMethods.DCompositionCreateDevice2(default, IID_IDCompositionDesktopDevice, out var cDevice); |
|||
if (result != UnmanagedMethods.HRESULT.S_OK) |
|||
{ |
|||
throw new Win32Exception((int)result); |
|||
} |
|||
|
|||
using (var device = MicroComRuntime.CreateProxyFor<IDCompositionDesktopDevice>(cDevice, false)) |
|||
{ |
|||
var shared = new DirectCompositionShared(device); |
|||
connect = new DirectCompositionConnection(shared); |
|||
} |
|||
|
|||
AvaloniaLocator.CurrentMutable.Bind<IWindowsSurfaceFactory>().ToConstant(connect); |
|||
AvaloniaLocator.CurrentMutable.Bind<IRenderTimer>().ToConstant(connect); |
|||
tcs.SetResult(true); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
tcs.SetException(e); |
|||
return; |
|||
} |
|||
|
|||
connect.RunLoop(); |
|||
}) { IsBackground = true, Name = "DwmRenderTimerLoop" }; |
|||
th.SetApartmentState(ApartmentState.STA); |
|||
th.Start(); |
|||
return tcs.Task.Result; |
|||
} |
|||
|
|||
private void RunLoop() |
|||
{ |
|||
var cts = new CancellationTokenSource(); |
|||
AppDomain.CurrentDomain.ProcessExit += (_, _) => |
|||
cts.Cancel(); |
|||
|
|||
var _stopwatch = Stopwatch.StartNew(); |
|||
var device = _shared.Device.CloneReference(); |
|||
|
|||
while (!cts.IsCancellationRequested) |
|||
{ |
|||
try |
|||
{ |
|||
device.WaitForCommitCompletion(); |
|||
Tick?.Invoke(_stopwatch.Elapsed); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Logger.TryGet(LogEventLevel.Error, LogArea.Win32Platform) |
|||
?.Log(this, $"Failed to wait for vblank, Exception: {ex.Message}, HRESULT = {ex.HResult}"); |
|||
} |
|||
} |
|||
|
|||
device?.Dispose(); |
|||
} |
|||
|
|||
public static bool IsSupported() |
|||
{ |
|||
return Win32Platform.WindowsVersion >= PlatformConstants.Windows8_1; |
|||
} |
|||
|
|||
public static bool TryCreateAndRegister() |
|||
{ |
|||
if (IsSupported()) |
|||
{ |
|||
try |
|||
{ |
|||
TryCreateAndRegisterCore(); |
|||
return true; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Logger.TryGet(LogEventLevel.Error, LogArea.Win32Platform) |
|||
?.Log(null, "Unable to initialize WinUI compositor: {0}", e); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
var osVersionNotice = |
|||
$"Windows {PlatformConstants.Windows8_1} is required. Your machine has Windows {Win32Platform.WindowsVersion} installed."; |
|||
|
|||
Logger.TryGet(LogEventLevel.Warning, LogArea.Win32Platform)?.Log(null, |
|||
$"Unable to initialize WinUI compositor: {osVersionNotice}"); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public bool RequiresNoRedirectionBitmap => true; |
|||
public object CreateSurface(EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info) => new DirectCompositedWindowSurface(_shared, info); |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Threading; |
|||
using Avalonia.Win32.Interop; |
|||
using MicroCom.Runtime; |
|||
|
|||
namespace Avalonia.Win32.DComposition; |
|||
|
|||
internal class DirectCompositionShared : IDisposable |
|||
{ |
|||
public object SyncRoot { get; } = new(); |
|||
|
|||
public DirectCompositionShared(IDCompositionDesktopDevice device) |
|||
{ |
|||
Device = device.CloneReference(); |
|||
} |
|||
|
|||
public IDCompositionDesktopDevice Device { get; } |
|||
|
|||
public void Dispose() |
|||
{ |
|||
Device.Dispose(); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using Avalonia.Win32.DirectX; |
|||
using Avalonia.Win32.Interop; |
|||
|
|||
namespace Avalonia.Win32.DComposition; |
|||
|
|||
internal class NativeMethods |
|||
{ |
|||
[DllImport("dcomp", ExactSpelling = true)] |
|||
public static extern UnmanagedMethods.HRESULT DCompositionCreateDevice2( /* _In_opt_ */ |
|||
IntPtr renderingDevice, /* _In_ */ |
|||
[MarshalAs(UnmanagedType.LPStruct)] Guid iid, /* _Outptr_ */ out IntPtr dcompositionDevice); |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System.Runtime.InteropServices; |
|||
using Avalonia.Win32.DirectX; |
|||
|
|||
namespace Avalonia.Win32.DComposition; |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct DXGI_RATIONAL |
|||
{ |
|||
public uint Numerator; |
|||
public uint Denominator; |
|||
} |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct DCOMPOSITION_FRAME_STATISTICS |
|||
{ |
|||
public long lastFrameTime; |
|||
public DXGI_RATIONAL currentCompositionRate; |
|||
public long currentTime; |
|||
public long timeFrequency; |
|||
public long nextEstimatedFrameTime; |
|||
} |
|||
@ -0,0 +1,164 @@ |
|||
@clr-namespace Avalonia.Win32.DComposition |
|||
@clr-access internal |
|||
@clr-map FLOAT float |
|||
@clr-map HSTRING IntPtr |
|||
@clr-map Vector2 System.Numerics.Vector2 |
|||
@clr-map Vector3 System.Numerics.Vector3 |
|||
@clr-map Quaternion System.Numerics.Quaternion |
|||
@clr-map Matrix4x4 System.Numerics.Matrix4x4 |
|||
@clr-map RECT Avalonia.Win32.Interop.UnmanagedMethods.RECT |
|||
@clr-map SIZE Avalonia.Win32.Interop.UnmanagedMethods.SIZE |
|||
@clr-map POINT Avalonia.Win32.Interop.UnmanagedMethods.POINT |
|||
@clr-map DXGI_FORMAT Avalonia.Win32.DirectX.DXGI_FORMAT |
|||
@clr-map DXGI_ALPHA_MODE Avalonia.Win32.DirectX.DXGI_ALPHA_MODE |
|||
@clr-map HWND IntPtr |
|||
@clr-map HANDLE IntPtr |
|||
@clr-map BOOL int |
|||
@clr-map DWORD int |
|||
@clr-map SIZE_T IntPtr |
|||
@clr-map boolean int |
|||
@clr-map BYTE byte |
|||
@clr-map INT16 short |
|||
@clr-map INT32 int |
|||
@clr-map INT64 long |
|||
@clr-map UINT ushort |
|||
@clr-map UINT16 ushort |
|||
@clr-map ULONG uint |
|||
@clr-map UINT32 uint |
|||
@clr-map UINT64 ulong |
|||
@clr-map DOUBLE double |
|||
@clr-map GUID System.Guid |
|||
@clr-map REFGUID System.Guid* |
|||
@clr-map REFIID System.Guid* |
|||
@clr-map WCHAR System.Char |
|||
@clr-map HMODULE void* |
|||
@clr-map DXGI_USAGE uint |
|||
@clr-map LARGE_INTEGER ulong |
|||
@clr-map INT int |
|||
@clr-map DXGI_SHARED_RESOURCE void* |
|||
@clr-map LUID ulong |
|||
@clr-map LPSTR ushort* |
|||
@clr-map LPWSTR ushort* |
|||
@clr-map LPCWSTR ushort* |
|||
|
|||
[uuid(c37ea93a-e7aa-450d-b16f-9746cb0407f3)] |
|||
interface IDCompositionDevice : IUnknown |
|||
{ |
|||
HRESULT Commit(); |
|||
HRESULT WaitForCommitCompletion(); |
|||
HRESULT GetFrameStatistics(DCOMPOSITION_FRAME_STATISTICS* statistics); |
|||
HRESULT CreateTargetForHwnd(IntPtr hwnd, bool topmost, [out] IDCompositionVisual** target); |
|||
HRESULT CreateVisual([out] IDCompositionVisual** visual); |
|||
HRESULT CreateSurface(UINT width, UINT height, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, [out] IDCompositionSurface** surface); |
|||
HRESULT CreateVirtualSurface(UINT initialWidth, UINT initialHeight, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, [out] IDCompositionVirtualSurface** virtualSurface); |
|||
HRESULT CreateSurfaceFromHandle(IntPtr handle, [out] IUnknown** surface); |
|||
HRESULT CreateSurfaceFromHwnd(IntPtr hwnd, [out] IUnknown** surface); |
|||
HRESULT CreateTranslateTransform([out] void** translateTransform); |
|||
HRESULT CreateScaleTransform([out] void** scaleTransform); |
|||
HRESULT CreateRotateTransform([out] void** rotateTransform); |
|||
HRESULT CreateSkewTransform([out] void** skewTransform); |
|||
HRESULT CreateMatrixTransform([out] void** matrixTransform); |
|||
HRESULT CreateTransformGroup(void* transforms, int elements, [out] void** transformGroup); |
|||
HRESULT CreateTranslateTransform3D([out] void** translateTransform3D); |
|||
HRESULT CreateScaleTransform3D([out] void** scaleTransform3D); |
|||
HRESULT CreateRotateTransform3D([out] void** rotateTransform3D); |
|||
HRESULT CreateMatrixTransform3D([out] void** matrixTransform3D); |
|||
HRESULT CreateTransform3DGroup(void* transforms3D, int elements, [out] void** transform3DGroup); |
|||
HRESULT CreateEffectGroup([out] void** effectGroup); |
|||
HRESULT CreateRectangleClip([out] void** clip); |
|||
HRESULT CreateAnimation([out] void** animation); |
|||
HRESULT CheckDeviceState([out] BOOL* pfValid); |
|||
} |
|||
|
|||
// IDCompositionDevice2 DOES NOT inherit IDCompositionDevice, it's a completely different interface in DComp as it doesn't have desktop only APIs. |
|||
[uuid(75F6468D-1B8E-447C-9BC6-75FEA80B5B25)] |
|||
interface IDCompositionDevice2 : IUnknown |
|||
{ |
|||
HRESULT Commit(); |
|||
HRESULT WaitForCommitCompletion(); |
|||
HRESULT GetFrameStatistics(DCOMPOSITION_FRAME_STATISTICS* statistics); |
|||
HRESULT CreateVisual([out] IDCompositionVisual** visual); |
|||
HRESULT CreateSurfaceFactory(IUnknown* renderingDevice, [out] IDCompositionSurfaceFactory** surfaceFactory); |
|||
HRESULT CreateSurface(UINT width, UINT height, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, [out] IDCompositionSurface** surface); |
|||
HRESULT CreateVirtualSurface(UINT initialWidth, UINT initialHeight, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, [out] IDCompositionVirtualSurface** virtualSurface); |
|||
HRESULT CreateTranslateTransform([out] void** translateTransform); |
|||
HRESULT CreateScaleTransform([out] void** scaleTransform); |
|||
HRESULT CreateRotateTransform([out] void** rotateTransform); |
|||
HRESULT CreateSkewTransform([out] void** skewTransform); |
|||
HRESULT CreateMatrixTransform([out] void** matrixTransform); |
|||
HRESULT CreateTransformGroup(void* transforms, int elements, [out] void** transformGroup); |
|||
HRESULT CreateTranslateTransform3D([out] void** translateTransform3D); |
|||
HRESULT CreateScaleTransform3D([out] void** scaleTransform3D); |
|||
HRESULT CreateRotateTransform3D([out] void** rotateTransform3D); |
|||
HRESULT CreateMatrixTransform3D([out] void** matrixTransform3D); |
|||
HRESULT CreateTransform3DGroup(void* transforms3D, int elements, [out] void** transform3DGroup); |
|||
HRESULT CreateEffectGroup([out] void** effectGroup); |
|||
HRESULT CreateRectangleClip([out] void** clip); |
|||
HRESULT CreateAnimation([out] void** animation); |
|||
} |
|||
|
|||
[uuid(0987cb06-f916-48bf-8d35-ce7641781bd9)] |
|||
interface IDCompositionDevice3 : IDCompositionDevice2 |
|||
{ |
|||
HRESULT CreateGaussianBlurEffect([out] void** gaussianBlurEffect); |
|||
} |
|||
|
|||
[uuid(5f4633fe-1e08-4cb8-8c75-ce24333f5602)] |
|||
interface IDCompositionDesktopDevice : IDCompositionDevice2 |
|||
{ |
|||
HRESULT CreateTargetForHwnd(IntPtr hwnd, bool topmost, [out] IDCompositionVisual** target); |
|||
HRESULT CreateSurfaceFromHandle(IntPtr handle, [out] IUnknown** surface); |
|||
HRESULT CreateSurfaceFromHwnd(IntPtr hwnd, [out] IUnknown** surface); |
|||
} |
|||
|
|||
[uuid(4d93059d-097b-4651-9a60-f0f25116e2f3)] |
|||
interface IDCompositionVisual : IUnknown |
|||
{ |
|||
HRESULT SetOffsetX_IDCompositionAnimation(void* animation); |
|||
HRESULT SetOffsetX(float offsetX); |
|||
HRESULT SetOffsetY_IDCompositionAnimation(void* animation); |
|||
HRESULT SetOffsetY(float offsetY); |
|||
HRESULT SetTransform_IDCompositionTransform(void* transform); |
|||
HRESULT SetTransform(/* D2D_MATRIX_3X2_F */ void* matrix); |
|||
HRESULT SetTransformParent(IDCompositionVisual* visual); |
|||
HRESULT SetEffect(void* effect); |
|||
HRESULT SetBitmapInterpolationMode(/* DCOMPOSITION_BITMAP_INTERPOLATION_MODE */ int interpolationMode); |
|||
HRESULT SetBorderMode(/* DCOMPOSITION_BORDER_MODE */ int borderMode); |
|||
HRESULT SetClip_IDCompositionClip(void* clip); |
|||
HRESULT SetClip(/* D2D_RECT_F */ void* rect); |
|||
HRESULT SetContent(IUnknown* content); |
|||
HRESULT AddVisual(IDCompositionVisual* visual, BOOL insertAbove, IDCompositionVisual* referenceVisual); |
|||
HRESULT RemoveVisual(IDCompositionVisual* visual); |
|||
HRESULT RemoveAllVisuals(); |
|||
HRESULT SetCompositeMode(/* DCOMPOSITION_COMPOSITE_MODE */ int compositeMode); |
|||
} |
|||
|
|||
[uuid(eacdd04c-117e-4e17-88f4-d1b12b0e3d89)] |
|||
interface IDCompositionTarget : IUnknown |
|||
{ |
|||
HRESULT SetRoot(IDCompositionVisual* visual); |
|||
} |
|||
|
|||
[uuid(e334bc12-3937-4e02-85eb-fcf4eb30d2c8)] |
|||
interface IDCompositionSurfaceFactory : IUnknown |
|||
{ |
|||
HRESULT CreateSurface(UINT width, UINT height, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, [out] IDCompositionSurface** surface); |
|||
HRESULT CreateVirtualSurface(UINT initialWidth, UINT initialHeight, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, [out] IDCompositionVirtualSurface** virtualSurface); |
|||
} |
|||
|
|||
[uuid(bb8a4953-2c99-4f5a-96f5-4819027fa3ac)] |
|||
interface IDCompositionSurface : IUnknown |
|||
{ |
|||
HRESULT BeginDraw(RECT* updateRect, GUID* iid, [out] void** updateObject, [out] POINT* updateOffset); |
|||
HRESULT EndDraw(); |
|||
HRESULT SuspendDraw(); |
|||
HRESULT ResumeDraw(); |
|||
HRESULT Scroll(RECT* scrollRect, RECT* clipRect, int offsetX, int offsetY); |
|||
} |
|||
|
|||
[uuid(ae471c51-5f53-4a24-8d3e-d0c39c30b3f0)] |
|||
interface IDCompositionVirtualSurface : IDCompositionSurface |
|||
{ |
|||
HRESULT Resize(UINT width, UINT height); |
|||
HRESULT Trim(/* RECT* */ void* rectangles, INT count); |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
namespace Avalonia.Win32; |
|||
|
|||
internal enum BlurEffect |
|||
{ |
|||
None, |
|||
GaussianBlur, |
|||
Acrylic, |
|||
MicaLight, |
|||
MicaDark |
|||
} |
|||
|
|||
internal interface ICompositionEffectsSurface |
|||
{ |
|||
bool IsBlurSupported(BlurEffect effect); |
|||
|
|||
void SetBlur(BlurEffect enable); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.OpenGL.Egl; |
|||
|
|||
namespace Avalonia.Win32; |
|||
|
|||
internal interface IWindowsSurfaceFactory |
|||
{ |
|||
bool RequiresNoRedirectionBitmap { get; } |
|||
|
|||
object CreateSurface(EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info); |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
namespace Avalonia.Win32.WinRT |
|||
{ |
|||
internal enum BlurEffect |
|||
{ |
|||
None, |
|||
Acrylic, |
|||
MicaLight, |
|||
MicaDark |
|||
} |
|||
|
|||
internal interface IBlurHost |
|||
{ |
|||
void SetBlur(BlurEffect enable); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue