• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "fb_composition.h"
20 #include <vector>
21 #include <memory>
22 #include <cerrno>
23 #include "display_bytrace.h"
24 #include "display_adapter.h"
25 namespace OHOS {
26 namespace HDI {
27 namespace DISPLAY {
FbFresh(int fd,HdiLayer & clientlayer,int & fence)28 int32_t FbComposition::FbFresh(int fd, HdiLayer &clientlayer, int &fence)
29 {
30     DISPLAY_LOGD();
31     DisplayFrameInfo fbFrameInfo;
32     fbFrameInfo.rect.x = 0;
33     fbFrameInfo.rect.y = 0;
34     fbFrameInfo.rect.w = clientlayer.GetCurrentBuffer()->GetWidth();
35     fbFrameInfo.rect.h = clientlayer.GetCurrentBuffer()->GetHeight();
36     fbFrameInfo.inFence = clientlayer.GetAcquireFenceFd();
37     fbFrameInfo.stride = clientlayer.GetCurrentBuffer()->GetStride();
38     fbFrameInfo.bufaddr = clientlayer.GetCurrentBuffer()->GetMemHandle();
39     fbFrameInfo.format = PIXEL_FMT_RGBA_8888;
40     DisplayBytrace trace("fbfresh");
41     if (DisplayAdapter::GetInstance()->FbFresh(fd, fbFrameInfo) != 0) {
42         DISPLAY_LOGE(" HIFB_REFRESH_FRAMEINFO Error! %{public}d", errno);
43     }
44     fence = fbFrameInfo.outFence;
45     return DISPLAY_SUCCESS;
46 }
47 
FbComposition(std::vector<int> & fbs)48 FbComposition::FbComposition(std::vector<int> &fbs)
49 {
50     DISPLAY_LOGD();
51     fds_ = fbs;
52 }
53 
~FbComposition()54 FbComposition::~FbComposition()
55 {
56     DISPLAY_LOGD();
57 }
58 
Init()59 int32_t FbComposition::Init()
60 {
61     DISPLAY_LOGD();
62     return HdiComposition::Init();
63 }
64 
SetLayers(std::vector<HdiLayer * > & layers,HdiLayer & clientLayer)65 int32_t FbComposition::SetLayers(std::vector<HdiLayer*> &layers, HdiLayer &clientLayer)
66 {
67     DISPLAY_LOGD();
68     mCompLayers.clear();
69     mCompLayers.push_back(&clientLayer);
70     return DISPLAY_SUCCESS;
71 }
72 
Apply(bool modeSet)73 int32_t FbComposition::Apply(bool modeSet)
74 {
75     DISPLAY_LOGD("mCompLayers size %{public}d", mCompLayers.size());
76     for (uint32_t i = 0; i < mCompLayers.size(); i++) {
77         int fence = -1;
78         HdiLayer *layer = mCompLayers[i];
79         DisplayBytrace trace("fb apply");
80         int ret = FbFresh(fds_[i], *layer, fence);
81         layer->SetReleaseFence(fence);
82         DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("fb fresh failed"));
83     }
84     return DISPLAY_SUCCESS;
85 }
86 } // OHOS
87 } // HDI
88 } // DISPLAY
89