Exemplo n.º 1
0
        public ICompositionDrawingSurfaceInterop InitialiseWindowCompositionTree(IntPtr hwnd, out Windows.UI.Composition.Visual surfaceVisual, out IBlurHost blurHost)
        {
            var target = CreateDesktopWindowTarget(hwnd);

            var surface = _graphicsDevice.CreateDrawingSurface(new Windows.Foundation.Size(0, 0),
                                                               Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                                                               Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied);

            var surfaceInterop = surface.As <ICompositionDrawingSurfaceInterop>();

            var brush  = _compositor.CreateSurfaceBrush(surface);
            var visual = _compositor.CreateSpriteVisual();

            visual.Brush = brush;
            visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1, 1);

            var container = _compositor.CreateContainerVisual();

            target.Root = container;

            var blur = CreateBlur();

            blurHost = new CompositionBlurHost(blur);

            container.Children.InsertAtTop(blur);

            container.Children.InsertAtTop(visual);

            visual.CompositeMode = CompositionCompositeMode.SourceOver;

            surfaceVisual = container;

            return(surfaceInterop);
        }