• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 
18 namespace OHOS {
19 namespace HDI {
20 namespace DISPLAY {
HdiComposer(std::unique_ptr<HdiComposition> pre,std::unique_ptr<HdiComposition> post)21 HdiComposer::HdiComposer(std::unique_ptr<HdiComposition> pre, std::unique_ptr<HdiComposition> post)
22 {
23     mPreComp = std::move(pre);
24     mPostComp = std::move(post);
25 }
26 
Prepare(std::vector<HdiLayer * > & layers,HdiLayer & clientLayer)27 int32_t HdiComposer::Prepare(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer)
28 {
29     if (mPreComp == nullptr) {
30         DISPLAY_LOGD("HdiComposer::Prepare mPreComp is null");
31 	    return DISPLAY_FAILURE;
32 	}
33 	int ret = mPreComp->SetLayers(layers, clientLayer);
34     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("pre composition prepare failed"));
35     ret = mPostComp->SetLayers(layers, clientLayer);
36     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("post composition prepare failed"));
37     return DISPLAY_SUCCESS;
38 }
39 
Commit(bool modeSet)40 int32_t HdiComposer::Commit(bool modeSet)
41 {
42 	if (mPreComp == nullptr) {
43         DISPLAY_LOGD("HdiComposer::Commit mPreComp is null");
44 	    return DISPLAY_FAILURE;
45 	}
46 	int ret = mPreComp->Apply(modeSet);
47     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("pre composition apply failed"));
48     DISPLAY_LOGD("commit modSet=%{public}d", modeSet);
49     ret = mPostComp->Apply(modeSet);
50     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("post composition apply failed"));
51     return DISPLAY_SUCCESS;
52 }
53 } // OHOS
54 } // HDI
55 } // DISPLAY
56