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

git pushed a commit to branch up/x11-iconify-flake
in repository enlightenment.

View the commit online.

commit 425a93773ebe85814ed712164b22d535a630a293
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 14:19:48 2026 -0600

    e_comp_wl - add wp_single_pixel_buffer_v1
    
    A single-pixel buffer is a 1x1 wl_buffer of one colour, which a client
    stretches over a rectangle with a wp_viewport. Chromium draws the solid
    quads of a page with them (backgrounds, letterbox bars, the scrim
    behind a dialog) instead of a buffer of its own for each.
    
    It is the first wl_buffer E makes rather than receives: neither shm nor
    dmabuf, with no memory shared with the client. E_Comp_Wl_Buffer keeps
    its pixel, premultiplied ARGB8888 like the shm buffers evas is given,
    for as long as E holds the buffer, and e_pixmap shows it as pixels:
    
     - its format is known without asking EGL, which never saw it;
     - it is pixels, not a native surface, so a GL compositor does not hand
       the driver a buffer it cannot import;
     - the pixmap holds it like an shm buffer, without a pool to reference.
    
    The shm pool check in _e_pixmap_wayland_image_clear() already leaves a
    held buffer without a pool to the busy list, which releases it once.
    
    e_pixmap.c is shared with X11; these paths are Wayland only.
    
    wl-single-pixel-buffer stretches a red, a green and a blue buffer over
    a 200x100 window with a viewport, checks its corners, and that each
    buffer is released once the next one replaces it. It fails with red and
    blue swapped, without the pixel data, without the format and without
    the 1x1 size. The two GL paths, not a native surface and not imported,
    change nothing on the software engine the tests run on.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/e_comp_wl.c                          |   7 ++
 src/bin/e_comp_wl.h                          |   9 ++
 src/bin/e_comp_wl_extensions.c               |  72 +++++++++++
 src/bin/e_pixmap.c                           |  20 +++-
 src/bin/generated/meson.build                |   1 +
 src/tests/wayland/globals.expected           |   1 +
 src/tests/wayland/meson.build                |   2 +
 src/tests/wayland/test_single_pixel_buffer.c | 171 +++++++++++++++++++++++++++
 src/tests/wlcs/e_wlcs.c                      |   1 +
 9 files changed, 278 insertions(+), 6 deletions(-)

diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index 0af28d505..ae7968d25 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -4006,6 +4006,7 @@ e_comp_wl_buffer_get(struct wl_resource *resource)
    struct wl_listener *listener;
    struct wl_shm_buffer *shmbuff;
    struct linux_dmabuf_buffer *dmabuf;
+   uint32_t pixel;
 
    listener =
      wl_resource_get_destroy_listener(resource, _e_comp_wl_buffer_cb_destroy);
@@ -4053,6 +4054,12 @@ e_comp_wl_buffer_get(struct wl_resource *resource)
         buffer->w = dmabuf->attributes.width;
         buffer->h = dmabuf->attributes.height;
      }
