Skip to content
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: Rewrite Android C++ part (VisionCameraProxy + JFrame) #1661

Merged
merged 11 commits into from
Jul 21, 2023

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Jul 21, 2023

What

  • Fully rewrite the native Android C++ implementation for the Worklets/Frame Processors Runtime
  • Replace JImageProxy with JFrame wrapper
  • Expose everything through VisionCameraProxy
  • Make Frame Processor Plugins object oriented and constructable (VisionCameraProxy.getFrameProcessorPlugin(..))
  • Optimize performance in a lot of places by using const references to avoid copies

Changes

Tested on

Related issues

@vercel
Copy link

vercel bot commented Jul 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 21, 2023 10:12pm


std::vector<jsi::PropNameID> FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime &runtime) {
std::vector<jsi::PropNameID> result;
result.push_back(jsi::PropNameID::forUtf8(runtime, std::string("call")));
Copy link
Contributor

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 string [build/include_what_you_use] [4]

return jsi::Value::undefined();
}

} // namespace vision
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

using namespace facebook;

class FrameProcessorPluginHostObject: public jsi::HostObject {
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class FrameProcessorPluginHostObject [whitespace/indent] [3]

_plugin(plugin) { }
~FrameProcessorPluginHostObject() { }

public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class FrameProcessorPluginHostObject [whitespace/indent] [3]

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override;
jsi::Value get(jsi::Runtime& runtime, const jsi::PropNameID& name) override;

private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
private: should be indented +1 space inside class FrameProcessorPluginHostObject [whitespace/indent] [3]


private:
std::shared_ptr<RNWorklet::JsiWorkletContext> _workletContext;
std::shared_ptr<react::CallInvoker> _callInvoker;
Copy link
Contributor

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 shared_ptr<> [build/include_what_you_use] [4]

jni::alias_ref<JVisionCameraScheduler::javaobject> scheduler);
};

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

using namespace facebook;

struct JFrameProcessor : public jni::HybridClass<JFrameProcessor> {
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside struct JFrameProcessor [whitespace/indent] [3]

explicit JFrameProcessor(std::shared_ptr<RNWorklet::JsiWorklet> worklet,
std::shared_ptr<RNWorklet::JsiWorkletContext> context);

public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside struct JFrameProcessor [whitespace/indent] [3]

*/
void call(alias_ref<JFrame::javaobject> frame) const;

private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
private: should be indented +1 space inside struct JFrameProcessor [whitespace/indent] [3]

Copy link
Contributor

@github-actions github-actions bot left a 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

android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|41| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|47| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|48| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|49| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|53| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|54| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|58| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|59| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|60| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|64| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|65| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|66| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|70| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|71| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|72| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|73| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|74| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|76| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|77| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|78| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|79| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|81| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|84| Namespace should be terminated with "// namespace vision" [readability/namespace] [5]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|33| Add #include for move [build/include_what_you_use] [4]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|57| Add #include for string [build/include_what_you_use] [4]
android/src/main/cpp/java-bindings/JVisionCameraProxy.cpp|84| Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|20| public: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|21| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|23| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|24| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|25| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|26| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|27| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|29| public: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|30| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|32| private: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|33| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|35| private: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|36| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|37| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|38| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|39| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|41| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|42| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|43| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|44| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|45| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|46| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|47| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|48| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|51| Namespace should be terminated with "// namespace vision" [readability/namespace] [5]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|26| Add #include for string [build/include_what_you_use] [4]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|43| Add #include for shared_ptr<> [build/include_what_you_use] [4]

VisionCameraProxy::~VisionCameraProxy() {
__android_log_write(ANDROID_LOG_INFO, TAG, "Destroying Context...");
// Destroy ArrayBuffer cache for both the JS and the Worklet Runtime.
auto workletContext = _javaProxy->cthis()->getWorkletContext();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

throw std::runtime_error("Unknown FrameProcessor.type passed! Received: " + frameProcessorType);
}

_javaProxy->cthis()->setFrameProcessor(viewTag, make_global(frameProcessor));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

}

void VisionCameraProxy::removeFrameProcessor(int viewTag) {
_javaProxy->cthis()->removeFrameProcessor(viewTag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]



void VisionCameraInstaller::install(jni::alias_ref<jni::JClass>,
jni::alias_ref<JVisionCameraProxy::javaobject> proxy) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

_javaProxy->cthis()->removeFrameProcessor(viewTag);
}

jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, jsi::Value jsOptions) {
Copy link
Contributor

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 string [build/include_what_you_use] [4]

scheduler->cthis()->dispatchAsync([f = std::move(f)](){
f();
});
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

f();
});
};
_workletContext = std::make_shared<RNWorklet::JsiWorkletContext>("VisionCamera",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

});
};
_workletContext = std::make_shared<RNWorklet::JsiWorkletContext>("VisionCamera",
runtime,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

};
_workletContext = std::make_shared<RNWorklet::JsiWorkletContext>("VisionCamera",
runtime,
runOnJS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

_workletContext = std::make_shared<RNWorklet::JsiWorkletContext>("VisionCamera",
runtime,
runOnJS,
runOnWorklet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

Copy link
Contributor

@github-actions github-actions bot left a 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

android/src/main/cpp/java-bindings/JVisionCameraProxy.h|25| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|26| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|27| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|28| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|30| public: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|31| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|33| private: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|34| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|36| private: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|37| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|38| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|39| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|40| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|42| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|43| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|44| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|45| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|46| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|47| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|48| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|49| Tab found; better to use spaces [whitespace/tab] [1]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|52| Namespace should be terminated with "// namespace vision" [readability/namespace] [5]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|27| Add #include for string [build/include_what_you_use] [4]
android/src/main/cpp/java-bindings/JVisionCameraProxy.h|44| Add #include for shared_ptr<> [build/include_what_you_use] [4]

_javaProxy->cthis()->removeFrameProcessor(viewTag);
}

jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, const jsi::Object& jsOptions) {
Copy link
Contributor

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 string [build/include_what_you_use] [4]

runtime,
runOnJS,
runOnWorklet);
__android_log_write(ANDROID_LOG_INFO, TAG, "Worklet Context created!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]



void JVisionCameraProxy::setFrameProcessor(int viewTag,
alias_ref<JFrameProcessor::javaobject> frameProcessor) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]


