From 78058e6020ef996bf88c4c4535c89842d3eff695 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Fri, 18 Mar 2016 09:53:42 +0100 Subject: [PATCH] faster text rendering --- .../jpexs/decompiler/flash/tags/base/TextTag.java | 13 +++++++------ libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 012e3270b..fb3fec940 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; -import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.helpers.HighlightedText; import com.jpexs.decompiler.flash.importers.TextImportResizeTextBoundsMode; import com.jpexs.decompiler.flash.tags.text.JustifyAlignGlyphEntry; @@ -451,6 +450,8 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { int x = 0; int y = 0; List glyphs = null; + Matrix mat0 = transformation.clone(); + mat0 = mat0.concatenate(new Matrix(textMatrix)); for (TEXTRECORD rec : textRecords) { if (rec.styleFlagsHasColor) { if (numText == 2) { @@ -481,13 +482,13 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { double divider = font == null ? 1 : font.getDivider(); double rat = textHeight / 1024.0 / divider; + Matrix matScale = Matrix.getScaleInstance(rat); Color textColor2 = new Color(textColor, true); for (GLYPHENTRY entry : rec.glyphEntries) { - Matrix mat = transformation.clone(); - mat = mat.concatenate(new Matrix(textMatrix)); - Matrix matTr = Matrix.getTranslateInstance(x, y); - mat = mat.concatenate(matTr); - mat = mat.concatenate(Matrix.getScaleInstance(rat)); + matScale.translateX = x; + matScale.translateY = y; + + Matrix mat = mat0.concatenate(matScale); SHAPE shape = null; if (entry.glyphIndex != -1 && glyphs != null) { // shapeNum: 1 diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index 0b670ce61..c260936c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -1228,12 +1228,10 @@ public class Helper { BitSet bs = new BitSet(width * height); bs.set(type); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - int idx = width * y + x; - if ((imgData[idx] >>> 24) > 0) { - bs.set(idx); - } + int pixelCount = width * height; + for (int i = 0; i < pixelCount; i++) { + if ((imgData[i] >>> 24) > 0) { + bs.set(i); } }