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

git pushed a commit to reference refs/pull/229/head
in repository enlightenment.

View the commit online.

commit 46283e7f1da73e9cf900428d64d620d038ec7511
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 22:31:05 2026 -0600

    e_pixmap - blend every buffer format that has alpha
    
    Menus and drop-downs of Brave showed solid black where they should be
    transparent. Only ARGB8888 was taken to have alpha, while E advertises
    over zwp_linux_dmabuf_v1 whatever EGL can import, and Brave on a
    Mali-T860 allocates ABGR8888. Such a window was drawn without blending,
    so its transparent pixels came out black. Clients on wl_shm are not
    affected, as E only offers ARGB8888 and XRGB8888 there.
    
    The alpha formats are listed, rather than the opaque ones, so that a YUV
    or X buffer of a format not thought of is not blended by mistake.
    
    e_pixmap_format_has_alpha() is E_API only for the wl_test module. Only
    the DRM backend offers clients dmabuf today, so no test can show E such
    a buffer and read the screen back.
    
    Shared file: the change is in the Wayland case of e_pixmap_refresh(),
    called from e_comp.c, e_comp_object.c and e_comp_wl.c. The default and
    x11 suites pass. Not yet seen on screen on the DRM backend.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/e_pixmap.c                    |  53 ++++++++++----
 src/bin/e_pixmap.h                    |   3 +
 src/modules/wl_test/e_mod_main.c      |  10 ++-
 src/protocol/wl-test.xml              |  17 ++++-
 src/tests/wayland/meson.build         |   1 +
 src/tests/wayland/test_format_alpha.c | 130 ++++++++++++++++++++++++++++++++++
 6 files changed, 200 insertions(+), 14 deletions(-)

diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c
index 608d8a613..fadd32801 100644
--- a/src/bin/e_pixmap.c
+++ b/src/bin/e_pixmap.c
@@ -636,18 +636,7 @@ e_pixmap_refresh(E_Pixmap *cp)
              }
            else return EINA_FALSE;
 
-           switch (format)
-             {
-              case DRM_FORMAT_ARGB8888:
-              case WL_SHM_FORMAT_ARGB8888:
-              case EGL_TEXTURE_RGBA:
-                cp->image_argb = EINA_TRUE;
-                break;
-              default:
-                cp->image_argb = EINA_FALSE;
-                break;
-             }
-
+           cp->image_argb = e_pixmap_format_has_alpha(format);
            success = ((cp->w > 0) && (cp->h > 0));
         }
 #endif
@@ -1308,6 +1297,46 @@ e_pixmap_pre_render(void)
 
 
 #ifdef HAVE_WAYLAND
