• 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 "graphic_feature_param_manager.h"
17 
18 #include "platform/common/rs_log.h"
19 
20 namespace OHOS::Rosen {
GetInstance()21 GraphicFeatureParamManager& GraphicFeatureParamManager::GetInstance()
22 {
23     static GraphicFeatureParamManager instance;
24     return instance;
25 }
26 
GraphicFeatureParamManager()27 GraphicFeatureParamManager::GraphicFeatureParamManager()
28 {
29 }
30 
~GraphicFeatureParamManager()31 GraphicFeatureParamManager::~GraphicFeatureParamManager() noexcept
32 {
33 }
34 
Init()35 void GraphicFeatureParamManager::Init()
36 {
37     RS_LOGI("GraphicFeatureParamManager %{public}s : Init feature map", __func__);
38     // Init feature configs
39     for (const auto& module : FEATURE_MODULES) {
40         featureParseMap_.emplace(module.name, module.xmlParser());
41         featureParamMap_.emplace(module.name, module.featureParam());
42     }
43 
44     // Start parse feature
45     FeatureParamParseEntry();
46 }
47 
FeatureParamParseEntry()48 void GraphicFeatureParamManager::FeatureParamParseEntry()
49 {
50     RS_LOGI("GraphicFeatureParamManager %{public}s : In", __func__);
51     if (!featureParser_) {
52         featureParser_ = std::make_unique<XMLParserBase>();
53     }
54 
55     if (featureParser_->LoadGraphicConfiguration(graphicConfigPath_) != PARSE_EXEC_SUCCESS) {
56         RS_LOGD("GraphicFeatureParamManager failed to load xml configuration file");
57         return;
58     }
59 
60     if (featureParser_->ParseSysDoc() != PARSE_EXEC_SUCCESS) {
61         RS_LOGD("GraphicFeatureParamManager failed to parse sys xml configuration");
62     }
63 
64     if (featureParser_->ParseProdDoc() != PARSE_EXEC_SUCCESS) {
65         RS_LOGD("GraphicFeatureParamManager failed to parse prod xml configuration");
66     }
67 }
68 
GetFeatureParam(std::string featureName)69 std::shared_ptr<FeatureParam> GraphicFeatureParamManager::GetFeatureParam(std::string featureName)
70 {
71     RS_LOGD("GraphicFeatureParamManager %{public}s : %{public}s", __func__, featureName.c_str());
72 
73     auto iter = featureParamMap_.find(featureName);
74     if (iter == featureParamMap_.end()) {
75         RS_LOGD("GraphicFeatureParamManager %{public}s : %{public}s failed", __func__, featureName.c_str());
76         return nullptr;
77     }
78 
79     return iter->second;
80 }
81 } // namespace OHOS::Rosen