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 ad9430c8d682fbeae42049d65c924a0ddae8fc5e
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 15:03:53 2026 -0600
evas/tests: check padding_set and the transform offset
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/tests/evas/evas_test_filter_values.c | 125 ++++++++++++++++++++++++++++++-
1 file changed, 124 insertions(+), 1 deletion(-)
diff --git a/src/tests/evas/evas_test_filter_values.c b/src/tests/evas/evas_test_filter_values.c
index 98dd63bd7e..e08962b7ec 100644
--- a/src/tests/evas/evas_test_filter_values.c
+++ b/src/tests/evas/evas_test_filter_values.c
@@ -440,6 +440,24 @@ static const Value_Case _transform_cases[] = {
CASE("vflip in place",
TOP "transform { op = 'vflip', src = "" dst = a }" SHOW_A,
COV(64, 56, 255), COV(64, 8, 0)),
+ /* oy moves the mirror line, from the middle of the object, by oy: the row
+ * y of the source lands at 2 * (32 + oy) - y */
+#define BAND24 "fill { dst = a, color = 'black', t = 24, b = 32 } "
+ CASE("vflip with an offset",
+ "padding_set { 0 } " BAND24
+ "transform { op = 'vflip', src = "" dst = b, oy = 8 }" SHOW_B,
+ COV(64, 52, 255), COV(64, 44, 0), COV(64, 60, 0), COV(64, 28, 0)),
+ CASE("vflip with a negative offset",
+ "padding_set { 0 } " BAND24
+ "transform { op = 'vflip', src = "" dst = b, oy = -8 }" SHOW_B,
+ COV(64, 20, 255), COV(64, 12, 0), COV(64, 28, 0)),
+ /* the padding the offset asks for leaves the object 48px, mirrored about
+ * the middle of the buffer */
+ CASE("vflip with an offset and its own padding",
+ "fill { dst = a, color = 'black', t = 8, b = 48 } "
+ "transform { op = 'vflip', src = "" dst = b, oy = 8 }" SHOW_B,
+ COV(64, 51, 255), COV(64, 12, 0), COV(64, 40, 0), COV(64, 60, 0)),
+#undef BAND24
};
static const Value_Case _color_cases[] = {
@@ -501,6 +519,9 @@ _snapshot_save(void *data, Evas *e, void *event_info EINA_UNUSED)
evas_object_image_save(s->snap, s->file, NULL, NULL);
}
+/* the color of the pixels of the filtered image */
+static uint32_t _input = 0;
+
static Eina_Bool
_render(const char *engine, const char *code, uint32_t *out)
{
@@ -539,7 +560,9 @@ _render(const char *engine, const char *code, uint32_t *out)
evas_object_image_size_set(o, W, H);
evas_object_image_alpha_set(o, EINA_TRUE);
pixels = evas_object_image_data_get(o, EINA_TRUE);
- memset(pixels, 0, (size_t) evas_object_image_stride_get(o) * H);
+ for (y = 0; y < H; y++)
+ for (x = 0; x < W; x++)
+ pixels[(y * evas_object_image_stride_get(o) / 4) + x] = _input;
evas_object_image_data_set(o, pixels);
evas_object_image_data_update_add(o, 0, 0, W, H);
evas_object_resize(o, W, H);
@@ -605,6 +628,19 @@ _error_count(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file,
eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, data, args);
}
+/* the same with an opaque black input */
+static Eina_Bool
+_image_render(const char *engine, const char *code, uint32_t *out)
+{
+ Eina_Bool ret;
+
+ _input = 0xff000000;
+ ret = _render(engine, code, out);
+ _input = 0;
+
+ return ret;
+}
+
static void
_cases_check(const char *engine, const Value_Case *cases, int count)
{
@@ -882,8 +918,95 @@ EFL_START_TEST(evas_filter_gl_alpha)
}
EFL_END_TEST
+typedef struct _Padding_Case Padding_Case;
+struct _Padding_Case
+{
+ const char *code;
+ int l, r, t, b;
+};
+
+static const Padding_Case _paddings[] = {
+ { "padding_set { 8 } blend { }", 8, 8, 8, 8 },
+ { "padding_set { l = 4, r = 8, t = 12, b = 16 } blend { }", 4, 8, 12, 16 },
+ { "padding_set { 4, 8, 12, 16 } blend { }", 4, 8, 12, 16 },
+ /* r defaults to l, t to r, b to t */
+ { "padding_set { l = 6 } blend { }", 6, 6, 6, 6 },
+ { "padding_set { l = 4, r = 8 } blend { }", 4, 8, 8, 8 },
+ { "padding_set { l = 4, r = 8, t = 12 } blend { }", 4, 8, 12, 12 },
+ /* invalid values reset all of them */
+ { "padding_set { l = -4, r = 8 } blend { }", 0, 0, 0, 0 },
+};
+
+/* A Text object grows by the padding of its filter, and its text moves by the
+ * left and top ones; an image keeps its size and shrinks its content. */
+static void
+_padding_check(const char *engine)
+{
+ static uint32_t out[W * H];
+ Ecore_Evas *ee;
+ Evas_Object *text;
+ Evas_Coord w0, h0, w, h;
+ int failed = 0;
+
+ for (unsigned n = 0; n < EINA_C_ARRAY_LENGTH(_paddings); n++)
+ {
+ const Padding_Case *t = &_paddings[n];
+ int x0 = W, y0 = H, x1 = -1, y1 = -1;
+
+ ee = ecore_evas_new(engine, 0, 0, W, H, NULL);
+ if (!ee) return;
+ text = evas_object_text_add(ecore_evas_get(ee));
+ evas_object_text_font_set(text, "DejaVuSans", 20);
+ evas_object_text_text_set(text, "Text");
+ evas_object_geometry_get(text, NULL, NULL, &w0, &h0);
+ efl_gfx_filter_program_set(text, t->code, "padding");
+ evas_object_geometry_get(text, NULL, NULL, &w, &h);
+ ecore_evas_free(ee);
+ if ((w != w0 + t->l + t->r) || (h != h0 + t->t + t->b))
+ {
+ fprintf(stderr, "VALUE %s: text is %dx%d, expected %dx%d: %s\n",
+ engine, w, h, w0 + t->l + t->r, h0 + t->t + t->b, t->code);
+ failed++;
+ }
+
+ if (!_image_render(engine, t->code, out)) return;
+ for (int y = 0; y < H; y++)
+ for (int x = 0; x < W; x++)
+ if ((out[(y * W) + x] & 0xff) < 128)
+ {
+ if (x < x0) x0 = x;
+ if (x > x1) x1 = x;
+ if (y < y0) y0 = y;
+ if (y > y1) y1 = y;
+ }
+ if ((x0 != t->l) || (y0 != t->t) ||
+ (x1 != W - t->r - 1) || (y1 != H - t->b - 1))
+ {
+ fprintf(stderr, "VALUE %s: image covers %d,%d to %d,%d, expected "
+ "%d,%d to %d,%d: %s\n", engine, x0, y0, x1, y1, t->l,
+ t->t, W - t->r - 1, H - t->b - 1, t->code);
+ failed++;
+ }
+ }
+ ck_assert_int_eq(failed, 0);
+}
+
+EFL_START_TEST(evas_filter_padding_set)
+{
+ _padding_check("buffer");
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_filter_gl_padding_set)
+{
+ _padding_check("opengl_x11");
+}
+EFL_END_TEST
+
void evas_test_filter_values(TCase *tc)
{
+ tcase_add_test(tc, evas_filter_padding_set);
+ if (getenv("DISPLAY")) tcase_add_test(tc, evas_filter_gl_padding_set);
tcase_add_test(tc, evas_filter_alpha);
if (getenv("DISPLAY")) tcase_add_test(tc, evas_filter_gl_alpha);
tcase_add_test(tc, evas_filter_quiet);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.