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 #include "hdi_composer.h"
20 #include "hdi_video_composition.h"
21
22 namespace OHOS {
23 namespace HDI {
24 namespace DISPLAY {
HdiComposer(std::unique_ptr<HdiComposition> pre,std::unique_ptr<HdiComposition> post)25 HdiComposer::HdiComposer(std::unique_ptr<HdiComposition> pre, std::unique_ptr<HdiComposition> post)
26 {
27 preComp_.emplace_back(std::move(pre));
28 postComp_.emplace_back(std::move(post));
29 auto videoComp = std::make_unique<HdiVideoComposition>();
30 if (videoComp != nullptr) {
31 if (videoComp->Init() == DISPLAY_SUCCESS) {
32 AddPostComp(std::move(videoComp));
33 }
34 }
35 }
36
Prepare(std::vector<HdiLayer * > & layers,HdiLayer & clientLayer)37 int32_t HdiComposer::Prepare(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer)
38 {
39 DISPLAY_LOGD();
40 int32_t ret;
41 for (auto& composition : postComp_) {
42 ret = composition->SetLayers(layers, clientLayer);
43 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("post composition prepare failed"));
44 }
45
46 for (auto& composition : preComp_) {
47 ret = composition->SetLayers(layers, clientLayer);
48 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("pre composition prepare failed"));
49 }
50
51 return DISPLAY_SUCCESS;
52 }
53
Commit(bool modeSet)54 int32_t HdiComposer::Commit(bool modeSet)
55 {
56 DISPLAY_LOGD();
57 int32_t ret;
58 for (auto& composition : preComp_) {
59 ret = composition->Apply(modeSet);
60 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("pre composition prepare failed"));
61 }
62
63 for (auto& composition : postComp_) {
64 ret = composition->Apply(modeSet);
65 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("post composition prepare failed"));
66 }
67 return DISPLAY_SUCCESS;
68 }
69 } // OHOS
70 } // HDI
71 } // DISPLAY
72