21 m_eglDisplay(EGL_NO_DISPLAY),
22 m_eglSurface(EGL_NO_SURFACE)
26 m_requestedBufferSize = shouldMakeFullScreen() ? screen()->geometry().size() : window->geometry().size();
37 return m_eglSurface != EGL_NO_SURFACE;
42 if (m_newSurfaceRequested.testAndSetOrdered(
true,
false)) {
43 const QMutexLocker locker(&m_mutex);
46 if (m_requestedBufferSize != bufferSize() || m_eglSurface == EGL_NO_SURFACE) {
47 if (m_eglSurface != EGL_NO_SURFACE) {
51 createEGLSurface(context);
61 if (context->format().renderableType() != QSurfaceFormat::OpenGLES) {
62 qFatal(
"QQnxEglWindow: renderable type is not OpenGLES");
67 int usage = SCREEN_USAGE_OPENGL_ES2;
69 if (context->format().majorVersion() == 3)
70 usage |= SCREEN_USAGE_OPENGL_ES3;
73 const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &usage);
74 if (Q_UNLIKELY(result != 0))
75 qFatal(
"QQnxEglWindow: failed to set window usage, errno=%d", errno);
77 if (!m_requestedBufferSize.isValid()) {
78 qWarning(
"QQNX: Trying to create 0 size EGL surface. "
79 "Please set a valid window size before calling QOpenGLContext::makeCurrent()");
83 m_eglDisplay = context->eglDisplay();
84 m_eglConfig = context->eglConfig();
85 m_format = context->format();
88 setBufferSize(m_requestedBufferSize);
90 const EGLint eglSurfaceAttrs[] =
92 EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
96 qCDebug(lcQpaWindowEgl) <<
"Creating EGL surface from" <<
this << context
97 << window()->surfaceType() << window()->type();
100 EGLSurface eglSurface = eglCreateWindowSurface(
103 (EGLNativeWindowType) nativeHandle(),
106 if (eglSurface == EGL_NO_SURFACE)
107 qWarning(
"QQNX: failed to create EGL surface, err=%d", eglGetError());
109 m_eglSurface = eglSurface;
115 if (m_eglSurface != EGL_NO_SURFACE) {
116 EGLBoolean eglResult = eglDestroySurface(m_eglDisplay, m_eglSurface);
117 if (Q_UNLIKELY(eglResult != EGL_TRUE))
118 qFatal(
"QQNX: failed to destroy EGL surface, err=%d", eglGetError());
121 m_eglSurface = EGL_NO_SURFACE;
132 const QRect &newGeometry = shouldMakeFullScreen() ? screen()->geometry() : rect;
140 const QMutexLocker locker(&m_mutex);
141 m_requestedBufferSize = newGeometry.size();
142 if (isInitialized() && bufferSize() != newGeometry.size())
143 m_newSurfaceRequested.testAndSetRelease(
false,
true);
145 QQnxWindow::setGeometry(newGeometry);
151 const int redSize = m_format.redBufferSize();
152 if (Q_UNLIKELY(redSize == -1))
153 qFatal(
"QQnxWindow: red size not defined");
155 const int greenSize = m_format.greenBufferSize();
156 if (Q_UNLIKELY(greenSize == -1))
157 qFatal(
"QQnxWindow: green size not defined");
159 const int blueSize = m_format.blueBufferSize();
160 if (Q_UNLIKELY(blueSize == -1))
161 qFatal(
"QQnxWindow: blue size not defined");
164 if (redSize == 5 && greenSize == 6 && blueSize == 5)
165 return SCREEN_FORMAT_RGB565;
166 else if (redSize == 8 && greenSize == 8 && blueSize == 8)
167 return SCREEN_FORMAT_RGBA8888;
169 qFatal(
"QQnxWindow: unsupported pixel format");
174 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)