• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-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 #ifndef OHOS_JS_WINDOW_ANIMATION_UTILS_H
17 #define OHOS_JS_WINDOW_ANIMATION_UTILS_H
18 #include "napi/native_api.h"
19 #include "native_engine/native_engine.h"
20 #include "wm_common.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 
25 #define CHECK_NAPI_CREATE_OBJECT_RETURN_IF_NULL(env, objValue) \
26     do {                                                       \
27         napi_create_object((env), &(objValue));                \
28         if ((objValue) == nullptr) {                           \
29             TLOGE(WmsLogTag::DEFAULT, "Failed to get object"); \
30             return nullptr;                                    \
31         }                                                      \
32     } while (0)
33 
34 #define NAPI_CHECK_RETURN_IF_NULL(func, msg)                                                            \
35     do {                                                                                                \
36         napi_status status = func;                                                                      \
37         if (status != napi_ok) {                                                                        \
38             TLOGE(WmsLogTag::DEFAULT, "Failed with reason %{public}s, code: %{public}d", msg, status);  \
39             return nullptr;                                                                             \
40         }                                                                                               \
41     } while (0)
42 
43 napi_value ConvertTransitionAnimationToJsValue(napi_env env,
44     std::shared_ptr<TransitionAnimation> transitionAnimation);
45 napi_value ConvertWindowAnimationOptionToJsValue(napi_env env,
46     const WindowAnimationOption& animationConfig);
47 napi_value ConvertStartAnimationOptionsToJsValue(napi_env env,
48     std::shared_ptr<StartAnimationOptions> startAnimationOptions);
49 napi_value ConvertStartAnimationSystemOptionsToJsValue(napi_env env,
50     std::shared_ptr<StartAnimationSystemOptions> startAnimationSystemOptions);
51 bool ConvertTransitionAnimationFromJsValue(napi_env env, napi_value jsObject,
52     TransitionAnimation& transitionAnimation, WmErrorCode& result);
53 bool ConvertStartAnimationOptionsFromJsValue(napi_env env, napi_value jsObject,
54     StartAnimationOptions& startAnimationOptions);
55 bool ConvertStartAnimationSystemOptionsFromJsValue(napi_env env, napi_value jsObject,
56     StartAnimationSystemOptions& startAnimationSystemOptions);
57 bool ConvertWindowAnimationOptionFromJsValue(napi_env env, napi_value config,
58     WindowAnimationOption& animationConfig, WmErrorCode& result);
59 bool ConvertWindowCreateParamsFromJsValue(napi_env env, napi_value jsObject, WindowCreateParams& windowCreateParams);
60 bool CheckWindowAnimationOption(napi_env env, WindowAnimationOption& animationConfig, WmErrorCode& result);
61 }
62 }
63 #endif
64