6#include <QtCore/qcoreapplication.h>
7#include <QtCore/qdebug.h>
8#include <QtCore/qlist.h>
9#include <QtCore/qmutex.h>
10#include <QtGui/qwindow.h>
19AndroidSurfaceHolder::AndroidSurfaceHolder(
QJniObject object)
21 , m_surfaceCreated(
false)
23 if (!m_surfaceHolder.isValid())
28 surfaceHolders->append(
this);
32 m_surfaceHolder.callMethod<
void>(
"addCallback",
33 "(Landroid/view/SurfaceHolder$Callback;)V",
40 const int i = surfaceHolders->indexOf(
this);
44 surfaceHolders->remove(
i);
49 return m_surfaceHolder.object();
55 return m_surfaceCreated;
58void AndroidSurfaceHolder::handleSurfaceCreated(JNIEnv*, jobject, jlong
id)
65 (*surfaceHolders)[
i]->m_surfaceCreated =
true;
66 Q_EMIT (*surfaceHolders)[
i]->surfaceCreated();
69void AndroidSurfaceHolder::handleSurfaceDestroyed(JNIEnv*, jobject, jlong
id)
76 (*surfaceHolders)[
i]->m_surfaceCreated =
false;
81 static const JNINativeMethod
methods[] = {
82 {
"notifySurfaceCreated",
"(J)V", (
void *)AndroidSurfaceHolder::handleSurfaceCreated},
83 {
"notifySurfaceDestroyed",
"(J)V", (
void *)AndroidSurfaceHolder::handleSurfaceDestroyed}
93 , m_pendingVisible(-1)
95 QNativeInterface::QAndroidApplication::runOnAndroidMainThread([
this] {
96 m_surfaceView =
QJniObject(
"android/view/SurfaceView",
97 "(Landroid/content/Context;)V",
98 QNativeInterface::QAndroidApplication::context());
104 "()Landroid/view/SurfaceHolder;");
113 m_window = QWindow::fromWinId(WId(m_surfaceView.object()));
115 if (m_pendingVisible != -1)
117 if (m_pendingGeometry.
isValid())
125 delete m_surfaceHolder;
131 return m_surfaceHolder;
139 m_pendingVisible = int(
v);
152#include "moc_androidsurfaceview_p.cpp"
static JNINativeMethod methods[]
static QT_BEGIN_NAMESPACE const char QtSurfaceHolderCallbackClassName[]
QList< AndroidSurfaceHolder * > SurfaceHolders
jobject surfaceHolder() const
bool isSurfaceCreated() const
static bool registerNativeMethods()
AndroidSurfaceHolder * holder() const
void setGeometry(int x, int y, int width, int height)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\inmodule QtCore\reentrant
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
void setGeometry(int posx, int posy, int w, int h)
Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx,...
void setVisible(bool visible)
Combined button and popup list for selecting options.
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]