This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch devs/cedric/gl-slice-add
in repository efl.
View the commit online.
commit 95fefca5480310faf7ab01ede8633fbc9514a2ee
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 27 23:21:17 2026 -0600
evas/gl: let a managed buffer set the pixels of a new image
efl_gfx_buffer_managed_set() with ARGB8888, AGRY88 or GRY8 always
failed on a GL canvas the first time it was called on an image, which
is every time in practice. The image is then created without pixels,
and image_data_slice_add() refused it for having none before reaching
the line that hands it the caller's buffer. The object was left with
no engine image, and every later efl_gfx_buffer_map() failed.
expedite shows it: "Image Data ARGB" and "Image Data ARGB Alpha" print
"Failed to create internal image" and draw nothing on any GL engine,
while they work on the software ones. The check came with the buffer
API in 2016, so this is not a regression.
The check is only needed when the pixels are copied into the image's
own buffer, so it moves there. The software engine does not have it.
The test runs on opengl_x11 and needs a display, as the Evas GL tests
do: no other engine goes through this code.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DGDCUNaoKLQZTP2mPdMiUR
---
src/modules/evas/engines/gl_generic/evas_engine.c | 2 +-
src/tests/evas/evas_test_image.c | 98 +++++++++++++++++++++++
2 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index a22b53d2d1..4693ca49e4 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -3848,10 +3848,10 @@ eng_image_data_slice_add(void *engine, void *image,
case EFL_GFX_COLORSPACE_GRY8:
if (!bpp) bpp = 1;
if (plane != 0) goto fail;
- if (!im->im->image.data) goto fail;
if (!stride) stride = w * bpp;
if (copy)
{
+ if (!im->im->image.data) goto fail;
for (int y = 0; y < h; y++)
{
const unsigned char *src = "" + h * stride;
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index b34ed7c03f..6cbee4cebc 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -1146,6 +1146,100 @@ EFL_START_TEST(evas_object_image_buffer_copy)
}
EFL_END_TEST
+/* The GL engine has its own image_data_slice_add(), so the buffer API is
+ * checked again on a GL canvas. It needs a display: without one these tests
+ * have nothing to run on and pass, as the Evas GL tests do. */
+static void
+_buffer_pattern_fill(unsigned char *pixels, int w, int h, int stride)
+{
+ int x, y;
+
+ for (y = 0; y < h; y++)
+ {
+ unsigned int *row = (unsigned int *) (pixels + ((size_t) y * stride));
+
+ for (x = 0; x < w; x++)
+ row[x] = 0xff000000 | (unsigned int) ((y << 16) | (x << 8) | 0x11);
+ }
+}
+
+static void
+_buffer_pattern_check(Eo *o, int w, int h)
+{
+ Eina_Rw_Slice map;
+ int stride = 0;
+ int x, y;
+
+ map = efl_gfx_buffer_map(o, EFL_GFX_BUFFER_ACCESS_MODE_READ,
+ &EINA_RECT(0, 0, w, h),
+ EFL_GFX_COLORSPACE_ARGB8888, 0, &stride);
+ fail_if(!map.mem);
+
+ for (y = 0; y < h; y++)
+ {
+ const unsigned int *row = (const unsigned int *) (map.bytes + ((size_t) y * stride));
+
+ for (x = 0; x < w; x++)
+ {
+ unsigned int want = 0xff000000 | (unsigned int) ((y << 16) | (x << 8) | 0x11);
+
+ fail_if(row[x] != want);
+ }
+ }
+
+ efl_gfx_buffer_unmap(o, map);
+}
+
+static Ecore_Evas *
+_gl_ecore_evas_new(void)
+{
+ Ecore_Evas *ee;
+
+ ee = ecore_evas_new("opengl_x11", 0, 0, 16, 16, NULL);
+ if (!ee)
+ {
+ printf("Could not create an opengl_x11 canvas, skipping.\n");
+ return NULL;
+ }
+ ecore_evas_show(ee);
+ ecore_evas_manual_render_set(ee, EINA_TRUE);
+ ecore_evas_manual_render(ee);
+ return ee;
+}
+
+/* A managed buffer hands its pointer over: the image is created without
+ * pixels of its own and takes the caller's. */
+EFL_START_TEST(evas_object_image_buffer_managed_gl)
+{
+ const int w = 8, h = 4;
+ unsigned char *pixels;
+ Eina_Slice slice, managed;
+ Ecore_Evas *ee;
+ Eo *o;
+
+ ee = _gl_ecore_evas_new();
+ if (ee)
+ {
+ pixels = malloc((size_t) w * h * 4);
+ fail_if(!pixels);
+ _buffer_pattern_fill(pixels, w, h, w * 4);
+
+ o = efl_add(EFL_CANVAS_IMAGE_CLASS, ecore_evas_get(ee));
+ slice = (Eina_Slice) { .len = (size_t) w * h * 4, .mem = pixels };
+ fail_if(!efl_gfx_buffer_managed_set(o, &slice, EINA_SIZE2D(w, h), 0,
+ EFL_GFX_COLORSPACE_ARGB8888, 0));
+
+ managed = efl_gfx_buffer_managed_get(o, 0);
+ fail_if(managed.mem != pixels);
+ _buffer_pattern_check(o, w, h);
+
+ efl_del(o);
+ free(pixels);
+ ecore_evas_free(ee);
+ }
+}
+EFL_END_TEST
+
#if BUILD_LOADER_JP2K
EFL_START_TEST(evas_object_image_jp2k_loader_data)
{
@@ -1416,6 +1510,10 @@ void evas_test_image_object(TCase *tc)
tcase_add_test(tc, evas_object_image_scale_method);
tcase_add_test(tc, evas_object_image_buffer_copy);
#endif
+ if (getenv("DISPLAY"))
+ {
+ tcase_add_test(tc, evas_object_image_buffer_managed_gl);
+ }
tcase_add_test(tc, evas_object_image_partially_load_orientation);
tcase_add_test(tc, evas_object_image_cached_data_comparision);
tcase_add_test(tc, evas_object_image_9patch);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.