This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/285/head
in repository efl.
View the commit online.
commit 8d1ccfaceb390ce9bb52e21828eedd4e064d98d7
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 13:47:26 2026 -0600
evas/filters: make curve and displace replace their destination
A curve or displacement whose destination is its source runs into a
temporary buffer, which was then blended over the source instead of
replacing it. An in-place curve could thus never lower a value: one
mapping everything to zero left the buffer as it was. The curve and
mask filter examples, meant to draw an outline and an inner glow, drew
nearly solid black text.
The temporary is now copied back, as for an in-place blur. Filters
which use either in place render differently from before.
The GL curve also blended into a destination other than its source,
where software replaces it.
The new tests check the values left in the buffers on each engine,
since the two shared the first bug and agreed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/filters/evas_filter.c | 35 +++++++---
.../engines/gl_generic/filters/gl_filter_curve.c | 4 +-
src/tests/evas/evas_test_filters.c | 79 ++++++++++++++++++++++
3 files changed, 107 insertions(+), 11 deletions(-)
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 43f8656bc5..e721de7ebb 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -1360,6 +1360,30 @@ fail:
return NULL;
}
+/* An operation which can not run in place goes through a temporary buffer:
+ * its result then replaces the buffer, whatever the drawing context says. */
+static Evas_Filter_Command *
+_command_copy_back(Evas_Filter_Context *ctx, void *draw_context,
+ const Evas_Filter_Buffer *from, const Evas_Filter_Buffer *to)
+{
+ Evas_Filter_Command *cmd;
+ int R, G, B, A, render_op;
+
+ ENFN->context_color_get(ENC, draw_context, &R, &G, &B, &A);
+ render_op = ENFN->context_render_op_get(ENC, draw_context);
+ ENFN->context_color_set(ENC, draw_context, 255, 255, 255, 255);
+ ENFN->context_render_op_set(ENC, draw_context, EVAS_RENDER_COPY);
+
+ cmd = evas_filter_command_blend_add(ctx, draw_context, from->id, to->id,
+ 0, 0, EVAS_FILTER_FILL_MODE_NONE,
+ to->alpha_only);
+
+ ENFN->context_color_set(ENC, draw_context, R, G, B, A);
+ ENFN->context_render_op_set(ENC, draw_context, render_op);
+
+ return cmd;
+}
+
Evas_Filter_Command *
evas_filter_command_curve_add(Evas_Filter_Context *ctx,
void *draw_context EINA_UNUSED,
@@ -1411,10 +1435,7 @@ evas_filter_command_curve_add(Evas_Filter_Context *ctx,
if (tmp)
{
- blendcmd = evas_filter_command_blend_add(ctx, draw_context, curve_out->id,
- out->id, 0, 0,
- EVAS_FILTER_FILL_MODE_NONE,
- out->alpha_only);
+ blendcmd = _command_copy_back(ctx, draw_context, curve_out, out);
if (!blendcmd)
{
_command_del(ctx, cmd);
@@ -1435,7 +1456,6 @@ evas_filter_command_displacement_map_add(Evas_Filter_Context *ctx,
{
Evas_Filter_Buffer *in, *out, *map, *tmp = NULL, *disp_out;
Evas_Filter_Command *cmd = NULL;
- Eina_Bool alphaonly = EINA_FALSE;
EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(intensity >= 0, NULL);
@@ -1476,10 +1496,7 @@ evas_filter_command_displacement_map_add(Evas_Filter_Context *ctx,
{
Evas_Filter_Command *fillcmd;
- fillcmd = evas_filter_command_blend_add(ctx, draw_context, disp_out->id,
- out->id, 0, 0,
- EVAS_FILTER_FILL_MODE_NONE,
- alphaonly);
+ fillcmd = _command_copy_back(ctx, draw_context, disp_out, out);
if (!fillcmd) goto fail;
}
diff --git a/src/modules/evas/engines/gl_generic/filters/gl_filter_curve.c b/src/modules/evas/engines/gl_generic/filters/gl_filter_curve.c
index 43a7b51589..5208eecb00 100644
--- a/src/modules/evas/engines/gl_generic/filters/gl_filter_curve.c
+++ b/src/modules/evas/engines/gl_generic/filters/gl_filter_curve.c
@@ -33,8 +33,8 @@ _gl_filter_curve(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
gc->dc = evas_common_draw_context_new();
_gl_filter_multiplier_set(gc->dc, cmd);
evas_common_draw_context_clip_clip(gc->dc, 0, 0, w, h);
- if (cmd->input == cmd->output)
- gc->dc->render_op = EVAS_RENDER_COPY;
+ /* as software, a curve replaces what its destination holds */
+ gc->dc->render_op = EVAS_RENDER_COPY;
points = cmd->curve.data;
channel = (int) cmd->curve.channel;
diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c
index 2b0599b5da..4d519c06d1 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -1088,6 +1088,83 @@ EFL_START_TEST(evas_filter_gl_blur_offset)
}
EFL_END_TEST
+/* Agreeing with each other is not enough for what both engines share: these
+ * check the coverage a program leaves. Each fills buffers with a known one,
+ * and shows the result in black over white. */
+typedef struct _Value_Case Value_Case;
+struct _Value_Case
+{
+ const char *code;
+ int coverage;
+};
+
+#define A "a = buffer { 'alpha' } blend { dst = a } " \
+ "fill { dst = a, color = '#00000060' } " /* 96 */
+#define B "b = buffer { 'alpha' } blend { dst = b } " \
+ "fill { dst = b, color = '#00000060' } "
+#define RAISE "points = '0:0-128:192-255:255'" /* 96 gives 144 */
+#define ZERO "points = '0:0-255:0'"
+#define SHOW_A " blend { a, color = 'black' }"
+#define SHOW_B " blend { b, color = 'black' }"
+
+static void
+_values_check(const char *engine)
+{
+ static const Value_Case cases[] = {
+ { A "b = buffer { 'alpha' } curve { " RAISE ", src = "" dst = b }"
+ SHOW_B, 144 },
+ /* a curve replaces what its destination held... */
+ { A B "curve { " ZERO ", src = "" dst = b }" SHOW_B, 0 },
+ /* ...also when that is its source */
+ { A "curve { " RAISE ", src = "" dst = a }" SHOW_A, 144 },
+ { A "curve { " ZERO ", src = "" dst = a }" SHOW_A, 0 },
+ { "c = buffer { 'rgba' } blend { dst = c } "
+ "fill { dst = c, color = '#00000060' } "
+ "curve { " ZERO ", channel = 'a', src = "" dst = c } "
+ "blend { c }", 0 },
+ /* a map of middle grey displaces nothing */
+ { "m = buffer { 'rgba' } fill { dst = m, color = '#808080' } " A
+ "displace { m, src = "" dst = a, intensity = 1 }" SHOW_A, 96 },
+ };
+ int failed = 0;
+
+ for (unsigned k = 0; k < EINA_C_ARRAY_LENGTH(cases); k++)
+ {
+ DATA32 *pixels;
+ int got;
+
+ pixels = _engine_filter_render(engine, cases[k].code);
+ if (!pixels) return;
+ /* inside the text object, which the buffers cover */
+ got = 255 - (int) (pixels[(40 * GL_W) + 20] & 0xff);
+ free(pixels);
+ if (abs(got - cases[k].coverage) <= 6) continue;
+ fprintf(stderr, "%s: coverage %d, expected %d, with: %s\n",
+ engine, got, cases[k].coverage, cases[k].code);
+ failed++;
+ }
+ ck_assert_int_eq(failed, 0);
+}
+
+#undef A
+#undef B
+#undef RAISE
+#undef ZERO
+#undef SHOW_A
+#undef SHOW_B
+
+EFL_START_TEST(evas_filter_values)
+{
+ _values_check("buffer");
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_filter_gl_values)
+{
+ _values_check("opengl_x11");
+}
+EFL_END_TEST
+
void evas_test_filters(TCase *tc)
{
tcase_add_test(tc, evas_filter_parser);
@@ -1097,9 +1174,11 @@ void evas_test_filters(TCase *tc)
tcase_add_test(tc, evas_filter_parser_missing_lua_classes);
tcase_add_test(tc, evas_filter_group_forwards_test);
tcase_add_test(tc, evas_filter_color_glyphs);
+ tcase_add_test(tc, evas_filter_values);
if (getenv("DISPLAY"))
{
tcase_add_test(tc, evas_filter_gl_color_glyphs);
+ tcase_add_test(tc, evas_filter_gl_values);
tcase_add_test(tc, evas_filter_gl_text_color);
tcase_add_test(tc, evas_filter_gl_buffers_start_empty);
tcase_add_test(tc, evas_filter_gl_inverse_color);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.