From 3b0754021ebf9f26ca82004214ebbe897ef6ef01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 7 Jul 2013 08:39:25 +0200 Subject: [PATCH] Refreshing shape/frame cache after image replace formatting --- trunk/src/com/jpexs/decompiler/flash/KeyValue.java | 1 - trunk/src/com/jpexs/decompiler/flash/SWF.java | 6 ++++++ .../decompiler/flash/abc/avm2/graph/AVM2Graph.java | 2 +- .../jpexs/decompiler/flash/action/ActionGraph.java | 14 +++++++------- .../com/jpexs/decompiler/flash/graph/Graph.java | 8 ++++---- .../com/jpexs/decompiler/flash/gui/MainFrame.java | 1 + .../decompiler/flash/gui/action/ActionPanel.java | 2 +- .../com/jpexs/decompiler/flash/helpers/Helper.java | 4 ++-- .../decompiler/flash/tags/PlaceObject2Tag.java | 2 +- .../decompiler/flash/tags/PlaceObject3Tag.java | 2 +- .../decompiler/flash/tags/PlaceObjectTypeTag.java | 4 ++-- .../flash/types/shaperecords/SHAPERECORD.java | 4 ++++ 12 files changed, 30 insertions(+), 20 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/KeyValue.java b/trunk/src/com/jpexs/decompiler/flash/KeyValue.java index d37cc3714..22fd992e3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/KeyValue.java +++ b/trunk/src/com/jpexs/decompiler/flash/KeyValue.java @@ -47,7 +47,6 @@ public class KeyValue { return hash; } - @Override public boolean equals(Object obj) { if (obj == null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 49266e107..80069b16c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -92,6 +92,7 @@ import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.filters.BlendComposite; import com.jpexs.decompiler.flash.types.filters.FILTER; import com.jpexs.decompiler.flash.types.filters.Filtering; +import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.decompiler.flash.types.sound.AdpcmDecoder; import com.jpexs.decompiler.flash.xfl.XFLConverter; import java.awt.AlphaComposite; @@ -1899,6 +1900,11 @@ public class SWF { } private static Cache cache = new Cache(false); + public void clearImageCache() { + cache.clear(); + SHAPERECORD.clearShapeCache(); + } + public static RECT fixRect(RECT rect) { RECT ret = new RECT(); ret.Xmin = rect.Xmin; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 3ba71ee9e..43dd1eb0a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -382,7 +382,7 @@ public class AVM2Graph extends Graph { ret = new ArrayList<>(); ret.addAll(output); return ret; - } + } if (((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqTreeItem) diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java index 9bb7030e8..d18a56f6a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -278,7 +278,7 @@ public class ActionGraph extends Graph { });*/ //GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); - List mcp=new ArrayList<>(); + List mcp = new ArrayList<>(); mcp.addAll(caseBodyParts); mcp.add(defaultPart2); GraphPart breakPart = getMostCommonPart(mcp, loops); @@ -329,12 +329,12 @@ public class ActionGraph extends Graph { stopPart2x.add(next); defaultCommands = printGraph(new ArrayList(), localData, stack, allParts, null, defaultPart, stopPart2x, loops); } - - if(!defaultCommands.isEmpty()){ - if(defaultCommands.get(defaultCommands.size()-1) instanceof BreakItem){ - BreakItem bi=(BreakItem)defaultCommands.get(defaultCommands.size()-1); - if(bi.loopId==currentLoop.id){ - defaultCommands.remove(defaultCommands.size()-1); + + if (!defaultCommands.isEmpty()) { + if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) { + BreakItem bi = (BreakItem) defaultCommands.get(defaultCommands.size() - 1); + if (bi.loopId == currentLoop.id) { + defaultCommands.remove(defaultCommands.size() - 1); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index 70577f88f..2df14ce09 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -551,10 +551,10 @@ public class Graph { System.out.println("");*/ getPrecontinues(null, heads.get(0), loops, null); /*System.err.println(""); - for (Loop el : loops) { - System.err.println(el); - } - System.err.println("");//*/ + for (Loop el : loops) { + System.err.println(el); + } + System.err.println("");//*/ List ret = printGraph(new ArrayList(), localData, stack, allParts, null, heads.get(0), null, loops); processIfs(ret); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 3ed8d846c..2b725dd56 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -1664,6 +1664,7 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection byte data[] = Helper.readFile(selfile.getAbsolutePath()); try { it.setImage(data); + swf.clearImageCache(); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Invalid image", ex); JOptionPane.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index e93818865..b4bfdf5d8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -279,7 +279,7 @@ public class ActionPanel extends JPanel implements ActionListener { } }; asm.addDisassemblyListener(listener); - lastDisasm = asm.getASMSource(SWF.DEFAULT_VERSION, true); + lastDisasm = asm.getASMSource(SWF.DEFAULT_VERSION, true); asm.removeDisassemblyListener(listener); srcWithHex = Helper.hexToComments(lastDisasm); srcNoHex = Helper.stripComments(lastDisasm); diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java index 8289bee28..68c1d5db3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java @@ -422,9 +422,9 @@ public class Helper { bs = new byte[0]; Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex); } - String sn=""; + String sn = ""; for (int i = 0; i < bs.length; i++) { - sn += "0x" + Integer.toHexString(bs[i]&0xff) + " "; + sn += "0x" + Integer.toHexString(bs[i] & 0xff) + " "; } return sn; } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index 920437359..22855e7dc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -200,7 +200,7 @@ public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTa * * @param data Data bytes * @param version SWF version - * @param pos + * @param pos * @throws IOException */ public PlaceObject2Tag(byte data[], int version, long pos) throws IOException { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index cd1d93b9c..6ac864b08 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -272,7 +272,7 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa * * @param data Data bytes * @param version SWF version - * @param pos + * @param pos * @throws IOException */ public PlaceObject3Tag(byte data[], int version, long pos) throws IOException { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java index 3fcc9fd86..950b2e766 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java @@ -20,9 +20,9 @@ public interface PlaceObjectTypeTag { public MATRIX getMatrix(); public String getInstanceName(); - + public void setInstanceName(String name); - + public void setClassName(String className); public CXFORM getColorTransform(); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index eb5a9f230..73ea0b2d9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -813,6 +813,10 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters { } private static HashMap cache = new HashMap<>(); + public static void clearShapeCache() { + cache.clear(); + } + public static BufferedImage shapeToImage(List tags, int shapeNum, FILLSTYLEARRAY fillStyles, LINESTYLEARRAY lineStylesList, List records) { return shapeToImage(tags, shapeNum, fillStyles, lineStylesList, records, null); }