Skip to content

Commit

Permalink
fix(🖼️): remove uncessary JSI calls
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon committed Feb 1, 2025
1 parent 8be7039 commit ac3fb6a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions apps/paper/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-wgpu (0.1.20):
- react-native-wgpu (0.1.19):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1957,9 +1957,9 @@ SPEC CHECKSUMS:
React-Mapbuffer: 1c08607305558666fd16678b85ef135e455d5c96
React-microtasksnativemodule: 87b8de96f937faefece8afd2cb3a518321b2ef99
react-native-safe-area-context: ab8f4a3d8180913bd78ae75dd599c94cce3d5e9a
react-native-skia: abdd2ba5abed61445a25d9461b0a87bc08c50f64
react-native-skia: 30bdfaf0c7d9c38a715f29f36102ba3e60ff3329
react-native-slider: 97ce0bd921f40de79cead9754546d5e4e7ba44f8
react-native-wgpu: efaa8c7c3ae15b346d887d13cca2fe72ed5ea105
react-native-wgpu: 8d0437a304318e0e3d6ccbfed2a39880f8eae4dd
React-nativeconfig: 57781b79e11d5af7573e6f77cbf1143b71802a6d
React-NativeModulesApple: 7ff2e2cfb2e5fa5bdedcecf28ce37e696c6ef1e1
React-perflogger: 8a360ccf603de6ddbe9ff8f54383146d26e6c936
Expand Down
12 changes: 8 additions & 4 deletions packages/skia/cpp/api/recorder/JsiRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ class JsiRecorder : public JsiSkWrappingSharedPtrHostObject<Recorder> {
}

JSI_HOST_FUNCTION(play) {
auto jsiCanvas =
arguments[0].asObject(runtime).asHostObject<JsiSkCanvas>(runtime);
DrawingCtx ctx(jsiCanvas->getCanvas());
SkPictureRecorder pictureRecorder;
SkISize size = SkISize::Make(2'000'000, 2'000'000);
SkRect rect = SkRect::Make(size);
auto canvas = pictureRecorder.beginRecording(rect, nullptr);
DrawingCtx ctx(canvas);
getObject()->play(&ctx);
return jsi::Value::undefined();
auto picture = pictureRecorder.finishRecordingAsPicture();
return jsi::Object::createFromHostObject(
runtime, std::make_shared<JsiSkPicture>(getContext(), picture));
}

JSI_HOST_FUNCTION(applyUpdates) {
Expand Down
3 changes: 2 additions & 1 deletion packages/skia/src/skia/types/Recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {
import type { AnimatedProps } from "../../renderer/processors/Animations/Animations";

import type { SkCanvas } from "./Canvas";
import type { SkPicture } from "./Picture";

export interface BaseRecorder {
saveGroup(): void;
Expand Down Expand Up @@ -86,6 +87,6 @@ export interface BaseRecorder {
}

export interface JsiRecorder extends BaseRecorder {
play(canvas: SkCanvas): void;
play(): SkPicture;
applyUpdates(variables: SharedValue<unknown>[]): void;
}
7 changes: 1 addition & 6 deletions packages/skia/src/sksg/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,12 @@ const nativeDrawOnscreen = (
) => {
"worklet";

const rec = Skia.PictureRecorder();
const canvas = rec.beginRecording();
//const start = performance.now();

recorder.play(canvas);
const picture = rec.finishRecordingAsPicture();
const picture = recorder.play();
//const end = performance.now();
//console.log("Recording time: ", end - start);
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
rec.dispose();
picture.dispose();
};

export abstract class Container {
Expand Down

0 comments on commit ac3fb6a

Please sign in to comment.