mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-148739 [follow-up] Enable gutter icons scaling by default
Set a limit to the cache of icons of different sizes. When a gutter icon is scaled up/down as one is zooming, it can take about 50 values. There's no need to keep all those sizes in the cache. Moreover, the cache is rather used for a "common case", when an icon is scaled to meet different modes, like "standard", "presentation" w/ combination of possible "scaled" state. So, "5" should be enough for the cache limit.
This commit is contained in:
@@ -42,6 +42,7 @@ import java.lang.ref.Reference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -361,6 +362,7 @@ public final class IconLoader {
|
||||
private float scale;
|
||||
private ImageFilter filter;
|
||||
private HashMap<Float, Icon> scaledIcons;
|
||||
private static final int SCALED_ICONS_CACHE_LIMIT = 5;
|
||||
|
||||
public CachedImageIcon(@NotNull URL url) {
|
||||
myUrl = url;
|
||||
@@ -430,7 +432,12 @@ public final class IconLoader {
|
||||
return this;
|
||||
}
|
||||
if (scaledIcons == null) {
|
||||
scaledIcons = new HashMap<Float, Icon>(1);
|
||||
scaledIcons = new LinkedHashMap<Float, Icon>(1) {
|
||||
@Override
|
||||
public boolean removeEldestEntry(Map.Entry<Float, Icon> entry) {
|
||||
return size() > SCALED_ICONS_CACHE_LIMIT;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: consider clearing the cache on SCALE change
|
||||
|
||||
Reference in New Issue
Block a user