• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 INTERFACES_INNER_API_DRAWABLE_DESCRIPTOR_JS_DRAWABLE_DESCRIPTOR_H_
17 #define INTERFACES_INNER_API_DRAWABLE_DESCRIPTOR_JS_DRAWABLE_DESCRIPTOR_H_
18 
19 #include "drawable_descriptor.h"
20 #include "napi/native_api.h"
21 #include "napi/native_node_api.h"
22 
23 #include "base/marcos.h"
24 
25 namespace OHOS::Ace::Napi {
26 class JsDrawableDescriptor {
27 public:
28     static DRAWABLE_FORCE_EXPORT napi_value Export(napi_env env, napi_value exports);
29 
30     static DRAWABLE_FORCE_EXPORT napi_value ToNapi(napi_env, DrawableDescriptor*,
31         DrawableDescriptor::DrawableType type = DrawableDescriptor::DrawableType::LAYERED);
32 
33     static DRAWABLE_FORCE_EXPORT constexpr char MODULE_NAME[] = "arkui.drawableDescriptor";
34     static std::shared_ptr<Media::PixelMap> GetPixelMapFromNapi(napi_env env, napi_value napiValue);
35     static std::shared_ptr<Media::PixelMap> GetPixelMapFromDrawableNapi(napi_env env, napi_value napiValue);
36 
37 private:
38     static napi_value InitDrawable(napi_env env);
39     static napi_value InitLayeredDrawable(napi_env env);
40     static napi_value InitAnimatedDrawable(napi_env env);
41     static napi_value InitPixelMapDrawable(napi_env env);
42 
43     static napi_value Constructor(napi_env env, napi_callback_info info);
44     static void Destructor(napi_env env, void* nativeObject, void* finalize);
45     static napi_value AnimatedConstructor(napi_env env, napi_callback_info info);
46     static napi_value PixelMapConstructor(napi_env env, napi_callback_info info);
47     static napi_value LayeredConstructor(napi_env env, napi_callback_info info);
48 
49     // methods
50     static napi_value GetPixelMap(napi_env env, napi_callback_info info);
51     static napi_value GetLayeredPixelMap(napi_env env, napi_callback_info info);
52     static napi_value GetForeground(napi_env env, napi_callback_info info);
53     static napi_value GetBackground(napi_env env, napi_callback_info info);
54     static napi_value GetMask(napi_env env, napi_callback_info info);
55 
56     static napi_value GetMaskClipPath(napi_env env, napi_callback_info info);
57 
58     static thread_local napi_ref baseConstructor_;
59     static thread_local napi_ref layeredConstructor_;
60     static thread_local napi_ref animatedConstructor_;
61     static thread_local napi_ref pixelMapConstructor_;
62 };
63 } // namespace OHOS::Ace::Napi
64 #endif // INTERFACES_INNER_API_DRAWABLE_DESCRIPTOR_JS_DRAWABLE_DESCRIPTOR_H_
65