diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 08:41:51 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 08:41:51 +0300 |
| commit | 3b8af02be94a510e385f44d58c35c86bb89424a6 (patch) | |
| tree | 2573fb5ac41700d458109ee1cea4bfd875ecf1a2 /include/yasl/native.h | |
| parent | f7fa0930cb46046f995fa1ab927aef62466e995e (diff) | |
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.
Diffstat (limited to 'include/yasl/native.h')
| -rw-r--r-- | include/yasl/native.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/yasl/native.h b/include/yasl/native.h new file mode 100644 index 0000000..f7e3020 --- /dev/null +++ b/include/yasl/native.h @@ -0,0 +1,44 @@ +#ifndef YASL_NATIVE_H +#define YASL_NATIVE_H + +#include "yasl/yasl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Optional platform interoperability. All handles are borrowed and expire on + * object destruction. Check yasl_display_backend() before casting: + * + * display surface + * Wayland struct wl_display * struct wl_surface * + * X11 Display * Window (cast through uintptr_t) + * Cocoa NSApplication * NSWindow * (view: window.contentView) + */ +YASL_API void *yasl_display_get_native_handle(struct yasl_display *d); +YASL_API void *yasl_surface_get_native_handle(struct yasl_surface *s); + +/* Create a surface for application-managed native rendering. graphics_device + * must be non-NULL; currently an id<MTLDevice> on Cocoa, retained by the surface. + * Other backends return NULL with errno=ENOTSUP. CPU rendering uses the ordinary + * yasl_surface_create_toplevel() and requires no native device. */ +YASL_API struct yasl_surface *yasl_surface_create_native(struct yasl_display *d, + const struct yasl_surface_spec *spec, void *graphics_device); + +struct yasl_native_frame { + void *drawable; /* id<CAMetalDrawable> on Cocoa */ + bool transaction; /* CAMetalLayer.presentsWithTransaction */ +}; + +/* Query the current draw target's native drawable. Returns false for unsupported + * backends, stale targets, or outside the draw callback. The result expires on + * successful present, callback return, or surface destruction. Native renderers + * submit/present the drawable, then call yasl_surface_present() to record it. */ +YASL_API bool yasl_surface_get_native_frame(struct yasl_surface *s, + const struct yasl_framebuffer *target, struct yasl_native_frame *out); + +#ifdef __cplusplus +} +#endif + +#endif /* YASL_NATIVE_H */ |