+   else if (e_comp_wl_single_pixel_buffer_get(resource, &pixel))
+     {
+        buffer->w = buffer->h = 1;
+        buffer->single_pixel = EINA_TRUE;
+        buffer->pixel = pixel;
+     }
    else if (e_comp->gl)
      {
         e_comp_wl->wl.glapi->evasglQueryWaylandBuffer(e_comp_wl->wl.gl, resource, EGL_WIDTH, &buffer->w);
diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
index e2ef440c8..8b1f351f9 100644
--- a/src/bin/e_comp_wl.h
+++ b/src/bin/e_comp_wl.h
@@ -72,6 +72,10 @@ struct _E_Comp_Wl_Buffer
    int32_t w, h;
    uint32_t busy;
    Eina_Bool destroyed;
+   /* A wp_single_pixel_buffer_v1, made by E: 1x1, its premultiplied
+    * ARGB8888 pixel kept here for as long as E holds the buffer. */
+   Eina_Bool single_pixel;
+   uint32_t pixel;
 };
 
 /* A wp_viewport's source rectangle, in surface-local units before the
@@ -193,6 +197,10 @@ typedef struct E_Comp_Wl_Extension_Data
      {
         struct wl_global *global;
      } wp_fractional_scale_manager_v1;
+   struct
+     {
+        struct wl_global *global;
+     } wp_single_pixel_buffer_manager_v1;
    struct
      {
         struct wl_global *global;
@@ -539,6 +547,7 @@ EINTERN void e_comp_wl_presentation_feedback_present(E_Client *ec);
 EINTERN void e_comp_wl_presentation_feedback_discard(Eina_List **feedbacks);
 EINTERN void e_comp_wl_presentation_feedback_commit(E_Client *ec, Eina_List **feedbacks);
 EINTERN Eina_Bool e_comp_wl_extension_idle_inhibited(void);
+EINTERN Eina_Bool e_comp_wl_single_pixel_buffer_get(struct wl_resource *resource, uint32_t *pixel);
 
 EINTERN void e_comp_wl_privileges_init(void);
 EINTERN Eina_Bool e_comp_wl_text_input_init(void);
diff --git a/src/bin/e_comp_wl_extensions.c b/src/bin/e_comp_wl_extensions.c
index 007fcb303..6e5b875c4 100644
--- a/src/bin/e_comp_wl_extensions.c
+++ b/src/bin/e_comp_wl_extensions.c
@@ -15,6 +15,7 @@
 #include "keyboard-shortcuts-inhibit-unstable-v1-server-protocol.h"
 #include "viewporter-server-protocol.h"
 #include "fractional-scale-v1-server-protocol.h"
+#include "single-pixel-buffer-v1-server-protocol.h"
 
 /* mutter uses 32, seems reasonable */
 #define HANDLE_LEN 32
@@ -1884,6 +1885,75 @@ _e_fractional_scale_cb_zone_set(void *data EINA_UNUSED, int type EINA_UNUSED, vo
    return ECORE_CALLBACK_RENEW;
 }
 
+/* wp_single_pixel_buffer_v1: a 1x1 wl_buffer of one colour, made by E
+ * and not shared with the client, which stretches it with a wp_viewport.
+ * Its user data is the pixel, premultiplied ARGB8888 like the shm buffers
+ * evas is given. */
+static void
+_e_single_pixel_buffer_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static const struct wl_buffer_interface _e_single_pixel_buffer_interface =
+{
+   _e_single_pixel_buffer_cb_destroy,
+};
+
+static void
+_e_single_pixel_buffer_cb_resource_destroy(struct wl_resource *resource)
+{
+   free(wl_resource_get_user_data(resource));
+}
+
+EINTERN Eina_Bool
+e_comp_wl_single_pixel_buffer_get(struct wl_resource *resource, uint32_t *pixel)
+{
+   if (!wl_resource_instance_of(resource, &wl_buffer_interface,
+                                &_e_single_pixel_buffer_interface))
+     return EINA_FALSE;
+   *pixel = *(uint32_t *)wl_resource_get_user_data(resource);
+   return EINA_TRUE;
+}
+
+static void
+_e_wp_single_pixel_buffer_manager_v1_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+/* Each channel spans the whole range of 32 bits: its top byte is the
+ * 8 bit value. */
+static void
+_e_wp_single_pixel_buffer_manager_v1_cb_create_u32_rgba_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id, uint32_t r, uint32_t g, uint32_t b, uint32_t a)
+{
+   struct wl_resource *res;
+   uint32_t *pixel;
+
+   pixel = malloc(sizeof(uint32_t));
+   if (!pixel)
+     {
+        wl_resource_post_no_memory(resource);
+        return;
+     }
+   *pixel = ((a >> 24) << 24) | ((r >> 24) << 16) | ((g >> 24) << 8) | (b >> 24);
+   res = wl_resource_create(client, &wl_buffer_interface, 1, id);
+   if (!res)
+     {
+        free(pixel);
+        wl_resource_post_no_memory(resource);
+        return;
+     }
+   wl_resource_set_implementation(res, &_e_single_pixel_buffer_interface, pixel,
+                                  _e_single_pixel_buffer_cb_resource_destroy);
+}
+
+static const struct wp_single_pixel_buffer_manager_v1_interface _e_wp_single_pixel_buffer_manager_v1_interface =
+{
+   _e_wp_single_pixel_buffer_manager_v1_cb_destroy,
+   _e_wp_single_pixel_buffer_manager_v1_cb_create_u32_rgba_buffer,
+};
+
 #define GLOBAL_BIND_CB(NAME, IFACE, ...) \
 static void \
 _e_comp_wl_##NAME##_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id) \
