Esempio n. 1
0
        void SetDevice(CanvasDevice device, Size windowSize)
        {
            _drawLoopCancellationTokenSource?.Cancel();

            _swapChain             = new CanvasSwapChain(device, (float)this.ActualWidth, (float)this.ActualHeight, 96);
            _swapChainVisual.Brush = _compositor.CreateSurfaceBrush(CanvasComposition.CreateCompositionSurfaceForSwapChain(_compositor, _swapChain));

            _drawLoopCancellationTokenSource = new CancellationTokenSource();
            Task.Factory.StartNew(
                DrawLoop,
                _drawLoopCancellationTokenSource.Token,
                TaskCreationOptions.LongRunning,
                TaskScheduler.Default);
        }
Esempio n. 2
0
        public void SetDevice(CanvasDevice device, Size windowSize)
        {
            ++deviceCount;

            drawLoopCancellationTokenSource?.Cancel();

            swapChain             = new CanvasSwapChain(device, 256, 256, 96);
            swapChainVisual.Brush = compositor.CreateSurfaceBrush(CanvasComposition.CreateCompositionSurfaceForSwapChain(compositor, swapChain));

            drawLoopCancellationTokenSource = new CancellationTokenSource();
            Task.Factory.StartNew(
                DrawLoop,
                drawLoopCancellationTokenSource.Token,
                TaskCreationOptions.LongRunning,
                TaskScheduler.Default);
        }
Esempio n. 3
0
        public void SetDevice(CanvasDevice device)
        {
            drawLoopCancellationTokenSource?.Cancel();

            var displayInfo = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();

            this.swapChain = new CanvasSwapChain(
                device,
                (int)this.ActualWidth,
                (int)this.ActualHeight,
                displayInfo.LogicalDpi,
                Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                2,
                CanvasAlphaMode.Premultiplied);

            swapChainVisual.Brush = Window.Current.Compositor.CreateSurfaceBrush(CanvasComposition.CreateCompositionSurfaceForSwapChain(Window.Current.Compositor, swapChain));

            drawLoopCancellationTokenSource = new CancellationTokenSource();
        }
Esempio n. 4
0
        public void SetDevice(CanvasDevice device)
        {
            drawLoopCancellationTokenSource?.Cancel();

            var displayInfo = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();

            this.swapChain = new CanvasSwapChain(device, (int)this.ActualWidth, (int)this.ActualHeight, displayInfo.LogicalDpi);

            swapChainVisual.Brush = Window.Current.Compositor().CreateSurfaceBrush(CanvasComposition.CreateCompositionSurfaceForSwapChain(Window.Current.Compositor(), swapChain));

            drawLoopCancellationTokenSource = new CancellationTokenSource();

            Task.Factory.StartNew(

                DrawLoop,

                drawLoopCancellationTokenSource.Token,

                TaskCreationOptions.LongRunning,

                TaskScheduler.Default);
        }
Esempio n. 5
0
 public ICompositionSurface CreateSurface(Compositor compositor)
 {
     return(CanvasComposition.CreateCompositionSurfaceForSwapChain(compositor, _swapChain));
 }