Mark dirty flags when shaped texts are invalidated

This commit is contained in:
MinusKube 2023-01-28 03:31:44 +01:00
parent a43db5afa4
commit d59c221404
5 changed files with 53 additions and 0 deletions

View file

@ -418,6 +418,18 @@ void Label3D::_generate_glyph_surfaces(const Glyph &p_glyph, Vector2 &r_offset,
}
void Label3D::_shape() {
// When a shaped text is invalidated by an external source, we want to reshape it.
if (!TS->shaped_text_is_ready(text_rid)) {
dirty_text = true;
}
for (const RID &line_rid : lines_rid) {
if (!TS->shaped_text_is_ready(line_rid)) {
dirty_lines = true;
break;
}
}
// Clear mesh.
RS::get_singleton()->mesh_clear(mesh);
aabb = AABB();

View file

@ -345,6 +345,18 @@ void Label::_notification(int p_what) {
RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
}
// When a shaped text is invalidated by an external source, we want to reshape it.
if (!TS->shaped_text_is_ready(text_rid)) {
dirty = true;
}
for (const RID &line_rid : lines_rid) {
if (!TS->shaped_text_is_ready(line_rid)) {
lines_dirty = true;
break;
}
}
if (dirty || font_dirty || lines_dirty) {
_shape();
}

View file

@ -2890,6 +2890,18 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
dirty_cache = false;
}
// When a shaped text is invalidated by an external source, we want to reshape it.
if (!TS->shaped_text_is_ready(text_rid)) {
dirty_text = true;
}
for (const RID &line_rid : lines_rid) {
if (!TS->shaped_text_is_ready(line_rid)) {
dirty_lines = true;
break;
}
}
// Update text buffer.
if (dirty_text) {
TS->shaped_text_clear(text_rid);

View file

@ -101,6 +101,11 @@ void TextLine::_bind_methods() {
}
void TextLine::_shape() {
// When a shaped text is invalidated by an external source, we want to reshape it.
if (!TS->shaped_text_is_ready(rid)) {
dirty = true;
}
if (dirty) {
if (!tab_stops.is_empty()) {
TS->shaped_text_tab_align(rid, tab_stops);

View file

@ -134,6 +134,18 @@ void TextParagraph::_bind_methods() {
}
void TextParagraph::_shape_lines() {
// When a shaped text is invalidated by an external source, we want to reshape it.
if (!TS->shaped_text_is_ready(rid) || !TS->shaped_text_is_ready(dropcap_rid)) {
lines_dirty = true;
}
for (const RID &line_rid : lines_rid) {
if (!TS->shaped_text_is_ready(line_rid)) {
lines_dirty = true;
break;
}
}
if (lines_dirty) {
for (const RID &line_rid : lines_rid) {
TS->free_rid(line_rid);