This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch ecore-evas-gl-drm-offscreen
in repository efl.

View the commit online.

commit 3eecd2b09c5d85a3f339f13a90284fcac72dbabf
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 15:38:51 2026 -0600

    ecore_evas: let the consumer of an offscreen canvas choose the modifiers
    
    ecore_evas_gl_drm_offscreen_new() takes the DRM format modifiers the
    consumer can import, which the gl_drm engine intersects with what the
    driver draws in.  NULL and 0 keep the linear frames that a consumer
    which maps them needs.  The frames report the modifier and every plane
    the driver gave them, and the documentation says that only a linear
    frame can be read row by row.
    
    There is no call to ask a node which modifiers it draws in: that needs
    an EGL display on the node before any canvas exists, and the answer is
    only useful to a consumer that then calls this.  A consumer that wants
    the best layout passes what its importer takes, and tries again with
    NULL when no canvas comes.  A refused list leaves nothing behind.
    
    The signature changes on an API that is not released, instead of a
    second constructor that every caller would have to choose between.
    The list is copied: the engine reads it again whenever it makes its
    output again, as for a change of depth, long after the caller let go
    of it.
    
    Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
 src/lib/ecore_evas/Ecore_Evas.h                    |  51 ++-
 src/lib/ecore_evas/ecore_evas.c                    |   9 +-
 .../ecore_evas/engines/drm/ecore_evas_drm.c        |  24 +-
 src/tests/ecore/ecore_test_ecore_evas_gl_drm.c     | 358 ++++++++++++++++++++-
 src/tests/ecore/meson.build                        |   2 +-
 5 files changed, 426 insertions(+), 18 deletions(-)

diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h
index ea92e3cb52..28acaf64f2 100644
--- a/src/lib/ecore_evas/Ecore_Evas.h
+++ b/src/lib/ecore_evas/Ecore_Evas.h
@@ -1767,11 +1767,17 @@ typedef void (*Ecore_Evas_Gl_Drm_Buffer_Free_Cb)(void *data, uint64_t buffer_id)
  *        chosen.
  * @param w The width of the canvas, in pixels, at least 1.
  * @param h The height of the canvas, in pixels, at least 1.
+ * @param modifiers The DRM format modifiers the consumer can take for the
+ *        frames, in no order of preference, or @c NULL for linear. It is
+ *        copied.
+ * @param modifier_count The number of modifiers in @p modifiers, 0 for
+ *        linear.
  * @return The new canvas, or @c NULL if it could not be made: no node
  *         given, the node cannot be opened, is not a DRM render node (a
  *         primary node, such as <tt>/dev/dri/card0</tt>, is refused) or
  *         cannot be drawn on (software GL is refused), the gl_drm engine
- *         is not available, or a canvas already draws on another node.
+ *         is not available, a canvas already draws on another node, a
+ *         count with no list, or none of the modifiers can be had.
  *
  * It is meant for a compositor with no monitor, such as a remote desktop
  * session. The canvas is hidden: show it with ecore_evas_show(), and make
@@ -1785,6 +1791,33 @@ typedef void (*Ecore_Evas_Gl_Drm_Buffer_Free_Cb)(void *data, uint64_t buffer_id)
  * the canvas of ecore_evas_gl_drm_new().
  *
  * The frames are XRGB8888 and their rows run from the top to the bottom.
