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 "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, MMI::DisplayMode displayMode); 33 std::string DumpWindowInfo(const MMI::WindowInfo& info); 34 std::string DumpRect(const std::vector<MMI::Rect>& rects); 35 class SceneSessionDirtyManager { 36 private: 37 enum WindowAction : uint32_t { 38 UNKNOWN = 0, 39 WINDOW_ADD, 40 WINDOW_DELETE, 41 WINDOW_CHANGE, 42 WINDOW_ADD_END 43 }; 44 45 using ScreenInfoChangeListener = std::function<void(int32_t)>; 46 using FlushWindowInfoCallback = std::function<void()>; 47 public: 48 SceneSessionDirtyManager() = default; 49 virtual ~SceneSessionDirtyManager() = default; 50 51 void NotifyWindowInfoChange(const sptr<SceneSession>& sceneSession, 52 const WindowUpdateType& type, const bool startMoving = false); 53 std::pair<std::vector<MMI::WindowInfo>, std::vector<std::shared_ptr<Media::PixelMap>>> 54 GetFullWindowInfoList(); 55 void RegisterFlushWindowInfoCallback(const FlushWindowInfoCallback &&callback); 56 void ResetSessionDirty(); 57 void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap); 58 59 private: 60 std::vector<MMI::WindowInfo> FullSceneSessionInfoUpdate() const; 61 bool IsFilterSession(const sptr<SceneSession>& sceneSession) const; 62 std::pair<MMI::WindowInfo, std::shared_ptr<Media::PixelMap>> 63 GetWindowInfo(const sptr<SceneSession>& sceneSession, const WindowAction& action) const; 64 void CalNotRotateTransform(const sptr<SceneSession>& sceneSession, Matrix3f& transform, 65 bool useUIExtension = false) const; 66 void CalTransform(const sptr<SceneSession>& sceneSession, Matrix3f& transform, bool useUIExtension = false) const; 67 void UpdatePrivacyMode(const sptr<SceneSession>& sceneSession, 68 MMI::WindowInfo& windowInfo) const; 69 std::map<int32_t, sptr<SceneSession>> GetDialogSessionMap( 70 const std::map<int32_t, sptr<SceneSession>>& sessionMap) const; 71 void UpdateHotAreas(sptr<SceneSession> sceneSession, std::vector<MMI::Rect>& touchHotAreas, 72 std::vector<MMI::Rect>& pointerHotAreas) const; 73 void UpdateDefaultHotAreas(sptr<SceneSession> sceneSession, std::vector<MMI::Rect>& touchHotAreas, 74 std::vector<MMI::Rect>& pointerHotAreas) const; 75 void UpdatePointerAreas(sptr<SceneSession> sceneSession, std::vector<int32_t>& pointerChangeAreas) const; 76 void UpdateWindowFlags(DisplayId displayId, const sptr<SceneSession>& sceneSession, 77 MMI::WindowInfo& windowInfo) const; 78 void AddModalExtensionWindowInfo(std::vector<MMI::WindowInfo>& windowInfoList, MMI::WindowInfo windowInfo, 79 const sptr<SceneSession>& sceneSession, const ExtensionWindowEventInfo& extensionInfo); 80 std::vector<MMI::WindowInfo> GetSecSurfaceWindowinfoList(const sptr<SceneSession>& sceneSession, 81 const MMI::WindowInfo& hostWindowinfo, const Matrix3f& hostTransform) const; 82 MMI::WindowInfo GetSecComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo, 83 const MMI::WindowInfo& hostWindowinfo, const sptr<SceneSession>& sceneSession, 84 const Matrix3f hostTransform) const; 85 MMI::WindowInfo GetHostComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo, 86 const MMI::WindowInfo& hostWindowinfo, const Matrix3f hostTransform) const; 87 MMI::WindowInfo MakeWindowInfoFormHostWindow(const SecRectInfo& secRectInfo, 88 const MMI::WindowInfo& hostWindowinfo) const; 89 void ResetFlushWindowInfoTask(); 90 void CheckIfUpdatePointAreas(const sptr<SceneSession>& sceneSession, 91 const sptr<WindowSessionProperty>& windowSessionProperty, WindowType windowType, 92 std::vector<int32_t>& pointerChangeAreas) const; 93 std::mutex mutexlock_; 94 mutable std::shared_mutex secSurfaceInfoMutex_; 95 FlushWindowInfoCallback flushWindowInfoCallback_; 96 std::atomic_bool sessionDirty_ { false }; 97 std::atomic_bool hasPostTask_ { false }; 98 std::map<uint64_t, std::vector<SecSurfaceInfo>> secSurfaceInfoMap_; 99 }; 100 } //namespace OHOS::Rosen 101 102 #endif