+/* Spelled out because drm_fourcc.h comes with libdrm, which E does not
+ * require. */
+#define E_PIXMAP_FOURCC(a, b, c, d) \
+   ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | \
+    ((uint32_t)(d) << 24))
+
+E_API Eina_Bool
+e_pixmap_format_has_alpha(uint32_t format)
+{
+   switch (format)
+     {
+      case WL_SHM_FORMAT_ARGB8888:
+      case EGL_TEXTURE_RGBA:
+      case DRM_FORMAT_ARGB8888:
+      case E_PIXMAP_FOURCC('A', 'B', '2', '4'): /* ABGR8888 */
+      case E_PIXMAP_FOURCC('R', 'A', '2', '4'): /* RGBA8888 */
+      case E_PIXMAP_FOURCC('B', 'A', '2', '4'): /* BGRA8888 */
+      case E_PIXMAP_FOURCC('A', 'R', '3', '0'): /* ARGB2101010 */
+      case E_PIXMAP_FOURCC('A', 'B', '3', '0'): /* ABGR2101010 */
+      case E_PIXMAP_FOURCC('R', 'A', '3', '0'): /* RGBA1010102 */
+      case E_PIXMAP_FOURCC('B', 'A', '3', '0'): /* BGRA1010102 */
+      case E_PIXMAP_FOURCC('A', 'R', '1', '2'): /* ARGB4444 */
+      case E_PIXMAP_FOURCC('A', 'B', '1', '2'): /* ABGR4444 */
+      case E_PIXMAP_FOURCC('R', 'A', '1', '2'): /* RGBA4444 */
+      case E_PIXMAP_FOURCC('B', 'A', '1', '2'): /* BGRA4444 */
+      case E_PIXMAP_FOURCC('A', 'R', '1', '5'): /* ARGB1555 */
+      case E_PIXMAP_FOURCC('A', 'B', '1', '5'): /* ABGR1555 */
+      case E_PIXMAP_FOURCC('R', 'A', '1', '5'): /* RGBA5551 */
+      case E_PIXMAP_FOURCC('B', 'A', '1', '5'): /* BGRA5551 */
+      case E_PIXMAP_FOURCC('A', 'R', '4', '8'): /* ARGB16161616 */
+      case E_PIXMAP_FOURCC('A', 'B', '4', '8'): /* ABGR16161616 */
+      case E_PIXMAP_FOURCC('A', 'R', '4', 'H'): /* ARGB16161616F */
+      case E_PIXMAP_FOURCC('A', 'B', '4', 'H'): /* ABGR16161616F */
+      case E_PIXMAP_FOURCC('A', 'Y', 'U', 'V'): /* AYUV8888 */
+        return EINA_TRUE;
+      default:
+        return EINA_FALSE;
+     }
+}
+
 E_API Eina_Bool
 e_pixmap_dmabuf_test(struct linux_dmabuf_buffer *dmabuf)
 {
diff --git a/src/bin/e_pixmap.h b/src/bin/e_pixmap.h
index aa36ca283..65771e0b9 100644
--- a/src/bin/e_pixmap.h
+++ b/src/bin/e_pixmap.h
@@ -57,6 +57,9 @@ E_API void e_pixmap_alias(E_Pixmap *cp, E_Pixmap_Type type, ...);
 E_API void e_pixmap_pre_render(void);
 
 #ifdef HAVE_WAYLAND
+/* format is a DRM fourcc, a wl_shm format or an EGL_TEXTURE_FORMAT value,
+ * as the three kinds of Wayland buffer report theirs. */
+E_API Eina_Bool e_pixmap_format_has_alpha(uint32_t format);
 E_API Eina_Bool e_pixmap_dmabuf_test(struct linux_dmabuf_buffer *);
 E_API Eina_Bool e_pixmap_dmabuf_formats_query(int **formats, int *num_formats);
 E_API Eina_Bool e_pixmap_dmabuf_modifiers_query(int format, uint64_t **modifiers, int *num_modifiers);
diff --git a/src/modules/wl_test/e_mod_main.c b/src/modules/wl_test/e_mod_main.c
index b77056ca1..55aa306b5 100644
--- a/src/modules/wl_test/e_mod_main.c
+++ b/src/modules/wl_test/e_mod_main.c
@@ -654,6 +654,13 @@ _wl_test_cb_sync(struct wl_client *client EINA_UNUSED, struct wl_resource *resou
    if (!_sync_job) _sync_job = ecore_job_add(_wl_test_cb_sync_job, NULL);
 }
 
+static void
+_wl_test_cb_get_format_alpha(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t format)
+{
+   wl_test_send_format_alpha(resource, format,
+                             e_pixmap_format_has_alpha(format));
+}
+
 static const struct wl_test_interface _wl_test_implementation =
 {
    _wl_test_cb_destroy,
@@ -680,6 +687,7 @@ static const struct wl_test_interface _wl_test_implementation =
    _wl_test_cb_get_pixel,
    _wl_test_cb_output_scale_set,
    _wl_test_cb_output_remove,
+   _wl_test_cb_get_format_alpha,
 };
 
 static void
@@ -713,7 +721,7 @@ e_modapi_init(E_Module *m)
         return NULL;
      }
 