+ * Their layout is the one @c modifier of
+ * ecore_evas_gl_drm_frame_dmabuf_get() says. With no modifiers, or with
+ * @c DRM_FORMAT_MOD_LINEAR alone, they are linear, which every importer
+ * takes and which a consumer can map and read row by row. That costs
+ * rendering performance, since the GPU does not tile or compress what it
+ * draws, and is the safe default for a consumer that maps the frames with
+ * the CPU. A consumer that imports the frames into a device can say which
+ * modifiers that device takes: the canvas keeps those that the driver lists
+ * for XRGB8888 on the node and can allocate at its size, makes its buffers
+ * with them, and lets the driver choose, so the frames may have any of
+ * them, and which one is only known from the frame. The layout of such a frame may be tiled or
+ * compressed, and may have several planes. A list with
+ * @c DRM_FORMAT_MOD_LINEAR in it always gets a canvas, linear if the
+ * driver has nothing else of the list.
+ *
+ * A driver can allocate a layout at some sizes and not at others. When the
+ * canvas is resized to a size where it cannot, it makes linear buffers if
+ * linear was in the list, and goes on making them for good, whatever the
+ * size after; otherwise it gets none: no frame comes, with an error logged
+ * once, until the canvas has a size it can have.
+ *
+ * There is no call that asks which modifiers a node draws in: it needs a
+ * display on the node before any canvas exists. A consumer that wants to
+ * know tries, with the list of what its importer takes, and if this
+ * returns @c NULL for want of any, tries again with @c NULL, or another
+ * list. The canvas is not made, and nothing is left, when it is refused.
+ *
  * The canvas has no screen, pointer or rotation: ecore_evas_rotation_set()
  * and ecore_evas_fullscreen_set() log an error and do nothing, the screen
  * geometry is the canvas, the screen dpi is not reported,
@@ -1812,7 +1845,9 @@ typedef void (*Ecore_Evas_Gl_Drm_Buffer_Free_Cb)(void *data, uint64_t buffer_id)
  * @see ecore_evas_gl_drm_frame_callbacks_set()
  * @since 1.30
  */
-EAPI Ecore_Evas *ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h);
+EAPI Ecore_Evas *ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h,
+                                                 const uint64_t *modifiers,
+                                                 unsigned int modifier_count);
 
 /**
  * @brief Sets the callbacks of the consumer of the frames of a canvas made
@@ -1935,10 +1970,14 @@ struct _Ecore_Evas_Gl_Drm_Dmabuf
  *         resized or freed, which #Ecore_Evas_Gl_Drm_Buffer_Free_Cb tells
  *         of, or if it could not be exported.
  *
- * The frames are XRGB8888 (@c DRM_FORMAT_XRGB8888) in a single plane, and
- * linear: @c modifier is @c DRM_FORMAT_MOD_LINEAR, which is what the canvas
- * asked the driver for, and not the invalid modifier gbm reports for a
- * buffer made without any. An importer can use it as it is.
+ * The frames are XRGB8888 (@c DRM_FORMAT_XRGB8888). @c modifier is the
+ * layout of the buffer, one of those given to
+ * ecore_evas_gl_drm_offscreen_new(), or @c DRM_FORMAT_MOD_LINEAR when none
+ * was given, and never the invalid modifier. Each of the @c plane_count
+ * planes has a descriptor, a stride and an offset, and an importer takes
+ * them as they are. Only a linear buffer, which has a single plane, can be
+ * mapped and read row by row, from its first descriptor: a buffer of any
+ * other layout is meant for the import into a device that knows it.
  *
  * Each call makes new descriptors, which the caller closes. They stay
  * valid after the frame is released and after the canvas is resized or
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index 4787f70c58..41522282bf 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -4637,13 +4637,16 @@ ecore_evas_gl_drm_new(const char *disp_name, unsigned int parent,
 }
 
 EAPI Ecore_Evas *
-ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h)
+ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h,
+                                const uint64_t *modifiers,
+                                unsigned int modifier_count)
 {
    Ecore_Evas *ee;
-   Ecore_Evas *(*new)(const char *, int, int);
+   Ecore_Evas *(*new)(const char *, int, int, const uint64_t *, unsigned int);
    Eina_Module *m;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(render_node, NULL);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL((modifier_count > 0) && (!modifiers), NULL);
 
    m = _ecore_evas_engine_load("drm");
    EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
@@ -4651,7 +4654,7 @@ ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h)
    new = eina_module_symbol_get(m, "ecore_evas_gl_drm_offscreen_new_internal");
    EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL);
 
-   ee = new(render_node, w, h);
+   ee = new(render_node, w, h, modifiers, modifier_count);
    if (!ee) return NULL;
 
    if (!_ecore_evas_cursors_init(ee))
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 20186780a3..b21402a523 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -1212,6 +1212,9 @@ struct _Ecore_Evas_Gl_Drm_Offscreen_Data
    /* The buffers given to frame_func that buffer_free_func was not told
     * the end of yet, as uint64_t */
    Eina_Inarray *buffers_known;
