修复CPU占用过高,全局绘制脏标记

This commit is contained in:
daiqingshuang
2025-03-24 14:03:02 +08:00
parent 3bac5b548b
commit 0f014790c9
3 changed files with 8 additions and 2 deletions

View File

@@ -53,8 +53,8 @@ void mirage_app::run() {
widget_manager::get().update();
last_time = get_current_time();
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::this_thread::yield();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
// std::this_thread::yield();
}
running = false;
render_context->cleanup();

View File

@@ -57,6 +57,9 @@ public:
void set_parent(const widget_key& in_parent);
virtual void invalidate(invalidate_reason in_reason);
auto has_invalidate_reason(invalidate_reason in_reason) const { return get_component_ref<widget_invalidate>().has(in_reason); }
void clear_invalidate_reason(invalidate_reason in_reason) { get_component_ref<widget_invalidate>().unset(in_reason); }
auto get_invalidation_reason() const { return get_component_ref<widget_invalidate>().invalidate; }
auto is_enabled() const { return get_component_ref<widget_visibility>().is_enabled(); }

View File

@@ -224,6 +224,8 @@ void widget_render_system::onUpdate(mustache::World& in_world) {
return;
if (!window->is_visible())
return;
if (!window->has_invalidate_reason(invalidate_reason::paint))
return;
auto& window_state = window->get_state();
@@ -248,6 +250,7 @@ void widget_render_system::onUpdate(mustache::World& in_world) {
sg_commit();
window_state.present();
window->clear_invalidate_reason(invalidate_reason::paint);
}
void widget_render_system::paint(const widget_key& in_key) {