diff options
Diffstat (limited to 'src/common/native.c')
| -rw-r--r-- | src/common/native.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/common/native.c b/src/common/native.c index 42b065c..88604c9 100644 --- a/src/common/native.c +++ b/src/common/native.c @@ -2,7 +2,7 @@ #include <errno.h> -void *yasl_display_get_native_handle(struct yasl_display *d) +void *yasl_private_display_get_native_handle(struct yasl_private_display *d) { if (!d) return NULL; if (d->native_handle) return d->native_handle; @@ -10,7 +10,7 @@ void *yasl_display_get_native_handle(struct yasl_display *d) d->ops->display_get_native_handle(d) : NULL; } -void *yasl_surface_get_native_handle(struct yasl_surface *s) +void *yasl_private_surface_get_native_handle(struct yasl_surface *s) { if (!s) return NULL; if (s->native_handle) return s->native_handle; @@ -18,18 +18,18 @@ void *yasl_surface_get_native_handle(struct yasl_surface *s) s->display->ops->surface_get_native_handle(s) : NULL; } -struct yasl_surface *yasl_surface_create_native(struct yasl_display *d, - const struct yasl_window_spec *spec, void *graphics_device) +struct yasl_surface *yasl_private_surface_create_native(struct yasl_private_display *d, + const struct yasl_private_window_spec *spec, void *graphics_device) { if (!graphics_device) { errno = EINVAL; return NULL; } - return yasl_create_toplevel(d, spec, graphics_device); + return yasl_private_create_toplevel(d, spec, graphics_device); } -bool yasl_surface_get_native_frame(struct yasl_surface *s, - const struct yasl_framebuffer *target, struct yasl_native_frame *out) +bool yasl_private_surface_get_native_frame(struct yasl_surface *s, + const struct yasl_private_framebuffer *target, struct yasl_private_native_frame *out) { if (!s || !target || !out || !target->generation || target->generation != s->frame_generation || @@ -37,3 +37,39 @@ bool yasl_surface_get_native_frame(struct yasl_surface *s, return false; return s->display->ops->surface_get_native_frame(s, target, out); } + +#include "public_internal.h" +#include "yasl/metal.h" +#if YASL_HAS_WAYLAND +#include "yasl/native/wayland.h" +struct wl_display *yasl_wayland_display(const yasl_surface *s) +{ return s && s->display->ops->type==YASL_PRIVATE_BACKEND_WAYLAND ? yasl_private_display_get_native_handle(s->display):NULL; } +struct wl_surface *yasl_wayland_surface(const yasl_surface *s) +{ return s && s->display->ops->type==YASL_PRIVATE_BACKEND_WAYLAND ? yasl_private_surface_get_native_handle((yasl_surface*)s):NULL; } +#endif +#if YASL_HAS_X11 +#include "yasl/native/x11.h" +Display *yasl_x11_display(const yasl_surface *s) +{ return s && s->display->ops->type==YASL_PRIVATE_BACKEND_X11 ? yasl_private_display_get_native_handle(s->display):NULL; } +uintptr_t yasl_x11_window(const yasl_surface *s) +{ return s && s->display->ops->type==YASL_PRIVATE_BACKEND_X11 ? (uintptr_t)yasl_private_surface_get_native_handle((yasl_surface*)s):0; } +#endif +#if YASL_HAS_COCOA +#include "yasl/native/cocoa.h" +#include "common/private_native_cocoa.h" +NSApplication *yasl_cocoa_application(void) +{ struct yasl_private_display *d=yasl_public_display();return d ? yasl_private_cocoa_display_get_application(d):NULL; } +NSWindow *yasl_cocoa_window(const yasl_surface *s) +{ return yasl_private_cocoa_surface_get_window((yasl_surface*)s); } +NSView *yasl_cocoa_view(const yasl_surface *s) +{ return yasl_private_cocoa_surface_get_view((yasl_surface*)s); } +#endif +CAMetalLayer *yasl_metal_layer(yasl_surface *s) +{ + if(!yasl_public_surface(s,false))return NULL; + if(s->presenter!=YASL_PRIVATE_PRESENTER_NONE && s->presenter!=YASL_PRIVATE_PRESENTER_METAL) {yasl_public_fail(EBUSY);return NULL;} + if(!s->display->ops->surface_get_metal_layer){yasl_public_fail(ENOTSUP);return NULL;} + CAMetalLayer *layer=s->display->ops->surface_get_metal_layer(s); + if(!layer){yasl_public_fail(ENOTSUP);return NULL;} + s->presenter=YASL_PRIVATE_PRESENTER_METAL;return layer; +} |
