This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch v-1.29
in repository efl.

View the commit online.

commit b1f3926c506e02d7478ddb4f4cefd384b50d1a60
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 21 11:50:23 2026 -0600

    evas:textgrid: share the cached glyph array between cells
    
    On a text_props cache hit, evas_common_text_props_content_copy_and_ref()
    leaves glyphs NULL, so every cell of every changed row rebuilt its own
    glyph array with malloc each frame. In a GL callgrind of the Fire
    benchmark about 30% of the instructions were malloc and free from
    evas_common_font_draw_prepare().
    
    The textgrid now prepares the cache entry's array once and gives each
    cell that shares it one reference. Prepare only rewrites an array in
    place when its refcount is 1, and the cache always holds a reference,
    so a stale array is replaced and never rewritten under another user.
    
    Numbers, median fps, without -> with this change:
      GL:            Terminal Scroll 271 -> 422 (+56%)
                     Truecolor Fire  249 -> 309 (+24%)
                     Textgrid Change 683 -> 866 (+27%)
      buffer:        Scroll 370 -> 572 (+55%), Fire 290 -> 394 (+36%),
                     Change 1182 -> 1473 (+25%)
      software_x11:  Fire 142 -> 166 (+17%), Scroll 156 -> 185 (+19%)
    Callgrind, GL Fire: 46.0M -> 27.8M instructions per frame.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/evas/canvas/evas_object_textgrid.c |  9 +++++++
 src/tests/evas/evas_test_textgrid.c        | 43 ++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 0566ac8331..3b1c2eff12 100644
--- a/src/lib/evas/canvas/evas_object_textgrid.c
+++ b/src/lib/evas/canvas/evas_object_textgrid.c
@@ -691,8 +691,17 @@ evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row,
         if (cached)
           {
              /* Cache hit: copy the cached props and take an independent ref */
+             /* Cache hit: copy the cached props and take an independent ref.
+              * The glyph array is shared too, so a cell costs no allocation
+              * until its glyphs change. */
+             evas_common_font_draw_prepare(cached);
              evas_common_text_props_content_copy_and_ref(&(text->text_props),
                                                          cached);
+             if (cached->glyphs)
+               {
+                  text->text_props.glyphs = cached->glyphs;
+                  evas_common_font_glyphs_ref(cached->glyphs);
+               }
              break;
           }
 
diff --git a/src/tests/evas/evas_test_textgrid.c b/src/tests/evas/evas_test_textgrid.c
index 4a62cd8ecc..73c2036b99 100644
--- a/src/tests/evas/evas_test_textgrid.c
+++ b/src/tests/evas/evas_test_textgrid.c
@@ -501,6 +501,48 @@ EFL_START_TEST(evas_textgrid_test_text_cells_independent)
 }
 EFL_END_TEST
 
+/* Glyph arrays are shared between the cells showing the same character.
+ * Dropping what the font keeps in cache, as when memory runs low, must
+ * leave the output as it was, for cells redrawn and for cells new. */
+EFL_START_TEST(evas_textgrid_test_text_after_font_cache_flush)
+{
+   START_TG_TEST();
+   Evas_Object *tg = _textgrid_new(e);
+   unsigned int *before, *after;
+   int i;
+
+   _text_cells_fill(tg, -1);
+   before = _snapshot(ee);
+
+   for (i = 0; i < 3; i++)
+     {
+        evas_font_cache_flush(e);
+        evas_object_textgrid_update_add(tg, 0, 0, GRID_W, GRID_H);
+        after = _snapshot(ee);
+        fail_if(!_pixels_equal(before, after));
+        free(after);
+     }
+
+   /* other characters, with the shared ones still around */
+   evas_font_cache_flush(e);
+   evas_object_textgrid_cellrow_get(tg, 0)[2].codepoint = 'Z';
+   evas_object_textgrid_cellrow_get(tg, 0)[4].codepoint = 'A';
+   evas_object_textgrid_update_add(tg, 0, 0, GRID_W, 1);
+   after = _snapshot(ee);
+   fail_if(_pixels_equal(before, after));
+   evas_object_textgrid_cellrow_get(tg, 0)[2].codepoint = 'A' + 2;
+   evas_object_textgrid_cellrow_get(tg, 0)[4].codepoint = 'A' + 4;
+   evas_object_textgrid_update_add(tg, 0, 0, GRID_W, 1);
+   free(after);
+   after = _snapshot(ee);
+   fail_if(!_pixels_equal(before, after));
+
+   free(before);
+   free(after);
+   END_TG_TEST();
+}
+EFL_END_TEST
+
 void evas_test_textgrid(TCase *tc)
 {
    tcase_add_test(tc, evas_textgrid_test_truecolor_setget);
@@ -512,6 +554,7 @@ void evas_test_textgrid(TCase *tc)
    tcase_add_test(tc, evas_textgrid_test_truecolor_disable_fallback);
    tcase_add_test(tc, evas_textgrid_test_truecolor_cellrow_set);
    tcase_add_test(tc, evas_textgrid_test_text_cells_independent);
+   tcase_add_test(tc, evas_textgrid_test_text_after_font_cache_flush);
 }
 
 #endif // BUILD_ENGINE_BUFFER

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to