-   _wl_test_global = wl_global_create(e_comp_wl->wl.disp, &wl_test_interface, 11,
+   _wl_test_global = wl_global_create(e_comp_wl->wl.disp, &wl_test_interface, 12,
                                      NULL, _wl_test_cb_bind);
    if (!_wl_test_global)
      {
diff --git a/src/protocol/wl-test.xml b/src/protocol/wl-test.xml
index 4204daf65..3225ebe5f 100644
--- a/src/protocol/wl-test.xml
+++ b/src/protocol/wl-test.xml
@@ -23,7 +23,7 @@
     DEALINGS IN THE SOFTWARE.
   </copyright>
 
-  <interface name="wl_test" version="11">
+  <interface name="wl_test" version="12">
     <description summary="private interface for the compositor test suite">
       A back door into the compositor for its own test suite. It exposes
       internal state and synthesises input, so it is only built with
@@ -380,5 +380,20 @@
       </description>
       <arg name="zone" type="uint" summary="index of a zone from zone_add"/>
     </request>
+
+    <request name="get_format_alpha" since="12">
+      <description summary="ask whether a buffer format is drawn with alpha">
+        Answers with a format_alpha event. Only the DRM backend offers
+        clients dmabuf, so a test cannot show E such a buffer and read the
+        screen back; this asks what E would do with one.
+      </description>
+      <arg name="format" type="uint"
+           summary="a DRM fourcc, wl_shm format or EGL_TEXTURE_FORMAT value"/>
+    </request>
+
+    <event name="format_alpha" since="12">
+      <arg name="format" type="uint"/>
+      <arg name="alpha" type="uint" summary="1 if blended, 0 if opaque"/>
+    </event>
   </interface>
 </protocol>
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index b881b4b0c..ba1b73213 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -115,6 +115,7 @@ wl_protocol_tests = [
    {'PATH': meson.current_build_dir()}],
   ['client-iconify', 'test_client_iconify.c',
    {'ELM_TRANSITION_DURATION_FACTOR': '4'}],
+  ['format-alpha', 'test_format_alpha.c'],
 ]
 
 tk_src = files('e_wl_testkit.c')
diff --git a/src/tests/wayland/test_format_alpha.c b/src/tests/wayland/test_format_alpha.c
new file mode 100644
index 000000000..92f50d28f
--- /dev/null
+++ b/src/tests/wayland/test_format_alpha.c
@@ -0,0 +1,130 @@
+/* Which buffer formats is a window blended for? A format with an alpha
+ * channel that E takes as opaque shows the client's transparent pixels, the
+ * corners and shadow of a menu, as solid black.
+ *
+ * The formats are those E advertises over zwp_linux_dmabuf_v1, which are
+ * whatever EGL can import, so most never come through wl_shm. */
+#include <stdio.h>
+#include <stdint.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-format-alpha"
+
+#define FOURCC(a, b, c, d) \
+   ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | \
+    ((uint32_t)(d) << 24))
+
+typedef struct
+{
+   const char *name;
+   uint32_t format;
+   int alpha;
+} Format;
+
+static const Format _formats[] =
+{
+   { "wl_shm argb8888", WL_SHM_FORMAT_ARGB8888, 1 },
+   { "wl_shm xrgb8888", WL_SHM_FORMAT_XRGB8888, 0 },
+   { "EGL_TEXTURE_RGBA", 0x305E, 1 },
+   { "EGL_TEXTURE_RGB", 0x305D, 0 },
+
+   { "ARGB8888", FOURCC('A', 'R', '2', '4'), 1 },
+   { "ABGR8888", FOURCC('A', 'B', '2', '4'), 1 },
+   { "RGBA8888", FOURCC('R', 'A', '2', '4'), 1 },
+   { "BGRA8888", FOURCC('B', 'A', '2', '4'), 1 },
+   { "XRGB8888", FOURCC('X', 'R', '2', '4'), 0 },
+   { "XBGR8888", FOURCC('X', 'B', '2', '4'), 0 },
+   { "RGBX8888", FOURCC('R', 'X', '2', '4'), 0 },
+   { "BGRX8888", FOURCC('B', 'X', '2', '4'), 0 },
+   { "RGB888", FOURCC('R', 'G', '2', '4'), 0 },
+   { "RGB565", FOURCC('R', 'G', '1', '6'), 0 },
+
+   { "ARGB2101010", FOURCC('A', 'R', '3', '0'), 1 },
+   { "ABGR2101010", FOURCC('A', 'B', '3', '0'), 1 },
+   { "RGBA1010102", FOURCC('R', 'A', '3', '0'), 1 },
+   { "BGRA1010102", FOURCC('B', 'A', '3', '0'), 1 },
+   { "XRGB2101010", FOURCC('X', 'R', '3', '0'), 0 },
+   { "XBGR2101010", FOURCC('X', 'B', '3', '0'), 0 },
+
+   { "ARGB4444", FOURCC('A', 'R', '1', '2'), 1 },
+   { "ABGR4444", FOURCC('A', 'B', '1', '2'), 1 },
+   { "RGBA4444", FOURCC('R', 'A', '1', '2'), 1 },
+   { "BGRA4444", FOURCC('B', 'A', '1', '2'), 1 },
+   { "ARGB1555", FOURCC('A', 'R', '1', '5'), 1 },
+   { "ABGR1555", FOURCC('A', 'B', '1', '5'), 1 },
+   { "RGBA5551", FOURCC('R', 'A', '1', '5'), 1 },
+   { "BGRA5551", FOURCC('B', 'A', '1', '5'), 1 },
+
+   { "ARGB16161616", FOURCC('A', 'R', '4', '8'), 1 },
+   { "ABGR16161616", FOURCC('A', 'B', '4', '8'), 1 },
+   { "XBGR16161616", FOURCC('X', 'B', '4', '8'), 0 },
+   { "ARGB16161616F", FOURCC('A', 'R', '4', 'H'), 1 },
+   { "ABGR16161616F", FOURCC('A', 'B', '4', 'H'), 1 },
+   { "XBGR16161616F", FOURCC('X', 'B', '4', 'H'), 0 },
+
+   { "AYUV", FOURCC('A', 'Y', 'U', 'V'), 1 },
+   { "XYUV8888", FOURCC('X', 'Y', 'U', 'V'), 0 },
+   { "NV12", FOURCC('N', 'V', '1', '2'), 0 },
+   { "YUYV", FOURCC('Y', 'U', 'Y', 'V'), 0 },
+};
+
+typedef struct
+{
+   uint32_t format, alpha;
+   int answered;
+} Answer;
+
+static void
+_format_alpha(void *data, struct wl_test *t __attribute__((unused)),
+              uint32_t format, uint32_t alpha)
+{
+   Answer *answer = data;
+
+   answer->format = format;
+   answer->alpha = alpha;
+   answer->answered = 1;
+}
+
+/* Only the requests this test sends are answered on its own wl_test. */
+static const struct wl_test_listener _tester_listener =
+{
+   .format_alpha = _format_alpha
+};
+
+int
+main(void)
+{
+   struct wl_test *tester;
+   Answer answer = { 0 };
+   unsigned int i;
+   int wrong = 0;
+   Tk *tk;
+
+   tk = tk_connect(PROG);
+   tester = tk_bind(tk, &wl_test_interface, 12);
+   if (!tester) tk_fail(tk, "no wl_test version 12");
+   wl_test_add_listener(tester, &_tester_listener, &answer);
+
+   for (i = 0; i < sizeof(_formats) / sizeof(_formats[0]); i++)
+     {
+        const Format *f = &_formats[i];
+
+        answer.answered = 0;
+        wl_test_get_format_alpha(tester, f->format);
+        tk_sync(tk);
+        if ((!answer.answered) || (answer.format != f->format))
+          tk_fail(tk, "%s: no answer to get_format_alpha", f->name);
+        if ((int)answer.alpha == f->alpha) continue;
+        fprintf(stderr, PROG ": %s is %s, wanted %s\n", f->name,
+                answer.alpha ? "blended" : "opaque",
+                f->alpha ? "blended" : "opaque");
+        wrong++;
+     }
+
+   if (wrong) tk_fail(tk, "%d formats are drawn the wrong way", wrong);
+
+   tk_disconnect(tk);
+   printf(PROG ": ok\n");
+   return 0;
+}

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

Reply via email to