diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index ab748564c..f09750070 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2290,58 +2290,58 @@ public class AVM2Code implements Serializable { } AVM2Instruction ains = (AVM2Instruction) ins; /*if (ains.definition instanceof DupIns) { - do { - AVM2Instruction insAfter = (AVM2Instruction) code.get(ip + 1); - if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b - ip++; - insAfter = (AVM2Instruction) code.get(ip + 1); - } + do { + AVM2Instruction insAfter = (AVM2Instruction) code.get(ip + 1); + if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b + ip++; + insAfter = (AVM2Instruction) code.get(ip + 1); + } - if (insAfter.definition instanceof SetLocalTypeIns) { - //chained assignments - int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter)); - for (int t = ip + 1; t < code.size(); t++) { - if (((AVM2Instruction) code.get(t)).definition instanceof KillIns) { - if (((AVM2Instruction) code.get(t)).operands[0] == reg) { - break; - } - } - if (((AVM2Instruction) code.get(t)).definition instanceof GetLocalTypeIns) { - if (((GetLocalTypeIns) ((AVM2Instruction) code.get(t)).definition).getRegisterId((AVM2Instruction) code.get(t)) == reg) { - if (((AVM2Instruction) code.get(t + 1)).definition instanceof KillIns) { - if (((AVM2Instruction) code.get(t + 1)).operands[0] == reg) { - code.getCode().initToSource(); - ConvertOutput assignment = code.getCode().toSourceOutput(false, (Boolean) localData.get(0), (Integer) localData.get(13), (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), (ABC) localData.get(7), (ConstantPool) localData.get(4), (MethodInfo[]) localData.get(5), (MethodBody) localData.get(6), ip + 2, t - 1, (HashMap) localData.get(8), (List) localData.get(9), null); - stack.push(assignment.output.remove(assignment.output.size() - 1)); - ip = t + 2; - continue iploop; - } - } - } - } - } - if (!code.getCode().isKilled(reg, 0, code.size() - 1)) { - for (int i = ip; i >= 0; i--) { - if (((AVM2Instruction) code.get(i)).definition instanceof DupIns) { - GraphTargetItem v = stack.pop(); - stack.push(new LocalRegTreeItem((AVM2Instruction) ins, reg, v)); - stack.push(v); - } else { - break; - } - } - } else { - break; - } - ip++; - continue iploop; - //} + if (insAfter.definition instanceof SetLocalTypeIns) { + //chained assignments + int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter)); + for (int t = ip + 1; t < code.size(); t++) { + if (((AVM2Instruction) code.get(t)).definition instanceof KillIns) { + if (((AVM2Instruction) code.get(t)).operands[0] == reg) { + break; + } + } + if (((AVM2Instruction) code.get(t)).definition instanceof GetLocalTypeIns) { + if (((GetLocalTypeIns) ((AVM2Instruction) code.get(t)).definition).getRegisterId((AVM2Instruction) code.get(t)) == reg) { + if (((AVM2Instruction) code.get(t + 1)).definition instanceof KillIns) { + if (((AVM2Instruction) code.get(t + 1)).operands[0] == reg) { + code.getCode().initToSource(); + ConvertOutput assignment = code.getCode().toSourceOutput(false, (Boolean) localData.get(0), (Integer) localData.get(13), (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), (ABC) localData.get(7), (ConstantPool) localData.get(4), (MethodInfo[]) localData.get(5), (MethodBody) localData.get(6), ip + 2, t - 1, (HashMap) localData.get(8), (List) localData.get(9), null); + stack.push(assignment.output.remove(assignment.output.size() - 1)); + ip = t + 2; + continue iploop; + } + } + } + } + } + if (!code.getCode().isKilled(reg, 0, code.size() - 1)) { + for (int i = ip; i >= 0; i--) { + if (((AVM2Instruction) code.get(i)).definition instanceof DupIns) { + GraphTargetItem v = stack.pop(); + stack.push(new LocalRegTreeItem((AVM2Instruction) ins, reg, v)); + stack.push(v); + } else { + break; + } + } + } else { + break; + } + ip++; + continue iploop; + //} - } else { - break; - } - } while (((AVM2Instruction) ins).definition instanceof DupIns); - }*/ + } else { + break; + } + } while (((AVM2Instruction) ins).definition instanceof DupIns); + }*/ if ((ins instanceof AVM2Instruction) && (((AVM2Instruction) ins).definition instanceof NewFunctionIns)) { stack.push(new BooleanTreeItem(null, true)); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index 8c180091f..b2bc29804 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -30,7 +30,6 @@ import com.jpexs.decompiler.flash.abc.avm2.treemodel.clauses.ExceptionTreeItem; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index ecd0d8d60..3dce80c15 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.abc.avm2.treemodel.CommentTreeItem; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.helpers.Highlighting; import java.util.ArrayList; -import java.util.EmptyStackException; import java.util.HashMap; import java.util.List; import java.util.Stack; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java index 0af255494..636eb3175 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import java.awt.image.BufferedImage; @@ -53,8 +52,8 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { for (int i = 0; i < ba.length; i++) { ba[i] = (byte) 255; } - ByteArrayOutputStream baos=new ByteArrayOutputStream(); - SWFOutputStream sos=new SWFOutputStream(baos, SWF.DEFAULT_VERSION); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, SWF.DEFAULT_VERSION); try { sos.writeBytesZlib(ba); } catch (IOException ex) { @@ -68,8 +67,8 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { @Override public String getImageFormat() { - String fmt=ImageTag.getImageFormat(imageData); - if(fmt.equals("jpg")){ + String fmt = ImageTag.getImageFormat(imageData); + if (fmt.equals("jpg")) { fmt = "png"; //transparency } return fmt; @@ -78,13 +77,13 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { @Override public BufferedImage getImage(List tags) { try { - BufferedImage img=ImageIO.read(new ByteArrayInputStream(imageData)); - BufferedImage img2=new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB); - for(int y=0;y tags) { try { - BufferedImage img=ImageIO.read(new ByteArrayInputStream(imageData)); - BufferedImage img2=new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB); - for(int y=0;y getNeededCharacters() { + return shapes.getNeededCharacters(); + } + @Override public String toSVG() { return shapes.toSVG(2); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java index 3fb112c15..e62b749d4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; +import java.util.Set; public class DefineShape3Tag extends CharacterTag implements BoundedTag, AloneTag, ShapeTag { @@ -33,6 +34,11 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, AloneTa public RECT shapeBounds; public SHAPEWITHSTYLE shapes; + @Override + public Set getNeededCharacters() { + return shapes.getNeededCharacters(); + } + @Override public RECT getRect(HashMap characters) { return shapeBounds; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java index 16a73c05a..dcdeec396 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; +import java.util.Set; public class DefineShape4Tag extends CharacterTag implements BoundedTag, AloneTag, ShapeTag { @@ -37,6 +38,11 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, AloneTa public boolean usesScalingStrokes; public SHAPEWITHSTYLE shapes; + @Override + public Set getNeededCharacters() { + return shapes.getNeededCharacters(); + } + @Override public String toSVG() { return shapes.toSVG(4); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java index 37b8e5e75..27f684e41 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; +import java.util.Set; public class DefineShapeTag extends CharacterTag implements BoundedTag, AloneTag, ShapeTag { @@ -33,6 +34,11 @@ public class DefineShapeTag extends CharacterTag implements BoundedTag, AloneTag public RECT shapeBounds; public SHAPEWITHSTYLE shapes; + @Override + public Set getNeededCharacters() { + return shapes.getNeededCharacters(); + } + @Override public RECT getRect(HashMap characters) { return shapeBounds; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java index 1bb485864..db49b140e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -25,7 +26,7 @@ import java.util.Set; /** * Represents Tag inside SWF file */ -public class Tag { +public class Tag implements NeedsCharacters { /** * Identifier of tag type @@ -120,6 +121,7 @@ public class Tag { return pos; } + @Override public Set getNeededCharacters() { return new HashSet(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/NeedsCharacters.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/NeedsCharacters.java new file mode 100644 index 000000000..3e65ee9f9 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/NeedsCharacters.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.tags.base; + +import java.util.Set; + +/** + * + * @author JPEXS + */ +public interface NeedsCharacters { + + public Set getNeededCharacters(); +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java b/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java index cc6a07421..4dbb69906 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java @@ -16,11 +16,15 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; +import java.util.HashSet; +import java.util.Set; + /** * * @author JPEXS */ -public class FILLSTYLE { +public class FILLSTYLE implements NeedsCharacters { public int fillStyleType; public static final int SOLID = 0x0; @@ -39,4 +43,16 @@ public class FILLSTYLE { public FOCALGRADIENT focalGradient; public int bitmapId; public MATRIX bitmapMatrix; + + @Override + public Set getNeededCharacters() { + HashSet ret = new HashSet(); + if ((fillStyleType == REPEATING_BITMAP) + || (fillStyleType == CLIPPED_BITMAP) + || (fillStyleType == NON_SMOOTHED_REPEATING_BITMAP) + || (fillStyleType == NON_SMOOTHED_CLIPPED_BITMAP)) { + ret.add(bitmapId); + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLEARRAY.java b/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLEARRAY.java index 5aea423b4..eeb9c5ed3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLEARRAY.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/FILLSTYLEARRAY.java @@ -16,11 +16,24 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; +import java.util.HashSet; +import java.util.Set; + /** * * @author JPEXS */ -public class FILLSTYLEARRAY { +public class FILLSTYLEARRAY implements NeedsCharacters { public FILLSTYLE fillStyles[]; + + @Override + public Set getNeededCharacters() { + HashSet ret = new HashSet(); + for (FILLSTYLE fs : fillStyles) { + ret.addAll(fs.getNeededCharacters()); + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java b/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java index e05c3b66f..aa6c2cd2a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -16,19 +16,31 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * * @author JPEXS */ -public class SHAPE { +public class SHAPE implements NeedsCharacters { public int numFillBits; public int numLineBits; public List shapeRecords; + @Override + public Set getNeededCharacters() { + Set ret = new HashSet(); + for (SHAPERECORD r : shapeRecords) { + ret.addAll(r.getNeededCharacters()); + } + return ret; + } + /** * Converts shape to SVG * diff --git a/trunk/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java b/trunk/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java index 51429a433..d94d0dc4b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java @@ -16,14 +16,17 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * * @author JPEXS */ -public class SHAPEWITHSTYLE { +public class SHAPEWITHSTYLE implements NeedsCharacters { public FILLSTYLEARRAY fillStyles; public LINESTYLEARRAY lineStyles; @@ -31,6 +34,16 @@ public class SHAPEWITHSTYLE { public int numLineBits; public List shapeRecords; + @Override + public Set getNeededCharacters() { + HashSet ret = new HashSet(); + ret.addAll(fillStyles.getNeededCharacters()); + for (SHAPERECORD r : shapeRecords) { + ret.addAll(r.getNeededCharacters()); + } + return ret; + } + /** * Converts shape to SVG * 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 c03194597..cbdc615a4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.types.shaperecords; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.LINESTYLE; @@ -23,7 +24,9 @@ import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; import com.jpexs.decompiler.flash.types.RECT; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -31,12 +34,18 @@ import java.util.logging.Logger; * * @author JPEXS */ -public abstract class SHAPERECORD implements Cloneable { +public abstract class SHAPERECORD implements Cloneable, NeedsCharacters { public static float twipToPixel(int twip) { return ((float) twip) / 20.0f; } + @Override + public Set getNeededCharacters() { + HashSet ret = new HashSet(); + return ret; + } + private static class Path { public LINESTYLE lineStyle; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java index 51e11f97a..a00934ce5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.types.shaperecords; import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; +import java.util.Set; /** * @@ -42,6 +43,15 @@ public class StyleChangeRecord extends SHAPERECORD { public int numFillBits; public int numLineBits; + @Override + public Set getNeededCharacters() { + Set ret = super.getNeededCharacters(); + if (stateNewStyles) { + ret.addAll(fillStyles.getNeededCharacters()); + } + return ret; + } + @Override public String toString() { return "[StyleChangeRecord stateNewStyles=" + stateNewStyles + ", stateLineStyle=" + stateLineStyle + ",stateFillStyle1=" + stateFillStyle1 + ","