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