summaryrefslogtreecommitdiff
path: root/src/common/native.c
blob: 42b065c58d0e7ad2713d6f9bd87555012c7d0f55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "backend.h"

#include <errno.h>

void *yasl_display_get_native_handle(struct yasl_display *d)
{
    if (!d) return NULL;
    if (d->native_handle) return d->native_handle;
    return d->ops && d->ops->display_get_native_handle ?
        d->ops->display_get_native_handle(d) : NULL;
}

void *yasl_surface_get_native_handle(struct yasl_surface *s)
{
    if (!s) return NULL;
    if (s->native_handle) return s->native_handle;
    return s->display && s->display->ops && s->display->ops->surface_get_native_handle ?
        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)
{
    if (!graphics_device) {
        errno = EINVAL;
        return NULL;
    }
    return yasl_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)
{
    if (!s || !target || !out || !target->generation ||
        target->generation != s->frame_generation ||
        !s->display->ops->surface_get_native_frame)
        return false;
    return s->display->ops->surface_get_native_frame(s, target, out);
}