This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch up/pointer-shutdown
in repository enlightenment.
View the commit online.
commit a6812f37c5e2dd7f84e1e3111344c0ffb3eb2ba3
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 27 22:12:27 2026 -0600
e_comp_wl - honour wl_surface.set_buffer_transform
A client that drew its content rotated or mirrored says so with
set_buffer_transform, and the compositor shows the buffer with the
inverse applied. E ignored the request, so such a window came out the
wrong shape and the wrong way round.
The transform is latched at commit like the buffer scale. A quarter
turn exchanges the surface's width and height. The comp object turns
the image with evas_object_image_orient_set(), after
evas_object_image_data_set() since the pixels are copied through the
image's stride.
This needs the EFL fix "evas: keep an image's orientation when its
data is set": without it evas drops the orientation of every frame
after the first, and shows it unturned.
A buffer passed as a native surface (dmabuf) is shown as it is: evas
turns an image by rebuilding it from its pixels, and a native surface
has none.
Damage and the opaque region are in coordinates a turned buffer does
not share, so a turned buffer is redrawn whole and its opaque region,
only a hint, is dropped. Neither shows on screen, as E redraws a
surface whole on every commit.
e_comp_object.c is shared with X11, which never sets an orientation.
wl-buffer-transform shows a non-square quadrant buffer under each of
the eight transforms, twice, and checks the window's size and its
pixels against Weston's mapping from surface to buffer coordinates,
then that a transform of 8 is a protocol error. It fails without the
axis swap, without the orientation, with any two orientations of the
table exchanged, and against an EFL without the fix above.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bin/e_comp_object.c | 19 +++
src/bin/e_comp_object.h | 1 +
src/bin/e_comp_wl.c | 94 +++++++++---
src/bin/e_comp_wl.h | 6 +-
src/tests/wayland/meson.build | 1 +
src/tests/wayland/test_buffer_transform.c | 234 ++++++++++++++++++++++++++++++
6 files changed, 332 insertions(+), 23 deletions(-)
diff --git a/src/bin/e_comp_object.c b/src/bin/e_comp_object.c
index b08b79b16..0565d2f35 100644
--- a/src/bin/e_comp_object.c
+++ b/src/bin/e_comp_object.c
@@ -75,6 +75,8 @@ typedef struct _E_Comp_Object
/* The size a Wayland surface is shown at, which a buffer scale makes
* differ from its buffer; 0x0 is the pixmap size. */
int content_w, content_h;
+ /* How a Wayland buffer is turned to be shown the right way up. */
+ Evas_Image_Orient content_orient;
Eina_Stringshare *frame_theme;
Eina_Stringshare *frame_name;
@@ -916,6 +918,14 @@ _e_comp_object_setup(E_Comp_Object *cw)
}
}
+/* A native surface has no pixels for evas to turn. */
+static void
+_e_comp_object_content_orient_apply(E_Comp_Object *cw, Evas_Object *o)
+{
+ if (cw->native) return;
+ evas_object_image_orient_set(o, cw->content_orient);
+}
+
static void
_e_comp_object_mirror_pixels_get(void *data, Evas_Object *obj)
{
@@ -945,6 +955,7 @@ _e_comp_object_mirror_pixels_get(void *data, Evas_Object *obj)
if (cw->native) return;
evas_object_image_data_set(obj, e_pixmap_image_data_get(cw->ec->pixmap));
+ _e_comp_object_content_orient_apply(cw, obj);
}
/////////////////////////////////////////////
@@ -4192,6 +4203,13 @@ e_comp_object_content_size_set(Evas_Object *obj, int w, int h)
cw->content_h = h;
}
+EINTERN void
+e_comp_object_content_orient_set(Evas_Object *obj, Evas_Image_Orient orient)
+{
+ API_ENTRY;
+ cw->content_orient = orient;
+}
+
/* mark an object as dirty and setup damages */
E_API void
e_comp_object_dirty(Evas_Object *obj)
@@ -4406,6 +4424,7 @@ e_comp_object_render(Evas_Object *obj)
end:
eina_iterator_free(it);
evas_object_image_data_set(cw->obj, cw->blanked ? NULL : pix);
+ _e_comp_object_content_orient_apply(cw, cw->obj);
_e_comp_object_alpha_set(cw);
E_FREE_FUNC(cw->pending_updates, eina_tiler_free);
diff --git a/src/bin/e_comp_object.h b/src/bin/e_comp_object.h
index 111c3e11f..152454cd0 100644
--- a/src/bin/e_comp_object.h
+++ b/src/bin/e_comp_object.h
@@ -90,6 +90,7 @@ E_API Evas_Object *e_comp_object_agent_add(Evas_Object *obj);
E_API void e_comp_object_blank(Evas_Object *obj, Eina_Bool set);
E_API void e_comp_object_dirty(Evas_Object *obj);
EINTERN void e_comp_object_content_size_set(Evas_Object *obj, int w, int h);
+EINTERN void e_comp_object_content_orient_set(Evas_Object *obj, Evas_Image_Orient orient);
E_API Eina_Bool e_comp_object_render(Evas_Object *obj);
E_API Eina_Bool e_comp_object_effect_allowed_get(Evas_Object *obj);
E_API Eina_Bool e_comp_object_effect_set(Evas_Object *obj, const char *effect);
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index 09d4db9a5..5ecb7ba0c 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -1521,32 +1521,51 @@ _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mou
return ECORE_CALLBACK_RENEW;
}
+/* evas turns an image by rebuilding it from its pixels, and a native
+ * surface (dmabuf) has none, so such a buffer is shown as it is. */
+static int
+_e_comp_wl_buffer_transform_get(const E_Client *ec)
+{
+ if (!e_pixmap_is_pixels(ec->pixmap)) return WL_OUTPUT_TRANSFORM_NORMAL;
+ return ec->comp_data->buffer_transform;
+}
+
+/* The client applied the transform to its content, so the buffer is shown
+ * with the inverse: a turn the other way, and a flip is its own inverse. */
+static Evas_Image_Orient
+_e_comp_wl_buffer_transform_orient(int transform)
+{
+ switch (transform)
+ {
+ case WL_OUTPUT_TRANSFORM_90: return EVAS_IMAGE_ORIENT_90;
+ case WL_OUTPUT_TRANSFORM_180: return EVAS_IMAGE_ORIENT_180;
+ case WL_OUTPUT_TRANSFORM_270: return EVAS_IMAGE_ORIENT_270;
+ case WL_OUTPUT_TRANSFORM_FLIPPED: return EVAS_IMAGE_FLIP_HORIZONTAL;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90: return EVAS_IMAGE_FLIP_TRANSPOSE;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180: return EVAS_IMAGE_FLIP_VERTICAL;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270: return EVAS_IMAGE_FLIP_TRANSVERSE;
+ default: return EVAS_IMAGE_ORIENT_NONE;
+ }
+}
+
static void
_e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
{
Eina_Rectangle *window;
- /* double scale = 0.0; */
+ int w, h, transform;
- /* scale = e_comp_wl->output.scale; */
- /* switch (e_comp_wl->output.transform) */
- /* { */
- /* case WL_OUTPUT_TRANSFORM_90: */
- /* case WL_OUTPUT_TRANSFORM_270: */
- /* case WL_OUTPUT_TRANSFORM_FLIPPED_90: */
- /* case WL_OUTPUT_TRANSFORM_FLIPPED_270: */
- /* w = ec->comp_data->buffer_ref.buffer->h / scale; */
- /* h = ec->comp_data->buffer_ref.buffer->w / scale; */
- /* break; */
- /* default: */
- /* w = ec->comp_data->buffer_ref.buffer->w / scale; */
- /* h = ec->comp_data->buffer_ref.buffer->h / scale; */
- /* break; */
- /* } */
-
- if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
+ if (!e_pixmap_size_get(ec->pixmap, &w, &h)) return;
+ transform = _e_comp_wl_buffer_transform_get(ec);
+ /* The odd transforms are a quarter turn. */
+ if (transform & 1)
+ state->bw = h, state->bh = w;
+ else
+ state->bw = w, state->bh = h;
state->bw = (state->bw / ec->comp_data->buffer_scale) * e_comp_wl_client_scale_get(ec);
state->bh = (state->bh / ec->comp_data->buffer_scale) * e_comp_wl_client_scale_get(ec);
e_comp_object_content_size_set(ec->frame, state->bw, state->bh);
+ e_comp_object_content_orient_set(ec->frame,
+ _e_comp_wl_buffer_transform_orient(transform));
if (e_client_has_xwindow(ec) || e_comp_object_frame_exists(ec->frame)) return;
window = &ec->comp_data->shell.window;
if (window->x || window->y || window->w || window->h)
@@ -1581,6 +1600,7 @@ _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state)
_e_comp_wl_surface_state_cb_buffer_destroy;
state->sx = state->sy = 0;
state->buffer_scale = 1;
+ state->buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;
state->input = NULL;
@@ -1702,6 +1722,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
ec->comp_data->in_commit = 1;
ec->comp_data->buffer_scale = state->buffer_scale;
+ ec->comp_data->buffer_transform = state->buffer_transform;
if (ec->ignored && ec->comp_data->shell.surface)
{
EC_CHANGED(ec);
@@ -1973,7 +1994,20 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
e_comp_wl_presentation_feedback_commit(ec, &state->presentation_feedbacks);
/* put state damages into surface */
- if ((!e_comp->nocomp) && (ec->frame))
+ if ((!e_comp->nocomp) && (ec->frame) &&
+ (_e_comp_wl_buffer_transform_get(ec) != WL_OUTPUT_TRANSFORM_NORMAL))
+ {
+ int pw = 0, ph = 0;
+
+ /* Damage is in the turned buffer: redraw all of it. */
+ EINA_LIST_FREE(state->buffer_damages, dmg)
+ eina_rectangle_free(dmg);
+ EINA_LIST_FREE(state->damages, dmg)
+ eina_rectangle_free(dmg);
+ e_pixmap_size_get(ec->pixmap, &pw, &ph);
+ e_comp_object_damage(ec->frame, 0, 0, pw, ph);
+ }
+ else if ((!e_comp->nocomp) && (ec->frame))
{
int scale = ec->comp_data->buffer_scale;
@@ -1993,6 +2027,10 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
/* put state opaque into surface */
if (state->opaque)
{
+ /* Only a hint, and in surface coordinates that a turned buffer
+ * does not share: drop it. */
+ if (_e_comp_wl_buffer_transform_get(ec) != WL_OUTPUT_TRANSFORM_NORMAL)
+ eina_tiler_clear(state->opaque);
if (!eina_tiler_empty(state->opaque))
{
Eina_Rectangle *rect;
@@ -2324,9 +2362,22 @@ _e_comp_wl_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_res
}
static void
-_e_comp_wl_surface_cb_buffer_transform_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t transform EINA_UNUSED)
+_e_comp_wl_surface_cb_buffer_transform_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t transform)
{
- /* DBG("Surface Buffer Transform: %d", wl_resource_get_id(resource)); */
+ E_Client *ec;
+
+ if (!(ec = wl_resource_get_user_data(resource))) return;
+ if (e_object_is_del(E_OBJECT(ec))) return;
+
+ if ((transform < WL_OUTPUT_TRANSFORM_NORMAL) ||
+ (transform > WL_OUTPUT_TRANSFORM_FLIPPED_270))
+ {
+ wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_TRANSFORM,
+ "buffer transform %d is not a wl_output.transform",
+ transform);
+ return;
+ }
+ ec->comp_data->pending.buffer_transform = transform;
}
static void
@@ -2655,6 +2706,7 @@ _e_comp_wl_subsurface_commit_to_cache(E_Client *ec)
cdata->pending.buffer_damages);
cdata->pending.buffer_damages = NULL;
sdata->cached.buffer_scale = cdata->pending.buffer_scale;
+ sdata->cached.buffer_transform = cdata->pending.buffer_transform;
if (cdata->pending.new_attach)
{
diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
index 0df451123..612baa6f2 100644
--- a/src/bin/e_comp_wl.h
+++ b/src/bin/e_comp_wl.h
@@ -86,6 +86,7 @@ struct _E_Comp_Wl_Surface_State
Eina_List *presentation_feedbacks;
Eina_Tiler *input, *opaque;
int buffer_scale;
+ int buffer_transform;
Eina_Bool new_attach E_BITFIELD;
Eina_Bool has_data E_BITFIELD;
};
@@ -376,9 +377,10 @@ struct _E_Comp_Wl_Client_Data
} shell;
E_Comp_Wl_Surface_State pending;
- /* The wl_surface.set_buffer_scale in effect, and the surface size the
- * last commit worked out, in canvas pixels. */
+ /* The wl_surface.set_buffer_scale and set_buffer_transform in effect,
+ * and the surface size the last commit worked out, in canvas pixels. */
int buffer_scale;
+ int buffer_transform;
int surface_w, surface_h;
Eina_List *frames;
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index b05c7214b..ae21b7471 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -90,6 +90,7 @@ wl_protocol_tests = [
['output', 'test_output.c'],
['buffer-scale', 'test_buffer_scale.c'],
['output-scale', 'test_output_scale.c'],
+ ['buffer-transform', 'test_buffer_transform.c'],
['activation', 'test_activation.c'],
['activation-expiry', 'test_activation.c',
{'E_TEST_ACTIVATION_TOKEN_LIFETIME': '1'}],
diff --git a/src/tests/wayland/test_buffer_transform.c b/src/tests/wayland/test_buffer_transform.c
new file mode 100644
index 000000000..bcba7aaf6
--- /dev/null
+++ b/src/tests/wayland/test_buffer_transform.c
@@ -0,0 +1,234 @@
+/* wl_surface.set_buffer_transform names the transform the client applied
+ * to its content, and E shows the buffer with the inverse applied. */
+#define _GNU_SOURCE 1
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <time.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-buffer-transform"
+#define APP_ID "e.test.buffer-transform"
+
+#define TL 0xffff0000
+#define TR 0xff00ff00
+#define BL 0xff0000ff
+#define BR 0xffffff00
+
+typedef struct
+{
+ Tk *tk;
+ struct wl_test *tester;
+ struct wl_shm *shm;
+ 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
+};
+
+/* A buffer of four solid quadrants. */
+static struct wl_buffer *
+_buffer(Ctx *ctx, int w, int h)
+{
+ uint32_t colors[4] = { TL, TR, BL, BR };
+ struct wl_shm_pool *pool;
+ struct wl_buffer *buffer;
+ uint32_t *pixels;
+ int fd, x, y;
+
+ fd = memfd_create(PROG, MFD_CLOEXEC);
+ if ((fd < 0) || (ftruncate(fd, w * h * 4) < 0))
+ tk_fail(ctx->tk, "cannot make a %dx%d buffer", w, h);
+ pixels = mmap(NULL, w * h * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (pixels == MAP_FAILED) tk_fail(ctx->tk, "cannot map a buffer");
+ for (y = 0; y < h; y++)
+ for (x = 0; x < w; x++)
+ pixels[(y * w) + x] = colors[((y >= h / 2) * 2) + (x >= w / 2)];
+ munmap(pixels, w * h * 4);
+ pool = wl_shm_create_pool(ctx->shm, fd, w * h * 4);
+ buffer = wl_shm_pool_create_buffer(pool, 0, w, h, w * 4,
+ WL_SHM_FORMAT_ARGB8888);
+ wl_shm_pool_destroy(pool);
+ close(fd);
+ return buffer;
+}
+
+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);
+}
+
+/* The buffer pixel shown at surface-local sx,sy of a w x h surface, as
+ * weston_transformed_coord() maps it. */
+static void
+_buffer_coord(int transform, int w, int h, int sx, int sy, int *bx, int *by)
+{
+ switch (transform)
+ {
+ case WL_OUTPUT_TRANSFORM_90:
+ *bx = sy, *by = w - sx;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ *bx = w - sx, *by = h - sy;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ *bx = h - sy, *by = sx;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ *bx = w - sx, *by = sy;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ *bx = sy, *by = sx;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ *bx = sx, *by = h - sy;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ *bx = h - sy, *by = w - sx;
+ break;
+ default:
+ *bx = sx, *by = sy;
+ break;
+ }
+}
+
+static void
+_size_check(Ctx *ctx, struct wl_surface *surface, int w, int h,
+ const char *what)
+{
+ int sw, sh;
+
+ tk_surface_geometry(ctx->tk, surface, NULL, NULL, &sw, &sh);
+ if ((sw != w) || (sh != h))
+ tk_fail(ctx->tk, "%s: the window is %dx%d, wanted %dx%d", what, sw, sh,
+ w, h);
+}
+
+int
+main(void)
+{
+ uint32_t colors[4] = { TL, TR, BL, BR };
+ struct xdg_surface *xdg_surface;
+ struct xdg_toplevel *toplevel;
+ struct wl_surface *surface;
+ Ctx ctx = { 0 };
+ int transform, frame, i, x, y, w, h, bx, by;
+ char what[64];
+
+ ctx.tk = tk_connect(PROG);
+ ctx.tester = tk_bind(ctx.tk, &wl_test_interface, 9);
+ ctx.shm = tk_bind(ctx.tk, &wl_shm_interface, 1);
+ if (!ctx.tester) tk_fail(ctx.tk, "no wl_test version 9");
+ wl_test_add_listener(ctx.tester, &_tester_listener, &ctx);
+
+ surface = tk_surface_new(ctx.tk);
+ 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);
+
+ /* Not square, so that a quarter turn shows in the size too. Two
+ * buffers each, as a transform stays for the frames after the one that
+ * set it. */
+ for (transform = WL_OUTPUT_TRANSFORM_NORMAL;
+ transform <= WL_OUTPUT_TRANSFORM_FLIPPED_270; transform++)
+ for (frame = 0; frame < 2; frame++)
+ {
+ wl_surface_set_buffer_transform(surface, transform);
+ wl_surface_attach(surface, _buffer(&ctx, 200, 100), 0, 0);
+ wl_surface_damage_buffer(surface, 0, 0, 200, 100);
+ wl_surface_commit(surface);
+ tk_settle(ctx.tk);
+ tk_expect(ctx.tk, APP_ID);
+
+ w = (transform & 1) ? 100 : 200;
+ h = (transform & 1) ? 200 : 100;
+ snprintf(what, sizeof(what), "transform %d, frame %d", transform, frame);
+ _size_check(&ctx, surface, w, h, what);
+ tk_surface_geometry(ctx.tk, surface, &x, &y, NULL, NULL);
+ for (i = 0; i < 4; i++)
+ {
+ int sx = (i & 1) ? (3 * w / 4) : (w / 4);
+ int sy = (i & 2) ? (3 * h / 4) : (h / 4);
+
+ _buffer_coord(transform, w, h, sx, sy, &bx, &by);
+ snprintf(what, sizeof(what), "transform %d, frame %d, at %d,%d",
+ transform, frame, sx, sy);
+ _pixel_wait(&ctx, x + sx, y + sy,
+ colors[((by >= 50) * 2) + (bx >= 100)], what);
+ }
+ }
+
+ wl_surface_set_buffer_transform(surface, WL_OUTPUT_TRANSFORM_FLIPPED_270 + 1);
+ if (tk_protocol_error(ctx.tk, NULL) != WL_SURFACE_ERROR_INVALID_TRANSFORM)
+ {
+ fprintf(stderr, PROG ": a buffer transform of 8 was accepted\n");
+ return 1;
+ }
+
+ tk_disconnect(ctx.tk);
+ printf(PROG ": ok\n");
+ return 0;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.