-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
45 changed files
with
984 additions
and
858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Created by Marc Rousavy on 21.07.23. | ||
// | ||
|
||
#include "FrameProcessorPluginHostObject.h" | ||
#include <vector> | ||
#include "FrameHostObject.h" | ||
#include "JSIJNIConversion.h" | ||
#include <string> | ||
|
||
namespace vision { | ||
|
||
using namespace facebook; | ||
|
||
std::vector<jsi::PropNameID> FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime& runtime) { | ||
std::vector<jsi::PropNameID> result; | ||
result.push_back(jsi::PropNameID::forUtf8(runtime, std::string("call"))); | ||
return result; | ||
} | ||
|
||
jsi::Value FrameProcessorPluginHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) { | ||
auto name = propName.utf8(runtime); | ||
|
||
if (name == "call") { | ||
return jsi::Function::createFromHostFunction(runtime, | ||
jsi::PropNameID::forUtf8(runtime, "call"), | ||
2, | ||
[=](jsi::Runtime &runtime, | ||
const jsi::Value &thisValue, | ||
const jsi::Value *arguments, | ||
size_t count) -> jsi::Value { | ||
// Frame is first argument | ||
auto frameHostObject = arguments[0].asObject(runtime).asHostObject<FrameHostObject>(runtime); | ||
auto frame = frameHostObject->frame; | ||
|
||
// Options are second argument (possibly undefined) | ||
local_ref<react::ReadableNativeMap::javaobject> options = nullptr; | ||
if (count > 1) { | ||
options = JSIJNIConversion::convertJSIObjectToJNIMap(runtime, arguments[1].asObject(runtime)); | ||
} | ||
|
||
// Call actual plugin | ||
auto result = _plugin->callback(frame, options); | ||
|
||
// Convert result value to jsi::Value (possibly undefined) | ||
return JSIJNIConversion::convertJNIObjectToJSIValue(runtime, result); | ||
}); | ||
} | ||
|
||
return jsi::Value::undefined(); | ||
} | ||
|
||
} // namespace vision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Created by Marc Rousavy on 21.07.23. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <jsi/jsi.h> | ||
#include "java-bindings/JFrameProcessorPlugin.h" | ||
#include <memory> | ||
#include <ReactCommon/CallInvoker.h> | ||
#include <fbjni/fbjni.h> | ||
#include <vector> | ||
|
||
namespace vision { | ||
|
||
using namespace facebook; | ||
|
||
class FrameProcessorPluginHostObject: public jsi::HostObject { | ||
public: | ||
explicit FrameProcessorPluginHostObject(jni::alias_ref<JFrameProcessorPlugin::javaobject> plugin): | ||
_plugin(make_global(plugin)) { } | ||
~FrameProcessorPluginHostObject() { } | ||
|
||
public: | ||
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override; | ||
jsi::Value get(jsi::Runtime& runtime, const jsi::PropNameID& name) override; | ||
|
||
private: | ||
jni::global_ref<JFrameProcessorPlugin::javaobject> _plugin; | ||
}; | ||
|
||
} // namespace vision |
Oops, something went wrong.