cache display object as it is written in SWF documentation (placeobject cache flag or has filters)

This commit is contained in:
honfika@gmail.com
2016-04-09 14:23:51 +02:00
parent ded2675b37
commit 729b78ceda
3 changed files with 80 additions and 69 deletions

View File

@@ -328,6 +328,9 @@ public final class SWF implements SWFContainerItem, Timelined {
@Internal
private final Cache<String, SerializableImage> frameCache = Cache.getInstance(false, false, "frame");
@Internal
private final Cache<PlaceObjectTypeTag, SerializableImage> displayObjectCache = Cache.getInstance(false, false, "displayObject");
@Internal
private final Cache<CharacterTag, RECT> rectCache = Cache.getInstance(true, true, "rect");
@@ -399,6 +402,7 @@ public final class SWF implements SWFContainerItem, Timelined {
as2Cache.clear();
as3Cache.clear();
frameCache.clear();
displayObjectCache.clear();
soundCache.clear();
timeline = null;
@@ -2483,6 +2487,13 @@ public final class SWF implements SWFContainerItem, Timelined {
return null;
}
public SerializableImage getFromCache(PlaceObjectTypeTag key) {
if (displayObjectCache.contains(key)) {
return displayObjectCache.get(key);
}
return null;
}
public byte[] getFromCache(SoundTag soundTag) {
if (soundCache.contains(soundTag)) {
return soundCache.get(soundTag);
@@ -2496,12 +2507,17 @@ public final class SWF implements SWFContainerItem, Timelined {
}
}
public void putToCache(PlaceObjectTypeTag key, SerializableImage img) {
displayObjectCache.put(key, img);
}
public void putToCache(SoundTag soundTag, byte[] data) {
soundCache.put(soundTag, data);
}
public void clearImageCache() {
frameCache.clear();
displayObjectCache.clear();
rectCache.clear();
for (Tag tag : getTags()) {
if (tag instanceof ImageTag) {