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 "multiscreen_param_parse.h"
17
18 namespace OHOS::Rosen {
19
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t MultiScreenParamParse::ParseFeatureParam([[maybe_unused]] FeatureParamMapType& featureMap, xmlNode& node)
21 {
22 RS_LOGI("MultiScreenParamParse start");
23 xmlNode *currNode = &node;
24 if (currNode->xmlChildrenNode == nullptr) {
25 RS_LOGW("MultiScreenParamParse stop parsing, no children 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 (ParseMultiScreenInternal(*currNode) != PARSE_EXEC_SUCCESS) {
36 RS_LOGW("MultiScreenParamParse stop parsing, parse internal fail");
37 return PARSE_INTERNAL_FAIL;
38 }
39 }
40 RS_LOGI("MultiScreenParamParse end, isExternalScreenSecure: %{public}d, isSlrScaleEnabled: %{public}d,"
41 " isRsReportHwcDead: %{public}d, isRsSetScreenPowerStatus: %{public}d, isMirrorDisplayCloseP3: %{public}d,"
42 " mipMapModeValue: %{public}d",
43 MultiScreenParam::IsExternalScreenSecure(), MultiScreenParam::IsSlrScaleEnabled(),
44 MultiScreenParam::IsRsReportHwcDead(), MultiScreenParam::IsRsSetScreenPowerStatus(),
45 MultiScreenParam::IsMirrorDisplayCloseP3(), MultiScreenParam::GetMipmapMode());
46 return PARSE_EXEC_SUCCESS;
47 }
48
ParseMultiScreenInternal(xmlNode & node)49 int32_t MultiScreenParamParse::ParseMultiScreenInternal(xmlNode& node)
50 {
51 xmlNode *currNode = &node;
52
53 // Start Parse Feature Params
54 int xmlParamType = GetXmlNodeAsInt(*currNode);
55 auto name = ExtractPropertyValue("name", *currNode);
56 auto val = ExtractPropertyValue("value", *currNode);
57 if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
58 bool isEnabled = ParseFeatureSwitch(val);
59 if (name == "IsExternalScreenSecure") {
60 MultiScreenParam::SetExternalScreenSecure(isEnabled);
61 } else if (name == "IsSlrScaleEnabled") {
62 MultiScreenParam::SetSlrScaleEnabled(isEnabled);
63 } else if (name == "IsRsReportHwcDead") {
64 MultiScreenParam::SetRsReportHwcDead(isEnabled);
65 } else if (name == "IsRsSetScreenPowerStatus") {
66 MultiScreenParam::SetRsSetScreenPowerStatus(isEnabled);
67 } else if (name == "IsMirrorDisplayCloseP3") {
68 MultiScreenParam::SetMirrorDisplayCloseP3(isEnabled);
69 }
70 } else if (xmlParamType == PARSE_XML_FEATURE_SINGLEPARAM) {
71 if (name == "MipmapMode" && IsNumber(val)) {
72 int num = atoi(val.c_str());
73 if (num == 0) {
74 MultiScreenParam::SetMipmapMode(Drawing::MipmapMode::NONE);
75 RS_LOGI("Mipmapmode value %{public}d", MultiScreenParam::GetMipmapMode());
76 } else {
77 RS_LOGD("Mipmapmode use default value.");
78 }
79 } else {
80 RS_LOGW("MultiScreenParamParse unknown feature name.");
81 }
82 }
83 return PARSE_EXEC_SUCCESS;
84 }
85 } // namespace OHOS::Rosen