修复CPU占用过高,全局绘制脏标记
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user