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 2af76f112..ec449db5d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1566,7 +1566,7 @@ public final class SWF implements SWFContainerItem, Timelined { GraphSourceItem ins = code.get(ip); if (debugMode) { - System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(), new ArrayList(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); + System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(), new HashSet(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); } if (ins.isExit()) { break; @@ -2378,7 +2378,7 @@ public final class SWF implements SWFContainerItem, Timelined { colorTransform = new ColorTransform(); } - ColorTransform clrTrans = Helper.deepCopy(colorTransform); + ColorTransform clrTrans = colorTransform.clone(); if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode clrTrans = colorTransform.merge(layer.colorTransForm); } @@ -2525,7 +2525,7 @@ public final class SWF implements SWFContainerItem, Timelined { colorTransform = new ColorTransform(); } - ColorTransform clrTrans = Helper.deepCopy(colorTransform); + ColorTransform clrTrans = colorTransform.clone(); if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode clrTrans = colorTransform.merge(layer.colorTransForm); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 1498ffab5..d70aad830 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2987,14 +2987,13 @@ public class AVM2Code implements Cloneable { return 1; }*/ - @SuppressWarnings("unchecked") @Override - public Object clone() throws CloneNotSupportedException { + public AVM2Code clone() throws CloneNotSupportedException { AVM2Code ret = (AVM2Code) super.clone(); if (code != null) { List codeCopy = new ArrayList<>(code.size()); for (AVM2Instruction ins : code) { - codeCopy.add((AVM2Instruction) ins.clone()); + codeCopy.add(ins.clone()); } ret.code = codeCopy; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index 3bbc231dd..1ee85f7d0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -137,28 +137,28 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { s.add(constants.getString(operands[i])); break; case AVM2Code.DAT_INT_INDEX: - s.add(Long.valueOf(constants.getInt(operands[i]))); + s.add(constants.getInt(operands[i])); break; case AVM2Code.DAT_UINT_INDEX: - s.add(new Long(constants.getUInt(operands[i]))); + s.add(constants.getUInt(operands[i])); break; case AVM2Code.DAT_DOUBLE_INDEX: - s.add(Double.valueOf(constants.getDouble(operands[i]))); + s.add(constants.getDouble(operands[i])); break; case AVM2Code.DAT_OFFSET: - s.add(new Long(offset + operands[i] + getBytes().length)); + s.add(offset + operands[i] + getBytes().length); break; case AVM2Code.DAT_CASE_BASEOFFSET: - s.add(new Long(offset + operands[i])); + s.add(offset + operands[i]); break; case AVM2Code.OPT_CASE_OFFSETS: - s.add(new Long(operands[i])); + s.add((long) operands[i]); for (int j = i + 1; j < operands.length; j++) { s.add(offset + operands[j]); } break; default: - s.add(new Long(operands[i])); + s.add((long) operands[i]); } } @@ -367,7 +367,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { } @Override - public Object clone() throws CloneNotSupportedException { + public AVM2Instruction clone() throws CloneNotSupportedException { AVM2Instruction ret = (AVM2Instruction) super.clone(); if (operands != null) { ret.operands = Arrays.copyOf(operands, operands.length); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index b613e2333..d437a1e9a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -46,7 +46,7 @@ import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; -public class MethodBody implements Cloneable { +public final class MethodBody implements Cloneable { public boolean deleted; boolean debugMode = false; @@ -236,7 +236,7 @@ public class MethodBody implements Cloneable { } public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, AVM2ConstantPool constants, List method_info, ScopeStack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) throws InterruptedException { - MethodBody b = (MethodBody) clone(); + MethodBody b = clone(); AVM2Code deobfuscated = b.getCode(); deobfuscated.markMappedOffsets(); if (Configuration.autoDeobfuscate.get()) { @@ -252,25 +252,17 @@ public class MethodBody implements Cloneable { } @Override - public Object clone() { + public MethodBody clone() { try { MethodBody ret = (MethodBody) super.clone(); if (code != null) { - ret.code = (AVM2Code) code.clone(); + ret.code = code.clone(); } - ret.codeBytes = codeBytes; - ret.exceptions = exceptions; - ret.max_regs = max_regs; - ret.max_scope_depth = max_scope_depth; - ret.max_stack = max_stack; - ret.method_info = method_info; - ret.init_scope_depth = init_scope_depth; - ret.traits = traits; //maybe deep clone + //maybe deep clone traits return ret; } catch (CloneNotSupportedException ex) { - Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, null, ex); + throw new RuntimeException(); } - return null; } public boolean autoFillStats(ABC abc, int initScope, boolean hasThis) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 122382e3b..044d69629 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -81,7 +81,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.EmptyStackException; import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -164,7 +166,7 @@ public class Action implements GraphSourceItem { * * @param refs list of addresses */ - public void getRef(List refs) { + public void getRef(Set refs) { } /** @@ -173,8 +175,8 @@ public class Action implements GraphSourceItem { * @param list List of actions * @return List of addresses */ - public static List getActionsAllRefs(List list) { - List ret = new ArrayList<>(); + public static Set getActionsAllRefs(List list) { + Set ret = new HashSet<>(); for (Action a : list) { a.getRef(ret); } @@ -403,7 +405,7 @@ public class Action implements GraphSourceItem { */ public static GraphTextWriter actionsToString(List listeners, long address, ActionList list, int version, ScriptExportMode exportMode, GraphTextWriter writer) { long offset; - List importantOffsets = getActionsAllRefs(list); + Set importantOffsets = getActionsAllRefs(list); /*List cps = SWFInputStream.getConstantPool(new ArrayList(), new ActionGraphSource(list, version, new HashMap(), new HashMap(), new HashMap()), 0, version, path); if (!cps.isEmpty()) { setConstantPool(list, cps.get(cps.size() - 1)); @@ -583,7 +585,7 @@ public class Action implements GraphSourceItem { * @param exportMode PCode or hex? * @return String of P-code source */ - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { return toString(); } @@ -1220,7 +1222,7 @@ public class Action implements GraphSourceItem { } } - public GraphTextWriter getASMSourceReplaced(ActionList container, List knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(ActionList container, Set knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { writer.appendNoHilight(getASMSource(container, knownAddreses, exportMode)); return writer; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java index 55a345848..efe3ff495 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -52,6 +52,7 @@ import com.jpexs.helpers.Helper; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -806,7 +807,7 @@ public class ActionListReader { } if (debugMode) { - String atos = a.getASMSource(new ActionList(), new ArrayList(), ScriptExportMode.PCODE); + String atos = a.getASMSource(new ActionList(), new HashSet(), ScriptExportMode.PCODE); if (a instanceof GraphSourceItemContainer) { atos = a.toString(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index 5cb2031e1..c5107e13f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionWaitForFrame extends Action implements ActionStore { @@ -56,7 +57,7 @@ public class ActionWaitForFrame extends Action implements ActionStore { } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { String ret = "WaitForFrame " + frame + " " + skipCount; return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index aa91561d2..c348c046d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -28,6 +28,7 @@ import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -57,7 +58,7 @@ public class ActionIf extends Action { } @Override - public void getRef(List refs) { + public void getRef(Set refs) { refs.add(getAddress() + getTotalActionLength() + offset); } @@ -75,7 +76,7 @@ public class ActionIf extends Action { } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { long address = getAddress() + getTotalActionLength() + offset; String ofsStr = Helper.formatAddress(address); return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : "")); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index 9e47d37a2..755a14e3a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -29,6 +29,7 @@ import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -58,7 +59,7 @@ public class ActionJump extends Action { } @Override - public void getRef(List refs) { + public void getRef(Set refs) { refs.add(getAddress() + getTotalActionLength() + offset); } @@ -76,7 +77,7 @@ public class ActionJump extends Action { } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { long address = getAddress() + getTotalActionLength() + offset; String ofsStr = Helper.formatAddress(address); return "Jump loc" + ofsStr; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 10c0118f3..bea8306b8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -43,6 +43,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionPush extends Action { @@ -232,7 +233,7 @@ public class ActionPush extends Action { } @Override - public GraphTextWriter getASMSourceReplaced(ActionList container, List knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(ActionList container, Set knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { if (replacement == null || replacement.size() < values.size()) { return toString(writer); } @@ -243,7 +244,7 @@ public class ActionPush extends Action { return writer; } - public GraphTextWriter paramsToStringReplaced(List container, List knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter paramsToStringReplaced(List container, Set knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { if (replacement == null || replacement.size() < values.size()) { return paramsToString(writer); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index f60526c34..3f8e3ac37 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionWaitForFrame2 extends Action implements ActionStore { @@ -117,7 +118,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore { } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { String ret = "WaitForFrame2 " + skipCount; /*for (int i = 0; i < skipped.size(); i++) { if (skipped.get(i) instanceof ActionEnd) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index ecba630cc..da5a60fd0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionDefineFunction extends Action implements GraphSourceItemContainer { @@ -103,7 +104,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { StringBuilder paramStr = new StringBuilder(); for (int i = 0; i < paramNames.size(); i++) { paramStr.append("\"").append(Helper.escapeString(paramNames.get(i))).append("\" "); @@ -113,7 +114,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public GraphTextWriter getASMSourceReplaced(ActionList container, List knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(ActionList container, Set knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { List oldParamNames = paramNames; if (replacedParamNames != null) { paramNames = replacedParamNames; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index 317b22975..f449ea32f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionWith extends Action implements GraphSourceItemContainer { @@ -76,7 +77,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer { } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { return "With {"; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index f3065d0b7..80029e882 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer { @@ -160,7 +161,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public GraphTextWriter getASMSourceReplaced(ActionList container, List knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(ActionList container, Set knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) { List oldParamNames = paramNames; if (replacedParamNames != null) { paramNames = replacedParamNames; @@ -178,7 +179,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { StringBuilder paramStr = new StringBuilder(); for (int i = 0; i < paramNames.size(); i++) { paramStr.append(paramRegisters.get(i)).append(" \"").append(Helper.escapeString(paramNames.get(i))).append("\" "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index 6f36c4cfb..dfae5a526 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -37,6 +37,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class ActionTry extends Action implements GraphSourceItemContainer { @@ -149,7 +150,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer { } @Override - public String getASMSource(ActionList container, List knownAddreses, ScriptExportMode exportMode) { + public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { StringBuilder ret = new StringBuilder(); ret.append("Try "); if (catchBlockFlag) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java index 6912af3b1..35ae99dfa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java @@ -23,7 +23,7 @@ import java.awt.geom.AffineTransform; * * @author JPEXS */ -public class Matrix { +public final class Matrix implements Cloneable { public double scaleX = 1; public double scaleY = 1; @@ -82,14 +82,12 @@ public class Matrix { @Override public Matrix clone() { - Matrix mat = new Matrix(); - mat.translateX = translateX; - mat.translateY = translateY; - mat.scaleX = scaleX; - mat.scaleY = scaleY; - mat.rotateSkew0 = rotateSkew0; - mat.rotateSkew1 = rotateSkew1; - return mat; + try { + Matrix mat = (Matrix) super.clone(); + return mat; + } catch (CloneNotSupportedException ex) { + throw new RuntimeException(); + } } public Point transform(double x, double y) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 5d36004b7..cb6e94319 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -833,7 +833,7 @@ public class DefineEditTextTag extends TextTag { if (font != null && font.hasLayout()) { int kerningAdjustment = 0; if (nextChar != null) { - kerningAdjustment = font.getGlyphKerningAdjustment(ge.glyphIndex, font.charToGlyph(nextChar)); + kerningAdjustment = font.getCharKerningAdjustment(c, nextChar); kerningAdjustment /= font.getDivider(); } advance = (int) Math.round(Math.round((double) lastStyle.fontHeight * (font.getGlyphAdvance(ge.glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0))); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index 25740d9eb..bb1916079 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -448,6 +448,11 @@ public class DefineFont2Tag extends FontTag { public int getGlyphKerningAdjustment(int glyphIndex, int nextGlyphIndex) { char c1 = glyphToChar(glyphIndex); char c2 = glyphToChar(nextGlyphIndex); + return getCharKerningAdjustment(c1, c2); + } + + @Override + public int getCharKerningAdjustment(char c1, char c2) { int kerningAdjustment = 0; for (KERNINGRECORD ker : fontKerningTable) { if (ker.fontKerningCode1 == c1 && ker.fontKerningCode2 == c2) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 4bf9e1023..d6d27fcd0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -459,6 +459,11 @@ public class DefineFont3Tag extends FontTag { } char c1 = glyphToChar(glyphIndex); char c2 = glyphToChar(nextGlyphIndex); + return getCharKerningAdjustment(c1, c2); + } + + @Override + public int getCharKerningAdjustment(char c1, char c2) { int kerningAdjustment = 0; for (KERNINGRECORD ker : fontKerningTable) { if (ker.fontKerningCode1 == c1 && ker.fontKerningCode2 == c2) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java index f995848f9..c0eb7ae7b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java @@ -339,4 +339,8 @@ public class DefineFontTag extends FontTag { return 0; } + @Override + public int getCharKerningAdjustment(char c1, char c2) { + return 0; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index f83a30abd..52850131b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -268,7 +268,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag scr2 = new StyleChangeRecord(); endIndex--; } - StyleChangeRecord scr = (StyleChangeRecord) scr1.clone(); + StyleChangeRecord scr = scr1.clone(); if (scr1.stateMoveTo || scr2.stateMoveTo) { scr.moveDeltaX = startPosX + (endPosX - startPosX) * ratio / 65535; scr.moveDeltaY = startPosY + (endPosY - startPosY) * ratio / 65535; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index 18382ea7c..7adfd8099 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -249,7 +249,7 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag { scr2 = new StyleChangeRecord(); endIndex--; } - StyleChangeRecord scr = (StyleChangeRecord) scr1.clone(); + StyleChangeRecord scr = scr1.clone(); if (scr1.stateMoveTo || scr2.stateMoveTo) { scr.moveDeltaX = startPosX + (endPosX - startPosX) * ratio / MAX_RATIO; scr.moveDeltaY = startPosY + (endPosY - startPosY) * ratio / MAX_RATIO; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 1b97d1c5f..42e48eed7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -387,7 +387,7 @@ public class DefineText2Tag extends TextTag { if (font.hasLayout()) { int kerningAdjustment = 0; if (nextChar != null) { - kerningAdjustment = font.getGlyphKerningAdjustment(tr.glyphEntries[i].glyphIndex, font.charToGlyph(nextChar)); + kerningAdjustment = font.getCharKerningAdjustment(c, nextChar); } advance = (int) Math.round(((double) textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment)) / (font.getDivider() * 1024.0)); } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 681dd4369..fbb58b5b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -393,7 +393,7 @@ public class DefineTextTag extends TextTag { if (font.hasLayout()) { int kerningAdjustment = 0; if (nextChar != null) { - kerningAdjustment = font.getGlyphKerningAdjustment(tr.glyphEntries[i].glyphIndex, font.charToGlyph(nextChar)); + kerningAdjustment = font.getCharKerningAdjustment(c, nextChar); } advance = (int) Math.round(((double) textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment)) / (font.getDivider() * 1024.0)); } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index e2ca3ce5c..49675c624 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -75,6 +75,8 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable public abstract int getGlyphKerningAdjustment(int glyphIndex, int nextGlyphIndex); + public abstract int getCharKerningAdjustment(char c1, char c2); + public abstract int getGlyphWidth(int glyphIndex); public abstract String getFontNameIntag(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java index 05321d605..a0c964d50 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags.dynamictext; import com.jpexs.decompiler.flash.tags.base.FontTag; @@ -23,7 +24,7 @@ import com.jpexs.decompiler.flash.types.RGBA; * * @author JPEXS */ -public class TextStyle { +public final class TextStyle implements Cloneable { public FontTag font; @@ -41,13 +42,11 @@ public class TextStyle { @Override public TextStyle clone() { - TextStyle result = new TextStyle(); - result.font = font; - result.fontHeight = fontHeight; - result.bold = bold; - result.italic = italic; - result.underlined = underlined; - result.textColor = textColor; - return result; + try { + TextStyle result = (TextStyle) super.clone(); + return result; + } catch (CloneNotSupportedException ex) { + throw new RuntimeException(); + } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java index 58cc2fcc3..5ee395971 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -38,7 +38,6 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.helpers.ByteArrayRange; -import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.awt.Font; import java.io.ByteArrayOutputStream; @@ -224,10 +223,15 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { @Override public int getGlyphKerningAdjustment(int glyphIndex, int nextGlyphIndex) { - int char1 = glyphToChar(glyphIndex); - int char2 = glyphToChar(nextGlyphIndex); + char c1 = glyphToChar(glyphIndex); + char c2 = glyphToChar(nextGlyphIndex); + return getCharKerningAdjustment(c1, c2); + } + + @Override + public int getCharKerningAdjustment(char c1, char c2) { for (KerningPairType kp : fonts.get(0).kerning) { - if (kp.char1 == char1 && kp.char2 == char2) { + if (kp.char1 == c1 && kp.char2 == c2) { return resize(kp.advance); } } @@ -335,7 +339,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { ret.numLineBits = 0; List recs = new ArrayList<>(); for (SHAPERECORD r : shp.shapeRecords) { - SHAPERECORD c = Helper.deepCopy(r); + SHAPERECORD c = r.clone(); if (c instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) c; scr.moveDeltaX = resize(scr.moveDeltaX); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORM.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORM.java index f9baf67e2..b7f373824 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORM.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORM.java @@ -12,12 +12,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.types.annotations.Calculated; import com.jpexs.decompiler.flash.types.annotations.SWFType; -import java.io.Serializable; /** * Defines a transform that can be applied to the color space of a graphic @@ -25,7 +25,7 @@ import java.io.Serializable; * * @author JPEXS */ -public class CXFORM extends ColorTransform implements Serializable { +public class CXFORM extends ColorTransform { /** * Has color addition values @@ -99,4 +99,18 @@ public class CXFORM extends ColorTransform implements Serializable { return hasMultTerms ? blueMultTerm : super.getBlueMulti(); } + @Override + public CXFORM clone() { + CXFORM ret = (CXFORM) super.clone(); + ret.hasAddTerms = hasAddTerms; + ret.hasMultTerms = hasMultTerms; + ret.nbits = nbits; + ret.redMultTerm = redMultTerm; + ret.greenMultTerm = greenMultTerm; + ret.blueMultTerm = blueMultTerm; + ret.redAddTerm = redAddTerm; + ret.greenAddTerm = greenAddTerm; + ret.blueAddTerm = blueAddTerm; + return ret; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java index 4303acc6c..46c295496 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java @@ -12,13 +12,13 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.types.annotations.Calculated; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.SWFType; -import java.io.Serializable; /** * Defines a transform that can be applied to the color space of a graphic @@ -26,7 +26,7 @@ import java.io.Serializable; * * @author JPEXS */ -public class CXFORMWITHALPHA extends ColorTransform implements Serializable { +public class CXFORMWITHALPHA extends ColorTransform { /** * Has color addition values @@ -129,4 +129,20 @@ public class CXFORMWITHALPHA extends ColorTransform implements Serializable { return hasMultTerms ? alphaMultTerm : super.getAlphaMulti(); } + @Override + public CXFORMWITHALPHA clone() { + CXFORMWITHALPHA ret = (CXFORMWITHALPHA) super.clone(); + ret.hasAddTerms = hasAddTerms; + ret.hasMultTerms = hasMultTerms; + ret.nbits = nbits; + ret.redMultTerm = redMultTerm; + ret.greenMultTerm = greenMultTerm; + ret.blueMultTerm = blueMultTerm; + ret.alphaMultTerm = alphaMultTerm; + ret.redAddTerm = redAddTerm; + ret.greenAddTerm = greenAddTerm; + ret.blueAddTerm = blueAddTerm; + ret.alphaAddTerm = alphaAddTerm; + return ret; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ColorTransform.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ColorTransform.java index 84e5135e5..09cc6571f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ColorTransform.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ColorTransform.java @@ -12,21 +12,20 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.types.filters.Filtering; -import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.awt.image.RescaleOp; -import java.io.Serializable; /** * * @author JPEXS */ -public class ColorTransform implements Serializable { +public class ColorTransform implements Cloneable { public RescaleOp toRescaleOp() { return new RescaleOp(new float[]{getRedMulti() / 255f, getGreenMulti() / 255f, getBlueMulti() / 255f, getAlphaMulti() / 255f}, @@ -56,9 +55,14 @@ public class ColorTransform implements Serializable { } public GRADRECORD[] apply(GRADRECORD[] gradRecords) { - GRADRECORD[] ret = Helper.deepCopy(gradRecords); - for (GRADRECORD r : ret) { - r.color = apply(r.color); + GRADRECORD[] ret = new GRADRECORD[gradRecords.length]; + for (int i = 0; i < gradRecords.length; i++) { + GRADRECORD r = gradRecords[i]; + GRADRECORD r2 = new GRADRECORD(); + r2.inShape3 = r.inShape3; + r2.ratio = r.ratio; + r2.color = apply(r.color); + ret[i] = r2; } return ret; } @@ -147,4 +151,12 @@ public class ColorTransform implements Serializable { + ", redMulti=" + getRedMulti() + ", greenMulti=" + getGreenMulti() + ", blueMulti=" + getBlueMulti() + ", alphaMulti=" + getAlphaMulti() + "]"; } + @Override + public ColorTransform clone() { + try { + return (ColorTransform) super.clone(); + } catch (CloneNotSupportedException ex) { + throw new RuntimeException(); + } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/GRADRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/GRADRECORD.java index ec5bb485a..90944c5be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/GRADRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/GRADRECORD.java @@ -12,18 +12,18 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; -import java.io.Serializable; /** * * @author JPEXS */ -public class GRADRECORD implements Serializable { +public class GRADRECORD { @SWFType(BasicType.UI8) public int ratio; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java index 0d1c6da1d..42b3f0991 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java @@ -41,8 +41,9 @@ public class ContourType implements Serializable { int i = 0; int divider = 1; for (; i < records.size(); i++) { - if (records.get(i) instanceof StyleChangeRecord) { - StyleChangeRecord scr = (StyleChangeRecord) records.get(i); + SHAPERECORD rec = records.get(i); + if (rec instanceof StyleChangeRecord) { + StyleChangeRecord scr = (StyleChangeRecord) rec; if (scr.stateMoveTo) { moveToX = scr.moveDeltaX / divider; moveToY = scr.moveDeltaY / divider; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/EdgeType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/EdgeType.java index fbc99609d..541193b6a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/EdgeType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/EdgeType.java @@ -12,17 +12,15 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types.gfx; import com.jpexs.decompiler.flash.types.shaperecords.CurvedEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.Serializable; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -52,54 +50,28 @@ public class EdgeType implements Serializable { private static final int Edge_Line = 2; private static final int Edge_Quad = 3; public int data[]; - public byte raw[]; public EdgeType(boolean vertical, int v) { data = new int[]{vertical ? Edge_VLine : Edge_HLine, v}; - calcRaw(); } public EdgeType(int x, int y) { data = new int[]{Edge_Line, x, y}; - calcRaw(); } public EdgeType(int cx, int cy, int ax, int ay) { data = new int[]{Edge_Quad, cx, cy, ax, ay}; - calcRaw(); - } - - private void calcRaw() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - GFxOutputStream sos = new GFxOutputStream(baos); - try { - write(sos); - } catch (IOException ex) { - Logger.getLogger(EdgeType.class.getName()).log(Level.SEVERE, null, ex); - } - raw = baos.toByteArray(); } @Override public String toString() { - String ret = "[Edge " + (raw[0] & 0xf) + " data:"; + String ret = "[Edge data:"; for (int i = 0; i < data.length; i++) { if (i > 0) { ret += ", "; } ret += "" + data[i]; } - ret += " raw: 0x"; - for (int i = 0; i < raw.length; i++) { - if (i > 0) { - ret += ""; - } - String h = Integer.toHexString(raw[i] & 0xff); - if (h.length() < 2) { - h = "0" + h; - } - ret += "" + h; - } ret += "]"; return ret; } @@ -118,19 +90,6 @@ public class EdgeType implements Serializable { }*/ } - private byte[] readRawEdge(GFxInputStream sis) throws IOException { - int firstByte = sis.readUI8("firstByte"); - int nb = sizes[firstByte & 0xF]; - byte ret[] = new byte[1 + nb]; - ret[0] = (byte) firstByte; - int i; - for (i = 0; i < nb; i++) { - ret[i + 1] = (byte) sis.readUI8("byte"); - } - - return ret; - } - private static int SInt8(int val) { /*boolean sign = (val & 0x80) == 0x80; val = val & 0x7F; @@ -144,7 +103,7 @@ public class EdgeType implements Serializable { public SHAPERECORD toSHAPERECORD() { int multiplier = 1; StraightEdgeRecord ser; - CurvedEdgeRecord cer; + CurvedEdgeRecord cer; switch (data[0]) { case Edge_HLine: ser = new StraightEdgeRecord(); @@ -179,116 +138,163 @@ public class EdgeType implements Serializable { } private int[] readEdge(GFxInputStream sis) throws IOException { - raw = readRawEdge(sis); + byte firstByte = (byte) sis.readUI8("firstByte"); + int nb = sizes[firstByte & 0xF]; + byte raw1, raw2, raw3, raw4, raw5, raw6, raw7, raw8, raw9; + raw1 = (byte) sis.readUI8("byte1"); int data[] = new int[5]; - switch (raw[0] & 0xF) { + switch (firstByte & 0xF) { case Edge_H12: data[0] = Edge_HLine; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8(raw[1] & 0xff) << 4); + data[1] = ((firstByte & 0xff) >> 4) | (SInt8(raw1 & 0xff) << 4); break; case Edge_H20: + raw2 = (byte) sis.readUI8("byte2"); data[0] = Edge_HLine; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8(raw[2] & 0xff) << 12); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8(raw2 & 0xff) << 12); break; case Edge_V12: data[0] = Edge_VLine; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8(raw[1] & 0xff) << 4); + data[1] = ((firstByte & 0xff) >> 4) | (SInt8(raw1 & 0xff) << 4); break; case Edge_V20: data[0] = Edge_VLine; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8(raw[2] & 0xff) << 12); + raw2 = (byte) sis.readUI8("byte2"); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8(raw2 & 0xff) << 12); break; case Edge_L6: data[0] = Edge_Line; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8((raw[1] & 0xff) << 6) >> 2); - data[2] = SInt8(raw[1] & 0xff) >> 2; + data[1] = ((firstByte & 0xff) >> 4) | (SInt8((raw1 & 0xff) << 6) >> 2); + data[2] = SInt8(raw1 & 0xff) >> 2; break; case Edge_L10: + raw2 = (byte) sis.readUI8("byte2"); data[0] = Edge_Line; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8((raw[1] & 0xff) << 2) << 2); - data[2] = ((raw[1] & 0xff) >> 6) | (SInt8((raw[2] & 0xff)) << 2); + data[1] = ((firstByte & 0xff) >> 4) | (SInt8((raw1 & 0xff) << 2) << 2); + data[2] = ((raw1 & 0xff) >> 6) | (SInt8((raw2 & 0xff)) << 2); break; case Edge_L14: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); data[0] = Edge_Line; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8((raw[2] & 0xff) << 6) << 6); - data[2] = ((raw[2] & 0xff) >> 2) | (SInt8((raw[3] & 0xff)) << 6); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8((raw2 & 0xff) << 6) << 6); + data[2] = ((raw2 & 0xff) >> 2) | (SInt8((raw3 & 0xff)) << 6); break; case Edge_L18: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); data[0] = Edge_Line; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8((raw[2] & 0xff) << 2) << 10); - data[2] = ((raw[2] & 0xff) >> 6) | ((raw[3] & 0xff) << 2) | (SInt8((raw[4] & 0xff)) << 10); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8((raw2 & 0xff) << 2) << 10); + data[2] = ((raw2 & 0xff) >> 6) | ((raw3 & 0xff) << 2) | (SInt8((raw4 & 0xff)) << 10); break; case Edge_C5: + raw2 = (byte) sis.readUI8("byte2"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8((raw[1] & 0xff) << 7) >> 3); - data[2] = SInt8((raw[1] & 0xff) << 2) >> 3; - data[3] = ((raw[1] & 0xff) >> 6) | (SInt8((raw[2] & 0xff) << 5) >> 3); - data[4] = SInt8((raw[2] & 0xff)) >> 3; + data[1] = ((firstByte & 0xff) >> 4) | (SInt8((raw1 & 0xff) << 7) >> 3); + data[2] = SInt8((raw1 & 0xff) << 2) >> 3; + data[3] = ((raw1 & 0xff) >> 6) | (SInt8((raw2 & 0xff) << 5) >> 3); + data[4] = SInt8((raw2 & 0xff)) >> 3; break; case Edge_C7: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8((raw[1] & 0xff) << 5) >> 1); - data[2] = ((raw[1] & 0xff) >> 3) | (SInt8((raw[2] & 0xff) << 6) >> 1); - data[3] = ((raw[2] & 0xff) >> 2) | (SInt8((raw[3] & 0xff) << 7) >> 1); - data[4] = SInt8(raw[3]) >> 1; + data[1] = ((firstByte & 0xff) >> 4) | (SInt8((raw1 & 0xff) << 5) >> 1); + data[2] = ((raw1 & 0xff) >> 3) | (SInt8((raw2 & 0xff) << 6) >> 1); + data[3] = ((raw2 & 0xff) >> 2) | (SInt8((raw3 & 0xff) << 7) >> 1); + data[4] = SInt8(raw3) >> 1; break; case Edge_C9: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8((raw[1] & 0xff) << 3) << 1); - data[2] = ((raw[1] & 0xff) >> 5) | (SInt8((raw[2] & 0xff) << 2) << 1); - data[3] = ((raw[2] & 0xff) >> 6) | (SInt8((raw[3] & 0xff) << 1) << 1); - data[4] = ((raw[3] & 0xff) >> 7) | (SInt8(raw[4] & 0xff) << 1); + data[1] = ((firstByte & 0xff) >> 4) | (SInt8((raw1 & 0xff) << 3) << 1); + data[2] = ((raw1 & 0xff) >> 5) | (SInt8((raw2 & 0xff) << 2) << 1); + data[3] = ((raw2 & 0xff) >> 6) | (SInt8((raw3 & 0xff) << 1) << 1); + data[4] = ((raw3 & 0xff) >> 7) | (SInt8(raw4 & 0xff) << 1); break; case Edge_C11: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); + raw5 = (byte) sis.readUI8("byte5"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | (SInt8((raw[1] & 0xff) << 1) << 3); - data[2] = (raw[1] >> 7) | ((raw[2] & 0xff) << 1) | (SInt8((raw[3] & 0xff) << 6) << 3); - data[3] = ((raw[3] & 0xff) >> 2) | (SInt8((raw[4] & 0xff) << 3) << 3); - data[4] = ((raw[4] & 0xff) >> 5) | (SInt8(raw[5] & 0xff) << 3); + data[1] = ((firstByte & 0xff) >> 4) | (SInt8((raw1 & 0xff) << 1) << 3); + data[2] = (raw1 >> 7) | ((raw2 & 0xff) << 1) | (SInt8((raw3 & 0xff) << 6) << 3); + data[3] = ((raw3 & 0xff) >> 2) | (SInt8((raw4 & 0xff) << 3) << 3); + data[4] = ((raw4 & 0xff) >> 5) | (SInt8(raw5 & 0xff) << 3); break; case Edge_C13: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); + raw5 = (byte) sis.readUI8("byte5"); + raw6 = (byte) sis.readUI8("byte6"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8((raw[2] & 0xff) << 7) << 5); - data[2] = ((raw[2] & 0xff) >> 1) | (SInt8((raw[3] & 0xff) << 2) << 5); - data[3] = ((raw[3] & 0xff) >> 6) | ((raw[4] & 0xff) << 2) | (SInt8((raw[5] & 0xff) << 5) << 5); - data[4] = ((raw[5] & 0xff) >> 3) | (SInt8(raw[6] & 0xff) << 5); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8((raw2 & 0xff) << 7) << 5); + data[2] = ((raw2 & 0xff) >> 1) | (SInt8((raw3 & 0xff) << 2) << 5); + data[3] = ((raw3 & 0xff) >> 6) | ((raw4 & 0xff) << 2) | (SInt8((raw5 & 0xff) << 5) << 5); + data[4] = ((raw5 & 0xff) >> 3) | (SInt8(raw6 & 0xff) << 5); break; case Edge_C15: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); + raw5 = (byte) sis.readUI8("byte5"); + raw6 = (byte) sis.readUI8("byte6"); + raw7 = (byte) sis.readUI8("byte7"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8((raw[2] & 0xff) << 5) << 7); - data[2] = ((raw[2] & 0xff) >> 3) | ((raw[3] & 0xff) << 5) | (SInt8((raw[4] & 0xff) << 6) << 7); - data[3] = ((raw[4] & 0xff) >> 2) | ((raw[5] & 0xff) << 6) | (SInt8((raw[6] & 0xff) << 7) << 7); - data[4] = ((raw[6] & 0xff) >> 1) | (SInt8((raw[7] & 0xff)) << 7); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8((raw2 & 0xff) << 5) << 7); + data[2] = ((raw2 & 0xff) >> 3) | ((raw3 & 0xff) << 5) | (SInt8((raw4 & 0xff) << 6) << 7); + data[3] = ((raw4 & 0xff) >> 2) | ((raw5 & 0xff) << 6) | (SInt8((raw6 & 0xff) << 7) << 7); + data[4] = ((raw6 & 0xff) >> 1) | (SInt8((raw7 & 0xff)) << 7); break; case Edge_C17: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); + raw5 = (byte) sis.readUI8("byte5"); + raw6 = (byte) sis.readUI8("byte6"); + raw7 = (byte) sis.readUI8("byte7"); + raw8 = (byte) sis.readUI8("byte8"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8((raw[2] & 0xff) << 3) << 9); - data[2] = ((raw[2] & 0xff) >> 5) | ((raw[3] & 0xff) << 3) | (SInt8((raw[4] & 0xff) << 2) << 9); - data[3] = ((raw[4] & 0xff) >> 6) | ((raw[5] & 0xff) << 2) | (SInt8((raw[6] & 0xff) << 1) << 9); - data[4] = ((raw[6] & 0xff) >> 7) | ((raw[7] & 0xff) << 1) | (SInt8(raw[8] & 0xff) << 9); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8((raw2 & 0xff) << 3) << 9); + data[2] = ((raw2 & 0xff) >> 5) | ((raw3 & 0xff) << 3) | (SInt8((raw4 & 0xff) << 2) << 9); + data[3] = ((raw4 & 0xff) >> 6) | ((raw5 & 0xff) << 2) | (SInt8((raw6 & 0xff) << 1) << 9); + data[4] = ((raw6 & 0xff) >> 7) | ((raw7 & 0xff) << 1) | (SInt8(raw8 & 0xff) << 9); break; case Edge_C19: + raw2 = (byte) sis.readUI8("byte2"); + raw3 = (byte) sis.readUI8("byte3"); + raw4 = (byte) sis.readUI8("byte4"); + raw5 = (byte) sis.readUI8("byte5"); + raw6 = (byte) sis.readUI8("byte6"); + raw7 = (byte) sis.readUI8("byte7"); + raw8 = (byte) sis.readUI8("byte8"); + raw9 = (byte) sis.readUI8("byte9"); data[0] = Edge_Quad; - data[1] = ((raw[0] & 0xff) >> 4) | ((raw[1] & 0xff) << 4) | (SInt8(raw[2] << 1) << 11); - data[2] = ((raw[2] & 0xff) >> 7) | ((raw[3] & 0xff) << 1) | ((raw[4] & 0xff) << 9) | (SInt8(raw[5] << 6) << 11); - data[3] = ((raw[5] & 0xff) >> 2) | ((raw[6] & 0xff) << 6) | (SInt8(raw[7] << 3) << 11); - data[4] = ((raw[7] & 0xff) >> 5) | ((raw[8] & 0xff) << 3) | (SInt8(raw[9]) << 11); + data[1] = ((firstByte & 0xff) >> 4) | ((raw1 & 0xff) << 4) | (SInt8(raw2 << 1) << 11); + data[2] = ((raw2 & 0xff) >> 7) | ((raw3 & 0xff) << 1) | ((raw4 & 0xff) << 9) | (SInt8(raw5 << 6) << 11); + data[3] = ((raw5 & 0xff) >> 2) | ((raw6 & 0xff) << 6) | (SInt8(raw7 << 3) << 11); + data[4] = ((raw7 & 0xff) >> 5) | ((raw8 & 0xff) << 3) | (SInt8(raw9) << 11); break; } return data; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/CurvedEdgeRecord.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/CurvedEdgeRecord.java index bc4cb1997..0a603ca6f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/CurvedEdgeRecord.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/CurvedEdgeRecord.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types.shaperecords; import com.jpexs.decompiler.flash.SWFOutputStream; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index c76d876e8..65e082d31 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -28,7 +28,6 @@ import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.SHAPE; -import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.awt.Font; @@ -423,7 +422,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali ret.numLineBits = shp.numLineBits; List recs = new ArrayList<>(); for (SHAPERECORD r : shp.shapeRecords) { - SHAPERECORD c = Helper.deepCopy(r); + SHAPERECORD c = r.clone(); if (c instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) c; scr.moveDeltaX = (int) (multiplier * scr.moveDeltaX); @@ -465,4 +464,13 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali s = AffineTransform.getTranslateInstance(-dx / SWF.unitDivisor, -dy / SWF.unitDivisor).createTransformedShape(s); return s; } + + @Override + public SHAPERECORD clone() { + try { + return (SHAPERECORD) super.clone(); + } catch (CloneNotSupportedException ex) { + throw new RuntimeException(); + } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java index 98201e513..524636b96 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/StyleChangeRecord.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types.shaperecords; import com.jpexs.decompiler.flash.SWFOutputStream; @@ -23,14 +24,12 @@ import com.jpexs.decompiler.flash.types.annotations.Calculated; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.SWFType; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; /** * * @author JPEXS */ -public class StyleChangeRecord extends SHAPERECORD implements Cloneable { +public final class StyleChangeRecord extends SHAPERECORD implements Cloneable { public boolean typeFlag = false; public boolean stateNewStyles; @@ -127,13 +126,8 @@ public class StyleChangeRecord extends SHAPERECORD implements Cloneable { } @Override - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(StyleChangeRecord.class.getName()).log(Level.SEVERE, null, ex); - } - return null; + public StyleChangeRecord clone() { + return (StyleChangeRecord) super.clone(); } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 9827e33bb..d8d2390c2 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -204,7 +204,6 @@ import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.filechooser.FileFilter; import javax.swing.plaf.basic.BasicTreeUI; -import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; /** diff --git a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java index e3fe2195c..16ab493f2 100644 --- a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java +++ b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java @@ -33,7 +33,6 @@ import com.jpexs.decompiler.flash.gui.View; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.awt.Color; -import java.awt.Component; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;