From 7886cbe4b90903510d2966453eddf77deac29765 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 26 Jul 2022 17:22:04 +0300 Subject: [PATCH] gl-renderer: pass initial output area explicitly This changes the GL-renderer interface to pass the initial framebuffer size and compositing area explicitly. All backends are changed to provide the correct parameters. GL-renderer mostly does not yet use these values, but later patches will. The pbuffer path uses it already, because they replaced the existing fields. All this is to make GL-renderer aware of the different sizes, so it can implement the future revision of the screenshooting API. Signed-off-by: Pekka Paalanen --- libweston/backend-drm/drm-gbm.c | 7 +++++++ libweston/backend-headless/headless.c | 9 +++++++-- libweston/backend-wayland/wayland.c | 19 +++++++++++++------ libweston/backend-x11/x11.c | 6 ++++++ libweston/renderer-gl/gl-renderer.c | 14 +++++++++----- libweston/renderer-gl/gl-renderer.h | 12 ++++++++---- 6 files changed, 50 insertions(+), 17 deletions(-) diff --git a/libweston/backend-drm/drm-gbm.c b/libweston/backend-drm/drm-gbm.c index c1a0993dc..4fcb080bc 100644 --- a/libweston/backend-drm/drm-gbm.c +++ b/libweston/backend-drm/drm-gbm.c @@ -236,6 +236,7 @@ create_gbm_surface(struct gbm_device *gbm, struct drm_output *output) int drm_output_init_egl(struct drm_output *output, struct drm_backend *b) { + const struct weston_mode *mode = output->base.current_mode; uint32_t format[2] = { output->gbm_format, fallback_format_for(output->gbm_format), @@ -243,6 +244,12 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b) struct gl_renderer_output_options options = { .drm_formats = format, .drm_formats_count = 1, + .area.x = 0, + .area.y = 0, + .area.width = mode->width, + .area.height = mode->height, + .fb_size.width = mode->width, + .fb_size.height = mode->height, }; assert(output->gbm_surface == NULL); diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index c62d5d95b..0ec603ac1 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -214,11 +214,16 @@ headless_output_enable_gl(struct headless_output *output) { struct weston_compositor *compositor = output->base.compositor; struct headless_backend *b = to_headless_backend(compositor); + const struct weston_mode *mode = output->base.current_mode; const struct gl_renderer_pbuffer_options options = { - .width = output->base.current_mode->width, - .height = output->base.current_mode->height, .drm_formats = headless_formats, .drm_formats_count = ARRAY_LENGTH(headless_formats), + .area.x = 0, + .area.y = 0, + .area.width = mode->width, + .area.height = mode->height, + .fb_size.width = mode->width, + .fb_size.height = mode->height, }; if (b->glri->output_pbuffer_create(&output->base, &options) < 0) { diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index edf618284..fa22d0d97 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -783,23 +783,30 @@ wayland_output_destroy(struct weston_output *base) static int wayland_output_init_gl_renderer(struct wayland_output *output) { - int32_t fwidth = 0, fheight = 0; + const struct weston_mode *mode = output->base.current_mode; 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); - fheight = frame_height(output->frame); + frame_interior(output->frame, &options.area.x, &options.area.y, + &options.area.width, &options.area.height); + options.fb_size.width = frame_width(output->frame); + options.fb_size.height = frame_height(output->frame); } else { - fwidth = output->base.current_mode->width; - fheight = output->base.current_mode->height; + options.area.x = 0; + options.area.y = 0; + options.area.width = mode->width; + options.area.height = mode->height; + options.fb_size.width = mode->width; + options.fb_size.height = mode->height; } output->gl.egl_window = wl_egl_window_create(output->parent.surface, - fwidth, fheight); + options.fb_size.width, + options.fb_size.height); if (!output->gl.egl_window) { weston_log("failure to create wl_egl_window\n"); return -1; diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index f29b78f74..d02ee3ca8 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -1065,6 +1065,12 @@ x11_output_enable(struct weston_output *base) .window_for_platform = &xid, .drm_formats = x11_formats, .drm_formats_count = ARRAY_LENGTH(x11_formats), + .area.x = 0, + .area.y = 0, + .area.width = mode->width, + .area.height = mode->height, + .fb_size.width = mode->width, + .fb_size.height = mode->height, }; ret = gl_renderer->output_window_create(&output->base, diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 144525b7a..1802b1423 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -3304,7 +3304,9 @@ gl_renderer_create_window_surface(struct gl_renderer *gr, static int gl_renderer_output_create(struct weston_output *output, - EGLSurface surface) + EGLSurface surface, + const struct weston_size *fb_size, + const struct weston_geometry *area) { struct gl_output_state *go; struct gl_renderer *gr = get_renderer(output->compositor); @@ -3372,7 +3374,8 @@ gl_renderer_output_window_create(struct weston_output *output, return -1; } - ret = gl_renderer_output_create(output, egl_surface); + ret = gl_renderer_output_create(output, egl_surface, + &options->fb_size, &options->area); if (ret < 0) weston_platform_destroy_egl_surface(gr->egl_display, egl_surface); @@ -3390,8 +3393,8 @@ gl_renderer_output_pbuffer_create(struct weston_output *output, EGLint value = 0; int ret; EGLint pbuffer_attribs[] = { - EGL_WIDTH, options->width, - EGL_HEIGHT, options->height, + EGL_WIDTH, options->fb_size.width, + EGL_HEIGHT, options->fb_size.height, EGL_NONE }; @@ -3422,7 +3425,8 @@ gl_renderer_output_pbuffer_create(struct weston_output *output, " Continuing anyway.\n", value); } - ret = gl_renderer_output_create(output, egl_surface); + ret = gl_renderer_output_create(output, egl_surface, + &options->fb_size, &options->area); if (ret < 0) { eglDestroySurface(gr->egl_display, egl_surface); } else { diff --git a/libweston/renderer-gl/gl-renderer.h b/libweston/renderer-gl/gl-renderer.h index 1430bb14e..c1a2d1172 100644 --- a/libweston/renderer-gl/gl-renderer.h +++ b/libweston/renderer-gl/gl-renderer.h @@ -81,6 +81,10 @@ struct gl_renderer_output_options { EGLNativeWindowType window_for_legacy; /** Native window handle for \c eglCreatePlatformWindowSurface */ void *window_for_platform; + /** Size of the framebuffer in pixels, including borders */ + struct weston_size fb_size; + /** Area inside the framebuffer in pixels for composited content */ + struct weston_geometry area; /** Array of DRM pixel formats acceptable for the window */ const uint32_t *drm_formats; /** The \c drm_formats array length */ @@ -88,10 +92,10 @@ struct gl_renderer_output_options { }; struct gl_renderer_pbuffer_options { - /** Width of the rendering surface in pixels */ - int width; - /** Height of the rendering surface in pixels */ - int height; + /** Size of the framebuffer in pixels, including borders */ + struct weston_size fb_size; + /** Area inside the framebuffer in pixels for composited content */ + struct weston_geometry area; /** Array of DRM pixel formats acceptable for the pbuffer */ const uint32_t *drm_formats; /** The \c drm_formats array length */