Example #1
0
static bool
wayland_platform_destroy(struct wcore_platform *wc_self)
{
    struct wayland_platform *self = wayland_platform(wegl_platform(wc_self));
    bool ok = true;
    int error;

    if (!self)
        return true;

    if (self->linux)
        ok &= linux_platform_destroy(self->linux);

    if (self->dl_wl_egl) {
        error = dlclose(self->dl_wl_egl);
        if (error) {
            ok &= false;
            wcore_errorf(WAFFLE_ERROR_UNKNOWN,
                         "dlclose(\"%s\") failed: %s",
                         libwl_egl_filename, dlerror());
        }
    }

    ok &= wayland_wrapper_teardown();
    ok &= wegl_platform_teardown(&self->wegl);
    free(self);
    return ok;
}
Example #2
0
static bool
wayland_dl_can_open(struct wcore_platform *wc_self,
                             int32_t waffle_dl)
{
    struct wayland_platform *self = wayland_platform(wegl_platform(wc_self));
    return linux_platform_dl_can_open(self->linux, waffle_dl);
}
Example #3
0
static void*
wayland_dl_sym(struct wcore_platform *wc_self,
                        int32_t waffle_dl,
                        const char *name)
{
    struct wayland_platform *self = wayland_platform(wegl_platform(wc_self));
    return linux_platform_dl_sym(self->linux, waffle_dl, name);
}
Example #4
0
struct wcore_window*
wgbm_window_create(struct wcore_platform *wc_plat,
                   struct wcore_config *wc_config,
                   int32_t width,
                   int32_t height,
                   const intptr_t attrib_list[])
{
    struct wgbm_display *dpy = wgbm_display(wc_config->display);
    struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
    struct wgbm_window *self;
    uint32_t gbm_format;
    bool ok = true;

    if (width == -1 && height == -1) {
        wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
                     "fullscreen window not supported");
        return NULL;
    }

    if (wcore_attrib_list_length(attrib_list) > 0) {
        wcore_error_bad_attribute(attrib_list[0]);
        return NULL;
    }

    self = wcore_calloc(sizeof(*self));
    if (self == NULL)
        return NULL;

    gbm_format = wgbm_config_get_gbm_format(wc_plat, wc_config->display,
                                            wc_config);
    assert(gbm_format != 0);
    self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device,
                                                 width, height, gbm_format,
                                                 GBM_BO_USE_RENDERING);
    if (!self->gbm_surface) {
        wcore_errorf(WAFFLE_ERROR_UNKNOWN,
                     "gbm_surface_create failed");
        goto error;
    }

    ok = wegl_window_init(&self->wegl, wc_config,
                          (intptr_t) self->gbm_surface);
    if (!ok)
        goto error;

    return &self->wegl.wcore;

error:
    wgbm_window_destroy(&self->wegl.wcore);
    return NULL;
}
Example #5
0
bool
wgbm_window_destroy(struct wcore_window *wc_self)
{
    struct wcore_platform *wc_plat = wc_self->display->platform;
    struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
    struct wgbm_window *self = wgbm_window(wc_self);
    bool ok = true;

    if (!self)
        return ok;

    ok &= wegl_surface_teardown(&self->wegl);
    plat->gbm_surface_destroy(self->gbm_surface);
    free(self);
    return ok;
}
Example #6
0
bool
wgbm_window_swap_buffers(struct wcore_window *wc_self)
{
    struct wcore_platform *wc_plat = wc_self->display->platform;
    struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));

    if (!wegl_surface_swap_buffers(wc_self))
        return false;

    struct wgbm_window *self = wgbm_window(wc_self);
    struct gbm_bo *bo = plat->gbm_surface_lock_front_buffer(self->gbm_surface);
    if (!bo)
        return false;

    plat->gbm_surface_release_buffer(self->gbm_surface, bo);
    return true;
}
Example #7
0
bool
wegl_make_current(struct wcore_platform *wc_plat,
                  struct wcore_display *wc_dpy,
                  struct wcore_window *wc_window,
                  struct wcore_context *wc_ctx)
{
    struct wegl_platform *plat = wegl_platform(wc_plat);
    EGLSurface surface = wc_window ? wegl_window(wc_window)->egl : NULL;
    bool ok;

    ok = plat->eglMakeCurrent(wegl_display(wc_dpy)->egl,
                              surface,
                              surface,
                              wc_ctx
                                  ? wegl_context(wc_ctx)->egl
                                  : NULL);
    if (!ok)
        wegl_emit_error(plat, "eglMakeCurrent");

    return ok;
}
Example #8
0
bool
wgbm_display_destroy(struct wcore_display *wc_self)
{
    struct wgbm_display *self = wgbm_display(wc_self);
    struct wcore_platform *wc_plat = wc_self->platform;
    struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
    bool ok = true;
    int fd;

    if (!self)
        return ok;


    ok &= wegl_display_teardown(&self->wegl);

    if (self->gbm_device) {
        fd = plat->gbm_device_get_fd(self->gbm_device);
        plat->gbm_device_destroy(self->gbm_device);
        close(fd);
    }

    free(self);
    return ok;
}
Example #9
0
void*
wegl_get_proc_address(struct wcore_platform *wc_self, const char *name)
{
    struct wegl_platform *self = wegl_platform(wc_self);
    return self->eglGetProcAddress(name);
}