Repository: AvaloniaUI/Avalonia
File: src/Avalonia.Visuals/Rendering/DeferredRenderer.cs (C#)

Code before:
                    {
                        context = context ?? RenderTarget.CreateDrawingContext(this);
                        RenderComposite(scene, context);
                    }

                    context?.Dispose();
                }
            }
            catch (RenderTargetCorruptedException ex)
            {
                Logging.Logger.Information("Renderer", this, "Render target was corrupted. Exception: {0}", ex);
                RenderTarget?.Dispose();
                RenderTarget = null;
            }
        }

        private void Render(IDrawingContextImpl context, VisualNode node, IVisual layer, Rect clipBounds)
        {
            if (layer == null || node.LayerRoot == layer)
            {
                clipBounds = node.ClipBounds.Intersect(clipBounds);

                var np = node.Visual.GetType().GetProperty("Name");
                var name = (string)np.GetValue(node.Visual);

                if (name == "abcd")
                {
                    var clip = (IStreamGeometryImpl)node.GeometryClip;
                    System.Diagnostics.Debug.WriteLine(clip?.GetRenderBounds(new Pen(Brushes.Black, 1)).ToString() ?? "(null)");
                }

                if (!clipBounds.IsEmpty && node.Opacity > 0)
                {
                    var isLayerRoot = node.Visual == layer;

                    node.BeginRender(context, isLayerRoot);

                    foreach (var operation in node.DrawOperations)
                    {
                        _currentDraw = operation;
                        operation.Render(context);
                        _currentDraw = null;
                    }

                    foreach (var child in node.Children)
                    {
                        Render(context, (VisualNode)child, layer, clipBounds);
                    }

                    node.EndRender(context, isLayerRoot);
                }

Review comment (bug):
Can we pick a more descriptive name (and maybe save it in a constant so it isn't a magic string)?
Also, is this used for anything other than debugging?


Code after:
                    {
                        context = context ?? RenderTarget.CreateDrawingContext(this);
                        RenderComposite(scene, context);
                    }

                    context?.Dispose();
                }
            }
            catch (RenderTargetCorruptedException ex)
            {
                Logging.Logger.Information("Renderer", this, "Render target was corrupted. Exception: {0}", ex);
                RenderTarget?.Dispose();
                RenderTarget = null;
            }
        }

        private void Render(IDrawingContextImpl context, VisualNode node, IVisual layer, Rect clipBounds)
        {
            if (layer == null || node.LayerRoot == layer)
            {
                clipBounds = node.ClipBounds.Intersect(clipBounds);

                if (!clipBounds.IsEmpty && node.Opacity > 0)
                {
                    var isLayerRoot = node.Visual == layer;

                    node.BeginRender(context, isLayerRoot);

                    foreach (var operation in node.DrawOperations)
                    {
                        _currentDraw = operation;
                        operation.Render(context);
                        _currentDraw = null;
                    }

                    foreach (var child in node.Children)
                    {
                        Render(context, (VisualNode)child, layer, clipBounds);
                    }

                    node.EndRender(context, isLayerRoot);
                }
            }
        }

        private void RenderToLayers(Scene scene)
        {
            if (scene.Layers.HasDirty)
            {
                foreach (var layer in scene.Layers)
                {