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 OHOS_ROSEN_SCENE_SESSION_DIRTY_MANAGER_H 17 #define OHOS_ROSEN_SCENE_SESSION_DIRTY_MANAGER_H 18 19 20 #include <map> 21 22 #include "common/rs_vector4.h" 23 #include "display_manager.h" 24 #include "session/host/include/scene_session.h" 25 #include "session/screen/include/screen_session.h" 26 #include "screen_session_manager/include/screen_session_manager.h" 27 #include "input_manager.h" 28 29 namespace OHOS::Rosen { 30 struct SecSurfaceInfo; 31 struct SecRectInfo; 32 MMI::Direction ConvertDegreeToMMIRotation(float degree); 33 std::string DumpWindowInfo(const MMI::WindowInfo& info); 34 std::string DumpRect(const std::vector<MMI::Rect>& rects); 35 36 struct SingleHandData { 37 float scaleX = 1.0f; 38 float scaleY = 1.0f; 39 float singleHandX = 0.f; 40 float singleHandY = 0.f; 41 float pivotX = 0.f; 42 float pivotY = 0.f; 43 SingleHandMode mode = SingleHandMode::MIDDLE; 44 }; 45 46 class SceneSessionDirtyManager { 47 private: 48 enum WindowAction : uint32_t { 49 UNKNOWN = 0, 50 WINDOW_ADD, 51 WINDOW_DELETE, 52 WINDOW_CHANGE, 53 WINDOW_ADD_END 54 }; 55 56 using ScreenInfoChangeListener = std::function<void(int32_t)>; 57 using FlushWindowInfoCallback = std::function<void()>; 58 public: 59 SceneSessionDirtyManager() = default; 60 virtual ~SceneSessionDirtyManager() = default; 61 62 void NotifyWindowInfoChange(const sptr<SceneSession>& sceneSession, 63 const WindowUpdateType& type, const bool startMoving = false); 64 std::pair<std::vector<MMI::WindowInfo>, std::vector<std::shared_ptr<Media::PixelMap>>> 65 GetFullWindowInfoList(); 66 void RegisterFlushWindowInfoCallback(FlushWindowInfoCallback&& callback); 67 void ResetSessionDirty(); 68 void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap); 69 void UpdateConstrainedModalUIExtInfo(const std::map<uint64_t, 70 std::vector<SecSurfaceInfo>>& constrainedModalUIExtInfoMap); 71 bool GetLastConstrainedModalUIExtInfo(const sptr<SceneSession>& sceneSession, 72 SecSurfaceInfo& constrainedModalUIExtInfo); 73 74 private: 75 std::vector<MMI::WindowInfo> FullSceneSessionInfoUpdate() const; 76 bool IsFilterSession(const sptr<SceneSession>& sceneSession) const; 77 std::pair<MMI::WindowInfo, std::shared_ptr<Media::PixelMap>> 78 GetWindowInfo(const sptr<SceneSession>& sceneSession, const WindowAction& action) const; 79 SingleHandData GetSingleHandData(const sptr<SceneSession>& sceneSession) const; 80 void CalNotRotateTransform(const sptr<SceneSession>& sceneSession, Matrix3f& transform, 81 bool useUIExtension = false) const; 82 void CalTransform(const sptr<SceneSession>& sceneSession, Matrix3f& transform, 83 const SingleHandData& singleHandData, bool useUIExtension = false) const; 84 void UpdatePrivacyMode(const sptr<SceneSession>& sceneSession, 85 MMI::WindowInfo& windowInfo) const; 86 std::map<int32_t, sptr<SceneSession>> GetDialogSessionMap( 87 const std::map<int32_t, sptr<SceneSession>>& sessionMap) const; 88 void UpdateHotAreas(const sptr<SceneSession>& sceneSession, std::vector<MMI::Rect>& touchHotAreas, 89 std::vector<MMI::Rect>& pointerHotAreas) const; 90 void UpdateDefaultHotAreas(sptr<SceneSession> sceneSession, std::vector<MMI::Rect>& touchHotAreas, 91 std::vector<MMI::Rect>& pointerHotAreas) const; 92 void UpdatePointerAreas(sptr<SceneSession> sceneSession, std::vector<int32_t>& pointerChangeAreas) const; 93 void UpdateWindowFlags(DisplayId displayId, const sptr<SceneSession>& sceneSession, 94 MMI::WindowInfo& windowInfo) const; 95 void AddModalExtensionWindowInfo(std::vector<MMI::WindowInfo>& windowInfoList, MMI::WindowInfo windowInfo, 96 const sptr<SceneSession>& sceneSession, const ExtensionWindowEventInfo& extensionInfo); 97 void GetModalUIExtensionInfo(std::vector<MMI::WindowInfo>& windowInfoList, 98 const sptr<SceneSession>& sceneSession, const MMI::WindowInfo& hostWindowInfo); 99 std::vector<MMI::WindowInfo> GetSecSurfaceWindowinfoList(const sptr<SceneSession>& sceneSession, 100 const MMI::WindowInfo& hostWindowinfo, const Matrix3f& hostTransform) const; 101 MMI::WindowInfo GetSecComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo, 102 const MMI::WindowInfo& hostWindowinfo, const sptr<SceneSession>& sceneSession, 103 const Matrix3f hostTransform) const; 104 MMI::WindowInfo GetHostComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo, 105 const MMI::WindowInfo& hostWindowinfo, const Matrix3f hostTransform) const; 106 MMI::WindowInfo MakeWindowInfoFormHostWindow(const MMI::WindowInfo& hostWindowinfo) const; 107 void ResetFlushWindowInfoTask(); 108 void CheckIfUpdatePointAreas(WindowType windowType, const sptr<SceneSession>& sceneSession, 109 const sptr<WindowSessionProperty>& windowSessionProperty, std::vector<int32_t>& pointerChangeAreas) const; 110 std::mutex mutexlock_; 111 mutable std::shared_mutex secSurfaceInfoMutex_; 112 mutable std::shared_mutex constrainedModalUIExtInfoMutex_; 113 FlushWindowInfoCallback flushWindowInfoCallback_; 114 std::atomic_bool sessionDirty_ { false }; 115 std::atomic_bool hasPostTask_ { false }; 116 std::map<uint64_t, std::vector<SecSurfaceInfo>> secSurfaceInfoMap_; 117 std::map<uint64_t, std::vector<SecSurfaceInfo>> constrainedModalUIExtInfoMap_; 118 }; 119 } //namespace OHOS::Rosen 120 121 #endif