Browse Source

Display # of layers next to FPS counter.

Steven Kirk 8 years ago
parent
commit
05575f9ea8

+ 1 - 0
src/Avalonia.Visuals/Rendering/DeferredRenderer.cs

@@ -354,6 +354,7 @@ namespace Avalonia.Rendering
             if (DrawFps)
             {
                 RenderFps(context, clientRect, true);
+                RenderFps(context, clientRect, scene.Layers.Count);
             }
         }
 

+ 1 - 1
src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs

@@ -69,7 +69,7 @@ namespace Avalonia.Rendering
 
                     if (DrawFps)
                     {
-                        RenderFps(context.PlatformImpl, _root.Bounds, true);
+                        RenderFps(context.PlatformImpl, _root.Bounds, null);
                     }
                 }
             }

+ 11 - 6
src/Avalonia.Visuals/Rendering/RendererBase.cs

@@ -22,15 +22,12 @@ namespace Avalonia.Rendering
             };
         }
 
-        protected void RenderFps(IDrawingContextImpl context, Rect clientRect, bool incrementFrameCount)
+        protected void RenderFps(IDrawingContextImpl context, Rect clientRect, int? layerCount)
         {
             var now = _stopwatch.Elapsed;
             var elapsed = now - _lastFpsUpdate;
 
-            if (incrementFrameCount)
-            {
-                ++_framesThisSecond;
-            }
+            ++_framesThisSecond;
 
             if (elapsed.TotalSeconds > 1)
             {
@@ -39,7 +36,15 @@ namespace Avalonia.Rendering
                 _lastFpsUpdate = now;
             }
 
-            _fpsText.Text = string.Format("FPS: {0:000}", _fps);
+            if (layerCount.HasValue)
+            {
+                _fpsText.Text = string.Format("Layers: {0} FPS: {1:000}", layerCount, _fps);
+            }
+            else
+            {
+                _fpsText.Text = string.Format("FPS: {0:000}", _fps);
+            }
+
             var size = _fpsText.Measure();
             var rect = new Rect(clientRect.Right - size.Width, 0, size.Width, size.Height);