1 /* 2 * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd 3 * This file contains confidential and proprietary information of 4 * OSWare Technology Co., Ltd 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef HDI_COMPOSER_H 20 #define HDI_COMPOSER_H 21 #include <vector> 22 #include <memory> 23 #include "hdi_layer.h" 24 25 namespace OHOS { 26 namespace HDI { 27 namespace DISPLAY { 28 class HdiComposition { 29 public: HdiComposition()30 HdiComposition() {} Init()31 virtual int32_t Init() 32 { 33 return DISPLAY_SUCCESS; 34 } SetLayers(std::vector<HdiLayer * > & layers,HdiLayer & clientLayer)35 virtual int32_t SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer) 36 { 37 return DISPLAY_SUCCESS; 38 } Apply(bool modeSet)39 virtual int32_t Apply(bool modeSet) 40 { 41 return DISPLAY_SUCCESS; 42 } ~HdiComposition()43 virtual ~HdiComposition() {} 44 45 protected: 46 std::vector<HdiLayer *> mCompLayers; 47 }; 48 49 class HdiComposer { 50 public: 51 HdiComposer(std::unique_ptr<HdiComposition> pre, std::unique_ptr<HdiComposition> post); ~HdiComposer()52 virtual ~HdiComposer() {} 53 int32_t Prepare(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer); 54 int32_t Commit(bool modeSet); GetPreCompostion(uint32_t index)55 HdiComposition *GetPreCompostion(uint32_t index) 56 { 57 if (index >= preComp_.size()) { 58 DISPLAY_LOGE("the index is overflow index %{public}d", index); 59 return nullptr; 60 } 61 return preComp_[index].get(); 62 } 63 GetPostCompostion(uint32_t index)64 HdiComposition *GetPostCompostion(uint32_t index) 65 { 66 if (index >= postComp_.size()) { 67 DISPLAY_LOGE("the index is overflow index %{public}d", index); 68 return nullptr; 69 } 70 return postComp_[index].get(); 71 } 72 AddPostComp(std::unique_ptr<HdiComposition> post)73 void AddPostComp(std::unique_ptr<HdiComposition> post) 74 { 75 postComp_.emplace_back(std::move(post)); 76 } 77 private: 78 std::vector<std::unique_ptr<HdiComposition>> preComp_; 79 std::vector<std::unique_ptr<HdiComposition>> postComp_; 80 }; 81 } // namespace OHOS 82 } // namespace HDI 83 } // namespace DISPLAY 84 85 #endif // HDI_COMPOSER_H