Skip to content

Commit 20dee96

Browse files
committed
[lib] Used efficient methods for glyph run creation in line resolver
1 parent cc4bd99 commit 20dee96

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

tehreer-android/src/main/java/com/mta/tehreer/layout/LineResolver.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import android.text.Spanned;
2020

21-
import com.mta.tehreer.collections.IntList;
2221
import com.mta.tehreer.internal.collections.JFloatArrayList;
2322
import com.mta.tehreer.internal.collections.JFloatArrayPointList;
2423
import com.mta.tehreer.internal.collections.JIntArrayList;
@@ -28,7 +27,6 @@
2827
import com.mta.tehreer.internal.layout.IntrinsicRun;
2928
import com.mta.tehreer.internal.layout.ParagraphCollection;
3029
import com.mta.tehreer.internal.layout.RunCollection;
31-
import com.mta.tehreer.internal.util.Clusters;
3230
import com.mta.tehreer.internal.util.StringUtils;
3331
import com.mta.tehreer.unicode.BidiRun;
3432

@@ -52,25 +50,19 @@ void reset(Spanned spanned, ParagraphCollection paragraphs, RunCollection runs)
5250
}
5351

5452
static GlyphRun createGlyphRun(IntrinsicRun intrinsicRun, int spanStart, int spanEnd, Object[] spans) {
55-
IntList clusterMap = IntList.of(intrinsicRun.clusterMap);
56-
boolean isBackward = intrinsicRun.isBackward;
57-
int intrinsicStart = intrinsicRun.charStart;
58-
int totalGlyphs = intrinsicRun.glyphCount();
53+
int clusterStart = intrinsicRun.clusterStart(spanStart);
54+
int clusterEnd = intrinsicRun.clusterEnd(spanEnd - 1);
5955

60-
int firstIndex = spanStart - intrinsicStart;
61-
int lastIndex = spanEnd - intrinsicStart - 1;
62-
63-
int clusterStart = Clusters.actualClusterStart(clusterMap, firstIndex) + intrinsicStart;
64-
int clusterEnd = Clusters.actualClusterEnd(clusterMap, lastIndex) + intrinsicStart;
6556
int startExtra = spanStart - clusterStart;
6657
int endExtra = clusterEnd - spanEnd;
6758

68-
int leadingIndex = Clusters.leadingGlyphIndex(clusterMap, firstIndex, isBackward, totalGlyphs);
69-
int trailingIndex = Clusters.trailingGlyphIndex(clusterMap, lastIndex, isBackward, totalGlyphs);
70-
int glyphOffset = Math.min(leadingIndex, trailingIndex);
71-
int glyphCount = Math.max(leadingIndex, trailingIndex) - glyphOffset + 1;
59+
int[] glyphRange = new int[2];
60+
intrinsicRun.loadGlyphRange(spanStart, spanEnd, glyphRange);
61+
62+
int glyphOffset = glyphRange[0];
63+
int glyphCount = glyphRange[1] - glyphOffset;
7264

73-
int chunkOffset = clusterStart - intrinsicStart;
65+
int chunkOffset = clusterStart - intrinsicRun.charStart;
7466
int chunkLength = clusterEnd - clusterStart;
7567

7668
return new GlyphRun(spanStart, spanEnd, startExtra, endExtra, Arrays.asList(spans),

0 commit comments

Comments
 (0)