Browse Source

keep around more loaded images

main
Colin McMillen 10 months ago
parent
commit
fe02e13a11
  1. 8
      Program.cs

8
Program.cs

@ -438,9 +438,11 @@ public class UiGeometry {
public UiGeometry(Vector2i windowSize, int starSize) {
WindowSize = windowSize;
int numThumbnails = 15;
int numThumbnails = WindowSize.Y / 100;
int thumbnailHeight = WindowSize.Y / numThumbnails;
int thumbnailWidth = (int) 1.0 * thumbnailHeight * activeCamera.Resolution.X / activeCamera.Resolution.Y;
Console.WriteLine($"thumbnail size: {thumbnailWidth} x {thumbnailHeight}");
for (int i = 0; i < numThumbnails; i++) {
Box2i box = Util.MakeBox(WindowSize.X - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight);
ThumbnailBoxes.Add(box);
@ -815,7 +817,7 @@ public class Game : GameWindow {
// Unload images that haven't been touched in a while.
// FIXME: keep around thumbnail-sized textures?
lock (loadedImagesLock) {
while (loadedImages.Count > 60) {
while (loadedImages.Count > 100) {
long earliestTime = long.MaxValue;
Photo? earliest = null;
foreach (Photo photo in loadedImages) {
@ -825,7 +827,7 @@ public class Game : GameWindow {
}
}
if (earliest != null) {
// Console.WriteLine($"loadedImages.Count: {loadedImages.Count}, evicting {earliest.Filename} @ {earliestTime}");
Console.WriteLine($"loadedImages.Count: {loadedImages.Count}, evicting {earliest.Filename} @ {earliestTime}");
// TODO: we have to free textures on the GL thread, but could we do that async'ly to keep the UI responsive?
earliest.Unload();
loadedImages.Remove(earliest);

Loading…
Cancel
Save