swayfx-mosaic/tooling/probes/step20c-effects-damage/effect-glass.patch

22 lines
1.3 KiB
Diff

--- a/nested-client.c
+++ b/nested-client.c
@@ -45,10 +45,17 @@
unlink(path);
uint32_t *pixels = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (pixels == MAP_FAILED) { perror("mmap"); exit(1); }
- for (size_t i=0; i<bytes/4; ++i) pixels[i] = s->color;
+ /* WHY: a translucent mapped SHM surface exposes actual blur of the
+ * checkerboard below, instead of merely accepting the blur command.
+ * CONTRACT: ARGB channels are premultiplied and the buffer size is fixed. */
+ bool glass = s == &top;
+ for (size_t i=0; i<bytes/4; ++i) pixels[i] = glass ? 0x88442010 : s->color;
struct wl_shm_pool *pool = wl_shm_create_pool(shm, fd, (int)bytes);
struct wl_buffer *buffer = wl_shm_pool_create_buffer(pool, 0, s->width, s->height,
- s->width*4, WL_SHM_FORMAT_XRGB8888);
+ s->width*4, glass ? WL_SHM_FORMAT_ARGB8888 : WL_SHM_FORMAT_XRGB8888);
+ fprintf(stderr,"EFFECT_BUFFER wl=%u format=%s width=%d height=%d argb=%08x\n",
+ wl_proxy_get_id((struct wl_proxy *)s->wl), glass ? "ARGB8888" : "XRGB8888",
+ s->width, s->height, glass ? 0x88442010 : s->color);
wl_surface_attach(s->wl, buffer, 0, 0);
wl_surface_damage_buffer(s->wl, 0, 0, s->width, s->height);
wl_surface_commit(s->wl);