+   /* The modifiers asked for, which the engine reads again whenever it
+    * makes its output again */
+   uint64_t *modifiers;
    /* The size of the last frame given to frame_func */
    int frame_w, frame_h;
    /* What the next frame holds is not relative to the last one given to the
@@ -1543,6 +1546,7 @@ _offscreen_free(Ecore_Evas *ee)
      }
    _offscreen_link_unref(odata->link);
    if (odata->buffers_known) eina_inarray_free(odata->buffers_known);
+   free(odata->modifiers);
    free(odata);
    ee->engine.data = ""
    _offscreen_node_unref();
@@ -1622,7 +1626,9 @@ static const Ecore_Evas_Engine_Func _ecore_evas_gl_drm_offscreen_engine_func =
 };
 
 EMODAPI Ecore_Evas *
-ecore_evas_gl_drm_offscreen_new_internal(const char *render_node, int w, int h)
+ecore_evas_gl_drm_offscreen_new_internal(const char *render_node, int w, int h,
+                                         const uint64_t *modifiers,
+                                         unsigned int modifier_count)
 {
    Ecore_Evas *ee;
    Ecore_Evas_Interface_Drm *iface;
@@ -1656,6 +1662,20 @@ ecore_evas_gl_drm_offscreen_new_internal(const char *render_node, int w, int h)
         return NULL;
      }
 
+   if (modifier_count)
+     {
+        odata->modifiers = malloc(sizeof(uint64_t) * modifier_count);
+        if (!odata->modifiers)
+          {
+             free(link);
+             free(odata);
+             free(ee);
+             _offscreen_node_unref();
+             return NULL;
+          }
+        memcpy(odata->modifiers, modifiers, sizeof(uint64_t) * modifier_count);
+     }
+
    ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
 
    ee->driver = "gl_drm";
@@ -1700,6 +1720,8 @@ ecore_evas_gl_drm_offscreen_new_internal(const char *render_node, int w, int h)
 
    einfo->info.fd = fd;
    einfo->info.format = DRM_FORMAT_XRGB8888;
+   einfo->info.modifiers = odata->modifiers;
+   einfo->info.modifier_count = modifier_count;
    if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
      {
         ERR("evas_engine_info_set() for engine '%s' failed", ee->driver);
diff --git a/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c b/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
index d0959549c8..719021b4ef 100644
--- a/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
+++ b/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
@@ -29,6 +29,8 @@
 #include <drm_fourcc.h>
 #include <gbm.h>
 #include <xf86drm.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
 
 #include <Ecore.h>
 #include <Ecore_Evas.h>
@@ -36,6 +38,7 @@
 #include "ecore_private.h"
 #include "ecore_evas_private.h"
 #include "ecore_evas_drm.h"
+#include "../../modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h"
 
 #include "ecore_suite.h"
 
@@ -43,6 +46,9 @@
 #ifndef DRM_FORMAT_MOD_LINEAR
 # define DRM_FORMAT_MOD_LINEAR 0ULL
 #endif
+#ifndef DRM_FORMAT_MOD_INVALID
+# define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)
+#endif
 
 #define RED 0x00ff0000u
 #define GREEN 0x0000ff00u
@@ -67,6 +73,7 @@ struct _Test_Canvas
    Ecore_Timer *guard;
    Ecore_Animator *animator;
    Ecore_Evas_Gl_Drm_Frame *held[HELD_MAX];
+   const uint64_t *modifiers;
 
    uint64_t ids[HELD_MAX];
    uint64_t freed[HELD_MAX];
@@ -80,6 +87,7 @@ struct _Test_Canvas
    unsigned int held_count;
    unsigned int id_count;
    unsigned int frame_count;
+   unsigned int modifier_count;
    unsigned int freed_count;
    unsigned int other_freed_count;
    unsigned int damage_count;
@@ -386,7 +394,8 @@ static Eina_Bool
 _canvas_open_on(Test_Canvas *c, const char *node)
 {
    c->quit_at = UINT_MAX;
-   c->ee = ecore_evas_gl_drm_offscreen_new(node, CANVAS_W, CANVAS_H);
+   c->ee = ecore_evas_gl_drm_offscreen_new(node, CANVAS_W, CANVAS_H,
+                                       c->modifiers, c->modifier_count);
    if (!c->ee) return EINA_FALSE;
 
    c->node = strdup(node);
@@ -398,7 +407,7 @@ _canvas_open_on(Test_Canvas *c, const char *node)
 
 /* Walks the render nodes until the engine accepts one. */
 static Test_Canvas *
