• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
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 #include "display_device.h"
16 #include "components/root_view.h"
17 #include "draw/draw_utils.h"
18 #include "fbdev.h"
19 
20 namespace OHOS
21 {
GetInstance()22 DisplayDevice *DisplayDevice::GetInstance()
23 {
24     static DisplayDevice instance;
25     if (!instance.isRegister_) {
26         FbdevInit();
27         instance.isRegister_ = true;
28 #ifdef CONFIG_DISPLAY_RM69330
29         instance.SetScreenShape(CIRCLE);
30 #endif
31     }
32     return &instance;
33 }
34 
GetFBBufferInfo()35 BufferInfo *DisplayDevice::GetFBBufferInfo()
36 {
37     static BufferInfo bufferInfo;
38     LiteSurfaceData *surfaceData = GetDevSurfaceData();
39     bufferInfo.rect = {0, 0, HORIZONTAL_RESOLUTION - 1, VERTICAL_RESOLUTION - 1};
40     bufferInfo.mode = ARGB8888;
41     bufferInfo.color = 0x44;
42     bufferInfo.phyAddr = surfaceData->phyAddr;
43     bufferInfo.virAddr = surfaceData->virAddr;
44     // 3: Shift right 3 bits
45     bufferInfo.stride = HORIZONTAL_RESOLUTION * (DrawUtils::GetPxSizeByColorMode(bufferInfo.mode) >> 3);
46     bufferInfo.width = HORIZONTAL_RESOLUTION;
47     bufferInfo.height = VERTICAL_RESOLUTION;
48     this->fbAddr = surfaceData->phyAddr;
49     return &bufferInfo;
50 }
51 
UpdateFBBuffer()52 void DisplayDevice::UpdateFBBuffer()
53 {
54     BufferInfo *bufferInfo = DisplayDevice::GetInstance()->GetFBBufferInfo();
55     if (this->fbAddr != bufferInfo->phyAddr) {
56         this->fbAddr = bufferInfo->phyAddr;
57         RootView::GetInstance()->UpdateBufferInfo(bufferInfo);
58         // Get the newest fbAddr, ensure that the buffer is available before TaskHandler()
59     }
60 }
61 
Flush(const Rect & flushRect)62 void DisplayDevice::Flush(const Rect& flushRect)
63 {
64     FbdevFlush();
65 }
66 
67 } // namespace OHOS
68