18void QEglFSRcarIntegration::platformInit()
22 QEglFSDeviceIntegration::platformInit();
26 mScreenSize = q_screenSizeFromFb(0);
27 mNativeDisplay = (NativeDisplayType)EGL_DEFAULT_DISPLAY;
29 mNativeDisplayID = qEnvironmentVariableIntValue(
"QT_QPA_WM_DISP_ID", &ok);
33 r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID);
34 if (wm_err != R_WM_ERR_OK)
35 qFatal(
"Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err);
36 wm_err = R_WM_ScreenBgColorSet(mNativeDisplayID, 0x20, 0x20, 0x20);
37 if (wm_err != R_WM_ERR_OK)
38 qFatal(
"Failed to set screen background: %d", wm_err);
39 wm_err = R_WM_ScreenEnable(mNativeDisplayID);
40 if (wm_err != R_WM_ERR_OK)
41 qFatal(
"Failed to enable screen: %d", wm_err);
56 const int a = format.alphaBufferSize();
57 const int r = format.redBufferSize();
58 const int g = format.greenBufferSize();
59 const int b = format.blueBufferSize();
63 if (g == 4 && b == 4 && a == 4)
64 return R_WM_COLORFMT_ARGB4444;
67 if (g == 6 && b == 5 && a == 0)
68 return R_WM_COLORFMT_RGB565;
69 else if (g == 5 && b == 5 && a == 1)
70 return R_WM_COLORFMT_ARGB1555;
73 if (g == 8 && b == 8 && a == 0)
74 return R_WM_COLORFMT_RGB0888;
75 else if (g == 8 && b == 8 && a == 8)
76 return R_WM_COLORFMT_ARGB8888;
80 qFatal(
"Unsupported color format: R:%d G:%d B:%d A:%d", r, g, b, a);
81 return R_WM_COLORFMT_LAST;
84EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *window,
const QSize &size,
const QSurfaceFormat &format)
88 mNativeWindow = (EGLNativeWindowTypeREL*)malloc(
sizeof(EGLNativeWindowTypeREL));
89 memset(mNativeWindow, 0,
sizeof(EGLNativeWindowTypeREL));
91 mNativeWindow->ColorFmt = getWMColorFormat(format);
92 mNativeWindow->PosX = 0;
93 mNativeWindow->PosY = 0;
94 mNativeWindow->PosZ = qEnvironmentVariableIntValue(
"QT_QPA_WM_LAYER", &ok);
97 mNativeWindow->Pitch = size.width();
98 mNativeWindow->Width = size.width();
99 mNativeWindow->Height = size.height();
100 mNativeWindow->Alpha = format.alphaBufferSize();
102 if (format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior)
103 mNativeWindow->Surface.BufNum = 3;
105 mNativeWindow->Surface.BufNum = format.swapBehavior();
107 mNativeWindow->Surface.Type = R_WM_SURFACE_FB;
108 mNativeWindow->Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL;
110 r_wm_Error_t wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow);
111 if (wm_err != R_WM_ERR_OK)
112 qFatal(
"Failed to create window layer: %d", wm_err);
113 wm_err = R_WM_DevEventRegister(mNativeDisplayID, R_WM_EVENT_VBLANK, 0);
114 if (wm_err != R_WM_ERR_OK)
115 qFatal(
"Failed to Register vsync event: %d", wm_err);
116 wm_err = R_WM_WindowEnable(mNativeDisplayID, mNativeWindow);
117 if (wm_err != R_WM_ERR_OK)
118 qFatal(
"Failed to Enable window surface: %d", wm_err);
120 return static_cast<EGLNativeWindowType>(mNativeWindow);
123void QEglFSRcarIntegration::destroyNativeWindow(EGLNativeWindowType window)
125 R_WM_WindowDisable(mNativeDisplayID, mNativeWindow);
127 R_WM_WindowDelete(mNativeDisplayID, mNativeWindow);
128 R_WM_DevDeinit(mNativeDisplayID);