keep around more loaded images
This commit is contained in:
parent
33f6ee739e
commit
fe02e13a11
@ -438,9 +438,11 @@ public class UiGeometry {
|
|||||||
public UiGeometry(Vector2i windowSize, int starSize) {
|
public UiGeometry(Vector2i windowSize, int starSize) {
|
||||||
WindowSize = windowSize;
|
WindowSize = windowSize;
|
||||||
|
|
||||||
int numThumbnails = 15;
|
int numThumbnails = WindowSize.Y / 100;
|
||||||
int thumbnailHeight = WindowSize.Y / numThumbnails;
|
int thumbnailHeight = WindowSize.Y / numThumbnails;
|
||||||
int thumbnailWidth = (int) 1.0 * thumbnailHeight * activeCamera.Resolution.X / activeCamera.Resolution.Y;
|
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++) {
|
for (int i = 0; i < numThumbnails; i++) {
|
||||||
Box2i box = Util.MakeBox(WindowSize.X - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight);
|
Box2i box = Util.MakeBox(WindowSize.X - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight);
|
||||||
ThumbnailBoxes.Add(box);
|
ThumbnailBoxes.Add(box);
|
||||||
@ -815,7 +817,7 @@ public class Game : GameWindow {
|
|||||||
// Unload images that haven't been touched in a while.
|
// Unload images that haven't been touched in a while.
|
||||||
// FIXME: keep around thumbnail-sized textures?
|
// FIXME: keep around thumbnail-sized textures?
|
||||||
lock (loadedImagesLock) {
|
lock (loadedImagesLock) {
|
||||||
while (loadedImages.Count > 60) {
|
while (loadedImages.Count > 100) {
|
||||||
long earliestTime = long.MaxValue;
|
long earliestTime = long.MaxValue;
|
||||||
Photo? earliest = null;
|
Photo? earliest = null;
|
||||||
foreach (Photo photo in loadedImages) {
|
foreach (Photo photo in loadedImages) {
|
||||||
@ -825,7 +827,7 @@ public class Game : GameWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (earliest != null) {
|
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?
|
// TODO: we have to free textures on the GL thread, but could we do that async'ly to keep the UI responsive?
|
||||||
earliest.Unload();
|
earliest.Unload();
|
||||||
loadedImages.Remove(earliest);
|
loadedImages.Remove(earliest);
|
||||||
|
Loading…
Reference in New Issue
Block a user