/* * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ROSEN_STARTING_WINDOW_H #define OHOS_ROSEN_STARTING_WINDOW_H #include #include #include #include "ability_info.h" #include "animation_config.h" #include "bundle_info.h" #include "image_source.h" #include "pixel_map.h" #include "surface_draw.h" #include "window_node.h" #include "window_root.h" #include "window_transition_info.h" #include "wm_common.h" namespace OHOS { namespace Rosen { struct ResInfoShowState { uint32_t frameIdx = 0; uint32_t frameCount = 0; std::vector delay; std::chrono::steady_clock::time_point next; }; struct StartingWindowShowInfo { wptr node; Rect rect; std::shared_ptr info; float vpRatio; std::array resStates {}; std::array frameIndex {}; }; class StartingWindow : public RefBase { public: StartingWindow() = delete; ~StartingWindow() = default; static sptr CreateWindowNode(const sptr& info, uint32_t winId); static void HandleClientWindowCreate(sptr& node, sptr& window, uint32_t& windowId, const std::shared_ptr& surfaceNode, sptr& property, int32_t pid, int32_t uid); static WMError DrawStartingWindow(sptr& node, std::shared_ptr pixelMap, uint32_t bkgColor, bool isColdStart); static void AddNodeOnRSTree(sptr& node, bool isMultiDisplay); static void ReleaseStartWinSurfaceNode(sptr& node); static void SetDefaultWindowMode(WindowMode defaultMode); static void SetAnimationConfig(AnimationConfig config); static bool transAnimateEnable_; static WindowUIType windowUIType_; private: static WMError CreateLeashAndStartingSurfaceNode(sptr& node); static WMError SetStartingWindowAnimation(wptr weak); static void ChangePropertyByApiVersion(const sptr& info, const Orientation orientation, sptr& property); static std::recursive_mutex mutex_; static WindowMode defaultMode_; static AnimationConfig animationConfig_; static bool IsWindowFollowParent(WindowType type); static sptr InitializeWindowProperty(const sptr& info, uint32_t winId); static void UpdateRSTree(sptr& node, bool isMultiDisplay); static sptr GetBundleManager(); static std::shared_ptr GetAbilityInfoFromBMS(const sptr& node, const sptr& bundleMgr); static std::shared_ptr CreateResourceManager( const std::shared_ptr& abilityInfo); static std::shared_ptr GetPixelMapListInfo(uint32_t mediaDataId, const std::shared_ptr& resourceMgr, const std::shared_ptr& abilityInfo); static std::shared_ptr GetCustomStartingWindowInfo( const sptr& node, const sptr& bundleMgr); static std::shared_ptr DoGetCustomStartingWindowInfo( const std::shared_ptr& abilityInfo, const std::shared_ptr& resourceMgr); static WMError DrawStartingWindow(const std::shared_ptr& info, const sptr& node, const Rect& rect); static void RegisterStartingWindowShowInfo(const sptr& node, const Rect& rect, const std::shared_ptr& info, float vpRatio); static void UnRegisterStartingWindowShowInfo(); static void UpdateWindowShowInfo(StartingWindowShowInfo& startingWindowShowInfo, bool& needRedraw); static void DrawStartingWindowShowInfo(); static StartingWindowShowInfo startingWindowShowInfo_; static std::atomic startingWindowShowRunning_; static std::thread startingWindowShowThread_; static std::mutex firstFrameMutex_; static std::condition_variable firstFrameCondition_; static std::atomic firstFrameCompleted_; }; } // Rosen } // OHOS #endif // OHOS_ROSEN_STARTING_WINDOW_H