[android] Cache text groups. Refactor Svg root group structure.

This commit is contained in:
Mikael Sand
2019-01-06 20:02:14 +02:00
parent 35dca0d98f
commit b559e73dbc
3 changed files with 17 additions and 18 deletions
@@ -44,7 +44,6 @@ class TSpanView extends TextView {
private static final String OTF = ".otf";
private static final String TTF = ".ttf";
private Path mCache;
@Nullable String mContent;
private TextPathView textPath;
@@ -68,29 +67,24 @@ class TSpanView extends TextView {
}
}
@Override
void releaseCachedPath() {
mCache = null;
mPath = null;
}
@Override
Path getPath(Canvas canvas, Paint paint) {
if (mCache != null) {
return mCache;
if (mPath != null) {
return mPath;
}
if (mContent == null) {
return getGroupPath(canvas, paint);
mPath = getGroupPath(canvas, paint);
return mPath;
}
setupTextPath();
pushGlyphContext();
mCache = getLinePath(mContent, paint, canvas);
mPath = getLinePath(mContent, paint, canvas);
popGlyphContext();
return mCache;
return mPath;
}
@SuppressWarnings("ConstantConditions")
@@ -137,6 +137,9 @@ class TextView extends GroupView {
@Override
Path getPath(Canvas canvas, Paint paint) {
if (mPath != null) {
return mPath;
}
setupGlyphContext(canvas);
return getGroupPath(canvas, paint);
}
@@ -186,11 +189,14 @@ class TextView extends GroupView {
}
Path getGroupPath(Canvas canvas, Paint paint) {
if (mPath != null) {
return mPath;
}
pushGlyphContext();
Path groupPath = super.getPath(canvas, paint);
mPath = super.getPath(canvas, paint);
popGlyphContext();
return groupPath;
return mPath;
}
@Override
+3 -4
View File
@@ -124,8 +124,9 @@ class Svg extends Shape {
]}
>
<G
style={style}
{...{
children,
style,
font,
transform,
fill,
@@ -140,9 +141,7 @@ class Svg extends Shape {
strokeLinejoin,
strokeMiterlimit,
}}
>
{children}
</G>
/>
</NativeSvgView>
);
}