From fe392bd42d5db6b8ad6a49af3631e41d4fa27bf5 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 5 May 2011 19:22:35 +1200 Subject: [PATCH] add render_widgets to perf history --- OpenRA.Game/Game.cs | 2 ++ OpenRA.Game/Graphics/Viewport.cs | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index c9b850a556..43f98f040c 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -147,6 +147,7 @@ namespace OpenRA PerfHistory.items["render"].Tick(); PerfHistory.items["batches"].Tick(); + PerfHistory.items["render_widgets"].Tick(); afterTickActions.PerformActions(); } @@ -301,6 +302,7 @@ namespace OpenRA PerfHistory.items["render"].hasNormalTick = false; PerfHistory.items["batches"].hasNormalTick = false; + PerfHistory.items["render_widgets"].hasNormalTick = false; JoinLocal(); viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer); diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 591061229a..5786cd3000 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.Widgets; +using OpenRA.Support; namespace OpenRA.Graphics { @@ -34,7 +35,7 @@ namespace OpenRA.Graphics public void Scroll(float2 delta) { - this.Scroll(delta, false); + Scroll(delta, false); } public void Scroll(float2 delta, bool ignoreBorders) @@ -85,13 +86,16 @@ namespace OpenRA.Graphics if (wr != null) wr.Draw(); - Widget.DoDraw(); - var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default"; - var cursorSequence = CursorProvider.GetCursorSequence(cursorName); - - cursorSequence.GetSprite((int)cursorFrame).DrawAt( - Viewport.LastMousePos + Location - cursorSequence.Hotspot, - Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette)); + using( new PerfSample("render_widgets") ) + { + Widget.DoDraw(); + var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default"; + var cursorSequence = CursorProvider.GetCursorSequence(cursorName); + + cursorSequence.GetSprite((int)cursorFrame).DrawAt( + Viewport.LastMousePos + Location - cursorSequence.Hotspot, + Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette)); + } renderer.EndFrame( inputHandler ); }