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 bf4d5e12ce9019f31e945a0e4364ae3a26bf9c57
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 21 11:49:47 2026 -0600
evas:textgrid: draw row text through multi_font_draw on every engine
The textgrid handed text to multi_font_draw only in async mode, so the
sync path drew one glyph run at a time, paying the target, clip and
cutout setup for each. A row's glyphs now go out as one array per font,
which is the best grouping possible: an Evas_Font_Array carries one y,
and the underline rects of row n must precede the text of row n+1.
The sync path reuses a scratch array and takes no glyph references. The
draw completes before the call returns, and for GL the glyph textures
live as long as the font instance, which the cells pin.
The cutout target now covers the whole row instead of three cells
around the start of the run. The old target missed cutouts that overlap
glyphs further along the run; that was an async-only bug.
Numbers, median fps, expedite 200x60 grid, without -> with this change:
GL (n=15): Truecolor Partial 323 -> 382 (+18%)
Terminal One Row 772 -> 1064 (+38%, ranges
overlap: 730-823 vs 711-1212)
software buffer (n=11): One Row 746 -> 851 (+14%)
Partial 474 -> 520 (+10%)
software_x11 async (n=9): Partial 524 -> 617 (+18%)
Full-redraw tests (Fire, Change) are within noise. Measured on top of
the glyph sharing below, the same change still gives GL One Row +44%
and Partial +18%: it pays where few cells change per frame and the
per-entry setup dominates.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/canvas/evas_object_textgrid.c | 75 ++++++++++++------
src/tests/evas/evas_test_textgrid.c | 122 +++++++++++++++++++++++++++++
2 files changed, 175 insertions(+), 22 deletions(-)
diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 347aa09f1f..0566ac8331 100644
--- a/src/lib/evas/canvas/evas_object_textgrid.c
+++ b/src/lib/evas/canvas/evas_object_textgrid.c
@@ -823,8 +823,8 @@ _drop_glyphs_ref(const void *container EINA_UNUSED, void *data, void *fdata)
Evas_Font_Array_Data *fad = data;
Evas_Public_Data *pd = fdata;
- if (fad->glyphs)
- evas_common_font_glyphs_unref(fad->glyphs);
+ if (!fad->glyphs) return EINA_TRUE;
+ evas_common_font_glyphs_unref(fad->glyphs);
eina_array_pop(&pd->glyph_unref_queue);
return EINA_TRUE;
@@ -956,7 +956,8 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
int rx = 0, rw = 0, run;
int line_th, underline_y, strikethrough_y;
Evas_Textgrid_Liga_Run lrun;
- Eina_Bool liga_on;
+ Eina_Bool liga_on, multi_font;
+ Evas_Font_Array sync_texts = { NULL, 0 };
/* render object to surface with context, and offset by x,y */
Evas_Textgrid_Data *o = type_private_data;
@@ -1067,6 +1068,12 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
if (tc) tc += o->cur.w;
}
yp = obj->cur->geometry.y + y;
+ multi_font = !!ENFN->multi_font_draw;
+ if ((multi_font) && (!do_async))
+ {
+ sync_texts.array = eina_inarray_new(sizeof(Evas_Font_Array_Data), 64);
+ multi_font = !!sync_texts.array;
+ }
// draw the row data that is generated from the cell array
for (yy = 0, cells = o->cur.cells; yy < o->cur.h; yy++)
{
@@ -1090,7 +1097,7 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
if (row->texts_num)
{
- if ((do_async) && (ENFN->multi_font_draw))
+ if (multi_font)
{
Evas_Font_Set *font, *current_font;
Eina_Bool async_unref;
@@ -1099,14 +1106,31 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
xx = 0;
do
{
- texts = malloc(sizeof(*texts));
- if (!texts)
+ if (do_async)
{
- ERR("Failed to allocate Evas_Font_Array.");
- return;
+ texts = malloc(sizeof(*texts));
+ if (!texts)
+ {
+ ERR("Failed to allocate Evas_Font_Array.");
+ goto done;
+ }
+ /* One allocation for a typical run, bounded
+ * for a row that alternates fonts. */
+ texts->array = eina_inarray_new(sizeof(Evas_Font_Array_Data),
+ MIN(row->texts_num - xx, 32));
+ if (!texts->array)
+ {
+ ERR("Failed to allocate Evas_Font_Array_Data array.");
+ free(texts);
+ goto done;
+ }
+ texts->refcount = 1;
+ }
+ else
+ {
+ texts = &sync_texts;
+ eina_inarray_resize(texts->array, 0);
}
- texts->array = eina_inarray_new(sizeof(Evas_Font_Array_Data), 1);
- texts->refcount = 1;
text = &row->texts[xx];
font = _textgrid_font_get(o, text->bold, text->italic);
@@ -1120,20 +1144,20 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
props = &text->text_props;
evas_common_font_draw_prepare(props);
- if (props->glyphs)
- {
- evas_common_font_glyphs_ref(props->glyphs);
- evas_unref_queue_glyph_put(obj->layer->evas,
- props->glyphs);
- }
fad = eina_inarray_grow(texts->array, 1);
if (!fad)
{
ERR("Failed to allocate Evas_Font_Array_Data.");
- eina_inarray_free(texts->array);
- free(texts);
- return;
+ if (do_async)
+ {
+ eina_inarray_foreach(texts->array,
+ _drop_glyphs_ref,
+ obj->layer->evas);
+ eina_inarray_free(texts->array);
+ free(texts);
+ }
+ goto done;
}
fad->color.r = text->r;
fad->color.g = text->g;
@@ -1141,8 +1165,12 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
fad->color.a = text->a;
fad->x = text->x;
fad->glyphs = props->glyphs;
-
- fad++;
+ if ((do_async) && (props->glyphs))
+ {
+ evas_common_font_glyphs_ref(props->glyphs);
+ evas_unref_queue_glyph_put(obj->layer->evas,
+ props->glyphs);
+ }
xx++;
if (xx >= row->texts_num)
@@ -1155,13 +1183,14 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
ENFN->context_cutout_target(engine, context,
xp - w, yp + o->ascent - h,
- w * 3, h * 3);
+ (o->cur.w + 2) * w, h * 3);
async_unref =
ENFN->multi_font_draw(engine, output, context, surface,
current_font,
xp,
yp + o->ascent,
ww, hh, ww, hh, texts, do_async);
+ if (!do_async) continue;
if (async_unref)
evas_unref_queue_texts_put(obj->layer->evas, texts);
else
@@ -1220,6 +1249,8 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
}
yp += h;
}
+done:
+ if (sync_texts.array) eina_inarray_free(sync_texts.array);
}
static void
diff --git a/src/tests/evas/evas_test_textgrid.c b/src/tests/evas/evas_test_textgrid.c
index d77831b335..4a62cd8ecc 100644
--- a/src/tests/evas/evas_test_textgrid.c
+++ b/src/tests/evas/evas_test_textgrid.c
@@ -380,6 +380,127 @@ EFL_START_TEST(evas_textgrid_test_truecolor_cellrow_set)
}
EFL_END_TEST
+static void
+_text_cells_fill(Evas_Object *tg, int only)
+{
+ int x, y;
+
+ evas_object_textgrid_truecolor_set(tg, EINA_TRUE);
+ for (y = 0; y < GRID_H; y++)
+ {
+ Evas_Textgrid_Cell *cells = evas_object_textgrid_cellrow_get(tg, y);
+ Evas_Textgrid_Truecolor *row =
+ evas_object_textgrid_truecolor_cellrow_get(tg, y);
+
+ for (x = 0; x < GRID_W; x++)
+ {
+ int idx = y * GRID_W + x;
+
+ cells[x].codepoint = (!(x & 1) && ((only < 0) || (_only_ == idx))) ?
+ 'A' + idx % 26 : 0;
+ cells[x].bold = x & 1;
+ cells[x].italic = y & 1;
+ cells[x].fg_truecolor = 1;
+ cells[x].bg_truecolor = 1;
+ row[x].fg.r = 40 + idx * 7;
+ row[x].fg.g = 255 - idx * 5;
+ row[x].fg.b = 90 + idx * 3;
+ row[x].fg.a = 255;
+ memset(&row[x].bg, 0, sizeof(row[x].bg));
+ }
+ }
+ evas_object_textgrid_update_add(tg, 0, 0, GRID_W, GRID_H);
+}
+
+/* The glyphs of a row are drawn together: they must come out as if each
+ * were drawn alone, whether the object is clipped (to nothing too) or
+ * partly covered, by one object or by several.
+ * Only every other column holds a glyph, so none overlaps another and the
+ * painted pixels of the single renders add up to the whole one. */
+EFL_START_TEST(evas_textgrid_test_text_cells_independent)
+{
+ int variant;
+
+ for (variant = 0; variant < 5; variant++)
+ {
+ START_TG_TEST();
+ Evas_Object *tg = _textgrid_new(e);
+ unsigned int *full, *single, *sum;
+ int idx, i;
+
+ if (variant == 1)
+ {
+ Evas_Object *clipper = evas_object_rectangle_add(e);
+
+ evas_object_geometry_set(clipper, cw / 2 + 1, ch / 2 + 1,
+ cw * 5 + 3, ch * 2 + 2);
+ evas_object_show(clipper);
+ evas_object_clip_set(tg, clipper);
+ }
+ else if (variant == 2)
+ {
+ Evas_Object *cover = evas_object_rectangle_add(e);
+
+ evas_object_color_set(cover, 0, 0, 255, 255);
+ evas_object_geometry_set(cover, cw * 2 + 3, ch + 2,
+ cw * 2 + 5, ch + 7);
+ evas_object_show(cover);
+ }
+ else if (variant == 3)
+ {
+ int i;
+
+ /* two opaque objects cut the same row of glyphs */
+ for (i = 0; i < 2; i++)
+ {
+ Evas_Object *cover = evas_object_rectangle_add(e);
+
+ evas_object_color_set(cover, 0, 0, 255, 255);
+ evas_object_geometry_set(cover, cw * (1 + 4 * i) + 3,
+ ch + 2, cw * 2 + 2, ch);
+ evas_object_show(cover);
+ }
+ }
+ else if (variant == 4)
+ {
+ Evas_Object *clipper = evas_object_rectangle_add(e);
+
+ evas_object_geometry_set(clipper, cw, ch, 0, 0);
+ evas_object_show(clipper);
+ evas_object_clip_set(tg, clipper);
+ }
+
+ sum = calloc(CANVAS_W * CANVAS_H, sizeof(unsigned int));
+ fail_if(!sum);
+ _text_cells_fill(tg, -1);
+ full = _snapshot(ee);
+ for (idx = 0; idx < GRID_W * GRID_H; idx++)
+ {
+ if ((idx % GRID_W) & 1) continue;
+ _text_cells_fill(tg, idx);
+ single = _snapshot(ee);
+ for (i = 0; i < CANVAS_W * CANVAS_H; i++)
+ {
+ if (!single[i]) continue;
+ if (sum[i] && (sum[i] != single[i]))
+ ck_abort_msg("variant %d: glyph %d paints pixel %d "
+ "over another glyph", variant, idx, i);
+ sum[i] = single[i];
+ }
+ free(single);
+ }
+ for (i = 0; i < CANVAS_W * CANVAS_H; i++)
+ if (full[i] != sum[i])
+ ck_abort_msg("variant %d pixel (%d,%d): %#08x alone, %#08x in "
+ "the grid", variant, i % CANVAS_W, i / CANVAS_W,
+ sum[i], full[i]);
+ free(sum);
+ free(full);
+ END_TG_TEST();
+ }
+}
+EFL_END_TEST
+
void evas_test_textgrid(TCase *tc)
{
tcase_add_test(tc, evas_textgrid_test_truecolor_setget);
@@ -390,6 +511,7 @@ void evas_test_textgrid(TCase *tc)
tcase_add_test(tc, evas_textgrid_test_truecolor_resize_zeroed);
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);
}
#endif // BUILD_ENGINE_BUFFER
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.