implement some APIs needed for OctoDroid

This commit is contained in:
Julian Winkler
2024-03-29 23:56:28 +01:00
parent 0352a307b9
commit 2f4cd3917f
36 changed files with 329 additions and 25 deletions

View File

@@ -113,6 +113,8 @@ void activity_close_all(void)
g_list_free(activities);
}
static jobject activity_not_created = NULL;
void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
{
/* -- run the activity's onCreate -- */
@@ -120,6 +122,12 @@ void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
if((*env)->ExceptionCheck(env))
(*env)->ExceptionDescribe(env);
if ((*env)->IsSameObject(env, activity_object, activity_not_created)) { // finish() was called before the activity was created
_UNREF(activity_not_created);
activity_not_created = NULL;
return;
}
if(recreate) // only allowed for toplevel, so we know for sure where in the stack it belongs
activity_backlog = g_list_append(activity_backlog, _REF(activity_object));
else
@@ -146,9 +154,12 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobje
}
}
activity_update_current(env);
activity_close(env, this);
if (removed_activity)
if (removed_activity) {
activity_close(env, removed_activity);
_UNREF(removed_activity);
} else {
activity_not_created = _REF(this);
}
if (activity_backlog == NULL && window)
gtk_window_close(GTK_WINDOW(_PTR(window)));
}

View File

@@ -190,6 +190,8 @@ JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1mapPoints(JNIEnv *en
dst[dst_idx + i * 2] = res.x;
dst[dst_idx + i * 2 + 1] = res.y;
}
(*env)->ReleaseFloatArrayElements(env, src_ref, src, 0);
(*env)->ReleaseFloatArrayElements(env, dst_ref, dst, 0);
}
JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setTranslate(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
@@ -213,3 +215,12 @@ JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1invert(JNIEnv *e
{
return graphene_matrix_inverse((graphene_matrix_t *)_PTR(matrix_ptr), (graphene_matrix_t *)_PTR(inverse_ptr));
}
JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1preScale__JFF(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
{
graphene_matrix_t *matrix = (graphene_matrix_t *)_PTR(matrix_ptr);
graphene_matrix_t scale;
graphene_matrix_init_scale(&scale, x, y, 1);
graphene_matrix_multiply(&scale, matrix, matrix);
return true;
}