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 FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILE_PROGRESS_H
17 #define FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILE_PROGRESS_H
18 
19 #include <render_context/render_context.h>
20 #include <ui/rs_canvas_node.h>
21 #include <ui/rs_display_node.h>
22 #include <ui/rs_surface_extractor.h>
23 
24 #include "draw/canvas.h"
25 #include "event_handler.h"
26 #include "log.h"
27 #include "util.h"
28 #include "vsync_receiver.h"
29 
30 namespace OHOS {
31 class BootCompileProgress {
32 public:
33     void Init(const BootAnimationConfig& config);
34 
35 private:
36     void OnVsync();
37     void DrawCompileProgress();
38     void UpdateCompileProgress();
39     bool WaitBmsStartIfNeeded();
40     bool CreateCanvasNode();
41     bool RegisterVsyncCallback();
42     Rosen::Drawing::Brush DrawProgressPoint(int32_t idx, int32_t frameNum);
43 
44     int32_t windowWidth_ = 0;
45     int32_t windowHeight_ = 0;
46     int32_t times_ = 0;
47     int32_t rotateDegree_ = 0;
48     int32_t progress_ = 0;
49     int32_t timeLimitSec_ = -1;
50     int64_t startTimeMs_ = -1;
51     int64_t endTimePredictMs_ = -1;
52     int32_t fontSize_ = 0;
53     Rosen::ScreenId screenId_;
54     std::string displayInfo_ = "";
55 
56     bool isBmsCompileDone_ = false;
57     volatile bool isUpdateOptEnd_ = false;
58 
59     std::shared_ptr<Rosen::RSSurfaceNode> rsSurfaceNode_;
60     std::shared_ptr<Rosen::RSCanvasNode> rsCanvasNode_;
61     std::shared_ptr<Rosen::Drawing::Typeface> tf_;
62     std::shared_ptr<Rosen::VSyncReceiver> receiver_;
63     std::shared_ptr<OHOS::AppExecFwk::EventHandler> compileHandler_;
64     std::shared_ptr<OHOS::AppExecFwk::EventRunner> compileRunner_;
65     std::shared_ptr<Rosen::RSInterpolator> sharpCurve_;
66 };
67 } // namespace OHOS
68 
69 #endif //FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILEPROGRESS_H
70