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 b76da1974176e82d7f151f8967fea84836252118
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 21:46:39 2026 -0600
evas/map: limit v by the source height when preparing spans
evas_common_map_rgba_prepare() compared v against the source width. On
an image taller than wide, any v past the width was moved to the bottom
of the image, stretching the texture. On a wider image, a v past the
bottom was left there, and rows past the end of the image were read.
Only the prepare and draw path is affected, which the software engine
takes with pipe rendering. The other path limits v correctly. The new
test drives the affected one directly.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/common/evas_map_image.c | 9 ++-
src/tests/evas/evas_test_map_prepare.c | 134 +++++++++++++++++++++++++++++++++
src/tests/evas/meson.build | 13 ++++
3 files changed, 152 insertions(+), 4 deletions(-)
diff --git a/src/lib/evas/common/evas_map_image.c b/src/lib/evas/common/evas_map_image.c
index fa5a8849ce..63b10ad391 100644
--- a/src/lib/evas/common/evas_map_image.c
+++ b/src/lib/evas/common/evas_map_image.c
@@ -704,7 +704,7 @@ _evas_common_map_rgba_span(RGBA_Map_Spans *span,
RGBA_Map_Point *p,
int cx, int cy, int cw, int ch)
{
- int ytop, ybottom, sw;
+ int ytop, ybottom, sw, sh;
unsigned int i;
span->havecol = 4;
@@ -743,17 +743,18 @@ _evas_common_map_rgba_span(RGBA_Map_Spans *span,
// get some source image information
sw = src->cache_entry.w;
+ sh = src->cache_entry.h;
// limit u,v coords of points to be within the source image
for (i = 0; i < 4; i++)
{
if (p[i].u < 0) p[i].u = 0;
else if (p[i].u > (int)(sw << FP))
- p[i].u = src->cache_entry.w << FP;
+ p[i].u = sw << FP;
if (p[i].v < 0) p[i].v = 0;
- else if (p[i].v > (int)(sw << FP))
- p[i].v = src->cache_entry.h << FP;
+ else if (p[i].v > (int)(sh << FP))
+ p[i].v = sh << FP;
}
// allocate some spans to hold out span list
diff --git a/src/tests/evas/evas_test_map_prepare.c b/src/tests/evas/evas_test_map_prepare.c
new file mode 100644
index 0000000000..be00a6b09f
--- /dev/null
+++ b/src/tests/evas/evas_test_map_prepare.c
@@ -0,0 +1,134 @@
+/* evas_common_map_rgba_prepare() limits the source coordinates of a map to
+ * the source image before cutting it into spans, u by the width and v by the
+ * height. The software engine only takes that way with pipe rendering, so
+ * this drives it directly; it needs the internal image and draw context
+ * structures and is its own program. */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <Evas.h>
+
+#include "evas_common_private.h"
+
+#define DST 32
+
+typedef struct
+{
+ const char *name;
+ int src_w, src_h;
+ int u, v; /* bottom right source corner, may be outside */
+ int dst_w, dst_h;
+} Test_Case;
+
+static const Test_Case cases[] =
+{
+ /* a v between the width and the height is inside a tall image */
+ { "top half of a tall image", 8, 32, 8, 16, 8, 16 },
+ /* and one between the height and the width is outside a wide one */
+ { "v past the bottom of a wide image", 32, 8, 16, 12, 16, 8 },
+};
+
+/* different for every source pixel */
+static DATA32
+_src_pixel(int x, int y)
+{
+ return 0xff000000 | ((DATA32)(x + 1) << 16) | ((DATA32)(y + 1) << 8) | 0x80;
+}
+
+static RGBA_Image *
+_image_new(int w, int h)
+{
+ RGBA_Image *im = calloc(1, sizeof(RGBA_Image));
+
+ im->cache_entry.w = w;
+ im->cache_entry.h = h;
+ /* exactly sized, so a read past the last row leaves the allocation */
+ im->image.data = "" * h, sizeof(DATA32));
+ return im;
+}
+
+static void
+_image_free(RGBA_Image *im)
+{
+ free(im->image.data);
+ free(im);
+}
+
+static int
+_run(const Test_Case *tc)
+{
+ RGBA_Image *src = "" tc->src_h);
+ RGBA_Image *dst = _image_new(DST, DST);
+ RGBA_Draw_Context *dc = evas_common_draw_context_new();
+ RGBA_Map *m = calloc(1, sizeof(RGBA_Map) + (3 * sizeof(RGBA_Map_Point)));
+ const int corner[4][2] = { { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 } };
+ Eina_Rectangle clip = { 0, 0, DST, DST };
+ int x, y, i, wrong = 0;
+ /* source rows that the drawn ones map to once v is limited */
+ int v_end = (tc->v > tc->src_h) ? tc->src_h : tc->v;
+
+ for (y = 0; y < tc->src_h; y++)
+ for (x = 0; x < tc->src_w; x++)
+ src->image.data[(y * tc->src_w) + x] = _src_pixel(x, y);
+
+ evas_common_draw_context_set_clip(dc, 0, 0, DST, DST);
+
+ m->count = 4;
+ for (i = 0; i < 4; i++)
+ {
+ RGBA_Map_Point *p = &m->pts[i];
+
+ p->x = (corner[i][0] * tc->dst_w) << FP;
+ p->y = (corner[i][1] * tc->dst_h) << FP;
+ p->fx = corner[i][0] * tc->dst_w;
+ p->fy = corner[i][1] * tc->dst_h;
+ p->u = (corner[i][0] * tc->u) << FP;
+ p->v = (corner[i][1] * tc->v) << FP;
+ p->col = 0xffffffff;
+ }
+
+ if (!evas_common_map_rgba_prepare(src, dst, dc, m))
+ {
+ fprintf(stderr, "%s: nothing prepared\n", tc->name);
+ return 1;
+ }
+ evas_common_map_rgba_do(&clip, src, dst, dc, m, 0, 0);
+
+ for (y = 0; y < (tc->dst_h - 1); y++)
+ for (x = 0; x < (tc->dst_w - 1); x++)
+ {
+ DATA32 got = dst->image.data[(y * DST) + x];
+ DATA32 want = _src_pixel((x * tc->u) / tc->dst_w, (y * v_end) / tc->dst_h);
+
+ if (got == want) continue;
+ if (!wrong++)
+ fprintf(stderr, "%s: at %d,%d got %08x want %08x\n",
+ tc->name, x, y, got, want);
+ }
+ if (wrong) fprintf(stderr, "%s: %d pixels wrong\n", tc->name, wrong);
+
+ evas_common_map_rgba_clean(m);
+ free(m);
+ evas_common_draw_context_free(dc);
+ _image_free(src);
+ _image_free(dst);
+ return !!wrong;
+}
+
+int
+main(void)
+{
+ size_t i;
+ int failed = 0;
+
+ evas_init();
+ for (i = 0; i < (sizeof(cases) / sizeof(cases[0])); i++)
+ failed |= _run(&cases[i]);
+ evas_shutdown();
+ return failed;
+}
diff --git a/src/tests/evas/meson.build b/src/tests/evas/meson.build
index 9bedbe0145..186b4ca1d3 100644
--- a/src/tests/evas/meson.build
+++ b/src/tests/evas/meson.build
@@ -108,6 +108,19 @@ if host_machine.system() != 'windows'
)
endif
+# Draws a map through the prepare and draw halves of the software rasterizer;
+# needs the internal image and map structures.
+evas_map_prepare = executable('evas_map_prepare',
+ ['evas_test_map_prepare.c'],
+ dependencies: [evas_bin, evas, evas_ext_none_static_deps, eet], #internal headers, as above
+ c_args : ['-DEVAS_BUILD']
+)
+
+test('evas-map-prepare', evas_map_prepare,
+ env : test_env,
+ timeout : master_timeout
+)
+
# Compares every C/NEON pair in the evas span and point op tables. It includes
# the op translation units directly rather than linking them, because the copy
# tables are static; that keeps the library itself untouched. Skips (exit 77)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.