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 namespace OHOS::Ace::Napi { 24 class JsDrawableDescriptor { 25 public: 26 static ACE_EXPORT napi_value Export(napi_env env, napi_value exports); 27 28 static ACE_EXPORT napi_value ToNapi(napi_env, DrawableDescriptor*, 29 DrawableDescriptor::DrawableType type = DrawableDescriptor::DrawableType::LAYERED); 30 31 static ACE_EXPORT constexpr char MODULE_NAME[] = "arkui.drawableDescriptor"; 32 33 private: 34 static napi_value InitDrawable(napi_env env); 35 static napi_value InitLayeredDrawable(napi_env env); 36 37 static napi_value Constructor(napi_env env, napi_callback_info info); 38 static void Destructor(napi_env env, void* nativeObject, void* finalize); 39 40 // methods 41 static napi_value GetPixelMap(napi_env env, napi_callback_info info); 42 static napi_value GetForeground(napi_env env, napi_callback_info info); 43 static napi_value GetBackground(napi_env env, napi_callback_info info); 44 static napi_value GetMask(napi_env env, napi_callback_info info); 45 46 static napi_value GetMaskClipPath(napi_env env, napi_callback_info info); 47 48 static thread_local napi_ref baseConstructor_; 49 static thread_local napi_ref layeredConstructor_; 50 }; 51 } // namespace OHOS::Ace::Napi 52 #endif // INTERFACES_INNER_API_DRAWABLE_DESCRIPTOR_JS_DRAWABLE_DESCRIPTOR_H_ 53