external player preview fixes

This commit is contained in:
honfika@gmail.com
2015-12-24 17:37:17 +01:00
parent 5255d9e80e
commit f9254ef60b
11 changed files with 285 additions and 104 deletions

View File

@@ -149,15 +149,15 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject2Tag(SWF swf, boolean placeFlagHasClipActions, boolean placeFlagHasClipDepth, boolean placeFlagHasName, boolean placeFlagHasRatio, boolean placeFlagHasColorTransform, boolean placeFlagHasMatrix, boolean placeFlagHasCharacter, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
public PlaceObject2Tag(SWF swf, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
super(swf, ID, NAME, null);
this.placeFlagHasClipActions = placeFlagHasClipActions;
this.placeFlagHasClipDepth = placeFlagHasClipDepth;
this.placeFlagHasName = placeFlagHasName;
this.placeFlagHasRatio = placeFlagHasRatio;
this.placeFlagHasColorTransform = placeFlagHasColorTransform;
this.placeFlagHasMatrix = placeFlagHasMatrix;
this.placeFlagHasCharacter = placeFlagHasCharacter;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
this.placeFlagHasName = name != null;
this.placeFlagHasRatio = ratio >= 0;
this.placeFlagHasColorTransform = colorTransform != null;
this.placeFlagHasMatrix = matrix != null;
this.placeFlagHasCharacter = characterId >= 0;
this.placeFlagMove = placeFlagMove;
this.depth = depth;
this.characterId = characterId;
@@ -256,6 +256,11 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public int getPlaceObjectNum() {
return 2;
}
@Override
public int getClipDepth() {
if (placeFlagHasClipDepth) {
@@ -329,6 +334,11 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
if (placeFlagHasName) {

View File

@@ -239,6 +239,38 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject3Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions) {
super(swf, ID, NAME, null);
this.placeFlagHasClassName = className != null;
this.placeFlagHasFilterList = surfaceFilterList != null;
this.placeFlagHasBlendMode = blendMode >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache >= 0;
this.placeFlagHasVisible = visible >= 0;
this.placeFlagOpaqueBackground = backgroundColor != null;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
this.placeFlagHasName = name != null;
this.placeFlagHasRatio = ratio >= 0;
this.placeFlagHasColorTransform = colorTransform != null;
this.placeFlagHasMatrix = matrix != null;
this.placeFlagHasCharacter = characterId >= 0;
this.placeFlagMove = placeFlagMove;
this.depth = depth;
this.className = className;
this.characterId = characterId;
this.matrix = matrix;
this.colorTransform = colorTransform;
this.ratio = ratio;
this.name = name;
this.clipDepth = clipDepth;
this.surfaceFilterList = surfaceFilterList;
this.blendMode = blendMode;
this.bitmapCache = bitmapCache;
this.visible = visible;
this.backgroundColor = backgroundColor;
this.clipActions = clipActions;
}
/**
* Constructor
*
@@ -390,12 +422,8 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
public int getPlaceObjectNum() {
return 3;
}
@Override
@@ -406,6 +434,15 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
return -1;
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
}
/**
* Returns all sub-items
*
@@ -466,6 +503,11 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
if (placeFlagHasName) {

View File

@@ -241,6 +241,39 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, byte[] amfData) {
super(swf, ID, NAME, null);
this.placeFlagHasClassName = className != null;
this.placeFlagHasFilterList = surfaceFilterList != null;
this.placeFlagHasBlendMode = blendMode >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache >= 0;
this.placeFlagHasVisible = visible >= 0;
this.placeFlagOpaqueBackground = backgroundColor != null;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
this.placeFlagHasName = name != null;
this.placeFlagHasRatio = ratio >= 0;
this.placeFlagHasColorTransform = colorTransform != null;
this.placeFlagHasMatrix = matrix != null;
this.placeFlagHasCharacter = characterId >= 0;
this.placeFlagMove = placeFlagMove;
this.depth = depth;
this.className = className;
this.characterId = characterId;
this.matrix = matrix;
this.colorTransform = colorTransform;
this.ratio = ratio;
this.name = name;
this.clipDepth = clipDepth;
this.surfaceFilterList = surfaceFilterList;
this.blendMode = blendMode;
this.bitmapCache = bitmapCache;
this.visible = visible;
this.backgroundColor = backgroundColor;
this.clipActions = clipActions;
this.amfData = amfData;
}
/**
* Constructor
*
@@ -394,12 +427,8 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
public int getPlaceObjectNum() {
return 4;
}
@Override
@@ -410,6 +439,15 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
return -1;
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
}
/**
* Returns all sub-items
*
@@ -470,6 +508,11 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
if (placeFlagHasName) {

View File

@@ -127,8 +127,8 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
public CXFORM colorTransform;
@Override
public List<FILTER> getFilters() {
return null;
public int getPlaceObjectNum() {
return 1;
}
@Override
@@ -136,6 +136,11 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
return -1;
}
@Override
public List<FILTER> getFilters() {
return null;
}
@Override
public void getNeededCharacters(Set<Integer> needed) {
needed.add(characterId);
@@ -172,6 +177,11 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
return matrix;
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
return null;

View File

@@ -38,10 +38,14 @@ public abstract class PlaceObjectTypeTag extends Tag implements CharacterIdTag {
super(swf, id, name, data);
}
public abstract int getPlaceObjectNum();
public abstract int getDepth();
public abstract MATRIX getMatrix();
public abstract void setMatrix(MATRIX matrix);
public abstract String getInstanceName();
public abstract void setInstanceName(String name);

View File

@@ -17,8 +17,14 @@
package com.jpexs.decompiler.flash.timeline;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
import com.jpexs.decompiler.flash.tags.PlaceObject3Tag;
import com.jpexs.decompiler.flash.tags.PlaceObject4Tag;
import com.jpexs.decompiler.flash.tags.PlaceObjectTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
import com.jpexs.decompiler.flash.types.CXFORM;
import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA;
import com.jpexs.decompiler.flash.types.ColorTransform;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RGBA;
@@ -35,11 +41,11 @@ public class DepthState {
public int characterId = -1;
public MATRIX matrix = null;
public MATRIX matrix;
public String instanceName = null;
public String instanceName;
public ColorTransform colorTransForm = null;
public ColorTransform colorTransForm;
public boolean cacheAsBitmap = false;
@@ -49,9 +55,11 @@ public class DepthState {
public boolean isVisible = true;
public RGBA backGroundColor = null;
public RGBA backGroundColor;
public CLIPACTIONS clipActions = null;
public CLIPACTIONS clipActions;
public byte[] amfData;
public int ratio = -1;
@@ -67,6 +75,8 @@ public class DepthState {
public PlaceObjectTypeTag placeObjectTag;
public int minPlaceObjectNum;
public long instanceId;
public boolean motionTween = false;
@@ -100,6 +110,7 @@ public class DepthState {
clipDepth = obj.clipDepth;
time = obj.time;
placeObjectTag = obj.placeObjectTag;
minPlaceObjectNum = obj.minPlaceObjectNum;
if (sameInstance) {
time++;
instanceId = obj.instanceId;
@@ -107,4 +118,20 @@ public class DepthState {
instanceId = getNewInstanceId();
}
}
public PlaceObjectTypeTag toPlaceObjectTag(int depth) {
if (minPlaceObjectNum <= 1) {
CXFORM cxForm0 = colorTransForm == null ? null : new CXFORM(colorTransForm);
return new PlaceObjectTag(swf, characterId, depth, matrix, cxForm0);
} else if (minPlaceObjectNum == 2) {
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
return new PlaceObject2Tag(swf, false, depth, characterId, matrix, cxForm, ratio, instanceName, clipDepth, clipActions);
} else if (minPlaceObjectNum == 3) {
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
return new PlaceObject3Tag(swf, false, depth, null/*todo: className*/, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions);
}
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
return new PlaceObject4Tag(swf, false, depth, null/*todo: className*/, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions, null);
}
}

