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 OHOS_NAPI_ACE_COMPONENT_SNAPSHOT_H 17 #define OHOS_NAPI_ACE_COMPONENT_SNAPSHOT_H 18 19 #include <functional> 20 #include <memory> 21 22 #include "js_native_api.h" 23 #include "js_native_api_types.h" 24 25 #include "core/components_ng/render/snapshot_param.h" 26 namespace OHOS::Media { 27 class PixelMap; 28 } // namespace OHOS::Media 29 30 namespace OHOS::Ace::Napi { 31 class JsComponentSnapshot { 32 public: 33 JsComponentSnapshot(napi_env env, napi_callback_info info); 34 35 bool CheckArgs(napi_valuetype firstArgType); 36 37 auto CreateCallback(napi_value* result); 38 39 napi_value GetArgv(int32_t idx); 40 41 void ParseParamForBuilder(NG::SnapshotParam& param); 42 43 void ParseParamForGet(NG::SnapshotOptions& options); 44 45 void ParseParam(int32_t idx, NG::SnapshotParam& param); 46 47 void ParseOptions(int32_t idx, NG::SnapshotOptions& options); 48 49 static constexpr int32_t ARGC_MAX = 5; 50 51 private: 52 napi_env env_ = nullptr; 53 napi_value argv_[ARGC_MAX] { nullptr }; 54 size_t argc_ = ARGC_MAX; 55 }; 56 } // namespace OHOS::Ace::Napi 57 58 #endif