From 8544a4d09bdc0bb601e785b84cac80f9652f4606 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 19 Jan 2022 17:59:50 +0000 Subject: [PATCH] weston_buffer: Move direct_display out of gl-renderer Just make it a generic buffer attribute, not hidden away in GL. Signed-off-by: Daniel Stone --- include/libweston/libweston.h | 2 ++ libweston/compositor.c | 4 ++++ libweston/renderer-gl/gl-renderer.c | 18 ++++++------------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 65c58428..f529ee22 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1219,6 +1219,8 @@ struct weston_buffer { ORIGIN_TOP_LEFT, /* buffer content starts at (0,0) */ ORIGIN_BOTTOM_LEFT, /* buffer content starts at (0, height) */ } buffer_origin; + bool direct_display; + void *backend_private; const struct pixel_format_info *pixel_format; diff --git a/libweston/compositor.c b/libweston/compositor.c index a9f043ba..b37a93bd 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2444,6 +2444,7 @@ weston_buffer_from_resource(struct weston_compositor *ec, } else if ((dmabuf = linux_dmabuf_buffer_get(buffer->resource))) { buffer->type = WESTON_BUFFER_DMABUF; buffer->dmabuf = dmabuf; + buffer->direct_display = dmabuf->direct_display; buffer->width = dmabuf->attributes.width; buffer->height = dmabuf->attributes.height; buffer->pixel_format = @@ -7729,6 +7730,9 @@ debug_scene_view_print_buffer(FILE *fp, struct weston_view *view) buffer->width, buffer->height); if (buffer->buffer_origin == ORIGIN_BOTTOM_LEFT) fprintf(fp, "\t\t\tbottom-left origin\n"); + + if (buffer->direct_display) + fprintf(fp, "\t\t\tdirect-display buffer (no renderer access)\n"); } static void diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index eae23efd..8272ce88 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -176,8 +176,6 @@ struct gl_buffer_state { int num_images; enum gl_shader_texture_variant shader_variant; - bool direct_display; - /* Extension needed for SHM YUV texture */ int offset[3]; /* offset per plane */ int hsub[3]; /* horizontal subsampling per plane */ @@ -964,7 +962,7 @@ maybe_censor_override(struct gl_shader_config *sconf, struct weston_view *ev) { struct gl_surface_state *gs = get_surface_state(ev->surface); - struct gl_buffer_state *gb = &gs->buffer; + struct weston_buffer *buffer = gs->buffer_ref.buffer; bool recording_censor = (output->disable_planes > 0) && (ev->surface->desired_protection > WESTON_HDCP_DISABLE); @@ -972,7 +970,7 @@ maybe_censor_override(struct gl_shader_config *sconf, bool unprotected_censor = (ev->surface->desired_protection > output->current_protection); - if (gb->direct_display) { + if (buffer->direct_display) { censor_override(sconf, output); return; } @@ -1042,6 +1040,7 @@ draw_paint_node(struct weston_paint_node *pnode, struct gl_renderer *gr = get_renderer(pnode->surface->compositor); struct gl_surface_state *gs = get_surface_state(pnode->surface); struct gl_buffer_state *gb = &gs->buffer; + struct weston_buffer *buffer = gs->buffer_ref.buffer; /* repaint bounding region in global coordinates: */ pixman_region32_t repaint; /* opaque region in surface coordinates: */ @@ -1054,7 +1053,8 @@ draw_paint_node(struct weston_paint_node *pnode, /* In case of a runtime switch of renderers, we may not have received * an attach for this surface since the switch. In that case we don't * have a valid buffer or a proper shader set up so skip rendering. */ - if (gb->shader_variant == SHADER_VARIANT_NONE && !gb->direct_display) + if (gb->shader_variant == SHADER_VARIANT_NONE && + !buffer->direct_display) return; pixman_region32_init(&repaint); @@ -2164,7 +2164,6 @@ unsupported: gb->gl_format[2] = gl_format[2]; gb->gl_pixel_type = gl_pixel_type; gb->needs_full_upload = true; - gb->direct_display = false; gs->surface = es; @@ -2888,9 +2887,7 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface, egl_image_unref(gb->images[i]); gb->num_images = 0; - gb->direct_display = dmabuf->direct_display; - - if (dmabuf->direct_display) + if (buffer->direct_display) return true; image = linux_dmabuf_buffer_get_user_data(dmabuf); @@ -3050,7 +3047,6 @@ out: gb->num_images = 0; glDeleteTextures(gs->num_textures, gs->textures); gs->num_textures = 0; - gb->direct_display = false; } static uint32_t @@ -3252,8 +3248,6 @@ gl_renderer_create_surface(struct weston_surface *surface) * they still go through texcoord computations. Do not divide * by zero there. */ - gb->direct_display = false; - gs->surface = surface; pixman_region32_init(&gb->texture_damage);