mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-05 07:59:28 +00:00
[android] Fix stroke hit testing
This commit is contained in:
@@ -307,7 +307,8 @@ abstract public class RenderableShadowNode extends VirtualNode {
|
||||
opacity *= mOpacity;
|
||||
|
||||
if (opacity > MIN_OPACITY_FOR_DRAW) {
|
||||
if (mPath == null) {
|
||||
boolean computePaths = mPath == null;
|
||||
if (computePaths) {
|
||||
mPath = getPath(canvas, paint);
|
||||
mPath.setFillType(mFillRule);
|
||||
}
|
||||
@@ -322,9 +323,17 @@ abstract public class RenderableShadowNode extends VirtualNode {
|
||||
clip(canvas, paint);
|
||||
|
||||
if (setupFillPaint(paint, opacity * mFillOpacity)) {
|
||||
if (computePaths) {
|
||||
mFillPath = new Path();
|
||||
paint.getFillPath(path, mFillPath);
|
||||
}
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
if (setupStrokePaint(paint, opacity * mStrokeOpacity)) {
|
||||
if (computePaths) {
|
||||
mStrokePath = new Path();
|
||||
paint.getFillPath(path, mStrokePath);
|
||||
}
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
}
|
||||
@@ -414,10 +423,16 @@ abstract public class RenderableShadowNode extends VirtualNode {
|
||||
int x = Math.round(dst[0]);
|
||||
int y = Math.round(dst[1]);
|
||||
|
||||
if (mRegion == null && mPath != null) {
|
||||
mRegion = getRegion(mPath);
|
||||
if (mRegion == null && mFillPath != null) {
|
||||
mRegion = getRegion(mFillPath);
|
||||
}
|
||||
if (mRegion == null || !mRegion.contains(x, y)) {
|
||||
if (mStrokeRegion == null && mStrokePath != null) {
|
||||
mStrokeRegion = getRegion(mStrokePath);
|
||||
}
|
||||
if (
|
||||
(mRegion == null || !mRegion.contains(x, y)) &&
|
||||
(mStrokeRegion == null || !mStrokeRegion.contains(x, y))
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.view.View;
|
||||
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.uimanager.ReactCompoundView;
|
||||
import com.facebook.react.uimanager.ReactCompoundViewGroup;
|
||||
import com.facebook.react.uimanager.ReactShadowNodeImpl;
|
||||
import com.facebook.react.views.view.ReactViewGroup;
|
||||
|
||||
@@ -26,7 +27,12 @@ import javax.annotation.Nullable;
|
||||
* Custom {@link View} implementation that draws an RNSVGSvg React view and its children.
|
||||
*/
|
||||
@SuppressLint("ViewConstructor")
|
||||
public class SvgView extends ReactViewGroup implements ReactCompoundView {
|
||||
public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactCompoundViewGroup {
|
||||
|
||||
@Override
|
||||
public boolean interceptsTouchEvent(float touchX, float touchY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public enum Events {
|
||||
|
||||
@@ -973,10 +973,16 @@ class TSpanShadowNode extends TextShadowNode {
|
||||
int x = Math.round(dst[0]);
|
||||
int y = Math.round(dst[1]);
|
||||
|
||||
if (mRegion == null && mPath != null) {
|
||||
mRegion = getRegion(mPath);
|
||||
if (mRegion == null && mFillPath != null) {
|
||||
mRegion = getRegion(mFillPath);
|
||||
}
|
||||
if (mRegion == null || !mRegion.contains(x, y)) {
|
||||
if (mStrokeRegion == null && mStrokePath != null) {
|
||||
mStrokeRegion = getRegion(mStrokePath);
|
||||
}
|
||||
if (
|
||||
(mRegion == null || !mRegion.contains(x, y)) &&
|
||||
(mStrokeRegion == null || !mStrokeRegion.contains(x, y))
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,11 @@ abstract class VirtualNode extends LayoutShadowNode {
|
||||
private GlyphContext glyphContext;
|
||||
|
||||
Path mPath;
|
||||
Path mFillPath;
|
||||
Path mStrokePath;
|
||||
RectF mBox;
|
||||
Region mRegion;
|
||||
Region mStrokeRegion;
|
||||
Region mClipRegion;
|
||||
Path mClipRegionPath;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user