-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Draw onto Frame
as if it was a Skia Canvas
#1479
Conversation
This reverts commit 253f586.
…` to `Frame` (#1487) * feat: Implement `orientation` and `isMirrored` on Frame * feat: Add `toArrayBuffer()` func * perf: Do faster buffer copy * feat: Implement `toArrayBuffer()` on Android * feat: Add `orientation` and `isMirrored` to Android * feat: Add `timestamp` to Frame * Update Frame.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
cpplint
cpp/JSITypedArray.h|115| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|116| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|117| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|118| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|119| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|121| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|122| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|129| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|130| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|132| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|132| Is this a non-const reference? If so, make const or use a pointer: jsi::Object &jsObj [runtime/references] [2]
cpp/JSITypedArray.h|134| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|135| Is this a non-const reference? If so, make const or use a pointer: jsi::ArrayBuffer &buffer [runtime/references] [2]
cpp/JSITypedArray.h|142| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|143| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|144| Single-parameter constructors should be marked explicit. [runtime/explicit] [5]
cpp/JSITypedArray.h|148| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|149| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|150| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|151| Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
cpp/JSITypedArray.h|149| Add #include for vector<> [build/include_what_you_use] [4]
cpp/JSITypedArray.h|181| Add #include for move [build/include_what_you_use] [4]
} | ||
|
||
// directly write to C++ JSI ArrayBuffer | ||
auto dst = (jbyte*)arrayBuffer.data(runtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Using C-style cast. Use reinterpret_cast<jbyte*>(...) instead [readability/casting] [4]
int getPlanesCount() const; | ||
int getBytesPerRow() const; | ||
long getTimestamp() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Use int16/int64/etc, rather than the C type long [runtime/int] [4]
|
||
class PropNameIDCache { | ||
public: | ||
const jsi::PropNameID &get(jsi::Runtime &runtime, Prop prop) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
return *(this->props[key][prop]); | ||
} | ||
|
||
const jsi::PropNameID &getConstructorNameProp(jsi::Runtime &runtime, TypedArrayKind kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
private: | ||
std::unordered_map<uintptr_t, std::unordered_map<Prop, std::unique_ptr<jsi::PropNameID>>> props; | ||
|
||
jsi::PropNameID createProp(jsi::Runtime &runtime, Prop prop); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
TypedArrayBase(TypedArrayBase &&) = default; | ||
TypedArrayBase &operator=(TypedArrayBase &&) = default; | ||
|
||
TypedArrayKind getKind(jsi::Runtime &runtime) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
TypedArrayKind getKind(jsi::Runtime &runtime) const; | ||
|
||
template <TypedArrayKind T> | ||
TypedArray<T> get(jsi::Runtime &runtime) const &; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
template <TypedArrayKind T> | ||
TypedArray<T> get(jsi::Runtime &runtime) const &; | ||
template <TypedArrayKind T> | ||
TypedArray<T> get(jsi::Runtime &runtime) &&; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
template <TypedArrayKind T> | ||
TypedArray<T> get(jsi::Runtime &runtime) &&; | ||
template <TypedArrayKind T> | ||
TypedArray<T> as(jsi::Runtime &runtime) const &; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
template <TypedArrayKind T> | ||
TypedArray<T> as(jsi::Runtime &runtime) const &; | ||
template <TypedArrayKind T> | ||
TypedArray<T> as(jsi::Runtime &runtime) &&; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
template <TypedArrayKind T> | ||
TypedArray<T> as(jsi::Runtime &runtime) &&; | ||
|
||
size_t size(jsi::Runtime &runtime) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
TypedArray<T> as(jsi::Runtime &runtime) &&; | ||
|
||
size_t size(jsi::Runtime &runtime) const; | ||
size_t length(jsi::Runtime &runtime) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
|
||
size_t size(jsi::Runtime &runtime) const; | ||
size_t length(jsi::Runtime &runtime) const; | ||
size_t byteLength(jsi::Runtime &runtime) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
size_t size(jsi::Runtime &runtime) const; | ||
size_t length(jsi::Runtime &runtime) const; | ||
size_t byteLength(jsi::Runtime &runtime) const; | ||
size_t byteOffset(jsi::Runtime &runtime) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
size_t length(jsi::Runtime &runtime) const; | ||
size_t byteLength(jsi::Runtime &runtime) const; | ||
size_t byteOffset(jsi::Runtime &runtime) const; | ||
bool hasBuffer(jsi::Runtime &runtime) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
TypedArray &operator=(TypedArray &&) = default; | ||
|
||
std::vector<ContentType<T>> toVector(jsi::Runtime &runtime); | ||
void update(jsi::Runtime &runtime, const std::vector<ContentType<T>> &data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
|
||
std::vector<ContentType<T>> toVector(jsi::Runtime &runtime); | ||
void update(jsi::Runtime &runtime, const std::vector<ContentType<T>> &data); | ||
void updateUnsafe(jsi::Runtime &runtime, ContentType<T> *data, size_t length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
std::vector<ContentType<T>> toVector(jsi::Runtime &runtime); | ||
void update(jsi::Runtime &runtime, const std::vector<ContentType<T>> &data); | ||
void updateUnsafe(jsi::Runtime &runtime, ContentType<T> *data, size_t length); | ||
uint8_t* data(jsi::Runtime &runtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Is this a non-const reference? If so, make const or use a pointer: jsi::Runtime &runtime [runtime/references] [2]
TypedArray &operator=(TypedArray &&) = default; | ||
|
||
std::vector<ContentType<T>> toVector(jsi::Runtime &runtime); | ||
void update(jsi::Runtime &runtime, const std::vector<ContentType<T>> &data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Add #include for vector<> [build/include_what_you_use] [4]
if (getKind(runtime) != T) { | ||
throw jsi::JSError(runtime, "Object is not a TypedArray"); | ||
} | ||
return std::move(*this).get<T>(runtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Add #include for move [build/include_what_you_use] [4]
* Create Shaders.ts * Add `previewType` and `enableFpsGraph` * Add RN Skia native dependency * Add Skia Preview View on iOS * Pass 1 * Update FrameHostObject.mm * Wrap Canvas * Lockfiles * fix: Fix stuff * chore: Upgrade RNWorklets * Add `previewType` to set the Preview * feat: Add Example * Update project.pbxproj * `enableFpsGraph` * Cache the `std::shared_ptr<FrameHostObject>` * Update CameraView+RecordVideo.swift * Update SkiaMetalCanvasProvider.mm * Android: Integrate Skia Dependency * fix: Use new Prefix * Add example for rendering shader * chore: Upgrade CameraX * Remove KTX * Enable `viewBinding` * Revert "Enable `viewBinding`" This reverts commit f2a603f. * Revert "chore: Upgrade CameraX" This reverts commit 8dc832c. * Remove unneeded `ProcessCameraProvider.getInstance()` call * fix: Add REA hotfix patch * fix: Fix FrameHostObject dead in runAsync * fix: Make `runAsync` run truly async by dropping new Frames while executing * chore: Upgrade RN Worklets to latest * chore: Upgrade RN Skia * Revert "Remove KTX" This reverts commit 253f586. * Make Skia optional in CMake * Fix import * Update CMakeLists.txt * Update build.gradle * Update CameraView.kt * Update CameraView.kt * Update CameraView.kt * Update Shaders.ts * Center Blur * chore: Upgrade RN Worklets * feat: Add `toByteArray()`, `orientation`, `isMirrored` and `timestamp` to `Frame` (#1487) * feat: Implement `orientation` and `isMirrored` on Frame * feat: Add `toArrayBuffer()` func * perf: Do faster buffer copy * feat: Implement `toArrayBuffer()` on Android * feat: Add `orientation` and `isMirrored` to Android * feat: Add `timestamp` to Frame * Update Frame.ts * Update JImageProxy.h * Update FrameHostObject.cpp * Update FrameHostObject.cpp * Update CameraPage.tsx * fix: Format Swift
* Create Shaders.ts * Add `previewType` and `enableFpsGraph` * Add RN Skia native dependency * Add Skia Preview View on iOS * Pass 1 * Update FrameHostObject.mm * Wrap Canvas * Lockfiles * fix: Fix stuff * chore: Upgrade RNWorklets * Add `previewType` to set the Preview * feat: Add Example * Update project.pbxproj * `enableFpsGraph` * Cache the `std::shared_ptr<FrameHostObject>` * Update CameraView+RecordVideo.swift * Update SkiaMetalCanvasProvider.mm * Android: Integrate Skia Dependency * fix: Use new Prefix * Add example for rendering shader * chore: Upgrade CameraX * Remove KTX * Enable `viewBinding` * Revert "Enable `viewBinding`" This reverts commit f2a603f. * Revert "chore: Upgrade CameraX" This reverts commit 8dc832c. * Remove unneeded `ProcessCameraProvider.getInstance()` call * fix: Add REA hotfix patch * fix: Fix FrameHostObject dead in runAsync * fix: Make `runAsync` run truly async by dropping new Frames while executing * chore: Upgrade RN Worklets to latest * chore: Upgrade RN Skia * Revert "Remove KTX" This reverts commit 253f586. * Make Skia optional in CMake * Fix import * Update CMakeLists.txt * Update build.gradle * Update CameraView.kt * Update CameraView.kt * Update CameraView.kt * Update Shaders.ts * Center Blur * chore: Upgrade RN Worklets * feat: Add `toByteArray()`, `orientation`, `isMirrored` and `timestamp` to `Frame` (mrousavy#1487) * feat: Implement `orientation` and `isMirrored` on Frame * feat: Add `toArrayBuffer()` func * perf: Do faster buffer copy * feat: Implement `toArrayBuffer()` on Android * feat: Add `orientation` and `isMirrored` to Android * feat: Add `timestamp` to Frame * Update Frame.ts * Update JImageProxy.h * Update FrameHostObject.cpp * Update FrameHostObject.cpp * Update CameraPage.tsx * fix: Format Swift
What
"Draw onto
Frame
" aka "Write-back Frame Processors".This is the fourth PR attempting to do this. It's hella complicated so I had to start from scratch a few times.
New API:
..and it will be applied to the Frame in realtime.
TODOs:
startRecording()
)takePhoto()
)startRecording()
)takePhoto()
)Changes
Tested on
Related issues