using SkiaSharp; using Vortice.Direct3D11; using Vortice.DXGI; namespace FenUISharp { public class SkiaDirectCompositionContext { public Action DrawAction { get; private set; } public SkiaDirectCompositionContext(Window window, Action drawAction) { this.DrawAction = drawAction; // Creating DirectCompositionContext and getting adapter var dxcc = new DirectCompositionContext(window.hWnd, () => window.WindowSize, Vortice.DXGI.Format.B8G8R8A8_UNorm); var adapter = dxcc.GetHardwareAdapter(); // Creating backend context for Skia D3D var backendContext = new GRD3DBackendContext() { Device = dxcc.Device.NativePointer, Adapter = adapter.NativePointer, ProtectedContext = false }; // Creating Skia D3D GRContext var grD3DContext = GRContext.CreateDirect3D(backendContext); // This line will throw an CLR/System.Runtime.InteropServices.SEHException: External component has thrown an exception if (grD3DContext == null) throw new Exception("Failed to create Skia D3D GRContext"); } internal void Draw() { throw new NotImplementedException(); } } }