From d75e9826d0258edd3f999c0de433d9bb7ce1186b Mon Sep 17 00:00:00 2001 From: pointer-to-bios Date: Thu, 28 Jul 2022 12:29:10 +0800 Subject: [PATCH] add update queue to sync --- BWLserver/threads.cc | 38 +++++++++++++++++++++++++++++++++----- BWLserver/update.cc | 5 +++++ BWLserver/update.hh | 20 +++++++++++++++++++- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/BWLserver/threads.cc b/BWLserver/threads.cc index 4992395..84ac1f3 100644 --- a/BWLserver/threads.cc +++ b/BWLserver/threads.cc @@ -7,11 +7,11 @@ #include #include -#include "update.hh" - #include "../includes/bsv.hh" #include "../includes/syscfg.hh" +#include "update.hh" + extern volatile bool server_running; //服务器运行标志 extern std::map pages; //页列表 @@ -41,11 +41,38 @@ namespace bwl else updating_signal = 0; //检查背景更新 - if(__ud.__bg.sig) + if (__ud.__bg.sig) { update_bg(); __ud.__bg.sig = 0; } + //检查更新鼠标 + if (__ud.__mo.sig) + { + update_mo(); + __ud.__mo.sig = 0; + } + } + + /** + * @brief 更新刷新队列 + * + */ + void update_queues() + { + //背景队列 + if (!__ud.bg_update_que.empty() && !__ud.__bg.sig) + { + __ud.__bg = __ud.bg_update_que.front(); + __ud.bg_update_que.pop(); + } + + //鼠标队列 + if (!__ud.mouse_update_que.empty() && !__ud.__bg.sig) + { + __ud.__mo = __ud.mouse_update_que.front(); + __ud.mouse_update_que.pop(); + } } void updateDrmBuffer() @@ -55,8 +82,9 @@ namespace bwl useconds_t itv = interval(server::getFPS()); //获取帧率并换算为每帧时间间隔 while (server_running) { - usleep(itv); //睡眠 - updater(); //更新屏幕 + usleep(itv); //睡眠 + update_queues(); //更新队列 + updater(); //更新屏幕 } } }; diff --git a/BWLserver/update.cc b/BWLserver/update.cc index bc4b1e3..0c37c6d 100644 --- a/BWLserver/update.cc +++ b/BWLserver/update.cc @@ -35,4 +35,9 @@ namespace bwl } } + void update_mo() + { + + } + }; diff --git a/BWLserver/update.hh b/BWLserver/update.hh index 933b3d6..1e0f208 100644 --- a/BWLserver/update.hh +++ b/BWLserver/update.hh @@ -4,6 +4,7 @@ #define __bwl_server #include +#include namespace bwl { @@ -15,14 +16,31 @@ namespace bwl int64_t pos[2]; //更新位置 uint64_t size[2]; //更新大小 } __bg; + + std::queue bg_update_que; //背景更新队列 + + struct mouse + { + uint8_t sig; //更新标志 + int64_t pos[2]; //更新位置 + uint64_t size[2]; //更新大小 + } __mo; + + std::queue mouse_update_que; //鼠标更新队列 }; /** * @brief 更新背景 - * + * */ void update_bg(); + /** + * @brief 更新鼠标 + * + */ + void update_mo(); + }; #endif -- GitLab