public void Draw(SpriteBatch spriteBatch) { if (!layoutDone) { DoLayout(); } #if DEBUG if (EnableProfilling) { drawProfiler.Start(); } #endif spriteBatch.Begin(spritemode: SpriteSortMode.Deferred); foreach (UIControl control in this) { if (control.Enabled && control.Visible) { control.Draw(spriteBatch); } } spriteBatch.End(); #if DEBUG if (EnableProfilling) { drawProfiler.Stop(); debugPanel.SetDebugValue("UI time", (drawProfiler.TotalElapsed + updateProfiler.TotalElapsed + layoutProfiler.TotalElapsed).ToString("0.00")); debugPanel.SetDebugValue(" Draw", drawProfiler.FullOutput(2, 4)); debugPanel.SetDebugValue(" Layout", layoutProfiler.FullOutput()); spriteBatch.Begin(); debugPanel.Draw(spriteBatch); spriteBatch.End(); } #endif }
public void Draw(SpriteBatch spriteBatch) { if (!layoutDone) { DoLayout(); } #if DEBUG if (EnableProfilling) { drawProfiler.Start(); } #endif spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.GraphicsDevice.BlendStates.NonPremultiplied); PrimitiveBatch.Begin(); foreach (UIControl control in this) { if (control.Enabled && control.Visible) { control.Draw(spriteBatch); } } PrimitiveBatch.End(); spriteBatch.End(); #if DEBUG if (EnableProfilling) { drawProfiler.Stop(); debugPanel.SetDebugValue("UI time", (drawProfiler.TotalElapsed + updateProfiler.TotalElapsed + layoutProfiler.TotalElapsed).ToString("0.00")); debugPanel.SetDebugValue(" Draw", drawProfiler.FullOutput(2, 4)); debugPanel.SetDebugValue(" Layout", layoutProfiler.FullOutput()); debugPanel.SetDebugValue("Primitives", PrimitiveBatch.DrawCount.ToString()); spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.GraphicsDevice.BlendStates.NonPremultiplied); PrimitiveBatch.Begin(); debugPanel.Draw(spriteBatch); PrimitiveBatch.End(); spriteBatch.End(); } #endif }