36void QAndroidPlatformOpenGLWindow::setGeometry(
const QRect &rect)
38 QAndroidPlatformWindow::setGeometry(rect);
40 QRect availableGeometry = screen()->availableGeometry();
43 && availableGeometry.width() > 0
44 && availableGeometry.height() > 0) {
45 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), rect.size()));
51EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config)
53 if (QAndroidEventDispatcherStopper::stopped() ||
54 QGuiApplication::applicationState() == Qt::ApplicationSuspended) {
55 qCDebug(lcQpaWindow) <<
"Application not active, return existing surface.";
61 static constexpr char funcName[] =
"QAndroidPlatformOpenGLWindow::eglSurface()";
62 QtAndroidPrivate::AndroidDeadlockProtector protector(funcName);
63 if (!protector.acquire()) {
64 qFatal(
"Failed to acquire deadlock protector for %s.", funcName);
69 qCDebug(lcQpaWindow) <<
"called createSurface(), waiting for Surface to be ready...";
70 m_surfaceWaitCondition.wait(&m_surfaceMutex);
73 if (m_eglSurface == EGL_NO_SURFACE)
74 ensureEglSurfaceCreated(config);
92bool QAndroidPlatformOpenGLWindow::ensureEglSurfaceCreated(EGLConfig config)
96 if (!m_androidSurfaceCreated || !m_androidSurfaceObject.isValid()) {
97 qCDebug(lcQpaWindow) <<
"Skipping create egl on invalid or not yet created surface";
102 m_nativeWindow = ANativeWindow_fromSurface(
103 QJniEnvironment::getJniEnv(), m_androidSurfaceObject.object());
104 m_androidSurfaceObject = QJniObject();
105 m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL);
106 m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat());
107 if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE)) {
108 EGLint error = eglGetError();
109 eglTerminate(m_eglDisplay);
110 qFatal(
"EGL Error : Could not create the egl surface: error = 0x%x\n", error);
127void QAndroidPlatformOpenGLWindow::clearSurface()
129 if (m_eglSurface != EGL_NO_SURFACE) {
130 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
131 eglDestroySurface(m_eglDisplay, m_eglSurface);
132 m_eglSurface = EGL_NO_SURFACE;
135 if (m_nativeWindow) {
136 ANativeWindow_release(m_nativeWindow);
137 m_nativeWindow =
nullptr;