17void QEglFSRcarIntegration::platformInit()
21 QEglFSDeviceIntegration::platformInit();
25 mScreenSize = q_screenSizeFromFb(0);
26 mNativeDisplay = (NativeDisplayType)EGL_DEFAULT_DISPLAY;
28 mNativeDisplayID = qEnvironmentVariableIntValue(
"QT_QPA_WM_DISP_ID", &ok);
32 r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID);
33 if (wm_err != R_WM_ERR_OK)
34 qFatal(
"Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err);
35 wm_err = R_WM_ScreenBgColorSet(mNativeDisplayID, 0x20, 0x20, 0x20);
36 if (wm_err != R_WM_ERR_OK)
37 qFatal(
"Failed to set screen background: %d", wm_err);
38 wm_err = R_WM_ScreenEnable(mNativeDisplayID);
39 if (wm_err != R_WM_ERR_OK)
40 qFatal(
"Failed to enable screen: %d", wm_err);
55 const int a = format.alphaBufferSize();
56 const int r = format.redBufferSize();
57 const int g = format.greenBufferSize();
58 const int b = format.blueBufferSize();
62 if (g == 4 && b == 4 && a == 4)
63 return R_WM_COLORFMT_ARGB4444;
66 if (g == 6 && b == 5 && a == 0)
67 return R_WM_COLORFMT_RGB565;
68 else if (g == 5 && b == 5 && a == 1)
69 return R_WM_COLORFMT_ARGB1555;
72 if (g == 8 && b == 8 && a == 0)
73 return R_WM_COLORFMT_RGB0888;
74 else if (g == 8 && b == 8 && a == 8)
75 return R_WM_COLORFMT_ARGB8888;
79 qFatal(
"Unsupported color format: R:%d G:%d B:%d A:%d", r, g, b, a);
80 return R_WM_COLORFMT_LAST;
83EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *window,
const QSize &size,
const QSurfaceFormat &format)
87 mNativeWindow = (EGLNativeWindowTypeREL*)malloc(
sizeof(EGLNativeWindowTypeREL));
88 memset(mNativeWindow, 0,
sizeof(EGLNativeWindowTypeREL));
90 mNativeWindow->ColorFmt = getWMColorFormat(format);
91 mNativeWindow->PosX = 0;
92 mNativeWindow->PosY = 0;
93 mNativeWindow->PosZ = qEnvironmentVariableIntValue(
"QT_QPA_WM_LAYER", &ok);
96 mNativeWindow->Pitch = size.width();
97 mNativeWindow->Width = size.width();
98 mNativeWindow->Height = size.height();
99 mNativeWindow->Alpha = format.alphaBufferSize();
101 if (format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior)
102 mNativeWindow->Surface.BufNum = 3;
104 mNativeWindow->Surface.BufNum = format.swapBehavior();
106 mNativeWindow->Surface.Type = R_WM_SURFACE_FB;
107 mNativeWindow->Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL;
109 r_wm_Error_t wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow);
110 if (wm_err != R_WM_ERR_OK)
111 qFatal(
"Failed to create window layer: %d", wm_err);
112 wm_err = R_WM_DevEventRegister(mNativeDisplayID, R_WM_EVENT_VBLANK, 0);
113 if (wm_err != R_WM_ERR_OK)
114 qFatal(
"Failed to Register vsync event: %d", wm_err);
115 wm_err = R_WM_WindowEnable(mNativeDisplayID, mNativeWindow);
116 if (wm_err != R_WM_ERR_OK)
117 qFatal(
"Failed to Enable window surface: %d", wm_err);
119 return static_cast<EGLNativeWindowType>(mNativeWindow);
122void QEglFSRcarIntegration::destroyNativeWindow(EGLNativeWindowType window)
124 R_WM_WindowDisable(mNativeDisplayID, mNativeWindow);
126 R_WM_WindowDelete(mNativeDisplayID, mNativeWindow);
127 R_WM_DevDeinit(mNativeDisplayID);