Skip to content

Commit d6a8b8b

Browse files
committed
Fix minor regressions
1 parent 71161bd commit d6a8b8b

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

package/src/external/reanimated/interpolators.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import {
1515
useSharedValue,
1616
useDerivedValue,
1717
} from "./moduleWrapper";
18+
import { Platform } from "../../Platform";
1819

1920
export const notifyChange = (value: SharedValue<unknown>) => {
2021
"worklet";
21-
if (_WORKLET) {
22+
if (_WORKLET || Platform.OS === "web") {
2223
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2324
(value as any)._value = value.value;
2425
}

package/src/renderer/Canvas.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import type { LayoutChangeEvent } from "react-native";
1717
import { SkiaDomView } from "../views";
1818
import { Skia } from "../skia/Skia";
1919
import type { TouchHandler, SkiaBaseViewProps } from "../views";
20-
import { SkiaDomView2 } from "../views/SkiaDomView2";
21-
import { Platform } from "../Platform";
20+
import { SkiaJSDomView } from "../views/SkiaJSDomView";
2221

2322
import { SkiaRoot } from "./Reconciler";
2423
import { NATIVE_DOM } from "./HostComponents";
@@ -91,7 +90,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
9190
};
9291
}, [root]);
9392

94-
if (NATIVE_DOM || Platform.OS === "web") {
93+
if (NATIVE_DOM) {
9594
return (
9695
<SkiaDomView
9796
ref={ref}
@@ -106,7 +105,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
106105
);
107106
} else {
108107
return (
109-
<SkiaDomView2
108+
<SkiaJSDomView
110109
Skia={Skia}
111110
// eslint-disable-next-line @typescript-eslint/no-explicit-any
112111
ref={ref as any}

package/src/renderer/__tests__/e2e/Matrix4.spec.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,30 @@ describe("Matrix4", () => {
227227
0.1
228228
);
229229
});
230+
231+
it("Path.transform() should accept 4x4 (1)", async () => {
232+
let result = await surface.eval((Skia) => {
233+
const path = Skia.Path.MakeFromSVGString("M150 0L75 200L225 200L150 0Z")!;
234+
path.transform([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
235+
return path.toSVGString();
236+
});
237+
expect(result).toEqual("M150 0L75 200L225 200L150 0Z");
238+
239+
result = await surface.eval((Skia) => {
240+
const path = Skia.Path.MakeFromSVGString("M150 0L75 200L225 200L150 0Z")!;
241+
path.transform([1, 0, 0, 0, 0, 1, 0, 0, 0]);
242+
return path.toSVGString();
243+
});
244+
expect(result).not.toEqual("M150 0L75 200L225 200L150 0Z");
245+
});
246+
it("Path.transform() should accept 4x4 (2)", async () => {
247+
const result = await surface.eval((Skia) => {
248+
const path = Skia.Path.MakeFromSVGString("M150 0L75 200L225 200L150 0Z")!;
249+
path.transform([1, 0, 0, 100, 0, 1, 0, 100, 0, 0, 1, 0, 0, 0, 0, 1]);
250+
return path.toSVGString();
251+
});
252+
expect(result).toEqual("M250 100L175 300L325 300L250 100Z");
253+
});
230254
it("should correctly transform a point with an identity matrix", () => {
231255
const identityMatrix = Matrix4();
232256
const point = [100, -100, 200] as const; // Define some test point

package/src/skia/web/JsiSkPath.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CanvasKit, Path } from "canvaskit-wasm";
1+
import type { CanvasKit, Matrix3x3, Path } from "canvaskit-wasm";
22

33
import { PathVerb } from "../types";
44
import type {
@@ -11,6 +11,7 @@ import type {
1111
SkRect,
1212
InputRRect,
1313
StrokeOpts,
14+
InputMatrix,
1415
} from "../types";
1516

1617
import { getEnum, HostObject, optEnum } from "./Host";
@@ -339,8 +340,27 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
339340
return result === null ? result : this;
340341
}
341342

342-
transform(m3: SkMatrix) {
343-
this.ref.transform(Array.isArray(m3) ? m3 : JsiSkMatrix.fromValue(m3));
343+
transform(m: InputMatrix) {
344+
let matrix =
345+
m instanceof JsiSkMatrix
346+
? Array.from(JsiSkMatrix.fromValue<Matrix3x3>(m))
347+
: (m as Exclude<InputMatrix, SkMatrix>);
348+
if (matrix.length === 16) {
349+
matrix = [
350+
matrix[0],
351+
matrix[1],
352+
matrix[3],
353+
matrix[4],
354+
matrix[5],
355+
matrix[7],
356+
matrix[12],
357+
matrix[13],
358+
matrix[15],
359+
];
360+
} else if (matrix.length !== 9) {
361+
throw new Error(`Invalid matrix length: ${matrix.length}`);
362+
}
363+
this.ref.transform(matrix);
344364
return this;
345365
}
346366

package/src/views/SkiaDomView2.tsx renamed to package/src/views/SkiaJSDomView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const NativeSkiaPictureView: HostComponent<SkiaPictureViewProps> =
1616
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
1717
(null as any);
1818

19-
export class SkiaDomView2 extends React.Component<
19+
export class SkiaJSDomView extends React.Component<
2020
SkiaDomViewProps & { Skia: Skia }
2121
> {
2222
constructor(props: SkiaDomViewProps & { Skia: Skia }) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { SkiaDomView as SkiaJSDomView } from "./SkiaDomView";

0 commit comments

Comments
 (0)