1 /*
2  * Copyright (c) 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 OHOS_ROSEN_SCREEN_SCENE_CONFIG_H
17 #define OHOS_ROSEN_SCREEN_SCENE_CONFIG_H
18 
19 
20 #include <refbase.h>
21 
22 #include "cutout_info.h"
23 #include "xml_config_base.h"
24 #include "libxml/parser.h"
25 
26 namespace OHOS::Rosen {
27 class ScreenSceneConfig : public RefBase, public XmlConfigBase {
28 public:
29     ScreenSceneConfig() = delete;
30     ~ScreenSceneConfig() = default;
31 
32     static bool LoadConfigXml();
33     static const std::map<std::string, bool>& GetEnableConfig();
34     static const std::map<std::string, std::vector<int>>& GetIntNumbersConfig();
35     static const std::map<std::string, std::string>& GetStringConfig();
36     static const std::map<std::string, std::vector<std::string>>& GetStringListConfig();
37     static void DumpConfig();
38     static std::vector<DMRect> GetCutoutBoundaryRect(uint64_t displayId);
39     static std::vector<DMRect> GetSubCutoutBoundaryRect();
40     static void SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath);
41     static void SetSubCutoutSvgPath(const std::string& svgPath);
42     static bool IsWaterfallDisplay();
43     static void SetCurvedCompressionAreaInLandscape();
44     static std::vector<int> GetCurvedScreenBoundaryConfig();
45     static uint32_t GetCurvedCompressionAreaInLandscape();
46     static bool IsSupportRotateWithSensor();
47     static std::string GetExternalScreenDefaultMode();
48     static std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalConfig();
49     static bool IsSupportCapture();
50 
51 private:
52     static std::map<int32_t, std::string> xmlNodeMap_;
53     static std::map<std::string, bool> enableConfig_;
54     static std::map<std::string, std::vector<int>> intNumbersConfig_;
55     static std::map<std::string, std::string> stringConfig_;
56     static std::map<uint64_t, std::vector<DMRect>> cutoutBoundaryRectMap_;
57     static std::map<std::string, std::vector<std::string>> stringListConfig_;
58     static std::vector<DMRect> subCutoutBoundaryRect_;
59     static bool isWaterfallDisplay_;
60     static bool isScreenCompressionEnableInLandscape_;
61     static uint32_t curvedAreaInLandscape_;
62     static std::vector<DisplayPhysicalResolution> displayPhysicalResolution_;
63     static bool isSupportCapture_;
64 
65     static bool IsValidNode(const xmlNode& currNode);
66     static void ReadEnableConfigInfo(const xmlNodePtr& currNode);
67     static void ReadIntNumbersConfigInfo(const xmlNodePtr& currNode);
68     static void ReadStringConfigInfo(const xmlNodePtr& currNode);
69     static void ReadStringListConfigInfo(const xmlNodePtr& currNode, std::string name);
70     static std::string GetConfigPath(const std::string& configFileName);
71     static void ParseNodeConfig(const xmlNodePtr& currNode);
72 
73     static std::vector<std::string> Split(std::string str, std::string pattern);
74     static bool IsNumber(std::string str);
75     static DMRect CalcCutoutBoundaryRect(const std::string svgPath);
76     static void ReadPhysicalDisplayConfigInfo(const xmlNodePtr& currNode);
77 };
78 } // namespace OHOS::Rosen
79 #endif // OHOS_ROSEN_SCREEN_SCENE_CONFIG_H
80