1 /* 2 * Copyright (c) 2023 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 <display_type.h> 26 #include <display_manager.h> 27 #include <media_errors.h> 28 #include <foundation/window/window_manager/interfaces/innerkits/wm/window_manager.h> 29 #include <ipc_skeleton.h> 30 #include <iremote_broker.h> 31 #include <iservice_registry.h> 32 #include <platform/ohos/rs_irender_service.h> 33 #include <parameters.h> 34 #ifdef NEW_RENDER_CONTEXT 35 #include "render_context_base.h" 36 #include "rs_render_surface.h" 37 #else 38 #include <render_context/render_context.h> 39 #endif 40 #include <system_ability_definition.h> 41 #include <ui/rs_surface_extractor.h> 42 #include <window.h> 43 #include <window_option.h> 44 #include <window_scene.h> 45 #include "boot_animationconfig.h" 46 #include "boot_videoplayer.h" 47 #include "event_handler.h" 48 #include "player.h" 49 #include "vsync_receiver.h" 50 #include "util.h" 51 52 namespace OHOS { 53 class BootAnimation { 54 public: 55 void Init(Rosen::ScreenId defaultId, int32_t width, int32_t height); 56 void Draw(); 57 bool CheckExitAnimation(); 58 void PlaySound(); 59 void PlayVideo(); 60 void Run(Rosen::ScreenId id, int screenWidth, int screenHeight); 61 ~BootAnimation(); 62 void CloseVideoPlayer(); 63 private: 64 void OnVsync(); 65 void OnDraw(SkCanvas* canvas, int32_t curNo); 66 void InitRsSurface(); 67 void InitRsSurfaceNode(); 68 void InitPicCoordinates(); 69 int32_t windowWidth_; 70 int32_t windowHeight_; 71 Rosen::ScreenId defaultId_; 72 sptr<OHOS::Rosen::Window> window_; 73 sptr<OHOS::Rosen::WindowScene> scene_; 74 #ifdef NEW_RENDER_CONTEXT 75 std::shared_ptr<OHOS::Rosen::RenderContextBase> renderContext_; 76 std::shared_ptr<OHOS::Rosen::RSRenderSurface> rsSurface_; 77 #else 78 std::unique_ptr<OHOS::Rosen::RSSurfaceFrame> framePtr_; 79 std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface_; 80 OHOS::Rosen::RenderContext* rc_; 81 #endif 82 std::shared_ptr<OHOS::Rosen::RSSurfaceNode> rsSurfaceNode_; 83 int32_t freq_ = 30; 84 int32_t realHeight_ = 0; 85 int32_t realWidth_ = 0; 86 int32_t pointX_ = 0; 87 int32_t pointY_ = 0; 88 int32_t picCurNo_ = -1; 89 int32_t imgVecSize_ = 0; 90 std::shared_ptr<OHOS::Rosen::VSyncReceiver> receiver_; 91 std::shared_ptr<Media::Player> soundPlayer_; 92 ImageStructVec imageVector_; 93 std::shared_ptr<OHOS::AppExecFwk::EventHandler> mainHandler_; 94 std::shared_ptr<AppExecFwk::EventRunner> runner_; 95 bool isAnimationEnd_ = false; 96 std::shared_ptr<BootVideoPlayer> bootVideoPlayer_; 97 BootAnimationConfig animationConfig_; 98 OHOS::FrameCallback fcb_; 99 }; 100 } // namespace OHOS 101 102 #endif // FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_ANIMATION_H 103