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 <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2022-07-26 17:22:04 +03:00 committed by Pekka Paalanen
parent 84b5d0eb4b
commit 7886cbe4b9
6 changed files with 50 additions and 17 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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;

View file

@ -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,

View file

@ -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 {

View file

@ -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 */