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

git pushed a commit to branch textgrid-render-perf
in repository efl.

View the commit online.

commit 2d2725e2f52eadbeaaed41ff947f4100957434f9
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 21 12:01:47 2026 -0600

    evas/gl: draw the textgrid background image without dither
    
    Since the textgrid draws cell backgrounds as a one-pixel-per-cell image,
    GL samples that image through the fragment shader's 2x2 ordered dither.
    On a flat color, about one pixel in four gets one level added. The rect
    backgrounds this replaced were exact, and terminal backgrounds are flat
    colors, so the dither only adds noise there.
    
    Add a draw-context bit, set through a new context_no_dither_set engine
    call, that asks GL to pick the undithered shader variant for that one
    image draw. The textgrid sets it around its background draw only, so
    every other draw keeps its dither, including regular image objects. The
    software engines have no dither and ignore the bit, and GL honours it
    for plain image draws only, not native, map or YUV ones, which the
    textgrid does not use. Batching stays safe because pipes are keyed on
    the shader program, so dithered and undithered draws never merge.
    
    On a GL window (opengl_x11, AMD), next to a regular image with the same
    colors, the textgrid background's off-color pixels went from 1088/9792
    to 0, while the regular image stayed at 1088/9792, pixel-identical.
    Expedite textgrid benchmarks on GL (n=32) show no slowdown; the runs
    were too noisy to claim a gain.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/evas/canvas/evas_object_textgrid.c              | 3 +++
 src/lib/evas/common/evas_draw.h                         | 1 +
 src/lib/evas/common/evas_draw_main.c                    | 6 ++++++
 src/lib/evas/include/evas_common_private.h              | 1 +
 src/lib/evas/include/evas_private.h                     | 1 +
 src/modules/evas/engines/gl_common/evas_gl_shader.c     | 2 ++
 src/modules/evas/engines/software_generic/evas_engine.c | 7 +++++++
 7 files changed, 21 insertions(+)

diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 26a0aad3d9..f7c49c1371 100644
--- a/src/lib/evas/canvas/evas_object_textgrid.c
+++ b/src/lib/evas/canvas/evas_object_textgrid.c
@@ -1228,11 +1228,14 @@ evas_object_textgrid_render(Evas_Object *eo_obj,
         xp = obj->cur->geometry.x + x;
         ENFN->context_cutout_target(engine, context, xp, yp,
                                     o->cur.w * w, o->cur.h * h);
+        /* One pixel per cell: GL dither would add a level to flat colors. */
+        ENFN->context_no_dither_set(engine, context, EINA_TRUE);
         async_unref = ENFN->image_draw(engine, output, context, surface,
                                        o->bg.image,
                                        0, 0, o->cur.w, o->cur.h,
                                        xp, yp, o->cur.w * w, o->cur.h * h,
                                        EINA_FALSE, do_async);
+        ENFN->context_no_dither_set(engine, context, EINA_FALSE);
         if ((do_async) && (async_unref))
           {
              evas_cache_image_ref((Image_Entry *)o->bg.image);
diff --git a/src/lib/evas/common/evas_draw.h b/src/lib/evas/common/evas_draw.h
index 14fa3ca811..44251c8af2 100644
--- a/src/lib/evas/common/evas_draw.h
+++ b/src/lib/evas/common/evas_draw.h
@@ -35,6 +35,7 @@ EVAS_API void               evas_common_draw_context_apply_clean_cutouts     (Cu
 EVAS_API void               evas_common_draw_context_set_anti_alias          (RGBA_Draw_Context *dc, unsigned char aa);
 EVAS_API void               evas_common_draw_context_set_color_interpolation (RGBA_Draw_Context *dc, int color_space);
 EVAS_API void               evas_common_draw_context_set_render_op           (RGBA_Draw_Context *dc, int op);
+EVAS_API void               evas_common_draw_context_set_no_dither           (RGBA_Draw_Context *dc, Eina_Bool no_dither);
 EVAS_API void               evas_common_draw_context_target_set              (RGBA_Draw_Context *dc, int x, int y, int w, int h);
 
 #endif /* _EVAS_DRAW_H */
diff --git a/src/lib/evas/common/evas_draw_main.c b/src/lib/evas/common/evas_draw_main.c
index df5a4a59cb..492233dffe 100644
--- a/src/lib/evas/common/evas_draw_main.c
+++ b/src/lib/evas/common/evas_draw_main.c
@@ -881,3 +881,9 @@ evas_common_draw_context_set_render_op(RGBA_Draw_Context *dc , int op)
 {
    dc->render_op = op;
 }
+
+EVAS_API void
+evas_common_draw_context_set_no_dither(RGBA_Draw_Context *dc, Eina_Bool no_dither)
+{
+   dc->no_dither = !!no_dither;
+}
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index e0393990b4..8bc18d6408 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -717,6 +717,7 @@ struct _RGBA_Draw_Context
    } interpolation;
    unsigned char render_op;
    unsigned char anti_alias : 1;
+   unsigned char no_dither : 1;
 };
 
 #ifdef BUILD_PIPE_RENDER
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 9fedeb9348..58c79ff635 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -915,6 +915,7 @@ struct _Evas_Func
    int  (*context_color_interpolation_get) (void *engine, void *context);
    void (*context_render_op_set)           (void *engine, void *context, int render_op);
    int  (*context_render_op_get)           (void *engine, void *context);
+   void (*context_no_dither_set)           (void *engine, void *context, Eina_Bool no_dither);
 
    void (*rectangle_draw)                  (void *engine, void *data, void *context, void *surface, int x, int y, int w, int h, Eina_Bool do_async);
 
diff --git a/src/modules/evas/engines/gl_common/evas_gl_shader.c b/src/modules/evas/engines/gl_common/evas_gl_shader.c
index b298df8742..2896ca6332 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_shader.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c
@@ -1047,6 +1047,8 @@ evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
                                            sw, sh, w, h, smooth, tex, tex_only,
                                            mtex, mask_smooth, mask_color, mw, mh,
                                            alphaonly, psam, pnomul, pmasksam);
+   if ((type == SHD_IMAGE) && gc->dc && gc->dc->no_dither)
+     flags &= ~SHADER_FLAG_DITHER;
    p = eina_hash_find(gc->shared->shaders_hash, &flags);
    if (!p)
      {
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 642a356516..207455cf70 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -666,6 +666,12 @@ eng_context_render_op_get(void *data EINA_UNUSED, void *context)
    return ((RGBA_Draw_Context *)context)->render_op;
 }
 
+static void
+eng_context_no_dither_set(void *data EINA_UNUSED, void *context, Eina_Bool no_dither)
+{
+   evas_common_draw_context_set_no_dither(context, no_dither);
+}
+
 static void
 _draw_thread_rectangle_draw(void *data)
 {
@@ -4713,6 +4719,7 @@ static Evas_Func func =
      eng_context_color_interpolation_get,
      eng_context_render_op_set,
      eng_context_render_op_get,
+     eng_context_no_dither_set,
      /* rect draw funcs */
      eng_rectangle_draw,
      /* line draw funcs */

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

Reply via email to