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_PICTURE_PLAYER_H
17 #define FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_PICTURE_PLAYER_H
18 
19 #include "boot_player.h"
20 #include "util.h"
21 #include <ui/rs_surface_extractor.h>
22 #include "vsync_receiver.h"
23 
24 namespace OHOS {
25 class BootPicturePlayer : public BootPlayer {
26 public:
27     BootPicturePlayer(const PlayerParams& params);
28 
29     virtual ~BootPicturePlayer() = default;
30 
31     void Play() override;
32 
33 private:
34     void OnVsync();
35     bool Draw();
36     bool OnDraw(Rosen::Drawing::CoreCanvas* canvas, int32_t curNo);
37     void InitPicCoordinates(Rosen::ScreenId screenId);
38     bool ReadPicZipFile(ImageStructVec& imgVec, int32_t& freq);
39     bool CheckFrameRateValid(int32_t frameRate);
40     std::string GetPicZipPath();
41 
42     int32_t windowWidth_;
43     int32_t windowHeight_;
44     int32_t picCurNo_ = 0;
45     int32_t realHeight_ = 0;
46     int32_t realWidth_ = 0;
47     int32_t pointX_ = 0;
48     int32_t pointY_ = 0;
49     int32_t imgVecSize_ = 0;
50     int32_t freq_ = 30;
51     ImageStructVec imageVector_;
52 
53 #ifdef NEW_RENDER_CONTEXT
54     std::shared_ptr<OHOS::Rosen::RSRenderSurface> rsSurface_;
55 #endif
56     std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface_;
57     std::unique_ptr<OHOS::Rosen::RSSurfaceFrame> rsSurfaceFrame_;
58     std::shared_ptr<OHOS::Rosen::VSyncReceiver> receiver_;
59 };
60 } // namespace OHOS
61 
62 #endif // FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_PICTURE_PLAYER_H
63