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