1 /* 2 * Copyright (c) 2022 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_ANIMATION_H 17 #define FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_ANIMATION_H 18 19 #include <include/core/SkCanvas.h> 20 #include <include/core/SkData.h> 21 #include <include/core/SkImageInfo.h> 22 #include <include/core/SkImage.h> 23 #include <include/codec/SkCodec.h> 24 #include <display.h> 25 #include <foundation/window/window_manager/interfaces/innerkits/wm/window_manager.h> 26 #include <ipc_skeleton.h> 27 #include <iremote_broker.h> 28 #include <iservice_registry.h> 29 #include <platform/ohos/rs_irender_service.h> 30 #include <parameters.h> 31 #include <render_context/render_context.h> 32 #include <system_ability_definition.h> 33 #include <ui/rs_surface_extractor.h> 34 #include <window.h> 35 #include <window_option.h> 36 #include <window_scene.h> 37 #include "event_handler.h" 38 #include "player.h" 39 #include "vsync_receiver.h" 40 #include "util.h" 41 42 namespace OHOS { 43 class BootAnimation { 44 public: 45 void Init(int32_t width, int32_t height); 46 void Draw(); 47 void CheckExitAnimation(); 48 void PlaySound(); 49 bool CheckFrameRateValid(int32_t ratevalue); 50 void Run(std::vector<sptr<OHOS::Rosen::Display>>& displays); 51 ~BootAnimation(); 52 private: 53 void OnVsync(); 54 void OnDraw(SkCanvas* canvas, int32_t curNo); 55 void InitBootWindow(); 56 void InitRsSurface(); 57 void InitPicCoordinates(); 58 int32_t windowWidth_; 59 int32_t windowHeight_; 60 sptr<OHOS::Rosen::Window> window_; 61 sptr<OHOS::Rosen::WindowScene> scene_; 62 std::unique_ptr<OHOS::Rosen::RSSurfaceFrame> framePtr_; 63 std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface_; 64 OHOS::Rosen::RenderContext* rc_; 65 int32_t freq_ = 30; 66 int32_t realHeight_ = 0; 67 int32_t realWidth_ = 0; 68 int32_t pointX_ = 0; 69 int32_t pointY_ = 0; 70 int32_t picCurNo_ = -1; 71 int32_t imgVecSize_ = 0; 72 std::shared_ptr<OHOS::Rosen::VSyncReceiver> receiver_ = nullptr; 73 std::shared_ptr<Media::Player> soundPlayer_ = nullptr; 74 ImageStructVec imageVector_; 75 std::shared_ptr<OHOS::AppExecFwk::EventHandler> mainHandler_ = nullptr; 76 std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr; 77 bool setBootEvent_ = false; 78 }; 79 } // namespace OHOS 80 81 #endif // FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_ANIMATION_H 82