1 /*
2 * Copyright (C) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ani_effect_kit_module.h"
17 #include "effect_utils.h"
18
19 extern "C" {
ANI_Constructor(ani_vm * vm,uint32_t * result)20 ANI_EXPORT ani_status ANI_Constructor(ani_vm* vm, uint32_t* result)
21 {
22 ani_env* env;
23 if (vm->GetEnv(ANI_VERSION_1, &env) != ANI_OK) {
24 EFFECT_LOG_E("[ANI_Constructor] Unsupported ANI_VERSION_1");
25 return ANI_ERROR;
26 }
27
28 static const char* staticClassName = "L@ohos/effectKit/effectKit;";
29 ani_namespace effectKitNamespace;
30 if (env->FindNamespace(staticClassName, &effectKitNamespace) != ANI_OK) {
31 EFFECT_LOG_E("[ANI_Constructor] FindNamespace failed");
32 return ANI_ERROR;
33 }
34 std::array staticMethods = {
35 ani_native_function { "createEffect", nullptr, reinterpret_cast<void*>(OHOS::Rosen::AniFilter::CreateEffect) }
36 };
37 if (env->Namespace_BindNativeFunctions(effectKitNamespace, staticMethods.data(), staticMethods.size()) != ANI_OK) {
38 EFFECT_LOG_E("[ANI_Constructor] Namespace_BindNativeFunctions failed");
39 return ANI_ERROR;
40 };
41 OHOS::Rosen::AniFilter::Init(env);
42 *result = ANI_VERSION_1;
43 return ANI_OK;
44 }
45 }