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 b7d36d5571a813691a2836b3f5fa739789a5784c
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 22:17:00 2026 -0600
evas/map: limit vertex colors in anti-aliased maps
Edge pixels of the anti-aliased rasterizer extrapolate a little past the
corners. A color channel that left 0 to 255 there was converted and
or-ed into the color unchecked, overwriting the channels above it: a
face shaded from black could show near white pixels along an edge.
Values in range are truncated as before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/common/evas_map_image_internal_high.c | 11 +++-
src/tests/evas/evas_test_map.c | 70 ++++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/src/lib/evas/common/evas_map_image_internal_high.c b/src/lib/evas/common/evas_map_image_internal_high.c
index 02069c865c..a624c8682c 100644
--- a/src/lib/evas/common/evas_map_image_internal_high.c
+++ b/src/lib/evas/common/evas_map_image_internal_high.c
@@ -341,6 +341,14 @@ _map_aa_apply(AASpans *aa_spans, DATA32 *dst, int dw)
#endif
/************************** TEXTURE MAPPING CODE ******************************/
+/* One vertex color channel: the edges extrapolate a hair past the corners,
+ * and past its range a channel would run into its neighbours. */
+static inline DATA32
+_map_triangle_channel(float value)
+{
+ return (value <= 0) ? 0 : ((value >= 255) ? 255 : (DATA32)value);
+}
+
/* Inlined once with persp false and once with it true, so that flat faces
* do not pay for the division. */
static EFL_ALWAYS_INLINE void
@@ -493,7 +501,8 @@ _map_triangle_scanlines(RGBA_Image *src, RGBA_Image *dst,
tmp = ((DATA32)channel[0] << 24) | (channel[1] << 16) | (channel[2] << 8) | channel[3];
}
else
- tmp = (((int) c[0]) << 24) | (((int) c[1]) << 16) | (((int) c[2]) << 8) | ((int) c[3]);
+ tmp = (_map_triangle_channel(c[0]) << 24) | (_map_triangle_channel(c[1]) << 16) |
+ (_map_triangle_channel(c[2]) << 8) | _map_triangle_channel(c[3]);
*(buf++) = MUL4_SYM(tmp, px);
c[0] += _dcdx[0];
c[1] += _dcdx[1];
diff --git a/src/tests/evas/evas_test_map.c b/src/tests/evas/evas_test_map.c
index b77b564df0..dccfd24bac 100644
--- a/src/tests/evas/evas_test_map.c
+++ b/src/tests/evas/evas_test_map.c
@@ -460,6 +460,75 @@ EFL_START_TEST(evas_object_map_anti_alias_edges)
}
EFL_END_TEST
+/* Vertex colors are limited to their range too: extrapolated past it at an
+ * edge, a channel of the anti-aliased rasterizer ran into its neighbours.
+ * A white image shaded from black to white stays gray. */
+EFL_START_TEST(evas_object_map_anti_alias_edge_colors)
+{
+ Ecore_Evas *ee;
+ Evas_Object *bg, *img;
+ Evas_Map *map;
+ unsigned int *source;
+ const unsigned int *pixels;
+ int i, j, wrong = 0;
+ unsigned int first = 0;
+
+ ee = ecore_evas_buffer_new(160, 120);
+ ecore_evas_show(ee);
+ bg = evas_object_rectangle_add(ecore_evas_get(ee));
+ evas_object_resize(bg, 160, 120);
+ evas_object_show(bg);
+ img = evas_object_image_filled_add(ecore_evas_get(ee));
+ evas_object_image_size_set(img, 37, 23);
+ source = evas_object_image_data_get(img, EINA_TRUE);
+ memset(source, 0xff, 37 * 23 * sizeof(*source));
+ evas_object_image_data_set(img, source);
+ evas_object_image_data_update_add(img, 0, 0, 37, 23);
+ evas_object_resize(img, 37, 23);
+ evas_object_anti_alias_set(img, EINA_TRUE);
+ evas_object_show(img);
+ map = evas_map_new(4);
+
+ for (i = 0; i < 400; i++)
+ {
+ const int w = 3 + ((i * 37) % 90), h = 3 + ((i * 23) % 80);
+
+ evas_map_util_points_populate_from_geometry
+ (map, 10 + ((i * 13) % 50), 5 + ((i * 7) % 30), w, h, 0);
+ for (j = 0; j < 4; j++)
+ {
+ int c = ((j == 1) || (j == 2)) ? 255 : 0;
+
+ evas_map_point_image_uv_set(map, j, c ? 37 : 0, (j >= 2) ? 23 : 0);
+ evas_map_point_color_set(map, j, c, c, c, 255);
+ }
+ /* one corner pulled elsewhere: such faces fold over */
+ evas_map_point_coord_set(map, i % 4, (i * 53) % 160, (i * 41) % 120, 0);
+ evas_map_util_rotate(map, 3.7 * (i + 1), 80, 60);
+ evas_map_smooth_set(map, EINA_TRUE);
+ evas_object_map_set(img, map);
+ evas_object_map_enable_set(img, EINA_TRUE);
+ evas_damage_rectangle_add(ecore_evas_get(ee), 0, 0, 160, 120);
+ ecore_evas_manual_render(ee);
+ pixels = ecore_evas_buffer_pixels_get(ee);
+ for (j = 0; j < (160 * 120); j++)
+ {
+ int r = (pixels[j] >> 16) & 0xff;
+ int g = (pixels[j] >> 8) & 0xff;
+ int b = pixels[j] & 0xff;
+
+ if (((pixels[j] >> 24) == 0xff) && (abs(r - g) <= 2) && (abs(g - b) <= 2))
+ continue;
+ if (!wrong++) first = pixels[j];
+ }
+ }
+ ck_assert_msg(!wrong, "%d pixels are not gray, the first is %08x", wrong, first);
+
+ evas_map_free(map);
+ ecore_evas_free(ee);
+}
+EFL_END_TEST
+
void evas_test_map(TCase *tc)
{
tcase_add_test(tc, evas_object_map_api);
@@ -471,4 +540,5 @@ void evas_test_map(TCase *tc)
tcase_add_test(tc, evas_object_map_perspective_colors);
tcase_add_test(tc, evas_object_map_perspective_colors_anti_alias);
tcase_add_test(tc, evas_object_map_anti_alias_edges);
+ tcase_add_test(tc, evas_object_map_anti_alias_edge_colors);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.