weston_buffer: Add solid buffer type

Currently solid-colour displays (e.g. the background for fullscreen
views) is implemented by a special-case weston_surface which has no
buffer attached, with a special punch-through renderer callback to set
the colour.

Replace this with a weston_buffer type explicitly specifying the solid
colour, which helps us eliminate yet more special cases in renderers and
backends.

This is not handled yet in any renderer or backend, however it is also
not used by anything yet. Following commits add support to the renderers
and backends.

Signed-off-by: Daniel Stone <daniels@collabora.com>
dev
Daniel Stone 3 years ago
parent 7a27f6cbe4
commit 43715ff0c0
  1. 11
      include/libweston/libweston.h
  2. 56
      libweston/compositor.c

@ -1181,12 +1181,16 @@ struct weston_buffer {
WESTON_BUFFER_SHM,
WESTON_BUFFER_DMABUF,
WESTON_BUFFER_RENDERER_OPAQUE,
WESTON_BUFFER_SOLID,
} type;
union {
struct wl_shm_buffer *shm_buffer;
void *dmabuf;
void *legacy_buffer;
struct {
float r, g, b, a;
} solid;
};
int32_t width, height;
@ -1768,6 +1772,13 @@ weston_surface_create(struct weston_compositor *compositor);
struct weston_view *
weston_view_create(struct weston_surface *surface);
struct weston_buffer_reference *
weston_buffer_create_solid_rgba(struct weston_compositor *compositor,
float r, float g, float b, float a);
void
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref);
void
weston_view_destroy(struct weston_view *view);

@ -2590,6 +2590,56 @@ weston_buffer_release_move(struct weston_buffer_release_reference *dest,
weston_buffer_release_reference(src, NULL);
}
WL_EXPORT struct weston_buffer_reference *
weston_buffer_create_solid_rgba(struct weston_compositor *compositor,
float r, float g, float b, float a)
{
struct weston_buffer_reference *ret = zalloc(sizeof(*ret));
if (!ret)
return NULL;
ret->buffer = zalloc(sizeof(*ret->buffer));
if (!ret->buffer) {
free(ret);
return NULL;
}
wl_signal_init(&ret->buffer->destroy_signal);
ret->buffer->type = WESTON_BUFFER_SOLID;
ret->buffer->width = 1;
ret->buffer->height = 1;
ret->buffer->buffer_origin = ORIGIN_TOP_LEFT;
ret->buffer->solid.r = r;
ret->buffer->solid.g = g;
ret->buffer->solid.b = b;
ret->buffer->solid.a = a;
if (a == 1.0) {
ret->buffer->pixel_format =
pixel_format_get_info_shm(WL_SHM_FORMAT_XRGB8888);
} else {
ret->buffer->pixel_format =
pixel_format_get_info_shm(WL_SHM_FORMAT_ARGB8888);
}
ret->buffer->format_modifier = DRM_FORMAT_MOD_LINEAR;
weston_buffer_reference(ret, ret->buffer, BUFFER_MAY_BE_ACCESSED);
return ret;
}
WL_EXPORT void
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref)
{
assert(buffer_ref);
assert(buffer_ref->buffer);
assert(buffer_ref->type == BUFFER_MAY_BE_ACCESSED);
assert(buffer_ref->buffer->type == WESTON_BUFFER_SOLID);
weston_buffer_reference(buffer_ref, NULL, BUFFER_WILL_NOT_BE_ACCESSED);
free(buffer_ref);
}
static void
weston_surface_attach(struct weston_surface *surface,
struct weston_buffer *buffer)
@ -7543,6 +7593,12 @@ debug_scene_view_print_buffer(FILE *fp, struct weston_view *view)
case WESTON_BUFFER_DMABUF:
fprintf(fp, "\t\tdmabuf buffer\n");
break;
case WESTON_BUFFER_SOLID:
fprintf(fp, "\t\tsolid-colour buffer\n");
fprintf(fp, "\t\t\t[R %f, G %f, B %f, A %f]\n",
buffer->solid.r, buffer->solid.g, buffer->solid.b,
buffer->solid.a);
break;
case WESTON_BUFFER_RENDERER_OPAQUE:
fprintf(fp, "\t\tEGL buffer:\n");
fprintf(fp, "\t\t\t[format may be inaccurate]\n");

Loading…
Cancel
Save