diff --git a/src/app.cpp b/src/app.cpp index e1ee65a..d8c8995 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -17,7 +17,7 @@ void android_async_unlock(struct engine* engine); #elif _WIN32 bool async_lock_try(); void async_lock(); -void async_swap(); +void win32_async_swap(); void async_unlock(); void destroy_window(); #endif @@ -521,6 +521,19 @@ void App::async_end() #endif } +void App::async_swap() +{ +#if __OSX__ + [osx_view async_swap]; +#elif __IOS__ + [ios_view async_swap]; +#elif __ANDROID__ + android_async_swap(and_engine); +#elif _WIN32 + win32_async_swap(); +#endif +} + bool App::update_ui_observer(Node *n) { if (n && n->m_display) @@ -1039,7 +1052,7 @@ void App::render_thread_main() // execute the tasks if (!working_list.empty()) { - async_lock(); + async_start(); while (!working_list.empty()) { //LOG("render task %d", count); @@ -1047,7 +1060,7 @@ void App::render_thread_main() working_list.front()(); working_list.pop_front(); } - async_unlock(); + async_end(); } } } diff --git a/src/app.h b/src/app.h index dbc3b31..3d98f5a 100644 --- a/src/app.h +++ b/src/app.h @@ -178,6 +178,7 @@ public: void async_start(); void async_update(); void async_redraw(); + void async_swap(); void async_end(); void resize(float w, float h); void show_cursor(); @@ -272,7 +273,7 @@ public: // don't capture a reference to this ptr as the object may be destroyed // by the time the task is executed - template::type> + template std::future render_task_async(T task) { #ifdef _WIN32 @@ -294,7 +295,7 @@ public: #endif // _WIN32 } - template::type> + template R render_task(T task) { #ifdef _WIN32 @@ -342,7 +343,7 @@ public: // don't capture a reference to this ptr as the object may be destroyed // by the time the task is executed - template::type> + template std::future ui_task_async(T task) { std::packaged_task pt(task); @@ -362,7 +363,7 @@ public: return f; } - template::type> + template R ui_task(T task) { std::packaged_task pt(task); diff --git a/src/main.cpp b/src/main.cpp index a404796..40facd0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -146,7 +146,7 @@ bool async_lock_try() return true; } -void async_swap() +void win32_async_swap() { SwapBuffers(hDC); //LOG("swap");