chore: Change line width to 140 in C++
This commit is contained in:
@@ -37,8 +37,7 @@ __attribute__((objc_runtime_name("_TtC12VisionCamera10CameraView")))
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
VisionCameraProxy::VisionCameraProxy(jsi::Runtime& runtime,
|
||||
std::shared_ptr<react::CallInvoker> callInvoker) {
|
||||
VisionCameraProxy::VisionCameraProxy(jsi::Runtime& runtime, std::shared_ptr<react::CallInvoker> callInvoker) {
|
||||
_callInvoker = callInvoker;
|
||||
|
||||
NSLog(@"VisionCameraProxy: Creating Worklet Context...");
|
||||
@@ -51,8 +50,7 @@ VisionCameraProxy::VisionCameraProxy(jsi::Runtime& runtime,
|
||||
dispatch_async(CameraQueues.videoQueue, [f = std::move(f)]() { f(); });
|
||||
};
|
||||
|
||||
_workletContext = std::make_shared<RNWorklet::JsiWorkletContext>("VisionCamera", &runtime,
|
||||
runOnJS, runOnWorklet);
|
||||
_workletContext = std::make_shared<RNWorklet::JsiWorkletContext>("VisionCamera", &runtime, runOnJS, runOnWorklet);
|
||||
NSLog(@"VisionCameraProxy: Worklet Context Created!");
|
||||
}
|
||||
|
||||
@@ -71,23 +69,18 @@ std::vector<jsi::PropNameID> VisionCameraProxy::getPropertyNames(jsi::Runtime& r
|
||||
return result;
|
||||
}
|
||||
|
||||
void VisionCameraProxy::setFrameProcessor(jsi::Runtime& runtime, int viewTag,
|
||||
const jsi::Object& object) {
|
||||
void VisionCameraProxy::setFrameProcessor(jsi::Runtime& runtime, int viewTag, const jsi::Object& object) {
|
||||
auto frameProcessorType = object.getProperty(runtime, "type").asString(runtime).utf8(runtime);
|
||||
auto worklet = std::make_shared<RNWorklet::JsiWorklet>(
|
||||
runtime, object.getProperty(runtime, "frameProcessor"));
|
||||
auto worklet = std::make_shared<RNWorklet::JsiWorklet>(runtime, object.getProperty(runtime, "frameProcessor"));
|
||||
|
||||
RCTExecuteOnMainQueue(^{
|
||||
auto currentBridge = [RCTBridge currentBridge];
|
||||
auto anonymousView =
|
||||
[currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]];
|
||||
auto anonymousView = [currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]];
|
||||
auto view = static_cast<CameraView*>(anonymousView);
|
||||
if (frameProcessorType == "frame-processor") {
|
||||
view.frameProcessor = [[FrameProcessor alloc] initWithWorklet:worklet
|
||||
context:_workletContext];
|
||||
view.frameProcessor = [[FrameProcessor alloc] initWithWorklet:worklet context:_workletContext];
|
||||
} else {
|
||||
throw std::runtime_error("Unknown FrameProcessor.type passed! Received: " +
|
||||
frameProcessorType);
|
||||
throw std::runtime_error("Unknown FrameProcessor.type passed! Received: " + frameProcessorType);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -95,20 +88,16 @@ void VisionCameraProxy::setFrameProcessor(jsi::Runtime& runtime, int viewTag,
|
||||
void VisionCameraProxy::removeFrameProcessor(jsi::Runtime& runtime, int viewTag) {
|
||||
RCTExecuteOnMainQueue(^{
|
||||
auto currentBridge = [RCTBridge currentBridge];
|
||||
auto anonymousView =
|
||||
[currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]];
|
||||
auto anonymousView = [currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]];
|
||||
auto view = static_cast<CameraView*>(anonymousView);
|
||||
view.frameProcessor = nil;
|
||||
});
|
||||
}
|
||||
|
||||
jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name,
|
||||
const jsi::Object& options) {
|
||||
jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, const jsi::Object& options) {
|
||||
NSString* key = [NSString stringWithUTF8String:name.c_str()];
|
||||
NSDictionary* optionsObjc =
|
||||
JSINSObjectConversion::convertJSIObjectToNSDictionary(runtime, options, _callInvoker);
|
||||
FrameProcessorPlugin* plugin = [FrameProcessorPluginRegistry getPlugin:key
|
||||
withOptions:optionsObjc];
|
||||
NSDictionary* optionsObjc = JSINSObjectConversion::convertJSIObjectToNSDictionary(runtime, options, _callInvoker);
|
||||
FrameProcessorPlugin* plugin = [FrameProcessorPluginRegistry getPlugin:key withOptions:optionsObjc];
|
||||
if (plugin == nil) {
|
||||
return jsi::Value::undefined();
|
||||
}
|
||||
@@ -123,8 +112,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID&
|
||||
if (name == "setFrameProcessor") {
|
||||
return jsi::Function::createFromHostFunction(
|
||||
runtime, jsi::PropNameID::forUtf8(runtime, "setFrameProcessor"), 1,
|
||||
[this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments,
|
||||
size_t count) -> jsi::Value {
|
||||
[this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value {
|
||||
auto viewTag = arguments[0].asNumber();
|
||||
auto object = arguments[1].asObject(runtime);
|
||||
this->setFrameProcessor(runtime, static_cast<int>(viewTag), object);
|
||||
@@ -134,8 +122,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID&
|
||||
if (name == "removeFrameProcessor") {
|
||||
return jsi::Function::createFromHostFunction(
|
||||
runtime, jsi::PropNameID::forUtf8(runtime, "removeFrameProcessor"), 1,
|
||||
[this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments,
|
||||
size_t count) -> jsi::Value {
|
||||
[this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value {
|
||||
auto viewTag = arguments[0].asNumber();
|
||||
this->removeFrameProcessor(runtime, static_cast<int>(viewTag));
|
||||
return jsi::Value::undefined();
|
||||
@@ -144,8 +131,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID&
|
||||
if (name == "getFrameProcessorPlugin") {
|
||||
return jsi::Function::createFromHostFunction(
|
||||
runtime, jsi::PropNameID::forUtf8(runtime, "getFrameProcessorPlugin"), 1,
|
||||
[this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments,
|
||||
size_t count) -> jsi::Value {
|
||||
[this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value {
|
||||
if (count < 1 || !arguments[0].isString()) {
|
||||
throw jsi::JSError(runtime, "First argument needs to be a string (pluginName)!");
|
||||
}
|
||||
@@ -170,8 +156,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID&
|
||||
|
||||
// global.VisionCameraProxy
|
||||
auto visionCameraProxy = std::make_shared<VisionCameraProxy>(runtime, bridge.jsCallInvoker);
|
||||
runtime.global().setProperty(runtime, "VisionCameraProxy",
|
||||
jsi::Object::createFromHostObject(runtime, visionCameraProxy));
|
||||
runtime.global().setProperty(runtime, "VisionCameraProxy", jsi::Object::createFromHostObject(runtime, visionCameraProxy));
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user