summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinusKube <minuskube@gmail.com>2023-01-28 03:31:44 +0100
committerMinusKube <minuskube@gmail.com>2023-01-28 03:31:55 +0100
commitd59c2214042d8623d28cea04af0f4e8ab10280bd (patch)
tree1f5128eab673500f549d8459151574fa3f0a9671
parenta43db5afa4bbec4772be2f296931a6d44bb4cbb3 (diff)
Mark dirty flags when shaped texts are invalidated
-rw-r--r--scene/3d/label_3d.cpp12
-rw-r--r--scene/gui/label.cpp12
-rw-r--r--scene/resources/primitive_meshes.cpp12
-rw-r--r--scene/resources/text_line.cpp5
-rw-r--r--scene/resources/text_paragraph.cpp12
5 files changed, 53 insertions, 0 deletions
diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp
index d0f71768d2..5410576cdb 100644
--- a/scene/3d/label_3d.cpp
+++ b/scene/3d/label_3d.cpp
@@ -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();
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index f59702835c..05aec8f08b 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -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();
}
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 86ed0001dd..7147fdeab1 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -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);
diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp
index 93611ea2c4..38a865b170 100644
--- a/scene/resources/text_line.cpp
+++ b/scene/resources/text_line.cpp
@@ -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);
diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp
index dfafc7d2bc..729063245c 100644
--- a/scene/resources/text_paragraph.cpp
+++ b/scene/resources/text_paragraph.cpp
@@ -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);