8#include <QtGui/private/qeglconvenience_p.h>
10# include <QtGui/private/qeglplatformcontext_p.h>
15#include <KD/NV_initialize.h>
27 QMinimalEglContext(
const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display)
36 return screen->surface();
45 , m_platformContext(
nullptr)
48#ifdef QEGL_EXTRA_DEBUG
49 qWarning(
"QEglScreen %p\n",
this);
54 if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) {
55 qWarning(
"Could not bind GL_ES API\n");
59 m_dpy = eglGetDisplay(display);
60 if (Q_UNLIKELY(m_dpy == EGL_NO_DISPLAY)) {
61 qWarning(
"Could not open egl display\n");
64 qWarning(
"Opened display %p\n", m_dpy);
66 if (Q_UNLIKELY(!eglInitialize(m_dpy, &major, &minor))) {
67 qWarning(
"Could not initialize egl display\n");
71 qWarning(
"Initialized display %d %d\n", major, minor);
77 eglDestroySurface(m_dpy, m_surface);
88 QSurfaceFormat platformFormat;
90 QByteArray depthString = qgetenv(
"QT_QPA_EGLFS_DEPTH");
91 if (depthString.toInt() == 16) {
92 platformFormat.setDepthBufferSize(16);
93 platformFormat.setRedBufferSize(5);
94 platformFormat.setGreenBufferSize(6);
95 platformFormat.setBlueBufferSize(5);
97 m_format = QImage::Format_RGB16;
99 platformFormat.setDepthBufferSize(24);
100 platformFormat.setStencilBufferSize(8);
101 platformFormat.setRedBufferSize(8);
102 platformFormat.setGreenBufferSize(8);
103 platformFormat.setBlueBufferSize(8);
105 m_format = QImage::Format_RGB32;
108 if (!qEnvironmentVariableIsEmpty(
"QT_QPA_EGLFS_MULTISAMPLE"))
109 platformFormat.setSamples(4);
111 EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat);
113 EGLNativeWindowType eglWindow = 0;
115 if (Q_UNLIKELY(kdInitializeNV() == KD_ENOTINITIALIZED))
116 qFatal(
"Did not manage to initialize openkode");
118 KDWindow *window = kdCreateWindow(m_dpy,config,0);
120 kdRealizeWindow(window,&eglWindow);
123#ifdef QEGL_EXTRA_DEBUG
124 q_printEglConfig(m_dpy, config);
127 m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow,
nullptr);
128 if (Q_UNLIKELY(m_surface == EGL_NO_SURFACE)) {
129 qWarning(
"Could not create the egl surface: error = 0x%x\n", eglGetError());
136 QEGLPlatformContext *platformContext =
new QMinimalEglContext(platformFormat,
nullptr, m_dpy);
137 m_platformContext = platformContext;
140 eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
141 eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);
143 m_geometry = QRect(0,0,w,h);
149 if (m_geometry.isNull()) {
150 createAndSetPlatformContext();
162 if (m_format == QImage::Format_Invalid)
163 createAndSetPlatformContext();
169 if (!m_platformContext) {
171 that->createAndSetPlatformContext();
173 return m_platformContext;
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override
QMinimalEglContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display)
QMinimalEglScreen(EGLNativeDisplayType display)
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
QPlatformOpenGLContext * platformContext() const
int depth() const override
Reimplement in subclass to return current depth of the screen.
Combined button and popup list for selecting options.