diff --git a/android/src/main/java/com/horcrux/svg/RenderableShadowNode.java b/android/src/main/java/com/horcrux/svg/RenderableShadowNode.java index 4f97ca3e..594b9a80 100644 --- a/android/src/main/java/com/horcrux/svg/RenderableShadowNode.java +++ b/android/src/main/java/com/horcrux/svg/RenderableShadowNode.java @@ -208,19 +208,6 @@ abstract public class RenderableShadowNode extends VirtualNode { if (mPath == null) { mPath = getPath(canvas, paint); mPath.setFillType(mFillRule); - - mBox = new RectF(); - mPath.computeBounds(mBox, true); - - mRegion = new Region(); - mRegion.setPath(mPath, - new Region( - (int) Math.floor(mBox.left), - (int) Math.floor(mBox.top), - (int) Math.ceil(mBox.right), - (int) Math.ceil(mBox.bottom) - ) - ); } clip(canvas, paint); @@ -292,6 +279,10 @@ abstract public class RenderableShadowNode extends VirtualNode { } else if (colorType == 1) { Brush brush = getSvgShadowNode().getDefinedBrush(colors.getString(1)); if (brush != null) { + if (mBox == null) { + mBox = new RectF(); + mPath.computeBounds(mBox, true); + } brush.setupPaint(paint, mBox, mScale, opacity); } } @@ -311,6 +302,9 @@ abstract public class RenderableShadowNode extends VirtualNode { int x = Math.round(dst[0]); int y = Math.round(dst[1]); + if (mRegion == null) { + mRegion = getRegion(mPath); + } if (!mRegion.contains(x, y)) { return -1; } diff --git a/android/src/main/java/com/horcrux/svg/VirtualNode.java b/android/src/main/java/com/horcrux/svg/VirtualNode.java index bde0883f..dd0c3952 100644 --- a/android/src/main/java/com/horcrux/svg/VirtualNode.java +++ b/android/src/main/java/com/horcrux/svg/VirtualNode.java @@ -69,8 +69,8 @@ abstract class VirtualNode extends LayoutShadowNode { Path mPath; RectF mBox; Region mRegion; - Path mClipRegionPath; Region mClipRegion; + Path mClipRegionPath; VirtualNode() { setIsLayoutOnly(true); @@ -90,9 +90,9 @@ abstract class VirtualNode extends LayoutShadowNode { @Override public void markUpdated() { super.markUpdated(); + mRegion = null; mPath = null; mBox = null; - mRegion = null; } @Nullable