-_canvas_new(void)
+_canvas_new_with(const uint64_t *modifiers, unsigned int modifier_count)
 {
    Test_Canvas *c;
    drmDevicePtr devices[16];
@@ -413,6 +422,8 @@ _canvas_new(void)
 
    c = calloc(1, sizeof(Test_Canvas));
    ck_assert_ptr_nonnull(c);
+   c->modifiers = modifiers;
+   c->modifier_count = modifier_count;
 
    count = drmGetDevices2(0, devices, 16);
    if (count <= 0)
@@ -444,6 +455,12 @@ skip:
    return NULL;
 }
 
+static Test_Canvas *
+_canvas_new(void)
+{
+   return _canvas_new_with(NULL, 0);
+}
+
 static void
 _held_release_all(Test_Canvas *c)
 {
@@ -907,21 +924,23 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_node_required)
    eina_log_print_cb_set(_log_count_cb, NULL);
    nulls = _dev_null_fd_count();
 
-   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(NULL, CANVAS_W, CANVAS_H));
+   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(NULL, CANVAS_W, CANVAS_H,
+                                                     NULL, 0));
    ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new("/nonexistent/renderD0",
-                                                     CANVAS_W, CANVAS_H));
+                                                     CANVAS_W, CANVAS_H, NULL, 0));
    ck_assert_ptr_nonnull(strstr(_last_log, "Could not open"));
 
    /* What opens and is not a render node is refused as such, whatever the
     * engine would have made of it */
    ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new("/dev/null",
-                                                     CANVAS_W, CANVAS_H));
+                                                     CANVAS_W, CANVAS_H, NULL, 0));
    ck_assert_ptr_nonnull(strstr(_last_log, "not a DRM render node"));
 
    fd = mkstemp(file);
    ck_assert_int_ge(fd, 0);
    close(fd);
-   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(file, CANVAS_W, CANVAS_H));
+   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(file, CANVAS_W, CANVAS_H,
+                                                     NULL, 0));
    unlink(file);
    ck_assert_ptr_nonnull(strstr(_last_log, "not a DRM render node"));
 
@@ -1254,7 +1273,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_other_node)
 
    render_fds = _render_nodes_fd_count();
    ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new("/dev/null",
-                                                     CANVAS_W, CANVAS_H));
+                                                     CANVAS_W, CANVAS_H, NULL, 0));
    ck_assert_int_eq(_render_nodes_fd_count(), render_fds);
 
    _frames_wait(c, 1);
@@ -1792,6 +1811,324 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_buffer_free_none_wanted)
 }
 EFL_END_TEST
 
