improve dialog browse, wrap ui task for every Node method that modifies the children list, update the ui every time the scene tree changes, restore fps and stylus state on win, fix bucket tool, fix snapshop restore, init in ui thread
This commit is contained in:
24
src/app.cpp
24
src/app.cpp
@@ -718,7 +718,6 @@ void App::update_memory_usage(size_t bytes)
|
||||
static char buffer[128];
|
||||
sprintf(buffer, "History memory: %.2f Mb", bytes / 1024.f / 1024.f);
|
||||
txt->set_text(buffer);
|
||||
layout[main_id]->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,6 +1020,8 @@ void App::rec_loop()
|
||||
|
||||
void App::render_thread_main()
|
||||
{
|
||||
BT_SetTerminate();
|
||||
|
||||
uint32_t count = 0;
|
||||
render_thread_id = std::this_thread::get_id();
|
||||
render_running = true;
|
||||
@@ -1053,9 +1054,14 @@ void App::render_thread_main()
|
||||
|
||||
void App::ui_thread_main()
|
||||
{
|
||||
BT_SetTerminate();
|
||||
|
||||
uint32_t count = 0;
|
||||
ui_thread_id = std::this_thread::get_id();
|
||||
ui_running = true;
|
||||
|
||||
init();
|
||||
|
||||
auto t_start = std::chrono::high_resolution_clock::now();
|
||||
float t_frame = 0;
|
||||
float t_fps_counter = 0;
|
||||
@@ -1067,7 +1073,8 @@ void App::ui_thread_main()
|
||||
// move the task list locally to free the queue for other threads
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(ui_task_mutex);
|
||||
ui_cv.wait(lock, [this] { return ui_tasklist.empty() && ui_running ? false : true; });
|
||||
ui_cv.wait_for(lock, std::chrono::milliseconds(100),
|
||||
[this] { return ui_tasklist.empty() && ui_running ? false : true; });
|
||||
working_list = std::move(ui_tasklist);
|
||||
}
|
||||
|
||||
@@ -1085,6 +1092,12 @@ void App::ui_thread_main()
|
||||
|
||||
auto t_now = std::chrono::high_resolution_clock::now();
|
||||
float dt = std::chrono::duration<float>(t_now - t_start).count();
|
||||
t_start = t_now;
|
||||
|
||||
#ifdef _WIN32
|
||||
extern void win32_update_stylus(float dt);
|
||||
win32_update_stylus(dt);
|
||||
#endif
|
||||
|
||||
// increment timers
|
||||
t_frame += dt;
|
||||
@@ -1092,7 +1105,12 @@ void App::ui_thread_main()
|
||||
|
||||
if (t_fps_counter > 1.f)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
extern void win32_update_fps(int frames);
|
||||
win32_update_fps(rendered_frames);
|
||||
#endif
|
||||
t_fps_counter = 0;
|
||||
rendered_frames = 0;
|
||||
}
|
||||
|
||||
tick(dt);
|
||||
|
||||
Reference in New Issue
Block a user