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:
@@ -156,9 +156,12 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", downPressed || downDisabled ? "down_pressed" : "down_arrow"),
|
||||
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)
|
||||
if (child.Bounds.IntersectsWith(drawBounds))
|
||||
child.DrawOuter();
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
|
||||
Reference in New Issue
Block a user