+#define MODIFIERS_MAX 32
+
+/* A canvas made while another is there: the library is initialized once
+ * more for it, which the last _canvas_free() cannot count. */
+static void
+_canvas_nested_free(Test_Canvas *c)
+{
+   _canvas_close(c);
+   free(c);
+   ck_assert_int_gt(ecore_evas_shutdown(), 0);
+}
+
+/* The modifiers the driver says it can draw XRGB8888 in, that are not
+ * linear. They belong to the vendor, and are found out here, never assumed. */
+static unsigned int
+_driver_modifiers_get(const char *node, uint64_t *modifiers)
+{
+   struct gbm_device *gbm;
+   EGLDisplay disp;
+   PFNEGLGETPLATFORMDISPLAYEXTPROC get_display;
+   PFNEGLQUERYDMABUFMODIFIERSEXTPROC query;
+   uint64_t listed[MODIFIERS_MAX];
+   EGLBoolean external_only[MODIFIERS_MAX];
+   EGLint major, minor, listed_count = 0, i;
+   unsigned int count = 0;
+   int fd;
+
+   fd = open(node, O_RDWR | O_CLOEXEC);
+   ck_assert_int_ge(fd, 0);
+   gbm = gbm_create_device(fd);
+   ck_assert_ptr_nonnull(gbm);
+   get_display = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
+     eglGetProcAddress("eglGetPlatformDisplayEXT");
+   query = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC)
+     eglGetProcAddress("eglQueryDmaBufModifiersEXT");
+   if ((!get_display) || (!query)) goto end;
+
+   disp = get_display(EGL_PLATFORM_GBM_MESA, gbm, NULL);
+   if ((disp == EGL_NO_DISPLAY) || (!eglInitialize(disp, &major, &minor)))
+     goto end;
+
+   if (query(disp, DRM_FORMAT_XRGB8888, MODIFIERS_MAX, listed, external_only,
+             &listed_count))
+     {
+        for (i = 0; i < listed_count; i++)
+          {
+             if ((external_only[i]) || (listed[i] == DRM_FORMAT_MOD_LINEAR))
+               continue;
+
+             modifiers[count++] = listed[i];
+          }
+     }
+   eglTerminate(disp);
+
+end:
+   gbm_device_destroy(gbm);
+   close(fd);
+   return count;
+}
+
+/* The canvases of the modifiers tests are made on the node the first one
+ * found, and the driver is asked about that node. */
+static unsigned int
+_driver_modifiers_of(Test_Canvas *c, uint64_t *modifiers)
+{
+   unsigned int count = _driver_modifiers_get(c->node, modifiers);
+
+   if (!count)
+     fprintf(stderr, "gl_drm offscreen: skipped, the driver offers no other modifier than linear\n");
+   return count;
+}
+
+/* Every plane is described: a descriptor of a dmabuf that holds it, a
+ * stride and an offset inside it, and no descriptor for the rest. */
+static void
+_dmabuf_planes_check(const Ecore_Evas_Gl_Drm_Dmabuf *dmabuf)
+{
+   unsigned int i;
+
+   ck_assert_uint_ge(dmabuf->plane_count, 1);
+   ck_assert_uint_le(dmabuf->plane_count, 4);
+   ck_assert_uint_eq(dmabuf->format, DRM_FORMAT_XRGB8888);
+   for (i = 0; i < 4; i++)
+     {
+        off_t size;
+
+        if (i >= dmabuf->plane_count)
+          {
+             ck_assert_int_eq(dmabuf->fd[i], -1);
+             continue;
+          }
+
+        ck_assert_int_gt(dmabuf->fd[i], 2);
+        size = lseek(dmabuf->fd[i], 0, SEEK_END);
+        ck_assert_int_gt(size, 0);
+        ck_assert_uint_gt(dmabuf->stride[i], 0);
+        ck_assert((off_t)dmabuf->offset[i] < size);
+     }
+   ck_assert_uint_ge(dmabuf->stride[0], dmabuf->w * 4);
+   ck_assert_uint_eq(dmabuf->offset[0], 0);
+}
+
+static Eina_Bool
+_modifier_listed(const uint64_t *list, unsigned int count, uint64_t modifier)
+{
+   unsigned int i;
+
+   for (i = 0; i < count; i++)
+     {
+        if (list[i] == modifier) return EINA_TRUE;
+     }
+   return EINA_FALSE;
+}
+
+/* Linear is what a consumer that maps the frames gets by default, and by
+ * asking for it. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_linear)
+{
+   static const uint64_t linear[] = { DRM_FORMAT_MOD_LINEAR };
+   Test_Canvas *c = _canvas_new_with(linear, 1);
+   Ecore_Evas_Gl_Drm_Dmabuf dmabuf;
+
+   if (!c) return;
+
+   c->hold = EINA_TRUE;
+   _frames_wait(c, 1);
+   _dmabuf_get(c, 0, &dmabuf);
+   ck_assert(dmabuf.modifier == DRM_FORMAT_MOD_LINEAR);
+   ck_assert_uint_eq(dmabuf.plane_count, 1);
+   _dmabuf_planes_check(&dmabuf);
+#ifdef HAVE_DMABUF_SYNC
+   _dmabuf_pixel_check(_mapped_pixel_cb, &dmabuf, CANVAS_W, CANVAS_H);
+#endif
+   _dmabuf_close(&dmabuf);
+
+   _canvas_free(c);
+}
+EFL_END_TEST
+
+/* A modifier the driver lists comes back as the layout of the frames, with
+ * every plane described. The pixels of such a frame are proven by the tests
+ * of the engine, which reads them back through the driver. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_listed)
+{
+   Test_Canvas *probe = _canvas_new();
+   uint64_t listed[MODIFIERS_MAX];
+   unsigned int count, i;
+
+   if (!probe) return;
+
+   count = _driver_modifiers_of(probe, listed);
+   for (i = 0; i < count; i++)
+     {
+        Test_Canvas *c = _canvas_new_with(&listed[i], 1);
+        Ecore_Evas_Gl_Drm_Dmabuf dmabuf;
+
+        ck_assert_ptr_nonnull(c);
+        c->hold = EINA_TRUE;
+        _frames_wait(c, 1);
+        _dmabuf_get(c, 0, &dmabuf);
+        ck_assert(dmabuf.modifier == listed[i]);
+        _dmabuf_planes_check(&dmabuf);
+        _dmabuf_close(&dmabuf);
+        _canvas_nested_free(c);
+     }
+
+   _canvas_free(probe);
+}
+EFL_END_TEST
+
+/* The list is the consumer's again once the call returns, and the engine
+ * reads it again when it makes its output again, as it does when the depth
+ * changes. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_copied)
+{
+   Test_Canvas *probe = _canvas_new();
+   uint64_t listed[MODIFIERS_MAX], *given;
+   unsigned int count, i;
+   Test_Canvas *c;
+   Evas_Engine_Info_GL_Drm *info;
+   Ecore_Evas_Gl_Drm_Dmabuf dmabuf;
+
+   if (!probe) return;
+
+   count = _driver_modifiers_of(probe, listed);
+   if (!count)
+     {
+        _canvas_free(probe);
+        return;
+     }
+
+   given = malloc(sizeof(uint64_t) * count);
+   ck_assert_ptr_nonnull(given);
+   memcpy(given, listed, sizeof(uint64_t) * count);
+   c = _canvas_new_with(given, count);
+   ck_assert_ptr_nonnull(c);
+   /* Written through a volatile, or the compiler drops what precedes free() */
+   for (i = 0; i < count; i++)
+     {
+        ((volatile uint64_t *)given)[i] = DRM_FORMAT_MOD_INVALID;
+     }
+   free(given);
+
+   info = (Evas_Engine_Info_GL_Drm *)evas_engine_info_get(ecore_evas_get(c->ee));
+   ck_assert_ptr_nonnull(info);
+   info->info.depth = 24;
+   ck_assert(evas_engine_info_set(ecore_evas_get(c->ee), (Evas_Engine_Info *)info));
+
+   c->hold = EINA_TRUE;
+   _frames_wait(c, 1);
+   _dmabuf_get(c, 0, &dmabuf);
+   ck_assert(_modifier_listed(listed, count, dmabuf.modifier));
+   _dmabuf_close(&dmabuf);
+
+   _canvas_nested_free(c);
+   _canvas_free(probe);
+}
+EFL_END_TEST
+
+/* Nothing the driver draws in: no canvas, a reason, and nothing left, with
+ * the canvas that is there not hurt. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus)
+{
+   static const uint64_t bogus[] = { 0x00ffee0123456789ULL, 0x00ffee0123456788ULL };
+   Test_Canvas *c = _canvas_new();
+   int nodes, dmabufs;
+
+   if (!c) return;
+
+   _frames_wait(c, 1);
+   nodes = _render_nodes_fd_count();
+   dmabufs = _dmabuf_fd_count();
+
+   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(c->node, CANVAS_W, CANVAS_H,
+                                                     bogus, 2));
+   /* The engine says why, and the library that it gave up */
+   ck_assert_uint_eq(_warnings, 2);
+   ck_assert_ptr_nonnull(strstr(_last_log, "evas_engine_info_set()"));
+   _warnings = 0;
+   ck_assert_int_eq(_render_nodes_fd_count(), nodes);
+   ck_assert_int_eq(_dmabuf_fd_count(), dmabufs);
+
+   _mover_step(c);
+   _frames_wait(c, 1);
+
+   _canvas_free(c);
+}
+EFL_END_TEST
+
+/* The same with no canvas to share the driver with, and then a canvas that
+ * is made. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus_alone)
+{
+   static const uint64_t bogus[] = { 0x00ffee0123456789ULL };
+   Test_Canvas *c = _canvas_new();
+   char *node;
+   int nodes;
+
+   if (!c) return;
+
+   node = strdup(c->node);
+   _canvas_close(c);
+   nodes = _render_nodes_fd_count();
+
+   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(node, CANVAS_W, CANVAS_H,
+                                                     bogus, 1));
+   _warnings = 0;
+   ck_assert_int_eq(_render_nodes_fd_count(), nodes);
+
+   c->ee = ecore_evas_gl_drm_offscreen_new(node, CANVAS_W, CANVAS_H, NULL, 0);
+   ck_assert_ptr_nonnull(c->ee);
+   ecore_evas_gl_drm_frame_callbacks_set(c->ee, _frame_cb, _buffer_free_cb, c);
+   _scene_build(c);
+   ecore_evas_show(c->ee);
+   c->node = node;
+   _frames_wait(c, 1);
+
+   _canvas_free(c);
+}
+EFL_END_TEST
+
+/* What is unknown next to linear is a request for linear. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus_and_linear)
+{
+   static const uint64_t list[] = { 0x00ffee0123456789ULL, DRM_FORMAT_MOD_LINEAR };
+   Test_Canvas *c = _canvas_new_with(list, 2);
+   Ecore_Evas_Gl_Drm_Dmabuf dmabuf;
+
+   if (!c) return;
+
+   c->hold = EINA_TRUE;
+   _frames_wait(c, 1);
+   _dmabuf_get(c, 0, &dmabuf);
+   ck_assert(dmabuf.modifier == DRM_FORMAT_MOD_LINEAR);
+   ck_assert_uint_eq(dmabuf.plane_count, 1);
+   _dmabuf_close(&dmabuf);
+
+   _canvas_free(c);
+}
+EFL_END_TEST
+
+/* A count and no list is a mistake of the caller. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_count_without_list)
+{
+   Test_Canvas *c = _canvas_new();
+   int nodes;
+
+   if (!c) return;
+
+   nodes = _render_nodes_fd_count();
+   ck_assert_ptr_null(ecore_evas_gl_drm_offscreen_new(c->node, CANVAS_W, CANVAS_H,
+                                                     NULL, 3));
+   ck_assert_int_eq(_render_nodes_fd_count(), nodes);
+
+   _canvas_free(c);
+}
+EFL_END_TEST
+
 void
 ecore_test_ecore_evas_gl_drm(TCase *tc)
 {
@@ -1826,6 +2163,13 @@ ecore_test_ecore_evas_gl_drm(TCase *tc)
    tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_buffer_free_consumer_replaced);
    tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_buffer_free_consumer_removed);
    tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_buffer_free_none_wanted);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_linear);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_listed);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_copied);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus_alone);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus_and_linear);
+   tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_count_without_list);
    tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_dmabuf_layout);
    tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_dmabuf_pixels);
    tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_dmabuf_import);
diff --git a/src/tests/ecore/meson.build b/src/tests/ecore/meson.build
index 79ed0bd07d..f7c7f56e90 100644
--- a/src/tests/ecore/meson.build
+++ b/src/tests/ecore/meson.build
@@ -75,7 +75,7 @@ endif
 # node to be had at run time.
 if get_option('drm') and (get_option('opengl') == 'es-egl')
   ecore_suite_src += 'ecore_test_ecore_evas_gl_drm.c'
-  ecore_suite_deps += [dependency('libdrm'), dependency('gbm')]
+  ecore_suite_deps += [dependency('libdrm'), dependency('gbm')] + gl_deps
   ecore_suite_drm2_args += '-DHAVE_ECORE_EVAS_GL_DRM_TEST=1'
 endif
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to