diff options
author | Christian Strømme <christian.stromme@digia.com> | 2014-02-04 11:30:00 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-14 00:34:25 +0100 |
commit | 539196689e806f8c175bb50343a4dc2cab52e838 (patch) | |
tree | 8ec129220be28e3297f00a8c292b8c85bc35796e /src/plugins/platforms/android/androidjnimain.cpp | |
parent | 4ce43b565f388c9327cb671887a4730225327006 (diff) |
Android: Add Foreign Window support
Change-Id: Ie41edd3f17214805673311a375191cd93d2378f6
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'src/plugins/platforms/android/androidjnimain.cpp')
-rw-r--r-- | src/plugins/platforms/android/androidjnimain.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 76129319c5..337e7419aa 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -84,6 +84,7 @@ static AAssetManager *m_assetManager = NULL; static jobject m_resourcesObj; static jobject m_activityObject = NULL; static jmethodID m_createSurfaceMethodID = 0; +static jmethodID m_insertNativeViewMethodID = 0; static jmethodID m_setSurfaceGeometryMethodID = 0; static jmethodID m_destroySurfaceMethodID = 0; @@ -359,6 +360,33 @@ namespace QtAndroid return surfaceId; } + int insertNativeView(jobject view, const QRect &geometry) + { + QJNIEnvironmentPrivate env; + if (!env) + return 0; + + m_surfacesMutex.lock(); + const int surfaceId = m_surfaceId++; + m_surfacesMutex.unlock(); + + jint x = 0, y = 0, w = -1, h = -1; + if (!geometry.isNull()) { + x = geometry.x(); + y = geometry.y(); + w = std::max(geometry.width(), 1); + h = std::max(geometry.height(), 1); + } + + env->CallStaticVoidMethod(m_applicationClass, + m_insertNativeViewMethodID, + surfaceId, + view, + x, y, w, h); + + return surfaceId; + } + void setSurfaceGeometry(int surfaceId, const QRect &geometry) { QJNIEnvironmentPrivate env; @@ -653,6 +681,7 @@ static int registerNatives(JNIEnv *env) } GET_AND_CHECK_STATIC_METHOD(m_createSurfaceMethodID, m_applicationClass, "createSurface", "(IZIIII)V"); + GET_AND_CHECK_STATIC_METHOD(m_insertNativeViewMethodID, m_applicationClass, "insertNativeView", "(ILandroid/view/View;IIII)V"); GET_AND_CHECK_STATIC_METHOD(m_setSurfaceGeometryMethodID, m_applicationClass, "setSurfaceGeometry", "(IIIII)V"); GET_AND_CHECK_STATIC_METHOD(m_destroySurfaceMethodID, m_applicationClass, "destroySurface", "(I)V"); |