10#include <QSurfaceFormat>
11#include <qpa/qplatformscreen.h>
12#include <qpa/qwindowsysteminterface.h>
14#include <android/native_window.h>
15#include <android/native_window_jni.h>
21 m_nativeSurfaceId(-1),
31 m_surfaceWaitCondition.
wakeOne();
33 if (m_nativeSurfaceId != -1)
47 if (m_nativeSurfaceId != -1)
53 && availableGeometry.
width() > 0
54 && availableGeometry.
height() > 0) {
67 if (m_nativeSurfaceId != -1) {
69 m_nativeSurfaceId = -1;
78 return window()->requestedFormat();
81void QAndroidPlatformVulkanWindow::clearSurface()
83 if (m_vkSurface && m_destroyVkSurface) {
84 m_destroyVkSurface(
window()->vulkanInstance()->vkInstance(), m_vkSurface,
nullptr);
89 ANativeWindow_release(m_nativeWindow);
90 m_nativeWindow =
nullptr;
94void QAndroidPlatformVulkanWindow::sendExpose()
108 m_androidSurfaceObject =
surface;
110 m_surfaceWaitCondition.
wakeOne();
122 bool needsExpose =
false;
127 if (m_nativeSurfaceId == -1) {
136 if (m_nativeSurfaceId == -1 || !m_androidSurfaceObject.isValid())
140 m_nativeWindow = ANativeWindow_fromSurface(env.jniEnv(), m_androidSurfaceObject.object());
142 VkAndroidSurfaceCreateInfoKHR surfaceInfo;
143 memset(&surfaceInfo, 0,
sizeof(surfaceInfo));
144 surfaceInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
145 surfaceInfo.window = m_nativeWindow;
148 qWarning(
"Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
151 if (!m_createVkSurface) {
152 m_createVkSurface =
reinterpret_cast<PFN_vkCreateAndroidSurfaceKHR
>(
153 inst->getInstanceProcAddr(
"vkCreateAndroidSurfaceKHR"));
155 if (!m_destroyVkSurface) {
156 m_destroyVkSurface =
reinterpret_cast<PFN_vkDestroySurfaceKHR
>(
157 inst->getInstanceProcAddr(
"vkDestroySurfaceKHR"));
159 VkResult err = m_createVkSurface(inst->vkInstance(), &surfaceInfo,
nullptr, &m_vkSurface);
160 if (err != VK_SUCCESS)
161 qWarning(
"Failed to create Android VkSurface: %d", err);
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
bool wait(QMutex *, QDeadlineTimer=QDeadlineTimer(QDeadlineTimer::Forever))
static bool handleExposeEvent(QWindow *window, const QRegion ®ion)
Combined button and popup list for selecting options.
void destroySurface(int surfaceId)
void setSurfaceGeometry(int surfaceId, const QRect &geometry)
int createSurface(AndroidSurfaceClient *client, const QRect &geometry, bool onTop, int imageDepth)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat GLfloat h