• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include <sstream>
17 #include "opinc_param_parse.h"
18 
19 namespace OHOS::Rosen {
20 
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)21 int32_t OPIncParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
22 {
23     RS_LOGI("OPIncParamParse start");
24     xmlNode *currNode = &node;
25     if (currNode->xmlChildrenNode == nullptr) {
26         RS_LOGD("OPIncParamParse stop parsing, no children nodes");
27         return PARSE_GET_CHILD_FAIL;
28     }
29 
30     currNode = currNode->xmlChildrenNode;
31     for (; currNode; currNode = currNode->next) {
32         if (currNode->type != XML_ELEMENT_NODE) {
33             continue;
34         }
35         ParseOPIncInternal(*currNode);
36     }
37     return PARSE_EXEC_SUCCESS;
38 }
39 
ParseOPIncInternal(xmlNode & node)40 int32_t OPIncParamParse::ParseOPIncInternal(xmlNode &node)
41 {
42     // Start Parse Feature Params
43     xmlNode *currNode = &node;
44     int xmlParamType = GetXmlNodeAsInt(*currNode);
45     auto name = ExtractPropertyValue("name", *currNode);
46     auto val = ExtractPropertyValue("value", *currNode);
47     if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
48         bool isEnabled = ParseFeatureSwitch(val);
49         if (name == "OPIncEnabled") {
50             OPIncParam::SetOPIncEnable(isEnabled);
51             RS_LOGI("OPIncParamParse parse OPIncEnabled %{public}d", OPIncParam::IsOPIncEnable());
52         }
53     } else if (xmlParamType == PARSE_XML_FEATURE_SINGLEPARAM) {
54         if (name == "CacheWidthThresholdPercentValue" && IsNumber(val)) {
55             int num;
56             std::istringstream iss(val);
57             if (iss >> num) {
58                 OPIncParam::SetCacheWidthThresholdPercentValue(num);
59                 RS_LOGI("OPIncParamParse parse CacheWidthThresholdPercentValue %{public}d",
60                     OPIncParam::GetCacheWidthThresholdPercentValue());
61             }
62         }
63     }
64 
65     return PARSE_EXEC_SUCCESS;
66 }
67 } // namespace OHOS::Rosen