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