1 /* 2 * Copyright (c) 2021 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 HDI_COMPOSER_H 17 #define HDI_COMPOSER_H 18 #include <vector> 19 #include <memory> 20 #include "hdi_layer.h" 21 22 namespace OHOS { 23 namespace HDI { 24 namespace DISPLAY { 25 class HdiComposition { 26 public: HdiComposition()27 HdiComposition() {} Init()28 virtual int32_t Init() 29 { 30 return DISPLAY_SUCCESS; 31 } SetLayers(std::vector<HdiLayer * > & layers,HdiLayer & clientLayer)32 virtual int32_t SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer) 33 { 34 return DISPLAY_SUCCESS; 35 } Apply(bool modeSet)36 virtual int32_t Apply(bool modeSet) 37 { 38 return DISPLAY_SUCCESS; 39 } ~HdiComposition()40 virtual ~HdiComposition() {} 41 42 protected: 43 std::vector<HdiLayer *> mCompLayers; 44 }; 45 46 class HdiComposer { 47 public: 48 HdiComposer(std::unique_ptr<HdiComposition> pre, std::unique_ptr<HdiComposition> post); ~HdiComposer()49 virtual ~HdiComposer() {} 50 int32_t Prepare(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer); 51 int32_t Commit(bool modeSet); GetPreCompostion(uint32_t index)52 HdiComposition *GetPreCompostion(uint32_t index) 53 { 54 if (index >= preComp_.size()) { 55 DISPLAY_LOGE("the index is overflow index %{public}d", index); 56 return nullptr; 57 } 58 return preComp_[index].get(); 59 } 60 GetPostCompostion(uint32_t index)61 HdiComposition *GetPostCompostion(uint32_t index) 62 { 63 if (index >= postComp_.size()) { 64 DISPLAY_LOGE("the index is overflow index %{public}d", index); 65 return nullptr; 66 } 67 return postComp_[index].get(); 68 } 69 AddPostComp(std::unique_ptr<HdiComposition> post)70 void AddPostComp(std::unique_ptr<HdiComposition> post) 71 { 72 postComp_.emplace_back(std::move(post)); 73 } 74 private: 75 std::vector<std::unique_ptr<HdiComposition>> preComp_; 76 std::vector<std::unique_ptr<HdiComposition>> postComp_; 77 }; 78 } // namespace OHOS 79 } // namespace HDI 80 } // namespace DISPLAY 81 82 #endif // HDI_COMPOSER_H