1 /*
2  * Copyright (c) 2024 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_SNAPSHOT_PARAM_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_SNAPSHOT_PARAM_H
18 
19 #include <string>
20 #include <utility>
21 
22 namespace OHOS::Ace::NG {
23 
24 constexpr float DEFAULT_SNAPSHOT_SCALE = 1.f;
25 constexpr int32_t DEFAULT_DELAY_TIME = 300;
26 
27 struct SnapshotOptions {
28     float scale;
29     bool waitUntilRenderFinished;
30     explicit SnapshotOptions(float scale = DEFAULT_SNAPSHOT_SCALE, bool waitUntilRenderFinished = false)
31         : scale(scale), waitUntilRenderFinished(waitUntilRenderFinished) {}
ToStringSnapshotOptions32     std::string ToString() const
33     {
34         return "{" + std::to_string(scale) + ", " + (waitUntilRenderFinished ? "true}" : "false}");
35     }
36 };
37 struct SnapshotParam {
38     int32_t delay;
39     bool checkImageStatus;
40     SnapshotOptions options;
41     explicit SnapshotParam(int32_t delay = DEFAULT_DELAY_TIME, bool checkImageStatus = false,
42         SnapshotOptions options = SnapshotOptions()) : delay(delay), checkImageStatus(checkImageStatus),
43         options(options) {}
ToStringSnapshotParam44     std::string ToString() const
45     {
46         return "{" + std::to_string(delay) + ", " + (checkImageStatus ? "true" : "false") + ", " +
47             std::to_string(options.scale) + ", " + (options.waitUntilRenderFinished ? "true}" : "false}");
48     }
49 };
50 } // namespace OHOS::Ace::NG
51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_LINE_PAINTER_H