@@ -1914,6 +1984,7 @@ GLOBAL_BIND_CB(zwp_idle_inhibit_manager_v1, zwp_idle_inhibit_manager_v1_interfac
 GLOBAL_BIND_CB(zwp_keyboard_shortcuts_inhibit_manager_v1, zwp_keyboard_shortcuts_inhibit_manager_v1_interface)
 GLOBAL_BIND_CB(wp_viewporter, wp_viewporter_interface)
 GLOBAL_BIND_CB(wp_fractional_scale_manager_v1, wp_fractional_scale_manager_v1_interface)
+GLOBAL_BIND_CB(wp_single_pixel_buffer_manager_v1, wp_single_pixel_buffer_manager_v1_interface)
 GLOBAL_BIND_CB(wp_presentation, wp_presentation_interface,
      wp_presentation_send_clock_id(res, CLOCK_MONOTONIC);
 )
@@ -2024,6 +2095,7 @@ e_comp_wl_extensions_init(void)
    GLOBAL_CREATE_OR_RETURN(zwp_keyboard_shortcuts_inhibit_manager_v1, zwp_keyboard_shortcuts_inhibit_manager_v1_interface, 1);
    GLOBAL_CREATE_OR_RETURN(wp_viewporter, wp_viewporter_interface, 1);
    GLOBAL_CREATE_OR_RETURN(wp_fractional_scale_manager_v1, wp_fractional_scale_manager_v1_interface, 1);
+   GLOBAL_CREATE_OR_RETURN(wp_single_pixel_buffer_manager_v1, wp_single_pixel_buffer_manager_v1_interface, 1);
    if (!e_comp_wl_text_input_init()) return EINA_FALSE;
    e_comp_wl_privileges_init();
 
diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c
index 0967d4a74..608d8a613 100644
--- a/src/bin/e_pixmap.c
+++ b/src/bin/e_pixmap.c
@@ -626,6 +626,8 @@ e_pixmap_refresh(E_Pixmap *cp)
              format = wl_shm_buffer_get_format(buffer->shm_buffer);
            else if (buffer->dmabuf_buffer)
              format = buffer->dmabuf_buffer->attributes.format;
+           else if (buffer->single_pixel)
+             format = WL_SHM_FORMAT_ARGB8888;
            else if (e_comp_wl->wl.glapi)
              {
                 e_comp_wl->wl.glapi->evasglQueryWaylandBuffer
@@ -803,6 +805,7 @@ e_pixmap_is_pixels(E_Pixmap *cp)
         case E_PIXMAP_TYPE_WL:
           if (!cp->buffer) return EINA_TRUE;
           if (cp->buffer->shm_buffer) return EINA_TRUE;
+          if (cp->buffer->single_pixel) return EINA_TRUE;
           return EINA_FALSE;
 #endif
         default:
@@ -899,7 +902,7 @@ e_pixmap_native_surface_init(E_Pixmap *cp, Evas_Native_Surface *ns)
                }
              ret = EINA_TRUE;
           }
