attach jni to ui thread, fix bucket bounding box
This commit is contained in:
@@ -62,7 +62,7 @@ EGLContext g_context = EGL_NO_CONTEXT;
|
|||||||
std::recursive_mutex mutex;
|
std::recursive_mutex mutex;
|
||||||
int mutex_count = 0;
|
int mutex_count = 0;
|
||||||
struct engine g_engine;
|
struct engine g_engine;
|
||||||
JNIEnv* jni;
|
thread_local JNIEnv* jni;
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
||||||
{
|
{
|
||||||
@@ -118,6 +118,16 @@ int GetUnicodeChar(struct android_app* app, int eventType, int keyCode, int meta
|
|||||||
return unicodeKey;
|
return unicodeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void android_attach_jni()
|
||||||
|
{
|
||||||
|
g_engine.app->activity->vm->AttachCurrentThread(&jni, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void android_detach_jni()
|
||||||
|
{
|
||||||
|
g_engine.app->activity->vm->DetachCurrentThread();
|
||||||
|
}
|
||||||
|
|
||||||
void android_async_lock(struct engine* engine)
|
void android_async_lock(struct engine* engine)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
void android_async_lock(struct engine* engine);
|
void android_async_lock(struct engine* engine);
|
||||||
void android_async_swap(struct engine* engine);
|
void android_async_swap(struct engine* engine);
|
||||||
void android_async_unlock(struct engine* engine);
|
void android_async_unlock(struct engine* engine);
|
||||||
|
void android_attach_jni();
|
||||||
|
void android_detach_jni();
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
bool async_lock_try();
|
bool async_lock_try();
|
||||||
void async_lock();
|
void async_lock();
|
||||||
@@ -853,6 +855,10 @@ void App::ui_thread_main()
|
|||||||
ui_thread_id = std::this_thread::get_id();
|
ui_thread_id = std::this_thread::get_id();
|
||||||
ui_running = true;
|
ui_running = true;
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
android_attach_jni();
|
||||||
|
#endif
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
auto t_start = std::chrono::high_resolution_clock::now();
|
auto t_start = std::chrono::high_resolution_clock::now();
|
||||||
@@ -922,6 +928,9 @@ void App::ui_thread_main()
|
|||||||
rendered_frames++;
|
rendered_frames++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if __ANDROID__
|
||||||
|
android_detach_jni();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::render_thread_start()
|
void App::render_thread_start()
|
||||||
|
|||||||
@@ -1395,7 +1395,8 @@ void Canvas::flood_fill(int layer, int plane, std::vector<glm::ivec2> pos, Flood
|
|||||||
rgb[i] = dest_color * 255.f;
|
rgb[i] = dest_color * 255.f;
|
||||||
plane_data.dirty[plane] = true;
|
plane_data.dirty[plane] = true;
|
||||||
glm::vec2 bb_min = glm::min((glm::vec2)p, xy(plane_data.bb[plane]));
|
glm::vec2 bb_min = glm::min((glm::vec2)p, xy(plane_data.bb[plane]));
|
||||||
glm::vec2 bb_max = glm::max((glm::vec2)p, zw(plane_data.bb[plane]));
|
// add 1 pixel to the end because 1 pixel has min(0) and max(1)
|
||||||
|
glm::vec2 bb_max = glm::max((glm::vec2)p + glm::vec2(1), zw(plane_data.bb[plane]));
|
||||||
plane_data.bb[plane] = { bb_min, bb_max };
|
plane_data.bb[plane] = { bb_min, bb_max };
|
||||||
}
|
}
|
||||||
pos.push_back(p);
|
pos.push_back(p);
|
||||||
|
|||||||
Reference in New Issue
Block a user