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