Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qandroidplatformopenglwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
7
10
11#include <QSurfaceFormat>
12#include <QtGui/private/qwindow_p.h>
13#include <QtGui/qguiapplication.h>
14
15#include <QtGui/private/qeglconvenience_p.h>
16#include <android/native_window.h>
17#include <android/native_window_jni.h>
18#include <qpa/qplatformscreen.h>
19#include <qpa/qwindowsysteminterface.h>
20
22
26
27QAndroidPlatformOpenGLWindow::~QAndroidPlatformOpenGLWindow()
28{
29 // The base class destructor can't reach destroyWindowSurface().
30 destroySurface();
31}
32
33void QAndroidPlatformOpenGLWindow::setGeometry(const QRect &rect)
34{
35 QAndroidPlatformWindow::setGeometry(rect);
36
37 // Programmatic resizes need an expose to drive Qt-internal re-layout on
38 // widget-embedded scenes (QQuickWidget).
39 if (!rect.isEmpty() && !screen()->availableGeometry().isEmpty())
40 QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), rect.size())));
41}
42
44{
45 if (Q_LIKELY(m_eglSurface != EGL_NO_SURFACE))
46 return m_eglSurface;
48 if (!m_nativeWindow)
49 return EGL_NO_SURFACE;
50
51 m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, nullptr);
52 if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE)) {
53 qWarning("EGL Error: could not create egl surface: 0x%x", eglGetError());
54 return EGL_NO_SURFACE;
55 }
56 m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat());
57 return m_eglSurface;
58}
59
61{
62 if (!m_nativeWindow)
63 return window()->requestedFormat();
64 return m_format;
65}
66
68{
69 if (m_eglSurface != EGL_NO_SURFACE) {
70 eglDestroySurface(m_eglDisplay, m_eglSurface);
71 m_eglSurface = EGL_NO_SURFACE;
72 }
73}
74
75QT_END_NAMESPACE
EGLSurface eglSurface(EGLConfig config)
QSurfaceFormat format() const override
Returns the actual surface format of the window.
\inmodule QtGui
Definition qwindow.h:64
Combined button and popup list for selecting options.