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 void DumpConfig(); 37 static std::vector<DMRect> GetCutoutBoundaryRect(); 38 static void SetCutoutSvgPath(const std::string& svgPath); 39 static bool IsWaterfallDisplay(); 40 static void SetCurvedCompressionAreaInLandscape(); 41 static std::vector<int> GetCurvedScreenBoundaryConfig(); 42 static uint32_t GetCurvedCompressionAreaInLandscape(); 43 44 private: 45 static std::map<std::string, bool> enableConfig_; 46 static std::map<std::string, std::vector<int>> intNumbersConfig_; 47 static std::map<std::string, std::string> stringConfig_; 48 static std::vector<DMRect> cutoutBoundaryRect_; 49 static bool isWaterfallDisplay_; 50 static bool isScreenCompressionEnableInLandscape_; 51 static uint32_t curvedAreaInLandscape_; 52 53 static bool IsValidNode(const xmlNode& currNode); 54 static void ReadEnableConfigInfo(const xmlNodePtr& currNode); 55 static void ReadIntNumbersConfigInfo(const xmlNodePtr& currNode); 56 static void ReadStringConfigInfo(const xmlNodePtr& currNode); 57 static std::string GetConfigPath(const std::string& configFileName); 58 59 static std::vector<std::string> Split(std::string str, std::string pattern); 60 static bool IsNumber(std::string str); 61 static DMRect CalcCutoutBoundaryRect(const std::string svgPath); 62 }; 63 } // namespace OHOS::Rosen 64 #endif // OHOS_ROSEN_SCREEN_SCENE_CONFIG_H 65