diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index ece225cb4..9e6b62089 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -328,9 +328,6 @@ public final class SWF implements SWFContainerItem, Timelined { @Internal private final Cache frameCache = Cache.getInstance(false, false, "frame"); - @Internal - private final Cache displayObjectCache = Cache.getInstance(false, false, "displayObject"); - @Internal private final Cache rectCache = Cache.getInstance(true, true, "rect"); @@ -402,7 +399,6 @@ public final class SWF implements SWFContainerItem, Timelined { as2Cache.clear(); as3Cache.clear(); frameCache.clear(); - displayObjectCache.clear(); soundCache.clear(); timeline = null; @@ -2487,13 +2483,6 @@ 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); @@ -2507,17 +2496,12 @@ 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) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RenderContext.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RenderContext.java index 616d4ca72..0516a8ee3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RenderContext.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RenderContext.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.timeline.DepthState; +import com.jpexs.helpers.Cache; import com.jpexs.helpers.SerializableImage; import java.awt.Point; import java.util.List; @@ -36,4 +37,6 @@ public class RenderContext { public ButtonTag mouseOverButton; public SerializableImage borderImage; + + public Cache displayObjectCache; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index ce7795e1d..ff8ca1836 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -623,8 +623,8 @@ public class Timeline { g.setComposite(AlphaComposite.Dst);*/ SerializableImage img = null; - if (cacheAsBitmap) { - img = swf.getFromCache(layer.placeObjectTag); + if (cacheAsBitmap && renderContext.displayObjectCache != null) { + img = renderContext.displayObjectCache.get(layer.placeObjectTag); } int stateCount = renderContext.stateUnderCursor == null ? 0 : renderContext.stateUnderCursor.size(); @@ -704,8 +704,8 @@ public class Timeline { } } - if (cacheAsBitmap) { - swf.putToCache(layer.placeObjectTag, img); + if (cacheAsBitmap && renderContext.displayObjectCache != null) { + renderContext.displayObjectCache.put(layer.placeObjectTag, img); } } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 58940eeb8..6178c32d6 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; +import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.base.RenderContext; import com.jpexs.decompiler.flash.tags.base.SoundTag; import com.jpexs.decompiler.flash.tags.base.TextTag; @@ -44,6 +45,7 @@ import com.jpexs.decompiler.flash.types.ConstantColorColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SOUNDINFO; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Cache; import com.jpexs.helpers.SerializableImage; import java.awt.AlphaComposite; import java.awt.BasicStroke; @@ -118,6 +120,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private final List soundPlayers = new ArrayList<>(); + private Cache displayObjectCache = Cache.getInstance(false, false, "displayObject"); + private final IconPanel iconPanel; private int time = 0; @@ -544,6 +548,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { boolean modified = this.zoom.value != zoom.value || this.zoom.fit != zoom.fit; if (modified) { this.zoom = zoom; + displayObjectCache.clear(); redraw(); if (textTag != null) { setText(textTag, newTextTag); @@ -656,6 +661,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { frame = ButtonTag.FRAME_UP; } + displayObjectCache.clear(); this.timelined = drawable; this.swf = swf; zoomAvailable = true; @@ -803,6 +809,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { textTag = null; newTextTag = null; + displayObjectCache.clear(); } private void nextFrame(Timer thisTimer, final int cnt, final int timeShouldBe) { @@ -1000,6 +1007,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } RenderContext renderContext = new RenderContext(); + renderContext.displayObjectCache = displayObjectCache; if (cursorPosition != null) { renderContext.cursorPosition = new Point((int) (cursorPosition.x * SWF.unitDivisor), (int) (cursorPosition.y * SWF.unitDivisor)); }