gfx dump view fixes, FileAttributeTag fix in dumpview

This commit is contained in:
honfika
2014-08-24 11:07:01 +02:00
parent c91f0b106c
commit 6a2f1027b8
9 changed files with 102 additions and 22 deletions
@@ -264,6 +264,7 @@ 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.ImmediateFuture;
import com.jpexs.helpers.MemoryInputStream;
import com.jpexs.helpers.ProgressListener;
import com.jpexs.helpers.utf8.Utf8Helper;
@@ -1010,9 +1011,6 @@ public class SWFInputStream implements AutoCloseable {
executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get());
futureResults = new ArrayList<>();
}
int tagCnt = 0;
int faPos = 0;
FileAttributesTag fileAttributes = null;
List<Tag> tags = new ArrayList<>();
Tag tag;
boolean isAS3 = false;
@@ -1024,7 +1022,6 @@ public class SWFInputStream implements AutoCloseable {
} catch (EOFException | EndOfStreamException ex) {
tag = null;
}
tagCnt++;
DumpInfo di = dumpInfo;
if (di != null && tag != null) {
di.name = tag.getName();
@@ -1048,11 +1045,10 @@ public class SWFInputStream implements AutoCloseable {
} else {
switch (tag.getId()) {
case FileAttributesTag.ID: //FileAttributes
faPos = tagCnt - 1; //should be 0, as it is first tag, but anyway
if (tag instanceof TagStub) {
tag = resolveTag((TagStub) tag, level, parallel, skipUnusualTags);
}
fileAttributes = (FileAttributesTag) tag;
FileAttributesTag fileAttributes = (FileAttributesTag) tag;
if (fileAttributes.actionScript3) {
isAS3 = true;
}
@@ -1091,11 +1087,12 @@ public class SWFInputStream implements AutoCloseable {
}
}
if (parseTags && doParse && tag instanceof TagStub) {
if (parallel) {
Future<Tag> future = executor.submit(new TagResolutionTask((TagStub) tag, di, level, parallel, skipUnusualTags));
futureResults.add(future);
}
if (parseTags && doParse && parallel && tag instanceof TagStub) {
Future<Tag> future = executor.submit(new TagResolutionTask((TagStub) tag, di, level, parallel, skipUnusualTags));
futureResults.add(future);
} else {
Future<Tag> future = new ImmediateFuture(tag);
futureResults.add(future);
}
if (tag.getId() == EndTag.ID) {
@@ -1116,10 +1113,6 @@ public class SWFInputStream implements AutoCloseable {
executor.shutdown();
}
//Workaround to not reading fileattributes twice. TODO:Handle this better
if (parallel && fileAttributes != null) {
tags.add(faPos, fileAttributes);
}
return tags;
}
@@ -3296,7 +3289,9 @@ public class SWFInputStream implements AutoCloseable {
public MemoryInputStream getBaseStream() throws IOException {
int pos = (int) is.getPos();
return new MemoryInputStream(is.getAllRead(), pos, is.available());
MemoryInputStream mis = new MemoryInputStream(is.getAllRead(), 0, pos + is.available());
mis.seek(pos);
return mis;
}
public SWFInputStream getLimitedStream(int limit) throws IOException {
@@ -452,8 +452,10 @@ public class Configuration {
Map<String, String> result = new HashMap<>();
for (String pair : fonts.split("::")) {
String[] splittedPair = pair.split("=");
result.put(splittedPair[0], splittedPair[1]);
if (!pair.isEmpty()) {
String[] splittedPair = pair.split("=");
result.put(splittedPair[0], splittedPair[1]);
}
}
return result;
}
@@ -97,7 +97,11 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
MemoryInputStream mis = sis.getBaseStream();
while (mis.available() > 0) {
fonts.add(new FontType(new GFxInputStream(mis)));
GFxInputStream gis = new GFxInputStream(mis);
gis.dumpInfo = sis.dumpInfo;
gis.newDumpLevel("fontType", "FontType");
fonts.add(new FontType(gis));
gis.endDumpLevel();
}
rebuildShapeCache();
}
@@ -104,14 +104,18 @@ public class FontTextureInfo extends Tag {
texGlyphs = new TEXGLYPH[numTexGlyphs];
MemoryInputStream mis = sis.getBaseStream();
for (int i = 0; i < numTexGlyphs; i++) {
texGlyphs[i] = new TEXGLYPH(new GFxInputStream(mis));
GFxInputStream gis = new GFxInputStream(mis);
gis.dumpInfo = sis.dumpInfo;
texGlyphs[i] = new TEXGLYPH(gis);
}
sis.skipBytes(mis.getPos());
int numFonts = sis.readUI16("numFonts");
fonts = new FONTINFO[numFonts];
mis = sis.getBaseStream();
for (int i = 0; i < numFonts; i++) {
fonts[i] = new FONTINFO(new GFxInputStream(sis.getBaseStream()));
GFxInputStream gis = new GFxInputStream(mis);
gis.dumpInfo = sis.dumpInfo;
fonts[i] = new FONTINFO(gis);
}
sis.skipBytes(mis.getPos());
}
@@ -85,7 +85,9 @@ public class ContourType implements Serializable {
edges = new EdgeType[(int) numEdgesRef];
for (int i = 0; i < edges.length; i++) {
sis.newDumpLevel("edgeType", "EdgeType");
edges[i] = new EdgeType(sis);
sis.endDumpLevel();
}
if (isReference) {
sis.setPos(oldPos);
@@ -42,6 +42,7 @@ public class FontType implements Serializable {
public List<KerningPairType> kerning;
public FontType(GFxInputStream sis) throws IOException {
long offset = sis.getPos();
fontName = sis.readString("fontName");
flags = sis.readUI16("flags");
nominalSize = sis.readUI16("nominalSize");
@@ -54,21 +55,27 @@ public class FontType implements Serializable {
sis.read(glyphBytes);
glyphInfo = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
sis.newDumpLevel("glyphInfoType", "GlyphInfoType");
glyphInfo.add(new GlyphInfoType(sis));
sis.endDumpLevel();
}
long kerningTableSize = sis.readUI30("kerningTableSize");
kerning = new ArrayList<>();
for (int i = 0; i < kerningTableSize; i++) {
sis.newDumpLevel("kerningPairType", "KerningPairType");
kerning.add(new KerningPairType(sis));
sis.endDumpLevel();
}
long pos = sis.getPos();
glyphs = new ArrayList<>();
for (int i = 0; i < glyphInfo.size(); i++) {
sis.setPos(glyphInfo.get(i).globalOffset);
sis.setPos(glyphInfo.get(i).globalOffset + offset);
sis.newDumpLevel("glyphType", "GlyphType");
glyphs.add(new GlyphType(sis));
sis.endDumpLevel();
}
sis.setPos(pos);
@@ -93,6 +93,7 @@ public class GFxInputStream {
/**
* Reads one SI16 (Signed 16bit integer) value from the stream
*
* @param name
* @return SI16 value
* @throws IOException
*/
@@ -206,6 +207,7 @@ public class GFxInputStream {
* Reads bytes from the stream
*
* @param count Number of bytes to read
* @param name
* @return Array of read bytes
* @throws IOException
*/
@@ -229,6 +231,7 @@ public class GFxInputStream {
/**
* Reads one string value from the stream
*
* @param name
* @return String value
* @throws IOException
*/
@@ -69,7 +69,9 @@ public class GlyphType implements Serializable {
int numContours = sis.readUI15("numContours");
contours = new ContourType[numContours];
for (int i = 0; i < numContours; i++) {
sis.newDumpLevel("contourType", "ContourType");
contours[i] = new ContourType(sis);
sis.endDumpLevel();
}
}