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 static const int MAX_WAIT_VSYNCRECEIVER_CREATE_TIME = 5000000; // 5S 26 27 class BootPicturePlayer : public BootPlayer { 28 public: 29 BootPicturePlayer(const PlayerParams& params); 30 31 virtual ~BootPicturePlayer() = default; 32 33 void Play() override; 34 35 private: 36 void OnVsync(); 37 bool Draw(); 38 bool Stop(); 39 bool OnDraw(Rosen::Drawing::CoreCanvas* canvas, int32_t curNo); 40 void InitPicCoordinates(Rosen::ScreenId screenId); 41 bool ReadPicZipFile(ImageStructVec& imgVec, int32_t& freq); 42 bool CheckFrameRateValid(int32_t frameRate); 43 std::string GetPicZipPath(); 44 45 int32_t windowWidth_; 46 int32_t windowHeight_; 47 int32_t picCurNo_ = 0; 48 int32_t realHeight_ = 0; 49 int32_t realWidth_ = 0; 50 int32_t pointX_ = 0; 51 int32_t pointY_ = 0; 52 int32_t imgVecSize_ = 0; 53 int32_t freq_ = 30; 54 ImageStructVec imageVector_; 55 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