MCPcopy Create free account
hub / github.com/BabitMF/bmf / startAlgorithm

Method startAlgorithm

bmf_lite/ohos/entry/src/main/cpp/render/plugin_render.cpp:398–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398napi_value PluginRender::startAlgorithm(napi_env env, napi_callback_info info) {
399 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "PluginRender",
400 "startAlgorithm");
401 napi_value thisArg;
402 if (napi_get_cb_info(env, info, nullptr, nullptr, &thisArg, nullptr) !=
403 napi_ok) {
404 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
405 "createCamera: napi_get_cb_info fail");
406 return nullptr;
407 }
408 /* // 获取环境变量中XComponent实例*/
409 napi_value exportInstance;
410 if (napi_get_named_property(env, thisArg, OH_NATIVE_XCOMPONENT_OBJ,
411 &exportInstance) != napi_ok) {
412 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
413 "NapiDrawPattern: napi_get_named_property fail");
414 return nullptr;
415 }
416
417 OH_NativeXComponent *nativeXComponent = nullptr;
418 if (napi_unwrap(env, exportInstance,
419 reinterpret_cast<void **>(&nativeXComponent)) != napi_ok) {
420 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
421 "NapiDrawPattern: napi_unwrap fail");
422 return nullptr;
423 }
424 // 获取XComponent实例的id
425 char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {'\0'};
426 uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1;
427 if (OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize) !=
428 OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {
429 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
430 "NapiDrawPattern: Unable to get XComponent id");
431 return nullptr;
432 }
433
434 size_t argc = 1;
435 napi_value args[1] = {nullptr};
436 napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
437
438 napi_valuetype valuetype0;
439 napi_typeof(env, args[0], &valuetype0);
440
441 int32_t alg_type;
442 napi_get_value_int32(env, args[0], &alg_type);
443
444 std::string id(idStr);
445 PluginRender *render = PluginRender::GetInstance(id);
446 if (render != nullptr) {
447 if (alg_type == 0) {
448 render->renderThread_->StartAlgorithm(
449 AlgorithmEnum::SUPER_RESOLUTION);
450 } else if (alg_type == 1) {
451 render->renderThread_->StartAlgorithm(AlgorithmEnum::DENOISE);
452 }
453 }
454 return nullptr;
455}

Callers

nothing calls this directly

Calls 1

StartAlgorithmMethod · 0.80

Tested by

no test coverage detected