mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
fix(ui): some dirty rectangles are not collected
This commit is contained in:
+6
-10
@@ -20,21 +20,17 @@
|
||||
|
||||
void ui_style_diff_init(ui_style_diff_t *diff, ui_widget_t *w)
|
||||
{
|
||||
ui_widget_t *parent;
|
||||
|
||||
diff->canvas_box = w->canvas_box;
|
||||
diff->padding_box = w->padding_box;
|
||||
diff->should_add_dirty_rect = false;
|
||||
if (w->parent) {
|
||||
if (!ui_widget_is_visible(w->parent)) {
|
||||
for (parent = w->parent; parent; parent = parent->parent) {
|
||||
if (!ui_widget_is_visible(parent) ||
|
||||
parent->rendering.dirty_rect_type ==
|
||||
UI_DIRTY_RECT_TYPE_FULL) {
|
||||
return;
|
||||
}
|
||||
if (w->parent->rendering.dirty_rect_type ==
|
||||
UI_DIRTY_RECT_TYPE_FULL) {
|
||||
w->rendering.dirty_rect_type = UI_DIRTY_RECT_TYPE_FULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (w->state < UI_WIDGET_STATE_LAYOUTED) {
|
||||
w->rendering.dirty_rect_type = UI_DIRTY_RECT_TYPE_FULL;
|
||||
}
|
||||
diff->should_add_dirty_rect = true;
|
||||
}
|
||||
|
||||
+17
-22
@@ -1,4 +1,4 @@
|
||||
// #define UI_DEBUG_ENABLED
|
||||
// #define UI_DEBUG_ENABLED
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <css.h>
|
||||
@@ -23,7 +23,6 @@ static struct ui_updater_t {
|
||||
* dict_t<hash, css_style_decl_t*>
|
||||
*/
|
||||
dict_t* style_cache;
|
||||
dict_type_t style_cache_dict;
|
||||
ui_metrics_t metrics;
|
||||
bool refresh_all;
|
||||
} ui_updater;
|
||||
@@ -129,19 +128,6 @@ void ui_widget_update_stacking_context(ui_widget_t* w)
|
||||
}
|
||||
}
|
||||
|
||||
void ui_init_updater(void)
|
||||
{
|
||||
dict_type_t* dt = &ui_updater.style_cache_dict;
|
||||
|
||||
dt->val_dup = NULL;
|
||||
dt->key_dup = ui_style_dict_string_key_dup;
|
||||
dt->key_compare = ui_style_dict_string_key_compare;
|
||||
dt->hash_function = ui_style_dict_hash;
|
||||
dt->key_destructor = ui_style_dict_string_key_free;
|
||||
dt->val_destructor = ui_style_dict_val_free;
|
||||
ui_updater.refresh_all = true;
|
||||
}
|
||||
|
||||
static void ui_widget_match_style(ui_widget_t* w)
|
||||
{
|
||||
css_selector_t* selector;
|
||||
@@ -318,7 +304,6 @@ size_t ui_widget_update(ui_widget_t* w)
|
||||
w->update.should_update_children = true;
|
||||
w->update.should_refresh_style = true;
|
||||
w->update.should_reflow = true;
|
||||
w->rendering.dirty_rect_type = UI_DIRTY_RECT_TYPE_FULL;
|
||||
}
|
||||
if (ui_widget_has_update(w)) {
|
||||
if (w->proto && w->proto->update) {
|
||||
@@ -440,15 +425,11 @@ size_t ui_update(void)
|
||||
size_t count;
|
||||
ui_widget_t* root;
|
||||
|
||||
ui_updater.style_cache =
|
||||
dict_create(&ui_updater.style_cache_dict, NULL);
|
||||
root = ui_root();
|
||||
if (memcmp(&ui_metrics, &ui_updater.metrics, sizeof(ui_metrics_t))) {
|
||||
ui_updater.refresh_all = true;
|
||||
root->rendering.dirty_rect_type = UI_DIRTY_RECT_TYPE_FULL;
|
||||
}
|
||||
if (ui_updater.refresh_all) {
|
||||
ui_refresh_style();
|
||||
}
|
||||
root = ui_root();
|
||||
count = ui_widget_update(root);
|
||||
ui_updater.metrics = ui_metrics;
|
||||
ui_updater.refresh_all = false;
|
||||
@@ -457,3 +438,17 @@ size_t ui_update(void)
|
||||
ui_trash_clear();
|
||||
return count;
|
||||
}
|
||||
|
||||
void ui_init_updater(void)
|
||||
{
|
||||
static dict_type_t type;
|
||||
|
||||
type.val_dup = NULL;
|
||||
type.key_dup = ui_style_dict_string_key_dup;
|
||||
type.key_compare = ui_style_dict_string_key_compare;
|
||||
type.hash_function = ui_style_dict_hash;
|
||||
type.key_destructor = ui_style_dict_string_key_free;
|
||||
type.val_destructor = ui_style_dict_val_free;
|
||||
ui_updater.refresh_all = true;
|
||||
ui_updater.style_cache = dict_create(&type, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user