This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit cee25bdd24157af81ea9362ae1595b3a22f392cc
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 12:46:43 2026 -0600
evas/filters: keep the text color out of alpha buffers
A text object draws its glyphs into the filter's alpha-only input with
its own color. A software alpha buffer is GRY8 and keeps the coverage
only, but the GL engine backs it with an RGBA texture which keeps the
color too, and filters multiply it with theirs: black text blended
with color=darkblue came out black on opengl_x11.
Glyphs bound for an alpha buffer are now drawn in white at the
object's alpha. The software engine only reads the alpha and renders
as before.
The test runs on opengl_x11 and needs a display.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/filters/evas_filter.c | 10 ++++++++++
src/tests/evas/evas_test_filters.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 912e8c6882..d3bb042d61 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -1770,6 +1770,7 @@ evas_filter_font_draw(Evas_Filter_Context *ctx,
Eina_Bool async_unref;
Evas_Filter_Buffer *fb;
void *surface = NULL;
+ int R, G, B, A;
fb = _filter_buffer_get(ctx, bufid);
EINA_SAFETY_ON_NULL_RETURN_VAL(fb, EINA_FALSE);
@@ -1777,10 +1778,19 @@ evas_filter_font_draw(Evas_Filter_Context *ctx,
surface = evas_filter_buffer_backing_get(ctx, bufid, EINA_TRUE);
EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
+ // An alpha buffer holds coverage only, the filter brings the color. The
+ // GL engine backs it with an RGBA texture though, so draw the glyphs in
+ // white or the object's color would tint every filter reading it.
+ ENFN->context_color_get(engine, draw_context, &R, &G, &B, &A);
+ if (fb->alpha_only)
+ ENFN->context_color_set(engine, draw_context, A, A, A, A);
+
// Copied from evas_font_draw_async_check
async_unref = ENFN->font_draw(engine, output, draw_context, surface,
font, x, y, fb->w, fb->h, fb->w, fb->h,
text_props, do_async);
+ if (fb->alpha_only)
+ ENFN->context_color_set(engine, draw_context, R, G, B, A);
if (do_async && async_unref)
{
evas_common_font_glyphs_ref(text_props->glyphs);
diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c
index dcf3d34a18..6dd866a566 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -662,6 +662,35 @@ _gl_filter_render(Gl_Canvas *c, const char *code)
return copy;
}
+/* The text is rendered into an alpha buffer: its own color must not reach
+ * the filter, which picks the one it blends with. */
+EFL_START_TEST(evas_filter_gl_text_color)
+{
+ Gl_Canvas c;
+
+ if (_gl_canvas_new(&c))
+ {
+ DATA32 *pixels;
+ Eina_Bool blue = EINA_FALSE;
+
+ evas_object_color_set(c.text, 0, 0, 0, 255);
+ pixels = _gl_filter_render(&c, "blend { color = '#0000ff' }");
+ for (int k = 0; k < GL_W * GL_H; k++)
+ {
+ /* GL dithers, so not exactly the color asked for */
+ const DATA32 p = pixels[k];
+
+ if (((p & 0xff) > 0xf0) && (((p >> 16) & 0xff) < 0x10) &&
+ (((p >> 8) & 0xff) < 0x10))
+ blue = EINA_TRUE;
+ }
+ fail_if(!blue);
+ free(pixels);
+ _gl_canvas_free(&c);
+ }
+}
+EFL_END_TEST
+
/* A filter must not see what earlier filters left in GPU memory: after an
* animation of its radius, a blur renders the same pixels as on a canvas
* which never ran a filter before. */
@@ -717,6 +746,7 @@ void evas_test_filters(TCase *tc)
tcase_add_test(tc, evas_filter_group_forwards_test);
if (getenv("DISPLAY"))
{
+ tcase_add_test(tc, evas_filter_gl_text_color);
tcase_add_test(tc, evas_filter_gl_buffers_start_empty);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.