mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-07 16:54:52 +00:00
fix: FeMerge on paper (#2384)
# Summary Use empty string (`""`) instead of `undefined` for previous filter result in `FeMergeNode`
This commit is contained in:
@@ -6,7 +6,6 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import com.facebook.react.bridge.ReactContext;
|
import com.facebook.react.bridge.ReactContext;
|
||||||
import com.facebook.react.bridge.ReadableArray;
|
import com.facebook.react.bridge.ReadableArray;
|
||||||
import com.facebook.react.bridge.ReadableType;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
@@ -29,10 +28,9 @@ class FeMergeView extends FilterPrimitiveView {
|
|||||||
Canvas canvas = new Canvas(result);
|
Canvas canvas = new Canvas(result);
|
||||||
int nodesSize = this.mNodes.size();
|
int nodesSize = this.mNodes.size();
|
||||||
for (int i = 0; i < nodesSize; i++) {
|
for (int i = 0; i < nodesSize; i++) {
|
||||||
Bitmap sourceFromResults =
|
String nodeKey = this.mNodes.getString(i);
|
||||||
this.mNodes.getType(i) == ReadableType.String
|
Bitmap sourceFromResults = nodeKey.isEmpty() ? prevResult : resultsMap.get(nodeKey);
|
||||||
? resultsMap.get(this.mNodes.getString(i))
|
|
||||||
: prevResult;
|
|
||||||
if (sourceFromResults != null) {
|
if (sourceFromResults != null) {
|
||||||
canvas.drawBitmap(sourceFromResults, 0, 0, new Paint());
|
canvas.drawBitmap(sourceFromResults, 0, 0, new Paint());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ using namespace facebook::react;
|
|||||||
id json = RNSVGConvertFollyDynamicToId(node);
|
id json = RNSVGConvertFollyDynamicToId(node);
|
||||||
if ([json isKindOfClass:[NSString class]]) {
|
if ([json isKindOfClass:[NSString class]]) {
|
||||||
[nodesArray addObject:[json stringValue]];
|
[nodesArray addObject:[json stringValue]];
|
||||||
} else {
|
|
||||||
[nodesArray addObject:[NSNull null]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.nodes = nodesArray;
|
self.nodes = nodesArray;
|
||||||
@@ -78,8 +76,7 @@ using namespace facebook::react;
|
|||||||
|
|
||||||
for (int i = 0; i < [self.nodes count]; i++) {
|
for (int i = 0; i < [self.nodes count]; i++) {
|
||||||
NSString *nodeKey = [self.nodes objectAtIndex:i];
|
NSString *nodeKey = [self.nodes objectAtIndex:i];
|
||||||
CIImage *inputImage =
|
CIImage *inputImage = [nodeKey isEqual:@""] ? previous : [results objectForKey:nodeKey];
|
||||||
[nodeKey isEqual:[NSNull null]] ? previous : [results objectForKey:[self.nodes objectAtIndex:i]];
|
|
||||||
if (inputImage == nil) {
|
if (inputImage == nil) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ interface FilterPrimitiveCommonProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NativeProps extends ViewProps, FilterPrimitiveCommonProps {
|
export interface NativeProps extends ViewProps, FilterPrimitiveCommonProps {
|
||||||
nodes?: ReadonlyArray<UnsafeMixed<string | undefined>>;
|
nodes?: ReadonlyArray<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default codegenNativeComponent<NativeProps>('RNSVGFeMerge');
|
export default codegenNativeComponent<NativeProps>('RNSVGFeMerge');
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export const extractFeMerge = (
|
|||||||
props: FeMergeComponentProps,
|
props: FeMergeComponentProps,
|
||||||
parent: unknown
|
parent: unknown
|
||||||
): FeMergeNativeProps => {
|
): FeMergeNativeProps => {
|
||||||
const nodes: Array<string | undefined> = [];
|
const nodes: Array<string> = [];
|
||||||
const childArray = props.children
|
const childArray = props.children
|
||||||
? React.Children.map(props.children, (child) =>
|
? React.Children.map(props.children, (child) =>
|
||||||
React.cloneElement(child, { parent })
|
React.cloneElement(child, { parent })
|
||||||
@@ -106,7 +106,7 @@ export const extractFeMerge = (
|
|||||||
const {
|
const {
|
||||||
props: { in: in1 },
|
props: { in: in1 },
|
||||||
} = childArray[i];
|
} = childArray[i];
|
||||||
nodes.push(in1);
|
nodes.push(in1 || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return { nodes };
|
return { nodes };
|
||||||
|
|||||||
Reference in New Issue
Block a user