20 m_eglDisplay(EGL_NO_DISPLAY),
21 m_eglSurface(EGL_NO_SURFACE)
25 m_requestedBufferSize = shouldMakeFullScreen() ? screen()->geometry().size() : window->geometry().size();
36 return m_eglSurface != EGL_NO_SURFACE;
41 if (m_newSurfaceRequested.testAndSetOrdered(
true,
false)) {
42 const QMutexLocker locker(&m_mutex);
45 if (m_requestedBufferSize != bufferSize() || m_eglSurface == EGL_NO_SURFACE) {
46 if (m_eglSurface != EGL_NO_SURFACE) {
50 createEGLSurface(context);
60 if (context->format().renderableType() != QSurfaceFormat::OpenGLES) {
61 qFatal(
"QQnxEglWindow: renderable type is not OpenGLES");
66 int usage = SCREEN_USAGE_OPENGL_ES2;
68 if (context->format().majorVersion() == 3)
69 usage |= SCREEN_USAGE_OPENGL_ES3;
72 const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &usage);
73 if (Q_UNLIKELY(result != 0))
74 qFatal(
"QQnxEglWindow: failed to set window usage, errno=%d", errno);
76 if (!m_requestedBufferSize.isValid()) {
77 qWarning(
"QQNX: Trying to create 0 size EGL surface. "
78 "Please set a valid window size before calling QOpenGLContext::makeCurrent()");
82 m_eglDisplay = context->eglDisplay();
83 m_eglConfig = context->eglConfig();
84 m_format = context->format();
87 setBufferSize(m_requestedBufferSize);
89 const EGLint eglSurfaceAttrs[] =
91 EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
95 qCDebug(lcQpaWindowEgl) <<
"Creating EGL surface from" <<
this << context
96 << window()->surfaceType() << window()->type();
99 EGLSurface eglSurface = eglCreateWindowSurface(
102 (EGLNativeWindowType) nativeHandle(),
105 if (eglSurface == EGL_NO_SURFACE)
106 qWarning(
"QQNX: failed to create EGL surface, err=%d", eglGetError());
108 m_eglSurface = eglSurface;
114 if (m_eglSurface != EGL_NO_SURFACE) {
115 EGLBoolean eglResult = eglDestroySurface(m_eglDisplay, m_eglSurface);
116 if (Q_UNLIKELY(eglResult != EGL_TRUE))
117 qFatal(
"QQNX: failed to destroy EGL surface, err=%d", eglGetError());
120 m_eglSurface = EGL_NO_SURFACE;
131 const QRect &newGeometry = shouldMakeFullScreen() ? screen()->geometry() : rect;
139 const QMutexLocker locker(&m_mutex);
140 m_requestedBufferSize = newGeometry.size();
141 if (isInitialized() && bufferSize() != newGeometry.size())
142 m_newSurfaceRequested.testAndSetRelease(
false,
true);
144 QQnxWindow::setGeometry(newGeometry);
150 const int redSize = m_format.redBufferSize();
151 if (Q_UNLIKELY(redSize == -1))
152 qFatal(
"QQnxWindow: red size not defined");
154 const int greenSize = m_format.greenBufferSize();
155 if (Q_UNLIKELY(greenSize == -1))
156 qFatal(
"QQnxWindow: green size not defined");
158 const int blueSize = m_format.blueBufferSize();
159 if (Q_UNLIKELY(blueSize == -1))
160 qFatal(
"QQnxWindow: blue size not defined");
163 if (redSize == 5 && greenSize == 6 && blueSize == 5)
164 return SCREEN_FORMAT_RGB565;
165 else if (redSize == 8 && greenSize == 8 && blueSize == 8)
166 return SCREEN_FORMAT_RGBA8888;
168 qFatal(
"QQnxWindow: unsupported pixel format");
173 m_requestedBufferSize = QSize();
bool isInitialized() const
void resetBuffers() override
QQnxEglWindow(QWindow *window, screen_context_t context, bool needRootWindow)
int pixelFormat() const override
EGLSurface surface() const
void ensureInitialized(QQnxGLContext *context)
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
void doneCurrent() override
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
#define _SCREEN_MAKE_VERSION(major, minor, patch)