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

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit e95a478972d43aec6070b2bdf78f49171461f230
Author: Boris Faure <[email protected]>
AuthorDate: Sat Nov 7 21:35:31 2026 +0100

    termio: only redraw media block cells when they change
    
    Every render marked all cells covered by a media block as changed, so
    after tyls filled the screen with thumbnails each keystroke redrew the
    text grid and re-scaled every image under those cells. Echoing a key
    cost ~8ms of CPU instead of well under 1ms.
    
    Compare the cell against the blank, invisible state it is reset to,
    as the invisible-cell branch already does. The images above move by
    themselves and Evas tracks their damage.
---
 src/bin/termiointernals.c | 20 +++++++++++++++++---
 src/bin/termiointernals.h |  2 ++
 src/bin/termpty.c         | 35 +++++++++++++++++++++++++++++++++++
 src/bin/tytest.c          |  1 +
 src/bin/tytest.h          |  6 ++++++
 src/bin/tytest_common.c   | 20 ++++++++++++++++++++
 src/bin/unit_tests.h      |  1 +
 7 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/src/bin/termiointernals.c b/src/bin/termiointernals.c
index 844cf091..95e4a87b 100644
--- a/src/bin/termiointernals.c
+++ b/src/bin/termiointernals.c
@@ -2573,9 +2573,23 @@ termio_internal_render(Termio *sd,
                     bid = termpty_block_id_get(&(cells[x]), &bx, &by);
                   if (bid >= 0)
                     {
-                       if (ch1 < 0)
-                         ch1 = x;
-                       ch2 = x;
+                       if ((tc[x].codepoint != 0) ||
+                           (tc[x].fg != COL_INVIS) ||
+                           (tc[x].bg != COL_INVIS) ||
+                           (tc[x].fg_extended) ||
+                           (tc[x].bg_extended) ||
+                           TC_TRUECOLOR_IS_SET(tc[x]) ||
+                           (tc[x].underline) ||
+                           (tc[x].strikethrough) ||
+                           TC_OVERLINE_DIFFERS(tc[x], 0) ||
+                           (tc[x].bold) ||
+                           (tc[x].italic) ||
+                           (tc[x].double_width))
+                         {
+                            if (ch1 < 0)
+                              ch1 = x;
+                            ch2 = x;
+                         }
                        tc[x].codepoint = 0;
                        tc[x].fg_extended = 0;
                        tc[x].bg_extended = 0;
diff --git a/src/bin/termiointernals.h b/src/bin/termiointernals.h
index 19ac552b..81683964 100644
--- a/src/bin/termiointernals.h
+++ b/src/bin/termiointernals.h
@@ -26,8 +26,10 @@ typedef void Term;
           memset(&(_tr)[_x], 0, sizeof((_tr)[_x]));  \
      }                                               \
    while (0)
+# define TC_TRUECOLOR_IS_SET(_tc) ((_tc).fg_truecolor || (_tc).bg_truecolor)
 #else
 # define TC_TRUECOLOR_CLEAR(_tc, _tr, _x) ((void)0)
+# define TC_TRUECOLOR_IS_SET(_tc) (0)
 #endif
 
 typedef struct tag_Termio Termio;
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 32936fbb..51994ff8 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -3876,4 +3876,39 @@ tytest_truecolor_render(void)
 }
 #endif
 
+/* A media block left untouched must not dirty its cells on every render:
+ * the textgrid and the image above it would be redrawn on each keystroke. */
+#if defined(BINARY_TYTEST)
+int
+tytest_block_render_idle(void)
+{
+   Termpty *ty = tytest_termpty_get();
+   Termblock *blk;
+   Termio *sd;
+   int preedit_x = 0, preedit_y = 0;
+
+   eina_init();
+   ecore_init();
+   tytest_common_init();
+   tytest_termio_resize(ty->w, ty->h);
+   sd = termio_get_from_obj(ty->obj);
+
+   blk = termpty_block_new(ty, 2, 1, "/img.png", NULL);
+   assert(blk);
+   termpty_block_insert(ty, '#', blk);
+   ty->block.on = EINA_TRUE;
+   _ty_feed(ty, "\033[2J\033[H##");
+   ty->block.on = EINA_FALSE;
+
+   termio_internal_render(sd, 0, 0, &preedit_x, &preedit_y);
+   assert(tytest_textgrid_updated_cells_take() >= 2);
+
+   termio_internal_render(sd, 0, 0, &preedit_x, &preedit_y);
+   assert(tytest_textgrid_updated_cells_take() == 0);
+
+   tytest_common_shutdown();
+   return 0;
+}
+#endif
+
 #endif /* BINARY_TYFUZZ || BINARY_TYTEST */
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 99e55f86..1456b3e4 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -40,6 +40,7 @@ static struct {
 #if defined(HAVE_TEXTGRID_RGB)
        { "truecolor_render", tytest_truecolor_render},
 #endif
+       { "block_render_idle", tytest_block_render_idle},
        { "sb_add", tytest_sb_add},
        { "sb_prepend", tytest_sb_prepend},
        { "sb_skip", tytest_sb_skip},
diff --git a/src/bin/tytest.h b/src/bin/tytest.h
index 9e93901f..f71a1aa6 100644
--- a/src/bin/tytest.h
+++ b/src/bin/tytest.h
@@ -39,6 +39,12 @@ tytest_edje_object_color_class_set(Evas_Object *termio EINA_UNUSED, const char *
                                  int r1 EINA_UNUSED, int g1 EINA_UNUSED, int b1 EINA_UNUSED, int a1 EINA_UNUSED,
                                  int r2 EINA_UNUSED, int g2 EINA_UNUSED, int b2 EINA_UNUSED, int a2 EINA_UNUSED);
 
+#define evas_object_textgrid_update_add  tytest_textgrid_update_add
+void
+tytest_textgrid_update_add(Evas_Object *obj, int x, int y, int w, int h);
+int
+tytest_textgrid_updated_cells_take(void);
+
 void
 tytest_termio_resize(int w, int h);
 #endif
diff --git a/src/bin/tytest_common.c b/src/bin/tytest_common.c
index 02c793b3..1b13c8e4 100644
--- a/src/bin/tytest_common.c
+++ b/src/bin/tytest_common.c
@@ -133,6 +133,26 @@ tytest_termio_resize(int w, int h)
 #endif
 }
 
+/* number of cells passed to evas_object_textgrid_update_add() */
+static int _updated_cells;
+
+void
+tytest_textgrid_update_add(Evas_Object *obj EINA_UNUSED,
+                           int x EINA_UNUSED, int y EINA_UNUSED,
+                           int w, int h)
+{
+   _updated_cells += w * h;
+}
+
+int
+tytest_textgrid_updated_cells_take(void)
+{
+   int updated = _updated_cells;
+
+   _updated_cells = 0;
+   return updated;
+}
+
 Termpty *
 tytest_termpty_get(void)
 {
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 3c8a6e44..768fa8e4 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -14,6 +14,7 @@ int tytest_cell_is_empty_rgb(void);
 #if defined(HAVE_TEXTGRID_RGB)
 int tytest_truecolor_render(void);
 #endif
+int tytest_block_render_idle(void);
 int tytest_sb_add(void);
 int tytest_sb_prepend(void);
 int tytest_sb_skip(void);

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

Reply via email to