void JVisionCameraProxy::setFrameProcessor(int viewTag,
alias_ref<JFrameProcessor::javaobject> frameProcessor) {
auto setFrameProcessorMethod = javaClassLocal()->getMethod<void(int, alias_ref<JFrameProcessor::javaobject>)>("setFrameProcessor");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

void JVisionCameraProxy::setFrameProcessor(int viewTag,
alias_ref<JFrameProcessor::javaobject> frameProcessor) {
auto setFrameProcessorMethod = javaClassLocal()->getMethod<void(int, alias_ref<JFrameProcessor::javaobject>)>("setFrameProcessor");
setFrameProcessorMethod(_javaPart, viewTag, frameProcessor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

removeFrameProcessorMethod(_javaPart, viewTag);
}

local_ref<JFrameProcessorPlugin::javaobject> JVisionCameraProxy::getFrameProcessorPlugin(std::string name,
Copy link
Contributor

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 string [build/include_what_you_use] [4]

return makeCxxInstance(jThis, jsRuntime, jsCallInvoker, sharedScheduler);
}

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

using namespace facebook;

class JVisionCameraProxy : public jni::HybridClass<JVisionCameraProxy> {
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]


class JVisionCameraProxy : public jni::HybridClass<JVisionCameraProxy> {
public:
static void registerNatives();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

public:
static void registerNatives();

void setFrameProcessor(int viewTag,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

static void registerNatives();

void setFrameProcessor(int viewTag,
jni::alias_ref<JFrameProcessor::javaobject> frameProcessor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]


void setFrameProcessor(int viewTag,
jni::alias_ref<JFrameProcessor::javaobject> frameProcessor);
void removeFrameProcessor(int viewTag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

void setFrameProcessor(int viewTag,
jni::alias_ref<JFrameProcessor::javaobject> frameProcessor);
void removeFrameProcessor(int viewTag);
jni::local_ref<JFrameProcessorPlugin::javaobject> getFrameProcessorPlugin(std::string name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

jni::alias_ref<JFrameProcessor::javaobject> frameProcessor);
void removeFrameProcessor(int viewTag);
jni::local_ref<JFrameProcessorPlugin::javaobject> getFrameProcessorPlugin(std::string name,
jni::local_ref<react::ReadableNativeMap::javaobject> options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

jni::local_ref<JFrameProcessorPlugin::javaobject> getFrameProcessorPlugin(std::string name,
jni::local_ref<react::ReadableNativeMap::javaobject> options);

public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class JVisionCameraProxy [whitespace/indent] [3]

jni::global_ref<JVisionCameraScheduler::javaobject> scheduler);
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> javaThis,
jlong jsRuntimePointer,
jni::alias_ref<facebook::react::CallInvokerHolder::javaobject> jsCallInvokerHolder,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> javaThis,
jlong jsRuntimePointer,
jni::alias_ref<facebook::react::CallInvokerHolder::javaobject> jsCallInvokerHolder,
jni::alias_ref<JVisionCameraScheduler::javaobject> scheduler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

jni::alias_ref<JVisionCameraScheduler::javaobject> scheduler);
};

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Namespace should be terminated with "// namespace vision" [readability/namespace] [5]

void setFrameProcessor(int viewTag,
jni::alias_ref<JFrameProcessor::javaobject> frameProcessor);
void removeFrameProcessor(int viewTag);
jni::local_ref<JFrameProcessorPlugin::javaobject> getFrameProcessorPlugin(std::string name,
Copy link
Contributor

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 string [build/include_what_you_use] [4]


explicit JVisionCameraProxy(jni::alias_ref<JVisionCameraProxy::jhybridobject> javaThis,
jsi::Runtime* jsRuntime,
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker,
Copy link
Contributor

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 shared_ptr<> [build/include_what_you_use] [4]

@@ -8,6 +8,7 @@ import {
PhotoFile,
sortFormats,
useCameraDevices,
useFrameProcessor,
useSkiaFrameProcessor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[tsc] <6133> reported by reviewdog 🐶
'useSkiaFrameProcessor' is declared but its value is never read.

@@ -218,15 +219,10 @@
paint.setImageFilter(imageFilter);

const isIOS = Platform.OS === 'ios';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[tsc] <6133> reported by reviewdog 🐶
'isIOS' is declared but its value is never read.

}

jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime,
const std::string& name,
Copy link
Contributor

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 string [build/include_what_you_use] [4]

private:
void setFrameProcessor(int viewTag, jsi::Runtime& runtime, const jsi::Object& frameProcessor);
void removeFrameProcessor(int viewTag);
jsi::Value getFrameProcessorPlugin(jsi::Runtime& runtime, const std::string& name, const jsi::Object& options);
Copy link
Contributor

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 string [build/include_what_you_use] [4]


JVisionCameraProxy::JVisionCameraProxy(const jni::alias_ref<JVisionCameraProxy::jhybridobject>& javaThis,
jsi::Runtime* runtime,
const std::shared_ptr<facebook::react::CallInvoker>& callInvoker,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

JVisionCameraProxy::JVisionCameraProxy(const jni::alias_ref<JVisionCameraProxy::jhybridobject>& javaThis,
jsi::Runtime* runtime,
const std::shared_ptr<facebook::react::CallInvoker>& callInvoker,
const jni::global_ref<JVisionCameraScheduler::javaobject>& scheduler) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]



void JVisionCameraProxy::setFrameProcessor(int viewTag,
const alias_ref<JFrameProcessor::javaobject>& frameProcessor) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]


explicit JVisionCameraProxy(const jni::alias_ref<JVisionCameraProxy::jhybridobject>& javaThis,
jsi::Runtime* jsRuntime,
const std::shared_ptr<facebook::react::CallInvoker>& jsCallInvoker,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

explicit JVisionCameraProxy(const jni::alias_ref<JVisionCameraProxy::jhybridobject>& javaThis,
jsi::Runtime* jsRuntime,
const std::shared_ptr<facebook::react::CallInvoker>& jsCallInvoker,
const jni::global_ref<JVisionCameraScheduler::javaobject>& scheduler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> javaThis,
jlong jsRuntimePointer,
jni::alias_ref<facebook::react::CallInvokerHolder::javaobject> jsCallInvokerHolder,
const jni::alias_ref<JVisionCameraScheduler::javaobject>& scheduler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Tab found; better to use spaces [whitespace/tab] [1]

void setFrameProcessor(int viewTag,
const jni::alias_ref<JFrameProcessor::javaobject>& frameProcessor);
void removeFrameProcessor(int viewTag);
jni::local_ref<JFrameProcessorPlugin::javaobject> getFrameProcessorPlugin(const std::string& name,
Copy link
Contributor

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 string [build/include_what_you_use] [4]


explicit JVisionCameraProxy(const jni::alias_ref<JVisionCameraProxy::jhybridobject>& javaThis,
jsi::Runtime* jsRuntime,
const std::shared_ptr<facebook::react::CallInvoker>& jsCallInvoker,
Copy link
Contributor

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 shared_ptr<> [build/include_what_you_use] [4]

@@ -18,16 +19,12 @@ using namespace jni;
struct JFrameProcessorPlugin : public JavaClass<JFrameProcessorPlugin> {
static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/FrameProcessorPlugin;";

public:
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside struct JFrameProcessorPlugin [whitespace/indent] [3]

public:
explicit FrameHostObject(jni::alias_ref<JImageProxy::javaobject> image);
explicit FrameHostObject(const jni::alias_ref<JFrame::javaobject>& frame);
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class FrameHostObject [whitespace/indent] [3]

~FrameHostObject();

public:
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class FrameHostObject [whitespace/indent] [3]

jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override;
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;

public:
jni::global_ref<JImageProxy> frame;
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class FrameHostObject [whitespace/indent] [3]


private:
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
private: should be indented +1 space inside class FrameHostObject [whitespace/indent] [3]

class VisionCameraScheduler : public jni::HybridClass<VisionCameraScheduler> {
public:
class JVisionCameraScheduler : public jni::HybridClass<JVisionCameraScheduler> {
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class JVisionCameraScheduler [whitespace/indent] [3]


private:
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
private: should be indented +1 space inside class JVisionCameraScheduler [whitespace/indent] [3]

@mrousavy mrousavy marked this pull request as ready for review July 21, 2023 22:13
@mrousavy mrousavy merged commit 86dd703 into v3 Jul 21, 2023
10 of 12 checks passed
@mrousavy mrousavy deleted the feat/proxy-object-android branch July 21, 2023 22:15
mrousavy added a commit that referenced this pull request Jul 31, 2023
* First Android rewrite

* Rewrite Android C++ backend

* Pass `ReadableNativeMap`, fix build error

* fix: Fix FrameProcessor init

* Make a bunch of stuff const reference to avoid copies

* Indents

* Cleanup

* indents

* docs: Update Android docs

* Update CameraView.kt

* fix: Format C++ code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant