1 // SPDX-FileCopyrightText: Copyright 2012 Intel Corporation
2 // SPDX-License-Identifier: BSD-2-Clause
7 #include "wcore_error.h"
9 #include "posix_platform.h"
11 #include "wegl_config.h"
12 #include "wegl_context.h"
13 #include "wegl_platform.h"
14 #include "wegl_util.h"
16 #include "sl_config.h"
17 #include "sl_display.h"
18 #include "sl_platform.h"
19 #include "sl_window.h"
21 static const struct wcore_platform_vtbl sl_platform_vtbl
;
24 sl_platform_destroy(struct wcore_platform
*wc_self
)
26 struct sl_platform
*self
= sl_platform(wegl_platform(wc_self
));
27 bool ok
= wegl_platform_teardown(&self
->wegl
);
33 struct wcore_platform
*
34 sl_platform_create(void)
36 struct sl_platform
*self
= wcore_calloc(sizeof(*self
));
40 bool ok
= wegl_platform_init(&self
->wegl
, EGL_PLATFORM_SURFACELESS_MESA
);
44 self
->wegl
.egl_surface_type_mask
= EGL_PBUFFER_BIT
;
46 self
->wegl
.wcore
.vtbl
= &sl_platform_vtbl
;
47 return &self
->wegl
.wcore
;
50 sl_platform_destroy(&self
->wegl
.wcore
);
54 static union waffle_native_context
*
55 sl_context_get_native(struct wcore_context
*wc_ctx
)
57 struct sl_display
*dpy
= sl_display(wegl_display(wc_ctx
->display
));
58 struct wegl_context
*ctx
= wegl_context(wc_ctx
);
59 union waffle_native_context
*n_ctx
;
61 WCORE_CREATE_NATIVE_UNION(n_ctx
, surfaceless_egl
);
65 sl_display_fill_native(dpy
, &n_ctx
->surfaceless_egl
->display
);
66 n_ctx
->surfaceless_egl
->egl_context
= ctx
->egl
;
71 static const struct wcore_platform_vtbl sl_platform_vtbl
= {
72 .destroy
= sl_platform_destroy
,
74 .make_current
= wegl_make_current
,
75 .get_proc_address
= wegl_get_proc_address
,
77 .dl_can_open
= posix_platform_can_dlopen
,
78 .dl_sym
= posix_platform_dlsym
,
81 .connect
= sl_display_connect
,
82 .destroy
= sl_display_destroy
,
83 .supports_context_api
= wegl_display_supports_context_api
,
84 .get_native
= sl_display_get_native
,
88 .choose
= wegl_config_choose
,
89 .destroy
= wegl_config_destroy
,
90 .get_native
= sl_config_get_native
,
94 .create
= wegl_context_create
,
95 .destroy
= wegl_context_destroy
,
96 .get_native
= sl_context_get_native
,
100 .create
= sl_window_create
,
101 .destroy
= sl_window_destroy
,
102 .show
= sl_window_show
,
103 .resize
= sl_window_resize
,
104 .swap_buffers
= wegl_surface_swap_buffers
,
105 .get_native
= sl_window_get_native
,