fallback_format_for(b->gbm_format),
0,
};
- unsigned n_formats = 2;
+ struct gl_renderer_display_options options = {
+ .egl_platform = EGL_PLATFORM_GBM_KHR,
+ .egl_native_display = b->gbm,
+ .egl_surface_type = EGL_WINDOW_BIT,
+ .drm_formats = format,
+ .drm_formats_count = 2,
+ };
if (format[1])
- n_formats = 3;
- if (gl_renderer->display_create(b->compositor,
- EGL_PLATFORM_GBM_KHR,
- (void *)b->gbm,
- EGL_WINDOW_BIT,
- format,
- n_formats) < 0) {
+ options.drm_formats_count = 3;
+
+ if (gl_renderer->display_create(b->compositor, &options) < 0)
return -1;
- }
return 0;
}
static int
headless_gl_renderer_init(struct headless_backend *b)
{
+ const struct gl_renderer_display_options options = {
+ .egl_platform = EGL_PLATFORM_SURFACELESS_MESA,
+ .egl_native_display = EGL_DEFAULT_DISPLAY,
+ .egl_surface_type = EGL_PBUFFER_BIT,
+ .drm_formats = headless_formats,
+ .drm_formats_count = ARRAY_LENGTH(headless_formats),
+ };
+
b->glri = weston_load_module("gl-renderer.so", "gl_renderer_interface");
if (!b->glri)
return -1;
- if (b->glri->display_create(b->compositor,
- EGL_PLATFORM_SURFACELESS_MESA,
- EGL_DEFAULT_DISPLAY,
- EGL_PBUFFER_BIT,
- headless_formats,
- ARRAY_LENGTH(headless_formats)) < 0) {
- return -1;
- }
-
- return 0;
+ return b->glri->display_create(b->compositor, &options);
}
static const struct weston_windowed_output_api api = {
}
if (!b->use_pixman) {
- if (gl_renderer->display_create(compositor,
- EGL_PLATFORM_WAYLAND_KHR,
- b->parent.wl_display,
- EGL_WINDOW_BIT,
- wayland_formats,
- ARRAY_LENGTH(wayland_formats)) < 0) {
+ const struct gl_renderer_display_options options = {
+ .egl_platform = EGL_PLATFORM_WAYLAND_KHR,
+ .egl_native_display = b->parent.wl_display,
+ .egl_surface_type = EGL_WINDOW_BIT,
+ .drm_formats = wayland_formats,
+ .drm_formats_count = ARRAY_LENGTH(wayland_formats),
+ };
+ if (gl_renderer->display_create(compositor, &options) < 0) {
weston_log("Failed to initialize the GL renderer; "
"falling back to pixman.\n");
b->use_pixman = true;
static int
init_gl_renderer(struct x11_backend *b)
{
- int ret;
+ const struct gl_renderer_display_options options = {
+ .egl_platform = EGL_PLATFORM_X11_KHR,
+ .egl_native_display = b->dpy,
+ .egl_surface_type = EGL_WINDOW_BIT,
+ .drm_formats = x11_formats,
+ .drm_formats_count = ARRAY_LENGTH(x11_formats),
+ };
gl_renderer = weston_load_module("gl-renderer.so",
"gl_renderer_interface");
if (!gl_renderer)
return -1;
- ret = gl_renderer->display_create(b->compositor, EGL_PLATFORM_X11_KHR,
- (void *) b->dpy,
- EGL_WINDOW_BIT,
- x11_formats,
- ARRAY_LENGTH(x11_formats));
-
- return ret;
+ return gl_renderer->display_create(b->compositor, &options);
}
static const struct weston_windowed_output_api api = {
static int
gl_renderer_display_create(struct weston_compositor *ec,
- EGLenum platform,
- void *native_display,
- EGLint egl_surface_type,
- const uint32_t *drm_formats,
- unsigned drm_formats_count)
+ const struct gl_renderer_display_options *options)
{
struct gl_renderer *gr;
if (gr == NULL)
return -1;
- gr->platform = platform;
+ gr->platform = options->egl_platform;
if (gl_renderer_setup_egl_client_extensions(gr) < 0)
goto fail;
gl_renderer_surface_get_content_size;
gr->base.surface_copy_content = gl_renderer_surface_copy_content;
- if (gl_renderer_setup_egl_display(gr, native_display) < 0)
+ if (gl_renderer_setup_egl_display(gr, options->egl_native_display) < 0)
goto fail;
log_egl_info(gr->egl_display);
goto fail_with_error;
if (!gr->has_configless_context) {
+ EGLint egl_surface_type = options->egl_surface_type;
+
if (!gr->has_surfaceless_context)
egl_surface_type |= EGL_PBUFFER_BIT;
- gr->egl_config = gl_renderer_get_egl_config(gr,
- egl_surface_type,
- drm_formats,
- drm_formats_count);
+ gr->egl_config =
+ gl_renderer_get_egl_config(gr,
+ egl_surface_type,
+ options->drm_formats,
+ options->drm_formats_count);
if (gr->egl_config == EGL_NO_CONFIG_KHR) {
weston_log("failed to choose EGL config\n");
goto fail_terminate;
GL_RENDERER_BORDER_BOTTOM = 3,
};
+/**
+ * Options passed to the \c display_create method of the GL renderer interface.
+ *
+ * \see struct gl_renderer_interface
+ */
+struct gl_renderer_display_options {
+ /** The EGL platform identifier */
+ EGLenum egl_platform;
+ /** The native display corresponding to the given EGL platform */
+ void *egl_native_display;
+ /** EGL_SURFACE_TYPE bits for the base EGLConfig */
+ EGLint egl_surface_type;
+ /** Array of DRM pixel formats acceptable for the base EGLConfig */
+ const uint32_t *drm_formats;
+ /** The \c drm_formats array length */
+ unsigned drm_formats_count;
+};
+
struct gl_renderer_interface {
/**
* Initialize GL-renderer with the given EGL platform and native display
*
* \param ec The weston_compositor where to initialize.
- * \param platform The EGL platform identifier.
- * \param native_display The native display corresponding to the given
- * EGL platform.
- * \param egl_surface_type EGL_SURFACE_TYPE bits for the base EGLConfig.
- * \param drm_formats Array of DRM pixel formats that are acceptable
- * for the base EGLConfig.
- * \param drm_formats_count The drm_formats array length.
+ * \param options The options struct describing display configuration
* \return 0 on success, -1 on failure.
*
* This function creates an EGLDisplay and initializes it. It also
* DRM format.
*/
int (*display_create)(struct weston_compositor *ec,
- EGLenum platform,
- void *native_display,
- EGLint egl_surface_type,
- const uint32_t *drm_formats,
- unsigned drm_formats_count);
+ const struct gl_renderer_display_options *options);
/**
* Attach GL-renderer to the output with a native window