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 49 void UpdateRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, bool isAdd); 50 void InitRSDisplayNode(RSDisplayNodeConfig& config); 51 52 // colorspace, gamut 53 DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts); 54 DMError GetScreenColorGamut(ScreenColorGamut& colorGamut); 55 DMError SetScreenColorGamut(int32_t colorGamutIdx); 56 DMError GetScreenGamutMap(ScreenGamutMap& gamutMap); 57 DMError SetScreenGamutMap(ScreenGamutMap gamutMap); 58 DMError SetScreenColorTransform(); 59 60 const std::string name_; 61 const ScreenId dmsId_; 62 const ScreenId rsId_; 63 bool isScreenGroup_ { false }; 64 std::shared_ptr<RSDisplayNode> rsDisplayNode_; 65 RSDisplayNodeConfig rSDisplayNodeConfig_; 66 ScreenId groupDmsId_ { SCREEN_ID_INVALID }; 67 ScreenType type_ { ScreenType::REAL }; 68 int32_t activeIdx_ { 0 }; 69 std::vector<sptr<SupportedScreenModes>> modes_ = {}; 70 float virtualPixelRatio_ = { 1.0 }; 71 Orientation orientation_ { Orientation::UNSPECIFIED }; 72 Rotation rotation_ { Rotation::ROTATION_0 }; 73 Orientation screenRequestedOrientation_ { Orientation::UNSPECIFIED }; 74 protected: 75 void FillScreenInfo(sptr<ScreenInfo>) const; 76 const sptr<AbstractScreenController> screenController_; 77 }; 78 79 class AbstractScreenGroup : public AbstractScreen { 80 public: 81 AbstractScreenGroup(sptr<AbstractScreenController>, ScreenId dmsId, ScreenId rsId, std::string name, 82 ScreenCombination combination); 83 AbstractScreenGroup() = delete; 84 WM_DISALLOW_COPY_AND_MOVE(AbstractScreenGroup); 85 ~AbstractScreenGroup(); 86 87 bool AddChild(sptr<AbstractScreen>& dmsScreen, Point& startPoint); 88 bool AddChildren(std::vector<sptr<AbstractScreen>>& dmsScreens, std::vector<Point>& startPoints); 89 bool RemoveChild(sptr<AbstractScreen>& dmsScreen); 90 bool HasChild(ScreenId childScreen) const; 91 std::vector<sptr<AbstractScreen>> GetChildren() const; 92 std::vector<Point> GetChildrenPosition() const; 93 size_t GetChildCount() const; 94 sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const; 95 96 ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; 97 ScreenId mirrorScreenId_ { SCREEN_ID_INVALID }; 98 99 private: 100 bool GetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config); 101 102 std::map<ScreenId, std::pair<sptr<AbstractScreen>, Point>> abstractScreenMap_; 103 }; 104 } // namespace OHOS::Rosen 105 #endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H