1 /* 2 * Copyright (c) 2021-2022 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 FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H 17 #define FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H 18 19 20 #include <vector> 21 #include <map> 22 #include <refbase.h> 23 #include <screen_manager/screen_types.h> 24 #include <ui/rs_display_node.h> 25 #include <ui/rs_surface_node.h> 26 27 #include "noncopyable.h" 28 #include "screen.h" 29 #include "screen_group.h" 30 #include "screen_group_info.h" 31 #include "screen_info.h" 32 33 namespace OHOS::Rosen { 34 class AbstractScreenGroup; 35 class AbstractScreenController; 36 class AbstractScreen : public RefBase { 37 public: 38 AbstractScreen(sptr<AbstractScreenController>, const std::string& name, ScreenId dmsId, ScreenId rsId); 39 AbstractScreen() = delete; 40 WM_DISALLOW_COPY_AND_MOVE(AbstractScreen); 41 ~AbstractScreen(); 42 sptr<SupportedScreenModes> GetActiveScreenMode() const; 43 std::vector<sptr<SupportedScreenModes>> GetAbstractScreenModes() const; 44 sptr<AbstractScreenGroup> GetGroup() const; 45 sptr<ScreenInfo> ConvertToScreenInfo() const; 46 bool SetOrientation(Orientation orientation); 47 Rotation CalcRotation(Orientation orientation) const; 48 bool SetVirtualPixelRatio(float virtualPixelRatio); 49 float GetVirtualPixelRatio() const; 50 51 void UpdateRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, bool isAdd); 52 void UpdateDisplayGroupRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, NodeId parentNodeId, bool isAdd); 53 void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint); 54 ScreenId GetScreenGroupId() const; 55 56 // colorspace, gamut 57 DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts); 58 DMError GetScreenColorGamut(ScreenColorGamut& colorGamut); 59 DMError SetScreenColorGamut(int32_t colorGamutIdx); 60 DMError GetScreenGamutMap(ScreenGamutMap& gamutMap); 61 DMError SetScreenGamutMap(ScreenGamutMap gamutMap); 62 DMError SetScreenColorTransform(); 63 64 const std::string name_; 65 const ScreenId dmsId_; 66 const ScreenId rsId_; 67 bool isScreenGroup_ { false }; 68 std::shared_ptr<RSDisplayNode> rsDisplayNode_; 69 RSDisplayNodeConfig rSDisplayNodeConfig_; 70 ScreenId groupDmsId_ { SCREEN_ID_INVALID }; 71 ScreenId lastGroupDmsId_ { SCREEN_ID_INVALID }; 72 ScreenType type_ { ScreenType::REAL }; 73 int32_t activeIdx_ { 0 }; 74 std::vector<sptr<SupportedScreenModes>> modes_ = {}; 75 float virtualPixelRatio_ = { 1.0 }; 76 Orientation orientation_ { Orientation::UNSPECIFIED }; 77 Rotation rotation_ { Rotation::ROTATION_0 }; 78 Orientation screenRequestedOrientation_ { Orientation::UNSPECIFIED }; 79 protected: 80 void FillScreenInfo(sptr<ScreenInfo>) const; 81 const sptr<AbstractScreenController> screenController_; 82 }; 83 84 class AbstractScreenGroup : public AbstractScreen { 85 public: 86 AbstractScreenGroup(sptr<AbstractScreenController>, ScreenId dmsId, ScreenId rsId, std::string name, 87 ScreenCombination combination); 88 AbstractScreenGroup() = delete; 89 WM_DISALLOW_COPY_AND_MOVE(AbstractScreenGroup); 90 ~AbstractScreenGroup(); 91 92 bool AddChild(sptr<AbstractScreen>& dmsScreen, Point& startPoint); 93 bool AddChildren(std::vector<sptr<AbstractScreen>>& dmsScreens, std::vector<Point>& startPoints); 94 bool RemoveChild(sptr<AbstractScreen>& dmsScreen); 95 bool HasChild(ScreenId childScreen) const; 96 std::vector<sptr<AbstractScreen>> GetChildren() const; 97 std::vector<Point> GetChildrenPosition() const; 98 Point GetChildPosition(ScreenId screenId) const; 99 size_t GetChildCount() const; 100 sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const; 101 102 ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; 103 ScreenId mirrorScreenId_ { SCREEN_ID_INVALID }; 104 105 private: 106 bool GetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config); 107 108 std::map<ScreenId, std::pair<sptr<AbstractScreen>, Point>> abstractScreenMap_; 109 }; 110 } // namespace OHOS::Rosen 111 #endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H