Exemplo n.º 1
0
        void DisposeRenderTarget()
        {
            using (var l = _lock.TryLock())
            {
                if (l == null)
                {
                    // We are still trying to render on the render thread, try again a bit later
                    DispatcherTimer.RunOnce(DisposeRenderTarget, TimeSpan.FromMilliseconds(50),
                                            DispatcherPriority.Background);
                    return;
                }

                Layers.Clear();
                RenderTarget?.Dispose();
                RenderTarget = null;
            }
        }
Exemplo n.º 2
0
        private void Render(bool forceComposite)
        {
            using (var l = _lock.TryLock())
            {
                if (l == null)
                {
                    return;
                }

                IDrawingContextImpl context = null;
                try
                {
                    try
                    {
                        IDrawingContextImpl GetContext()
                        {
                            if (context != null)
                            {
                                return(context);
                            }
                            if (RenderTarget == null)
                            {
                                RenderTarget = ((IRenderRoot)_root).CreateRenderTarget();
                            }
                            return(context = RenderTarget.CreateDrawingContext(this));
                        }

                        var(scene, updated) = UpdateRenderLayersAndConsumeSceneIfNeeded(GetContext);
                        using (scene)
                        {
                            var overlay = DrawDirtyRects || DrawFps;
                            if (DrawDirtyRects)
                            {
                                _dirtyRectsDisplay.Tick();
                            }
                            if (overlay)
                            {
                                RenderOverlay(scene.Item, GetContext());
                            }
                            if (updated || forceComposite || overlay)
                            {
                                RenderComposite(scene.Item, GetContext());
                            }
                        }
                    }
                    finally
                    {
                        context?.Dispose();
                    }
                }
                catch (RenderTargetCorruptedException ex)
                {
                    Logging.Logger.Information("Renderer", this, "Render target was corrupted. Exception: {0}", ex);
                    RenderTarget?.Dispose();
                    RenderTarget = null;
                }
            }
        }
Exemplo n.º 3
0
 private void Render(bool forceComposite)
 {
     using (var l = _lock.TryLock())
         if (l != null)
         {
             using (var scene = _scene?.Clone())
             {
                 Render(scene?.Item, forceComposite);
             }
         }
 }