From 3b8af02be94a510e385f44d58c35c86bb89424a6 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Mon, 12 Oct 2026 08:41:51 +0300 Subject: refactor: simplify public API and isolate native extensions Separate loop/timer and native interoperability APIs from the portable surface header. Unify dispatch, geometry queries, and timer callbacks; keep framebuffer bookkeeping and frame clocks private, and hide implementation symbols. Update backends, documentation, examples, and API/integration coverage. Verify exports, strict C/C++ installed consumers, and normal plus ASan/UBSan suites. --- tests/common/test_backends.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'tests/common/test_backends.c') diff --git a/tests/common/test_backends.c b/tests/common/test_backends.c index 3372290..4f49765 100644 --- a/tests/common/test_backends.c +++ b/tests/common/test_backends.c @@ -1,4 +1,6 @@ #define _POSIX_C_SOURCE 200809L +#include "yasl/native.h" +#include "yasl/loop.h" #include "yasl/yasl.h" #include @@ -35,7 +37,7 @@ static int tick(int fd, short events, void *ud) struct pump *p = ud; for (int i = 0; i < 2; i++) { if (p->displays[i]) { - yasl_display_dispatch(p->displays[i]); + yasl_display_dispatch(p->displays[i], 0); yasl_display_flush(p->displays[i]); } } @@ -63,9 +65,11 @@ static void draw(struct yasl_surface *s, struct yasl_frame *frame, void *ud) assert(s == w->surface); assert(frame->surface == s); assert(yasl_surface_display(s) == w->display); - struct yasl_vector2i size = yasl_surface_size(s); + struct yasl_vector2i size = yasl_surface_geometry(s).size; assert(size.x == frame->target.size.x && size.y == frame->target.size.y); assert(frame->target.pixels); + struct yasl_native_frame native = {0}; + assert(!yasl_surface_get_native_frame(s, &frame->target, &native)); for (int i = 0; i < size.x * size.y; i++) frame->target.pixels[i] = 0xff4080c0; struct yasl_damage_list damage = {.n = YASL_DAMAGE_MAX + 1}; assert(!yasl_surface_present(s, &frame->target, &damage)); @@ -76,13 +80,13 @@ static void draw(struct yasl_surface *s, struct yasl_frame *frame, void *ud) assert(!yasl_surface_present(s, &frame->target, &damage)); damage.n = -1; struct yasl_framebuffer invalid = frame->target; - invalid.buffer++; + invalid.size.x++; assert(!yasl_surface_present(s, &invalid, &damage)); invalid = frame->target; invalid.generation--; assert(!yasl_surface_present(s, &invalid, &damage)); invalid = frame->target; - invalid.native_drawable = (void *)(uintptr_t)1; + invalid.pixels = (uint32_t *)(uintptr_t)1; assert(!yasl_surface_present(s, &invalid, &damage)); assert(!yasl_surface_present(s, &frame->target, NULL)); assert(yasl_surface_present(s, &frame->target, &damage)); @@ -95,9 +99,9 @@ static void configure(struct yasl_surface *s, struct yasl_geometry geometry, voi { struct window *w = ud; assert(w->surface == s); - struct yasl_vector2i size = yasl_surface_size(s); + struct yasl_vector2i size = yasl_surface_geometry(s).size; assert(geometry.size.x == size.x && geometry.size.y == size.y); - assert(geometry.scale_120 == yasl_surface_scale_120(s)); + assert(geometry.scale_120 == yasl_surface_geometry(s).scale_120); w->configures++; if (w->destroy_on_configure) { yasl_surface_destroy(s); w->surface = NULL; } } @@ -129,6 +133,8 @@ static struct window create(struct yasl_display *d) struct yasl_surface_spec spec = {.title = "Backend test", .size = {160, 100}}; struct yasl_surface *s = yasl_surface_create_toplevel(d, &spec); assert(s); + assert(yasl_display_get_native_handle(d)); + assert(yasl_surface_get_native_handle(s)); assert(yasl_surface_display(s) == d); assert(yasl_surface_timing(s).source == YASL_TIMING_UNKNOWN); return (struct window){.surface = s, .display = d}; @@ -152,7 +158,7 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct XFlush(native); pump(loop, d, NULL); assert(w->configures > 0); - struct yasl_vector2i size = yasl_surface_size(w->surface); + struct yasl_vector2i size = yasl_surface_geometry(w->surface).size; assert(size.x == 200 && size.y == 120); XEvent key = {0}; key.xkey = (XKeyEvent){.type = KeyPress, .display = native, .window = window, -- cgit v1.2.3