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