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 453a686f6a43d27f679b6547eadcb4b912504837
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 13:24:04 2026 -0600
evas/gl: blur as wide as the software engine
The GL gaussian used a third of the radius as its sigma, marked as an
experimental value to be adjusted. Measured on an edge, the software
blur (a raised cosine up to 2px, stacked boxes above) is wider than
that at small radii, by up to 20% at 4px, and about as wide from 32px
on. Text blurred on a GL canvas looked sharper than on a software one.
The divisor now goes from 2.55 to 3 with the radius asked for, which
keeps the two within 7% of each other at nearly every radius. The GL
passes run on downscaled buffers, so blur commands now carry the
factor. The weight texture is also uploaded again when the weights
change under the same pass radius, which can now happen.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/filters/evas_filter.c | 2 ++
src/lib/evas/filters/evas_filter_private.h | 1 +
.../evas/engines/gl_common/evas_gl_context.c | 3 +-
.../engines/gl_generic/filters/gl_filter_blur.c | 32 ++++++++++++-------
src/tests/evas/evas_test_filters.c | 37 ++++++++++++++++++++++
5 files changed, 63 insertions(+), 12 deletions(-)
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index b0e60cf3ab..82ce48aa3a 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -840,6 +840,7 @@ evas_filter_command_blur_add_gl(Evas_Filter_Context *ctx,
if (!cmd) goto fail;
cmd->blur.type = type;
cmd->blur.dx = dx;
+ cmd->blur.downscale = (dx_in != in) ? down_x : 1;
cmd->blur.count = count;
cmd->draw.alphaonly = alphaonly;
}
@@ -851,6 +852,7 @@ evas_filter_command_blur_add_gl(Evas_Filter_Context *ctx,
if (!cmd) goto fail;
cmd->blur.type = type;
cmd->blur.dy = dy;
+ cmd->blur.downscale = (dx_in != in) ? down_y : 1;
cmd->blur.count = count;
cmd->draw.alphaonly = alphaonly;
}
diff --git a/src/lib/evas/filters/evas_filter_private.h b/src/lib/evas/filters/evas_filter_private.h
index 4ea6e0a66a..9b3b3c9a49 100644
--- a/src/lib/evas/filters/evas_filter_private.h
+++ b/src/lib/evas/filters/evas_filter_private.h
@@ -188,6 +188,7 @@ struct _Evas_Filter_Command
{
float dx, dy;
int count;
+ int downscale; // factor the input was downscaled by, 0 if it was not
Evas_Filter_Blur_Type type;
Eina_Bool auto_count : 1; // If true, BOX blur will be smooth using
} blur;
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index 8b15793e5e..133b053a0b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -3826,7 +3826,8 @@ evas_gl_common_filter_blur_push(Evas_Engine_GL_Context *gc,
_filter_data_alloc(gc, pn, 0);
// Synchronous upload of Nx2 RGBA texture
- if (!EINA_DBL_EQ(prog->filter->blur_radius, radius))
+ /* the same radius may come with other weights, which their sum tells */
+ if (!EINA_DBL_EQ(prog->filter->blur_radius, radius) || update_uniforms)
{
prog->filter->blur_radius = radius;
diff --git a/src/modules/evas/engines/gl_generic/filters/gl_filter_blur.c b/src/modules/evas/engines/gl_generic/filters/gl_filter_blur.c
index b00f645340..758dea321f 100644
--- a/src/modules/evas/engines/gl_generic/filters/gl_filter_blur.c
+++ b/src/modules/evas/engines/gl_generic/filters/gl_filter_blur.c
@@ -3,14 +3,23 @@
// sqrt(2 * M_PI)
#define SQRT_2_PI 2.506628274631
+/* The software engine is the reference: a raised cosine up to 2px, then
+ * stacked box blurs. Their width, as a fraction of the radius asked for,
+ * goes down from about 1/2.55 at small radii to 1/3 at large ones, and the
+ * gaussian here follows it. radius is the one of this pass, which runs on
+ * buffers downscaled by the given factor. */
static inline double
-_radius_to_sigma(double radius)
+_radius_to_sigma(double radius, int downscale)
{
- // In theory, sqrt(radius / 3.0) but that means the outer pixel at radius
- // pixels away from the center have ~0.001 weight.
+ const double requested = radius * downscale;
+ double divisor = 3.0;
- // This is an experimental value - to be adjusted!
- return /*sqrt*/ (radius / 3.0);
+ /* the software kernel of 1px hardly blurs at all */
+ if (requested >= 2.0)
+ divisor = CLAMP(2.55 + ((requested - 12.0) * (3.0 - 2.55) / (32.0 - 12.0)),
+ 2.55, 3.0);
+
+ return radius / divisor;
}
static inline double
@@ -20,7 +29,7 @@ _gaussian_val(double a EINA_UNUSED, double b, double x)
}
static void
-_gaussian_calc(double *values, int max_index, double radius)
+_gaussian_calc(double *values, int max_index, double sigma)
{
// Gaussian: f(x) = a * exp(-(x^2 / b))
// sigma is such that variance v = sigma^2
@@ -29,10 +38,9 @@ _gaussian_calc(double *values, int max_index, double radius)
// b = 2 * sigma^2
// The constant a is not required since we always calculate the dividor
- double a, b, sigma;
+ double a, b;
int k;
- sigma = _radius_to_sigma(radius);
a = 1.0 / (sigma * SQRT_2_PI);
b = 2.0 * sigma * sigma;
@@ -44,7 +52,8 @@ _gaussian_calc(double *values, int max_index, double radius)
}
static int
-_gaussian_interpolate(double **weights, double **offsets, double radius)
+_gaussian_interpolate(double **weights, double **offsets, double radius,
+ int downscale)
{
int k, count, max_index;
double *w, *o;
@@ -54,7 +63,7 @@ _gaussian_interpolate(double **weights, double **offsets, double radius)
if (max_index & 0x1) max_index++;
values = alloca((max_index + 1) * sizeof(*values));
values[0] = 0.0;
- _gaussian_calc(values, max_index, radius);
+ _gaussian_calc(values, max_index, _radius_to_sigma(radius, downscale));
count = (max_index / 2) + 1;
*offsets = o = calloc(1, count * sizeof(*o));
@@ -187,7 +196,8 @@ _gl_filter_blur(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
else
gc->dc->render_op = _gfx_to_evas_render_op(cmd->draw.rop);
- count = _gaussian_interpolate(&weights, &offsets, radius);
+ count = _gaussian_interpolate(&weights, &offsets, radius,
+ MAX(cmd->blur.downscale, 1));
_output_scale_get(cmd->ctx, cmd, &scale_x, &scale_y);
d_ob = cmd->ctx->obscured.effective;
diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c
index 8e41441a2a..6a967f789d 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -874,6 +874,42 @@ EFL_END_TEST
#undef SHOW
#undef TEXT
+/* Both engines blur as much: the width matters to the eye where it moves the
+ * edge of a glyph by more than the noise of the two implementations. */
+EFL_START_TEST(evas_filter_gl_blur_width)
+{
+ static const int radii[] = { 4, 6, 8, 12, 16, 24, 48 };
+ int failed = 0;
+
+ for (unsigned r = 0; r < EINA_C_ARRAY_LENGTH(radii); r++)
+ for (int flat = 0; flat < 2; flat++)
+ {
+ DATA32 *sw, *gl;
+ char code[128];
+ int differ = 0;
+
+ snprintf(code, sizeof(code),
+ "padding_set { 50 } blur { %s%d, color = 'black' }",
+ flat ? "ry = 0, rx = " : "", radii[r]);
+ gl = _engine_filter_render("opengl_x11", code);
+ if (!gl) return;
+ sw = _engine_filter_render("buffer", code);
+ fail_if(!sw);
+ for (int k = 0; k < GL_W * GL_H; k++)
+ if (abs((int) (gl[k] & 0xff) - (int) (sw[k] & 0xff)) > 12)
+ differ++;
+ free(sw);
+ free(gl);
+ /* half a percent of the canvas */
+ if (differ <= GL_W * GL_H / 200) continue;
+ fprintf(stderr, "%d pixels differ from software with: %s\n",
+ differ, code);
+ failed++;
+ }
+ ck_assert_int_eq(failed, 0);
+}
+EFL_END_TEST
+
void evas_test_filters(TCase *tc)
{
tcase_add_test(tc, evas_filter_parser);
@@ -888,5 +924,6 @@ void evas_test_filters(TCase *tc)
tcase_add_test(tc, evas_filter_gl_buffers_start_empty);
tcase_add_test(tc, evas_filter_gl_inverse_color);
tcase_add_test(tc, evas_filter_gl_alpha_writes);
+ tcase_add_test(tc, evas_filter_gl_blur_width);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.