renderers: Set buffer properties earlier

When we first see a buffer attached, we create a weston_buffer for it.
The weston_buffer doesn't contain any useful information in and of
itself; that's left to renderers to populate later.

Switch this to doing it in the core at the first opportunity, at least
for SHM and dmabuf buffers; EGL buffers will follow in the next commit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
dev
Daniel Stone 3 years ago
parent fec0400886
commit ca9bb01fe6
  1. 15
      libweston/compositor.c
  2. 4
      libweston/pixman-renderer.c
  3. 15
      libweston/renderer-gl/gl-renderer.c
  4. 4
      libweston/screenshooter.c

@ -2388,6 +2388,8 @@ WL_EXPORT struct weston_buffer *
weston_buffer_from_resource(struct wl_resource *resource)
{
struct weston_buffer *buffer;
struct wl_shm_buffer *shm;
struct linux_dmabuf_buffer *dmabuf;
struct wl_listener *listener;
listener = wl_resource_get_destroy_listener(resource,
@ -2404,9 +2406,20 @@ weston_buffer_from_resource(struct wl_resource *resource)
buffer->resource = resource;
wl_signal_init(&buffer->destroy_signal);
buffer->destroy_listener.notify = weston_buffer_destroy_handler;
buffer->y_inverted = 1;
wl_resource_add_destroy_listener(resource, &buffer->destroy_listener);
if ((shm = wl_shm_buffer_get(buffer->resource))) {
buffer->shm_buffer = shm;
buffer->width = wl_shm_buffer_get_width(shm);
buffer->height = wl_shm_buffer_get_height(shm);
buffer->y_inverted = true;
} else if ((dmabuf = linux_dmabuf_buffer_get(buffer->resource))) {
buffer->width = dmabuf->attributes.width;
buffer->height = dmabuf->attributes.height;
buffer->y_inverted =
!(dmabuf->attributes.flags & ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT);
}
return buffer;
}

@ -666,10 +666,6 @@ pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
es->is_opaque = pixel_format_is_opaque(pixel_info);
buffer->shm_buffer = shm_buffer;
buffer->width = wl_shm_buffer_get_width(shm_buffer);
buffer->height = wl_shm_buffer_get_height(shm_buffer);
ps->image = pixman_image_create_bits(pixel_info->pixman_format,
buffer->width, buffer->height,
wl_shm_buffer_get_data(shm_buffer),

@ -1965,10 +1965,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
int num_planes;
bool using_glesv2 = gr->gl_version < gr_gl_version(3, 0);
buffer->shm_buffer = shm_buffer;
buffer->width = wl_shm_buffer_get_width(shm_buffer);
buffer->height = wl_shm_buffer_get_height(shm_buffer);
num_planes = 1;
gs->offset[0] = 0;
gs->hsub[0] = 1;
@ -2820,17 +2816,6 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
GLenum target;
int i;
buffer->width = dmabuf->attributes.width;
buffer->height = dmabuf->attributes.height;
/*
* GL-renderer uses the OpenGL convention of texture coordinates, where
* the origin is at bottom-left. Because dmabuf buffers have the origin
* at top-left, we must invert the Y_INVERT flag to get the image right.
*/
buffer->y_inverted =
!(dmabuf->attributes.flags & ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT);
for (i = 0; i < gs->num_images; i++)
egl_image_unref(gs->images[i]);
gs->num_images = 0;

@ -186,10 +186,6 @@ weston_screenshooter_shoot(struct weston_output *output,
return -1;
}
buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);
buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);
buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);
if (buffer->width < output->current_mode->width ||
buffer->height < output->current_mode->height) {
done(data, WESTON_SCREENSHOOTER_BAD_BUFFER);

Loading…
Cancel
Save