diff --git a/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj b/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj index a6c4f6da14..a7be9919f3 100644 --- a/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj +++ b/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj @@ -118,7 +118,7 @@ - + diff --git a/src/Perspex.SceneGraph/Rendering/RendererBase.cs b/src/Perspex.SceneGraph/Rendering/RendererMixin.cs similarity index 84% rename from src/Perspex.SceneGraph/Rendering/RendererBase.cs rename to src/Perspex.SceneGraph/Rendering/RendererMixin.cs index 24dbab3622..89c3ed4d0f 100644 --- a/src/Perspex.SceneGraph/Rendering/RendererBase.cs +++ b/src/Perspex.SceneGraph/Rendering/RendererMixin.cs @@ -5,14 +5,13 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Linq; using Perspex.Media; using Perspex.Platform; namespace Perspex.Rendering { /// - /// Base class for standard renderers. + /// Extension methods for rendering. /// /// /// This class provides implements the platform-independent parts of . @@ -21,11 +20,20 @@ namespace Perspex.Rendering [SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")] public static class RendererMixin { - static int s_frameNum; - static int s_fps; - static int s_currentFrames; - static TimeSpan s_lastMeasure; - static readonly Stopwatch s_stopwatch = Stopwatch.StartNew(); + private static int s_frameNum; + private static int s_fps; + private static int s_currentFrames; + private static TimeSpan s_lastMeasure; + private static readonly Stopwatch s_stopwatch = Stopwatch.StartNew(); + private static readonly Stack> s_listPool = new Stack>(); + private static readonly ZIndexComparer s_visualComparer = new ZIndexComparer(); + + /// + /// Gets or sets a value which determines whether an FPS counted will be drawn on each + /// rendered frame. + /// + public static bool DrawFpsCounter { get; set; } + /// /// Renders the specified visual. /// @@ -62,13 +70,10 @@ namespace Perspex.Rendering } } - public static bool DrawFpsCounter { get; set; } - /// /// Renders the specified visual. /// /// The visual to render. - /// /// The drawing context. public static void Render(this DrawingContext context, IVisual visual) { @@ -103,29 +108,24 @@ namespace Perspex.Rendering } } - static readonly Stack> ListPool = new Stack>(); - static readonly ZIndexComparer VisualComparer = new ZIndexComparer(); - class ZIndexComparer : IComparer - { - public int Compare(IVisual x, IVisual y) => x.ZIndex.CompareTo(y.ZIndex); - } - static void ReturnListToPool(List lst) { lst.Clear(); - ListPool.Push(lst); + s_listPool.Push(lst); } static List GetSortedVisualList(IReadOnlyList source) { - var lst = ListPool.Count == 0 ? new List() : ListPool.Pop(); + var lst = s_listPool.Count == 0 ? new List() : s_listPool.Pop(); for (var c = 0; c < source.Count; c++) lst.Add(source[c]); - lst.Sort(VisualComparer); + lst.Sort(s_visualComparer); return lst; } - - + class ZIndexComparer : IComparer + { + public int Compare(IVisual x, IVisual y) => x.ZIndex.CompareTo(y.ZIndex); + } } }