mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-02 10:48:04 +02:00
gl-renderer: Replace display-create args with struct
gl_rendererer's output_create has a lot of arguments now. Add a structure for the options to make it more clear what is what. This is in preparation for adding bare-integer arguments which are ripe for confusion when passing positional arguments. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
f9a6162595
commit
c890c384c8
6 changed files with 65 additions and 56 deletions
|
|
@ -98,18 +98,19 @@ drm_backend_create_gl_renderer(struct drm_backend *b)
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -387,20 +387,19 @@ headless_destroy(struct weston_compositor *ec)
|
|||
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 = {
|
||||
|
|
|
|||
|
|
@ -2773,12 +2773,14 @@ wayland_backend_create(struct weston_compositor *compositor,
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -1794,20 +1794,20 @@ x11_destroy(struct weston_compositor *ec)
|
|||
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 = {
|
||||
|
|
|
|||
|
|
@ -3374,11 +3374,7 @@ gl_renderer_create_pbuffer_surface(struct gl_renderer *gr) {
|
|||
|
||||
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;
|
||||
|
||||
|
|
@ -3386,7 +3382,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
|
|||
if (gr == NULL)
|
||||
return -1;
|
||||
|
||||
gr->platform = platform;
|
||||
gr->platform = options->egl_platform;
|
||||
|
||||
if (gl_renderer_setup_egl_client_extensions(gr) < 0)
|
||||
goto fail;
|
||||
|
|
@ -3401,7 +3397,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
|
|||
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);
|
||||
|
|
@ -3412,13 +3408,16 @@ gl_renderer_display_create(struct weston_compositor *ec,
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -58,18 +58,30 @@ enum gl_renderer_border_side {
|
|||
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
|
||||
|
|
@ -96,11 +108,7 @@ struct gl_renderer_interface {
|
|||
* 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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue