mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 21:28:50 +00:00
a/android: Use android_custom_surface constructor/destructor
This commit is contained in:
parent
66d6281a7f
commit
fc78b5de86
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include <android/native_window_jni.h>
|
#include <android/native_window_jni.h>
|
||||||
|
|
||||||
#include "jni.h"
|
|
||||||
|
|
||||||
using wrap::android::app::Activity;
|
using wrap::android::app::Activity;
|
||||||
using wrap::android::view::SurfaceHolder;
|
using wrap::android::view::SurfaceHolder;
|
||||||
|
@ -27,6 +26,7 @@ using wrap::android::view::SurfaceHolder;
|
||||||
|
|
||||||
struct android_custom_surface
|
struct android_custom_surface
|
||||||
{
|
{
|
||||||
|
explicit android_custom_surface(jobject act);
|
||||||
~android_custom_surface();
|
~android_custom_surface();
|
||||||
Activity activity{};
|
Activity activity{};
|
||||||
jni::Class monadoViewClass{};
|
jni::Class monadoViewClass{};
|
||||||
|
@ -35,8 +35,12 @@ struct android_custom_surface
|
||||||
jni::method_t markAsDiscardedMethod = nullptr;
|
jni::method_t markAsDiscardedMethod = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
android_custom_surface::android_custom_surface(jobject act) : activity(act) {}
|
||||||
|
|
||||||
android_custom_surface::~android_custom_surface()
|
android_custom_surface::~android_custom_surface()
|
||||||
{
|
{
|
||||||
|
// Tell Java that native code is done with this.
|
||||||
if (!monadoView.isNull() && markAsDiscardedMethod != nullptr) {
|
if (!monadoView.isNull() && markAsDiscardedMethod != nullptr) {
|
||||||
try {
|
try {
|
||||||
monadoView.call<void>(markAsDiscardedMethod);
|
monadoView.call<void>(markAsDiscardedMethod);
|
||||||
|
@ -58,9 +62,7 @@ android_custom_surface_async_start(struct _JavaVM *vm, void *activity)
|
||||||
jni::method_t attachToActivity;
|
jni::method_t attachToActivity;
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<android_custom_surface> ret =
|
std::unique_ptr<android_custom_surface> ret =
|
||||||
std::make_unique<android_custom_surface>();
|
std::make_unique<android_custom_surface>((jobject)activity);
|
||||||
|
|
||||||
ret->activity = Activity((jobject)activity);
|
|
||||||
auto info = getAppInfo(XRT_ANDROID_PACKAGE, (jobject)activity);
|
auto info = getAppInfo(XRT_ANDROID_PACKAGE, (jobject)activity);
|
||||||
if (info.isNull()) {
|
if (info.isNull()) {
|
||||||
U_LOG_E(
|
U_LOG_E(
|
||||||
|
|
Loading…
Reference in a new issue