mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-04 23:54:53 +00:00
[android] Cache text groups. Refactor Svg root group structure.
This commit is contained in:
@@ -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
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user