-        else if (!cp->buffer->shm_buffer)
+        else if ((!cp->buffer->shm_buffer) && (!cp->buffer->single_pixel))
           {
              ns->type = EVAS_NATIVE_SURFACE_WL;
              ns->data.wl.legacy_buffer = cp->buffer->resource;
@@ -1024,16 +1027,21 @@ e_pixmap_image_refresh(E_Pixmap *cp)
             */
            if (!cp->buffer) return EINA_FALSE;
 
-           if (!cp->buffer->shm_buffer) return EINA_TRUE;
+           if (cp->buffer->single_pixel)
+             cp->data = ""
+           else if (!cp->buffer->shm_buffer) return EINA_TRUE;
 
            cp->held_buffer = cp->buffer;
            if (!cp->held_buffer) return EINA_TRUE;
 
-           cp->held_buffer->pool =
-             wl_shm_buffer_ref_pool(cp->held_buffer->shm_buffer);
-           e_comp_wl_shm_guard_add(cp->held_buffer->pool, cp->held_buffer);
+           if (cp->held_buffer->shm_buffer)
+             {
+                cp->held_buffer->pool =
+                  wl_shm_buffer_ref_pool(cp->held_buffer->shm_buffer);
+                e_comp_wl_shm_guard_add(cp->held_buffer->pool, cp->held_buffer);
+                cp->data = ""
+             }
            cp->held_buffer->busy++;
-           cp->data = ""
            cp->held_buffer_destroy_listener.notify =
              _e_pixmap_cb_held_buffer_destroy;
 
diff --git a/src/bin/generated/meson.build b/src/bin/generated/meson.build
index 814fde429..19098ec33 100644
--- a/src/bin/generated/meson.build
+++ b/src/bin/generated/meson.build
@@ -12,6 +12,7 @@ protos = [
   '@0@/stable/presentation-time/presentation-time.xml'.format(dir_wayland_protocols),
   '@0@/stable/viewporter/viewporter.xml'.format(dir_wayland_protocols),
   '@0@/staging/fractional-scale/fractional-scale-v1.xml'.format(dir_wayland_protocols),
+  '@0@/staging/single-pixel-buffer/single-pixel-buffer-v1.xml'.format(dir_wayland_protocols),
   '@0@/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml'.format(dir_wayland_protocols),
   '@0@/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'.format(dir_wayland_protocols),
   '@0@/unstable/primary-selection/primary-selection-unstable-v1.xml'.format(dir_wayland_protocols),
diff --git a/src/tests/wayland/globals.expected b/src/tests/wayland/globals.expected
index 1e186b24e..9cb0f25e5 100644
--- a/src/tests/wayland/globals.expected
+++ b/src/tests/wayland/globals.expected
@@ -9,6 +9,7 @@ wl_shm	>=1
 wl_subcompositor	1
 wp_fractional_scale_manager_v1	1
 wp_presentation	1
+wp_single_pixel_buffer_manager_v1	1
 wp_viewporter	1
 xdg_activation_v1	1
 xdg_toplevel_drag_manager_v1	1
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 5ef264c00..04ab3ac5e 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -34,6 +34,7 @@ foreach p: [
   '@0@/stable/presentation-time/presentation-time.xml'.format(dir_wayland_protocols),
   '@0@/stable/viewporter/viewporter.xml'.format(dir_wayland_protocols),
   '@0@/staging/fractional-scale/fractional-scale-v1.xml'.format(dir_wayland_protocols),
+  '@0@/staging/single-pixel-buffer/single-pixel-buffer-v1.xml'.format(dir_wayland_protocols),
   '@0@/staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml'.format(dir_wayland_protocols),
   '@0@/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml'.format(dir_wayland_protocols),
   '@0@/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'.format(dir_wayland_protocols),
@@ -95,6 +96,7 @@ wl_protocol_tests = [
   ['buffer-transform', 'test_buffer_transform.c'],
   ['viewporter', 'test_viewporter.c'],
   ['fractional-scale', 'test_fractional_scale.c'],
+  ['single-pixel-buffer', 'test_single_pixel_buffer.c'],
   ['activation', 'test_activation.c'],
   ['activation-expiry', 'test_activation.c',
    {'E_TEST_ACTIVATION_TOKEN_LIFETIME': '1'}],
diff --git a/src/tests/wayland/test_single_pixel_buffer.c b/src/tests/wayland/test_single_pixel_buffer.c
new file mode 100644
index 000000000..08a2d3380
--- /dev/null
+++ b/src/tests/wayland/test_single_pixel_buffer.c
@@ -0,0 +1,171 @@
+/* wp_single_pixel_buffer_v1: a 1x1 buffer of one colour, stretched over a
+ * window by a viewport, is drawn in that colour, and released once another
+ * buffer replaces it. */
+#define _GNU_SOURCE 1
+#include <stdio.h>
+#include <stdint.h>
+#include <time.h>
+
+#include "e_wl_testkit.h"
+#include "viewporter-client-protocol.h"
+#include "single-pixel-buffer-v1-client-protocol.h"
+
+#define PROG "test-single-pixel-buffer"
+#define APP_ID "e.test.single-pixel-buffer"
+
+typedef struct
+{
+   Tk *tk;
+   struct wl_test *tester;
+   int configured;
+   unsigned int argb;
+   int answered;
+} Ctx;
+
+static void
+_pixel(void *data, struct wl_test *t __attribute__((unused)),
+       int32_t x __attribute__((unused)), int32_t y __attribute__((unused)),
+       uint32_t argb)
+{
+   Ctx *ctx = data;
+
+   ctx->argb = argb;
+   ctx->answered = 1;
+}
+
+/* Only the requests this test sends are answered on its own wl_test. */
+static const struct wl_test_listener _tester_listener =
+{
+   .pixel = _pixel
+};
+
+static void
+_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial)
+{
+   Ctx *ctx = data;
+
+   xdg_surface_ack_configure(xdg_surface, serial);
+   ctx->configured = 1;
+}
+
+static const struct xdg_surface_listener _xdg_surface_listener =
+{
+   _configure
+};
+
+static void
+_release(void *data, struct wl_buffer *buffer __attribute__((unused)))
+{
+   int *released = data;
+
+   *released = 1;
+}
+
+static const struct wl_buffer_listener _buffer_listener =
+{
+   _release
+};
+
+static unsigned int
+_pixel_get(Ctx *ctx, int x, int y)
+{
+   ctx->answered = 0;
+   wl_test_get_pixel(ctx->tester, x, y);
+   tk_sync(ctx->tk);
+   if (!ctx->answered) tk_fail(ctx->tk, "no answer to get_pixel");
+   return ctx->argb;
+}
+
+/* The theme animates a window being shown. */
+static void
+_pixel_wait(Ctx *ctx, int x, int y, unsigned int want, const char *what)
+{
+   struct timespec step = { 0, 50000000 };
+   unsigned int argb = 0;
+   int i;
+
+   for (i = 0; i < TK_WAIT_SECONDS * 20; i++)
+     {
+        argb = _pixel_get(ctx, x, y);
+        if (argb == want) return;
+        nanosleep(&step, NULL);
+     }
+   tk_fail(ctx->tk, "%s: pixel %d,%d is %#x, wanted %#x", what, x, y,
+           argb, want);
+}
+
+int
+main(void)
+{
+   static const struct
+   {
+      uint32_t r, g, b;
+      unsigned int argb;
+      const char *name;
+   } colors[] =
+   {
+      { UINT32_MAX, 0, 0, 0xffff0000, "red" },
+      { 0, UINT32_MAX, 0, 0xff00ff00, "green" },
+      { 0, 0, UINT32_MAX, 0xff0000ff, "blue" },
+   };
+   struct wp_single_pixel_buffer_manager_v1 *manager;
+   struct wp_viewporter *viewporter;
+   struct wp_viewport *viewport;
+   struct xdg_surface *xdg_surface;
+   struct xdg_toplevel *toplevel;
+   struct wl_surface *surface;
+   struct wl_buffer *buffer, *previous = NULL;
+   Ctx ctx = { 0 };
+   int released[3] = { 0 };
+   int i, x, y, w, h;
+
+   ctx.tk = tk_connect(PROG);
+   ctx.tester = tk_bind(ctx.tk, &wl_test_interface, 9);
+   viewporter = tk_bind(ctx.tk, &wp_viewporter_interface, 1);
+   manager = tk_bind(ctx.tk, &wp_single_pixel_buffer_manager_v1_interface, 1);
+   if (!ctx.tester) tk_fail(ctx.tk, "no wl_test version 9");
+   if (!manager) tk_fail(ctx.tk, "no wp_single_pixel_buffer_manager_v1");
+   wl_test_add_listener(ctx.tester, &_tester_listener, &ctx);
+
+   surface = tk_surface_new(ctx.tk);
+   viewport = wp_viewporter_get_viewport(viewporter, surface);
+   wp_viewport_set_destination(viewport, 200, 100);
+   xdg_surface = xdg_wm_base_get_xdg_surface(tk_wm_base(ctx.tk), surface);
+   xdg_surface_add_listener(xdg_surface, &_xdg_surface_listener, &ctx);
+   toplevel = xdg_surface_get_toplevel(xdg_surface);
+   xdg_toplevel_set_app_id(toplevel, APP_ID);
+   wl_surface_commit(surface);
+   while (!ctx.configured)
+     wl_display_dispatch(tk_display(ctx.tk));
+
+   /* The cursor is drawn on the same canvas. */
+   tk_pointer_warp(ctx.tk, 1023, 767);
+
+   /* One colour per channel, so that channels swapped show. */
+   for (i = 0; i < 3; i++)
+     {
+        buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer
+          (manager, colors[i].r, colors[i].g, colors[i].b, UINT32_MAX);
+        wl_buffer_add_listener(buffer, &_buffer_listener, &released[i]);
+        wl_surface_attach(surface, buffer, 0, 0);
+        wl_surface_damage_buffer(surface, 0, 0, 1, 1);
+        wl_surface_commit(surface);
+        tk_settle(ctx.tk);
+        tk_expect(ctx.tk, APP_ID);
+        tk_surface_geometry(ctx.tk, surface, &x, &y, &w, &h);
+        if ((w != 200) || (h != 100))
+          tk_fail(ctx.tk, "%s: the window is %dx%d, wanted 200x100",
+                  colors[i].name, w, h);
+        _pixel_wait(&ctx, x + 1, y + 1, colors[i].argb, colors[i].name);
+        _pixel_wait(&ctx, x + w - 2, y + h - 2, colors[i].argb, colors[i].name);
+        if ((i > 0) && (!released[i - 1]))
+          tk_fail(ctx.tk, "%s: the %s buffer it replaced was not released",
+                  colors[i].name, colors[i - 1].name);
+        if (previous) wl_buffer_destroy(previous);
+        previous = buffer;
+     }
+
+   tk_disconnect(ctx.tk);
+   printf(PROG ": ok\n");
+   return 0;
+}
diff --git a/src/tests/wlcs/e_wlcs.c b/src/tests/wlcs/e_wlcs.c
index 164b1d750..de7787e12 100644
--- a/src/tests/wlcs/e_wlcs.c
+++ b/src/tests/wlcs/e_wlcs.c
@@ -717,6 +717,7 @@ static const WlcsExtensionDescriptor _extensions[] =
    { "wl_data_device_manager", 3 },
    { "wp_viewporter", 1 },
    { "wp_fractional_scale_manager_v1", 1 },
+   { "wp_single_pixel_buffer_manager_v1", 1 },
    { "xdg_wm_base", 6 },
    { "zxdg_shell_v6", 1 },
    { "wl_shell", 1 },

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

Reply via email to