add general async swap
This commit is contained in:
19
src/app.cpp
19
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<typename T, typename R = std::result_of<T()>::type>
|
||||
template<typename T, typename R = void>
|
||||
std::future<R> render_task_async(T task)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -294,7 +295,7 @@ public:
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
template<typename T, typename R = std::result_of<T()>::type>
|
||||
template<typename T, typename R = void>
|
||||
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<typename T, typename R = std::result_of<T()>::type>
|
||||
template<typename T, typename R = void>
|
||||
std::future<R> ui_task_async(T task)
|
||||
{
|
||||
std::packaged_task<R()> pt(task);
|
||||
@@ -362,7 +363,7 @@ public:
|
||||
return f;
|
||||
}
|
||||
|
||||
template<typename T, typename R = std::result_of<T()>::type>
|
||||
template<typename T, typename R = void>
|
||||
R ui_task(T task)
|
||||
{
|
||||
std::packaged_task<R()> pt(task);
|
||||
|
||||
@@ -146,7 +146,7 @@ bool async_lock_try()
|
||||
return true;
|
||||
}
|
||||
|
||||
void async_swap()
|
||||
void win32_async_swap()
|
||||
{
|
||||
SwapBuffers(hDC);
|
||||
//LOG("swap");
|
||||
|
||||
Reference in New Issue
Block a user