• 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 "mem_param_parse.h"
17 
18 namespace OHOS::Rosen {
19 
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t MEMParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
21 {
22     RS_LOGI("MEMParamParse start");
23     xmlNode *currNode = &node;
24     if (currNode == nullptr || currNode->xmlChildrenNode == nullptr) {
25         RS_LOGD("MEMParamParse stop parsing, no nodes");
26         return PARSE_GET_CHILD_FAIL;
27     }
28 
29     currNode = currNode->xmlChildrenNode;
30     for (; currNode; currNode = currNode->next) {
31         if (currNode->type != XML_ELEMENT_NODE) {
32             continue;
33         }
34 
35         if (ParseMemInternal(featureMap, *currNode) != PARSE_EXEC_SUCCESS) {
36             RS_LOGD("MEMParamParse stop parsing, parse internal fail");
37             return PARSE_INTERNAL_FAIL;
38         }
39     }
40 
41     return PARSE_EXEC_SUCCESS;
42 }
43 
ParseMemInternal(FeatureParamMapType & featureMap,xmlNode & node)44 int32_t MEMParamParse::ParseMemInternal(FeatureParamMapType &featureMap, xmlNode &node)
45 {
46     xmlNode *currNode = &node;
47 
48     auto iter = featureMap.find(FEATURE_CONFIGS[MEM]);
49     if (iter != featureMap.end()) {
50         memParam_ = std::static_pointer_cast<MEMParam>(iter->second);
51     } else {
52         RS_LOGD("MEMParamParse stop parsing, no initializing param map");
53         return PARSE_NO_PARAM;
54     }
55 
56     // Start Parse Feature Params
57     int xmlParamType = GetXmlNodeAsInt(*currNode);
58     auto name = ExtractPropertyValue("name", *currNode);
59     auto val = ExtractPropertyValue("value", *currNode);
60     if (xmlParamType == PARSE_XML_FEATURE_SINGLEPARAM) {
61         if (name == "RsWatchPoint") {
62             memParam_->SetRSWatchPoint(val);
63             RS_LOGI("MEMParamParse parse RSWatchPoint %{public}s", memParam_->GetRSWatchPoint().c_str());
64         }
65     }
66 
67     return PARSE_EXEC_SUCCESS;
68 }
69 } // namespace OHOS::Rosen