fix recurseve mutex on Android
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//BEGIN_INCLUDE(all)
|
//BEGIN_INCLUDE(all)
|
||||||
|
#include <mutex>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
@@ -51,6 +52,7 @@ typedef void (*fnDebugMessageCallback)(GLDEBUGPROC callback, const void* userPar
|
|||||||
|
|
||||||
EGLDisplay g_display = EGL_NO_DISPLAY;
|
EGLDisplay g_display = EGL_NO_DISPLAY;
|
||||||
EGLContext g_context = EGL_NO_CONTEXT;
|
EGLContext g_context = EGL_NO_CONTEXT;
|
||||||
|
std::recursive_mutex mutex;
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
||||||
{
|
{
|
||||||
@@ -124,7 +126,7 @@ int GetUnicodeChar(struct android_app* app, int eventType, int keyCode, int meta
|
|||||||
|
|
||||||
void android_async_lock(struct engine* engine)
|
void android_async_lock(struct engine* engine)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&engine->app->mutex);
|
mutex.lock();
|
||||||
eglMakeCurrent(engine->display, engine->surface, engine->surface, engine->context);
|
eglMakeCurrent(engine->display, engine->surface, engine->surface, engine->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ void android_async_swap(struct engine* engine)
|
|||||||
void android_async_unlock(struct engine* engine)
|
void android_async_unlock(struct engine* engine)
|
||||||
{
|
{
|
||||||
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
pthread_mutex_unlock(&engine->app->mutex);
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct locker
|
struct locker
|
||||||
|
|||||||
@@ -388,6 +388,7 @@ void App::init_menu_file()
|
|||||||
b->on_click = [this](Node*) {
|
b->on_click = [this](Node*) {
|
||||||
App::I.pick_image([this](std::string path){
|
App::I.pick_image([this](std::string path){
|
||||||
Image img;
|
Image img;
|
||||||
|
async_start();
|
||||||
img.load_file(path);
|
img.load_file(path);
|
||||||
if (img.width == img.height / 6 || img.width == img.height * 2)
|
if (img.width == img.height / 6 || img.width == img.height * 2)
|
||||||
{
|
{
|
||||||
@@ -400,6 +401,8 @@ void App::init_menu_file()
|
|||||||
m->m_source_image = std::move(img);
|
m->m_source_image = std::move(img);
|
||||||
Canvas::set_mode(Canvas::kCanvasMode::Transform);
|
Canvas::set_mode(Canvas::kCanvasMode::Transform);
|
||||||
}
|
}
|
||||||
|
async_redraw();
|
||||||
|
async_end();
|
||||||
});
|
});
|
||||||
popup->mouse_release();
|
popup->mouse_release();
|
||||||
popup->destroy();
|
popup->destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user