mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-24 11:44:39 +00:00
Improve path caching on android
This commit is contained in:
@@ -67,8 +67,6 @@ abstract public class RenderableShadowNode extends VirtualNode {
|
||||
public float mFillOpacity = 1;
|
||||
public Path.FillType mFillRule = Path.FillType.WINDING;
|
||||
|
||||
protected Path mPath;
|
||||
|
||||
private @Nullable ReadableArray mLastMergedList;
|
||||
private @Nullable ArrayList<Object> mOriginProperties;
|
||||
protected @Nullable ReadableArray mPropList;
|
||||
@@ -204,10 +202,13 @@ abstract public class RenderableShadowNode extends VirtualNode {
|
||||
opacity *= mOpacity;
|
||||
|
||||
if (opacity > MIN_OPACITY_FOR_DRAW) {
|
||||
mPath = getPath(canvas, paint);
|
||||
mPath.setFillType(mFillRule);
|
||||
if (mPath == null) {
|
||||
mPath = getPath(canvas, paint);
|
||||
mPath.setFillType(mFillRule);
|
||||
}
|
||||
|
||||
clip(canvas, paint);
|
||||
|
||||
if (setupFillPaint(paint, opacity * mFillOpacity)) {
|
||||
canvas.drawPath(mPath, paint);
|
||||
}
|
||||
|
||||
@@ -106,13 +106,14 @@ public class SvgView extends ViewGroup {
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
ReactShadowNodeImpl node = getShadowNode();
|
||||
for (int i = 0; i < this.getChildCount(); i++) {
|
||||
View child = this.getChildAt(i);
|
||||
if (child instanceof ReactViewGroup) {
|
||||
ReactShadowNodeImpl node = getShadowNode();
|
||||
int id = child.getId();
|
||||
for (int j = 0; j < node.getChildCount(); j++) {
|
||||
ReactShadowNodeImpl nodeChild = node.getChildAt(j);
|
||||
if (nodeChild.getReactTag() != child.getId()) {
|
||||
if (nodeChild.getReactTag() != id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ abstract class VirtualNode extends LayoutShadowNode {
|
||||
private float canvasWidth = -1;
|
||||
private GlyphContext glyphContext;
|
||||
|
||||
Path mPath;
|
||||
|
||||
VirtualNode() {
|
||||
setIsLayoutOnly(true);
|
||||
mScale = DisplayMetricsHolder.getScreenDisplayMetrics().density;
|
||||
@@ -78,6 +80,12 @@ abstract class VirtualNode extends LayoutShadowNode {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markUpdated() {
|
||||
super.markUpdated();
|
||||
mPath = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
GroupShadowNode getTextRoot() {
|
||||
VirtualNode node = this;
|
||||
@@ -161,6 +169,7 @@ abstract class VirtualNode extends LayoutShadowNode {
|
||||
|
||||
@ReactProp(name = "clipPath")
|
||||
public void setClipPath(String clipPath) {
|
||||
mCachedClipPath = null;
|
||||
mClipPath = clipPath;
|
||||
markUpdated();
|
||||
}
|
||||
@@ -193,7 +202,7 @@ abstract class VirtualNode extends LayoutShadowNode {
|
||||
mMatrix = null;
|
||||
}
|
||||
|
||||
markUpdated();
|
||||
super.markUpdated();
|
||||
}
|
||||
|
||||
@ReactProp(name = "responsible")
|
||||
@@ -207,7 +216,7 @@ abstract class VirtualNode extends LayoutShadowNode {
|
||||
}
|
||||
|
||||
@Nullable Path getClipPath(Canvas canvas, Paint paint) {
|
||||
if (mClipPath != null) {
|
||||
if (mClipPath != null && mCachedClipPath == null) {
|
||||
VirtualNode node = getSvgShadowNode().getDefinedClipPath(mClipPath);
|
||||
|
||||
if (node != null) {
|
||||
|
||||
Reference in New Issue
Block a user