Avoid ScrollPanelWidget drawing invisible child items.

If child items in a scroll panel will be outside the scissor area, then we can avoid drawing them at all. If a scroll panel has many items, this reduces to the draw cost closer to those visible in the panel, rather than costing for all the items.
This commit is contained in:
RoosterDragon
2015-04-10 00:12:18 +01:00
parent 60238a858d
commit 087b407f46

View File

@@ -156,10 +156,13 @@ namespace OpenRA.Mods.Common.Widgets
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", downPressed || downDisabled ? "down_pressed" : "down_arrow"), WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", downPressed || downDisabled ? "down_pressed" : "down_arrow"),
new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset)); new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset));
Game.Renderer.EnableScissor(backgroundRect.InflateBy(-1, -1, -1, -1)); var drawBounds = backgroundRect.InflateBy(-1, -1, -1, -1);
Game.Renderer.EnableScissor(drawBounds);
drawBounds.Offset((-ChildOrigin).ToPoint());
foreach (var child in Children) foreach (var child in Children)
child.DrawOuter(); if (child.Bounds.IntersectsWith(drawBounds))
child.DrawOuter();
Game.Renderer.DisableScissor(); Game.Renderer.DisableScissor();
} }