View File

@@ -263,6 +263,7 @@ public class Timeline {
}
frame.layersChanged = true;
fl.placeObjectTag = po;
fl.minPlaceObjectNum = Math.max(fl.minPlaceObjectNum, po.getPlaceObjectNum());
int characterId = po.getCharacterId();
if (characterId != -1) {
fl.characterId = characterId;

View File

@@ -17,6 +17,7 @@
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;
/**
@@ -44,36 +45,42 @@ public class CXFORM extends ColorTransform {
/**
* Red multiply value
*/
@Conditional("hasMultTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int redMultTerm;
/**
* Green multiply value
*/
@Conditional("hasMultTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int greenMultTerm;
/**
* Blue multiply value
*/
@Conditional("hasMultTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int blueMultTerm;
/**
* Red addition value
*/
@Conditional("hasAddTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int redAddTerm;
/**
* Green addition value
*/
@Conditional("hasAddTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int greenAddTerm;
/**
* Blue addition value
*/
@Conditional("hasAddTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int blueAddTerm;
@@ -107,6 +114,20 @@ public class CXFORM extends ColorTransform {
return hasMultTerms ? blueMultTerm : super.getBlueMulti();
}
public CXFORM() {
}
public CXFORM(ColorTransform colorTransform) {
redMultTerm = colorTransform.getRedMulti();
greenMultTerm = colorTransform.getGreenMulti();
blueMultTerm = colorTransform.getBlueMulti();
redAddTerm = colorTransform.getRedAdd();
greenAddTerm = colorTransform.getGreenAdd();
blueAddTerm = colorTransform.getBlueAdd();
hasAddTerms = redAddTerm != 0 || greenAddTerm != 0 || blueAddTerm != 0;
hasMultTerms = redMultTerm != 255 || greenMultTerm != 255 || blueMultTerm != 255;
}
@Override
public CXFORM clone() {
CXFORM ret = (CXFORM) super.clone();

View File

@@ -38,6 +38,10 @@ public class CXFORMWITHALPHA extends ColorTransform {
*/
public boolean hasMultTerms;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int nbits;
/**
* Red multiply value
*/
@@ -94,10 +98,6 @@ public class CXFORMWITHALPHA extends ColorTransform {
@SWFType(value = BasicType.SB, countField = "nbits")
public int alphaAddTerm;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int nbits;
@Override
public int getRedAdd() {
return hasAddTerms ? redAddTerm : super.getRedAdd();
@@ -138,6 +138,22 @@ public class CXFORMWITHALPHA extends ColorTransform {
return hasMultTerms ? alphaMultTerm : super.getAlphaMulti();
}
public CXFORMWITHALPHA() {
}
public CXFORMWITHALPHA(ColorTransform colorTransform) {
redMultTerm = colorTransform.getRedMulti();
greenMultTerm = colorTransform.getGreenMulti();
blueMultTerm = colorTransform.getBlueMulti();
alphaMultTerm = colorTransform.getAlphaMulti();
redAddTerm = colorTransform.getRedAdd();
greenAddTerm = colorTransform.getGreenAdd();
blueAddTerm = colorTransform.getBlueAdd();
alphaAddTerm = colorTransform.getAlphaAdd();
hasAddTerms = redAddTerm != 0 || greenAddTerm != 0 || blueAddTerm != 0 || alphaAddTerm != 0;
hasMultTerms = redMultTerm != 255 || greenMultTerm != 255 || blueMultTerm != 255 || alphaMultTerm != 255;
}
@Override
public CXFORMWITHALPHA clone() {
CXFORMWITHALPHA ret = (CXFORMWITHALPHA) super.clone();