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)
56 if (m_androidSurfaceCreated &&
57 (QAndroidEventDispatcherStopper::stopped() ||
58 QGuiApplication::applicationState() == Qt::ApplicationSuspended)) {
59 qCDebug(lcQpaWindow) <<
"Application not active, return existing surface.";
64 if (!m_androidSurfaceCreated) {
65 static constexpr char funcName[] =
"QAndroidPlatformOpenGLWindow::eglSurface()";
66 QtAndroidPrivate::AndroidDeadlockProtector protector(funcName);
67 if (!protector.acquire()) {
68 qFatal(
"Failed to acquire deadlock protector for %s.", funcName);
73 qCDebug(lcQpaWindow) <<
"called createSurface(), waiting for Surface to be ready...";
74 m_surfaceWaitCondition.wait(&m_surfaceMutex);
77 if (m_eglSurface == EGL_NO_SURFACE)
78 ensureEglSurfaceCreated(config);
96bool QAndroidPlatformOpenGLWindow::ensureEglSurfaceCreated(EGLConfig config)
100 if (!m_androidSurfaceCreated || !m_androidSurfaceObject.isValid()) {
101 qCDebug(lcQpaWindow) <<
"Skipping create egl on invalid or not yet created surface";
106 m_nativeWindow = ANativeWindow_fromSurface(
107 QJniEnvironment::getJniEnv(), m_androidSurfaceObject.object());
108 m_androidSurfaceObject = QJniObject();
109 m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL);
110 m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat());
111 if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE)) {
112 EGLint error = eglGetError();
113 eglTerminate(m_eglDisplay);
114 qFatal(
"EGL Error : Could not create the egl surface: error = 0x%x\n", error);
133void QAndroidPlatformOpenGLWindow::clearSurface()
135 if (m_eglSurface != EGL_NO_SURFACE) {
136 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
137 eglDestroySurface(m_eglDisplay, m_eglSurface);
138 m_eglSurface = EGL_NO_SURFACE;
141 if (m_nativeWindow) {
142 ANativeWindow_release(m_nativeWindow);
143 m_nativeWindow =
nullptr;