Buffer the accuracy heatmap for performance

This commit is contained in:
smoogipoo 2020-06-22 21:00:13 +09:00
parent 1aec1ea53f
commit beb6e6ea88
1 changed files with 12 additions and 3 deletions

View File

@ -33,6 +33,7 @@ public class AccuracyHeatmap : CompositeDrawable
private const float rotation = 45;
private BufferedContainer bufferedGrid;
private GridContainer pointGrid;
private readonly ScoreInfo score;
@ -112,10 +113,16 @@ private void load()
}
}
},
pointGrid = new GridContainer
bufferedGrid = new BufferedContainer
{
RelativeSizeAxes = Axes.Both
}
RelativeSizeAxes = Axes.Both,
CacheDrawnFrameBuffer = true,
BackgroundColour = Color4Extensions.FromHex("#202624").Opacity(0),
Child = pointGrid = new GridContainer
{
RelativeSizeAxes = Axes.Both
}
},
}
};
@ -198,6 +205,8 @@ protected void AddPoint(Vector2 start, Vector2 end, Vector2 hitPoint, float radi
int c = Math.Clamp((int)Math.Round(localPoint.X), 0, points_per_dimension - 1);
((HitPoint)pointGrid.Content[r][c]).Increment();
bufferedGrid.ForceRedraw();
}
private class HitPoint : Circle