• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef OHOS_ROSEN_UI_EFFECT_CONTROLLR_MANAGER_H
16 #define OHOS_ROSEN_UI_EFFECT_CONTROLLR_MANAGER_H
17 #include <tuple>
18 
19 #include "ui_effect_controller.h"
20 #include "ui_effect_controller_client_interface.h"
21 #include "ui_effect_controller_common.h"
22 #include "wm_common.h"
23 #include "wm_single_instance.h"
24 
25 namespace OHOS::Rosen {
26 class UIEffectManager {
27 WM_DECLARE_SINGLE_INSTANCE(UIEffectManager)
28 public:
29     using NotifyUIEffectSetParamFunc = UIEffectController::SetParamsFunc;
30     using NotifyUIEffectAnimateToFunc = UIEffectController::AnimateToFunc;
31     using ControllerList = std::tuple<sptr<UIEffectController>,
32         sptr<IUIEffectControllerClient>, sptr<UIEffectControllerClientDeath>>;
33     void RegisterUIEffectSetParamsCallback(NotifyUIEffectSetParamFunc func);
34     void RegisterUIEffectAnimateToCallback(NotifyUIEffectAnimateToFunc func);
35 
36     WMError CreateUIEffectController(const sptr<IUIEffectControllerClient>& controllerClient,
37         sptr<IUIEffectController>& controller, int32_t& controllerId);
38     NotifyUIEffectSetParamFunc onUIEffectSetParams_;
39     NotifyUIEffectAnimateToFunc onUIEffectAnimateTo_;
40     void EraseUIEffectController(int32_t id);
41     void SetUIEffectControllerAliveState(int32_t id, bool isAlive);
42 
43 private:
44     bool IsControllerListValid(const ControllerList& list) const;
45     std::mutex UIEffectControllerMapMutex_;
46     std::unordered_map<int32_t, ControllerList> UIEffectControllerMap_;
47 };
48 }
49 #endif