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 BUILDER_H 17 #define BUILDER_H 18 19 #include <memory> 20 #include <unordered_map> 21 #include <vector> 22 #include "cJSON.h" 23 #include "image_chain.h" 24 #include "gaussian_blur_filter.h" 25 #include "input.h" 26 #include "output.h" 27 #include "saturation_filter.h" 28 #include "contrast_filter.h" 29 #include "brightness_filter.h" 30 #include "filter_factory.h" 31 32 namespace OHOS { 33 namespace Rosen { 34 class Builder { 35 public: 36 ImageChain* CreateFromConfig(std::string path); 37 38 private: 39 void AnalyseFilters(cJSON* filters); 40 void ParseParams(std::shared_ptr<Filter> filter, cJSON* params); 41 void ParseArray(std::shared_ptr<Filter> filter, cJSON* childParam); 42 void ConnectPipeline(cJSON* connections); 43 std::unordered_map<std::string, std::string> nameType_; 44 std::unordered_map<std::string, std::shared_ptr<Filter>> nameFilter_; 45 std::vector<std::shared_ptr<Input>> inputs_; 46 std::shared_ptr<cJSON> filters_ = nullptr; 47 std::shared_ptr<cJSON> connections_ = nullptr; 48 std::shared_ptr<FilterFactory> filterFactory = std::make_shared<FilterFactory>(); 49 }; 50 } // namespace Rosen 51 } // namespace OHOS 52 #endif // BUILDER_H 53