summaryrefslogtreecommitdiff
path: root/libweston
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2020-03-06 13:04:18 +0000
committerPekka Paalanen <pq@iki.fi>2020-03-20 15:25:24 +0000
commitdb6e6e1ec5e665cc45809cbce47b62edac9a2834 (patch)
treed37346fce800d929c3442e62bb39d3bccdffb410 /libweston
parentc890c384c82111d49dacfcc886b89adf9819844f (diff)
downloadweston-db6e6e1ec5e665cc45809cbce47b62edac9a2834.tar.gz
gl-renderer: Replace window-create args with struct
gl_rendererer's output_window_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>
Diffstat (limited to 'libweston')
-rw-r--r--libweston/backend-drm/drm-gbm.c17
-rw-r--r--libweston/backend-wayland/wayland.c12
-rw-r--r--libweston/backend-x11/x11.c26
-rw-r--r--libweston/renderer-gl/gl-renderer.c13
-rw-r--r--libweston/renderer-gl/gl-renderer.h23
5 files changed, 49 insertions, 42 deletions
diff --git a/libweston/backend-drm/drm-gbm.c b/libweston/backend-drm/drm-gbm.c
index e06372f1..4b83e994 100644
--- a/libweston/backend-drm/drm-gbm.c
+++ b/libweston/backend-drm/drm-gbm.c
@@ -185,7 +185,10 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
output->gbm_format,
fallback_format_for(output->gbm_format),
};
- unsigned n_formats = 1;
+ struct gl_renderer_output_options options = {
+ .drm_formats = format,
+ .drm_formats_count = 1,
+ };
struct weston_mode *mode = output->base.current_mode;
struct drm_plane *plane = output->scanout_plane;
unsigned int i;
@@ -231,13 +234,11 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
return -1;
}
- if (format[1])
- n_formats = 2;
- if (gl_renderer->output_window_create(&output->base,
- (EGLNativeWindowType)output->gbm_surface,
- output->gbm_surface,
- format,
- n_formats) < 0) {
+ if (options.drm_formats[1])
+ options.drm_formats_count = 2;
+ options.window_for_legacy = (EGLNativeWindowType) output->gbm_surface;
+ options.window_for_platform = output->gbm_surface;
+ if (gl_renderer->output_window_create(&output->base, &options) < 0) {
weston_log("failed to create gl renderer output state\n");
gbm_surface_destroy(output->gbm_surface);
output->gbm_surface = NULL;
diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c
index d638fe95..0224865c 100644
--- a/libweston/backend-wayland/wayland.c
+++ b/libweston/backend-wayland/wayland.c
@@ -762,6 +762,10 @@ static int
wayland_output_init_gl_renderer(struct wayland_output *output)
{
int32_t fwidth = 0, fheight = 0;
+ struct gl_renderer_output_options options = {
+ .drm_formats = wayland_formats,
+ .drm_formats_count = ARRAY_LENGTH(wayland_formats),
+ };
if (output->frame) {
fwidth = frame_width(output->frame);
@@ -778,12 +782,10 @@ wayland_output_init_gl_renderer(struct wayland_output *output)
weston_log("failure to create wl_egl_window\n");
return -1;
}
+ options.window_for_legacy = output->gl.egl_window;
+ options.window_for_platform = output->gl.egl_window;
- if (gl_renderer->output_window_create(&output->base,
- output->gl.egl_window,
- output->gl.egl_window,
- wayland_formats,
- ARRAY_LENGTH(wayland_formats)) < 0)
+ if (gl_renderer->output_window_create(&output->base, &options) < 0)
goto cleanup_window;
return 0;
diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c
index 23d501f0..dad0849f 100644
--- a/libweston/backend-x11/x11.c
+++ b/libweston/backend-x11/x11.c
@@ -854,14 +854,16 @@ x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode)
}
} else {
Window xid = (Window) output->window;
+ const struct gl_renderer_output_options options = {
+ .window_for_legacy = (EGLNativeWindowType) output->window,
+ .window_for_platform = &xid,
+ .drm_formats = x11_formats,
+ .drm_formats_count = ARRAY_LENGTH(x11_formats),
+ };
gl_renderer->output_destroy(&output->base);
- ret = gl_renderer->output_window_create(&output->base,
- (EGLNativeWindowType) output->window,
- &xid,
- x11_formats,
- ARRAY_LENGTH(x11_formats));
+ ret = gl_renderer->output_window_create(&output->base, &options);
if (ret < 0)
return -1;
}
@@ -1030,13 +1032,15 @@ x11_output_enable(struct weston_output *base)
/* eglCreatePlatformWindowSurfaceEXT takes a Window*
* but eglCreateWindowSurface takes a Window. */
Window xid = (Window) output->window;
+ const struct gl_renderer_output_options options = {
+ .window_for_legacy = (EGLNativeWindowType) output->window,
+ .window_for_platform = &xid,
+ .drm_formats = x11_formats,
+ .drm_formats_count = ARRAY_LENGTH(x11_formats),
+ };
- ret = gl_renderer->output_window_create(
- &output->base,
- (EGLNativeWindowType) output->window,
- &xid,
- x11_formats,
- ARRAY_LENGTH(x11_formats));
+ ret = gl_renderer->output_window_create(&output->base,
+ &options);
if (ret < 0)
goto err;
diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
index 3a000e51..3c69d779 100644
--- a/libweston/renderer-gl/gl-renderer.c
+++ b/libweston/renderer-gl/gl-renderer.c
@@ -3172,10 +3172,7 @@ gl_renderer_output_create(struct weston_output *output,
static int
gl_renderer_output_window_create(struct weston_output *output,
- EGLNativeWindowType window_for_legacy,
- void *window_for_platform,
- const uint32_t *drm_formats,
- unsigned drm_formats_count)
+ const struct gl_renderer_output_options *options)
{
struct weston_compositor *ec = output->compositor;
struct gl_renderer *gr = get_renderer(ec);
@@ -3183,10 +3180,10 @@ gl_renderer_output_window_create(struct weston_output *output,
int ret = 0;
egl_surface = gl_renderer_create_window_surface(gr,
- window_for_legacy,
- window_for_platform,
- drm_formats,
- drm_formats_count);
+ options->window_for_legacy,
+ options->window_for_platform,
+ options->drm_formats,
+ options->drm_formats_count);
if (egl_surface == EGL_NO_SURFACE) {
weston_log("failed to create egl surface\n");
return -1;
diff --git a/libweston/renderer-gl/gl-renderer.h b/libweston/renderer-gl/gl-renderer.h
index e1d35d41..434e8dc2 100644
--- a/libweston/renderer-gl/gl-renderer.h
+++ b/libweston/renderer-gl/gl-renderer.h
@@ -76,6 +76,17 @@ struct gl_renderer_display_options {
unsigned drm_formats_count;
};
+struct gl_renderer_output_options {
+ /** Native window handle for \c eglCreateWindowSurface */
+ EGLNativeWindowType window_for_legacy;
+ /** Native window handle for \c eglCreatePlatformWindowSurface */
+ void *window_for_platform;
+ /** Array of DRM pixel formats acceptable for the window */
+ 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
@@ -114,12 +125,7 @@ struct gl_renderer_interface {
* Attach GL-renderer to the output with a native window
*
* \param output The output to create a rendering surface for.
- * \param window_for_legacy Native window handle for
- * eglCreateWindowSurface().
- * \param window_for_platform Native window handle for
- * eglCreatePlatformWindowSurface().
- * \param drm_formats Array of DRM pixel formats that are acceptable.
- * \param drm_formats_count The drm_formats array length.
+ * \param options The options struct describing output configuration
* \return 0 on success, -1 on failure.
*
* This function creates the renderer data structures needed to repaint
@@ -138,10 +144,7 @@ struct gl_renderer_interface {
* with \c EGL_WINDOW_BIT in \c egl_surface_type.
*/
int (*output_window_create)(struct weston_output *output,
- EGLNativeWindowType window_for_legacy,
- void *window_for_platform,
- const uint32_t *drm_formats,
- unsigned drm_formats_count);
+ const struct gl_renderer_output_options *options);
/**
* Attach GL-renderer to the output with internal pixel storage