shell: Explicitly use solid weston_buffers
Rather than punching through to set the surface as a solid colour, attach an actual weston_buffer to it instead. This becomes the first user of attaching non-client-generated buffers to a weston_surface. As a result, it is necessary to introduce a function which will allow compositors and shells to attach a buffer to a surface. weston_surface_attach_solid() is therefore introduced as a special-purpose helper which will attach a solid buffer to a weston_surface. It is not intended as a general-purpose mechanism to allow compositors to attach client-generated buffers to surfaces, as doing so would have unknown effects on this core part of the compositor itself. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
@@ -1776,6 +1776,11 @@ struct weston_buffer_reference *
|
|||||||
weston_buffer_create_solid_rgba(struct weston_compositor *compositor,
|
weston_buffer_create_solid_rgba(struct weston_compositor *compositor,
|
||||||
float r, float g, float b, float a);
|
float r, float g, float b, float a);
|
||||||
|
|
||||||
|
void
|
||||||
|
weston_surface_attach_solid(struct weston_surface *surface,
|
||||||
|
struct weston_buffer_reference *buffer_ref,
|
||||||
|
int w, int h);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref);
|
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref);
|
||||||
|
|
||||||
|
|||||||
+40
-15
@@ -2595,40 +2595,65 @@ weston_buffer_create_solid_rgba(struct weston_compositor *compositor,
|
|||||||
float r, float g, float b, float a)
|
float r, float g, float b, float a)
|
||||||
{
|
{
|
||||||
struct weston_buffer_reference *ret = zalloc(sizeof(*ret));
|
struct weston_buffer_reference *ret = zalloc(sizeof(*ret));
|
||||||
|
struct weston_buffer *buffer;
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret->buffer = zalloc(sizeof(*ret->buffer));
|
buffer = zalloc(sizeof(*buffer));
|
||||||
if (!ret->buffer) {
|
if (!buffer) {
|
||||||
free(ret);
|
free(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_signal_init(&ret->buffer->destroy_signal);
|
wl_signal_init(&buffer->destroy_signal);
|
||||||
ret->buffer->type = WESTON_BUFFER_SOLID;
|
buffer->type = WESTON_BUFFER_SOLID;
|
||||||
ret->buffer->width = 1;
|
buffer->width = 1;
|
||||||
ret->buffer->height = 1;
|
buffer->height = 1;
|
||||||
ret->buffer->buffer_origin = ORIGIN_TOP_LEFT;
|
buffer->buffer_origin = ORIGIN_TOP_LEFT;
|
||||||
ret->buffer->solid.r = r;
|
buffer->solid.r = r;
|
||||||
ret->buffer->solid.g = g;
|
buffer->solid.g = g;
|
||||||
ret->buffer->solid.b = b;
|
buffer->solid.b = b;
|
||||||
ret->buffer->solid.a = a;
|
buffer->solid.a = a;
|
||||||
|
|
||||||
if (a == 1.0) {
|
if (a == 1.0) {
|
||||||
ret->buffer->pixel_format =
|
buffer->pixel_format =
|
||||||
pixel_format_get_info_shm(WL_SHM_FORMAT_XRGB8888);
|
pixel_format_get_info_shm(WL_SHM_FORMAT_XRGB8888);
|
||||||
} else {
|
} else {
|
||||||
ret->buffer->pixel_format =
|
buffer->pixel_format =
|
||||||
pixel_format_get_info_shm(WL_SHM_FORMAT_ARGB8888);
|
pixel_format_get_info_shm(WL_SHM_FORMAT_ARGB8888);
|
||||||
}
|
}
|
||||||
ret->buffer->format_modifier = DRM_FORMAT_MOD_LINEAR;
|
buffer->format_modifier = DRM_FORMAT_MOD_LINEAR;
|
||||||
|
|
||||||
weston_buffer_reference(ret, ret->buffer, BUFFER_MAY_BE_ACCESSED);
|
weston_buffer_reference(ret, buffer, BUFFER_MAY_BE_ACCESSED);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
weston_surface_attach_solid(struct weston_surface *surface,
|
||||||
|
struct weston_buffer_reference *buffer_ref,
|
||||||
|
int w, int h)
|
||||||
|
{
|
||||||
|
struct weston_buffer *buffer = buffer_ref->buffer;
|
||||||
|
|
||||||
|
assert(buffer);
|
||||||
|
assert(buffer->type == WESTON_BUFFER_SOLID);
|
||||||
|
weston_buffer_reference(&surface->buffer_ref, buffer,
|
||||||
|
BUFFER_MAY_BE_ACCESSED);
|
||||||
|
surface->compositor->renderer->attach(surface, buffer);
|
||||||
|
|
||||||
|
weston_surface_set_size(surface, w, h);
|
||||||
|
|
||||||
|
pixman_region32_fini(&surface->opaque);
|
||||||
|
if (buffer->solid.a == 1.0) {
|
||||||
|
surface->is_opaque = true;
|
||||||
|
pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
|
||||||
|
} else {
|
||||||
|
pixman_region32_init(&surface->opaque);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref)
|
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref)
|
||||||
{
|
{
|
||||||
|
|||||||
+18
-14
@@ -144,6 +144,7 @@ weston_curtain_create(struct weston_compositor *compositor,
|
|||||||
{
|
{
|
||||||
struct weston_curtain *curtain;
|
struct weston_curtain *curtain;
|
||||||
struct weston_surface *surface = NULL;
|
struct weston_surface *surface = NULL;
|
||||||
|
struct weston_buffer_reference *buffer_ref;
|
||||||
struct weston_view *view;
|
struct weston_view *view;
|
||||||
|
|
||||||
curtain = zalloc(sizeof(*curtain));
|
curtain = zalloc(sizeof(*curtain));
|
||||||
@@ -158,22 +159,23 @@ weston_curtain_create(struct weston_compositor *compositor,
|
|||||||
if (view == NULL)
|
if (view == NULL)
|
||||||
goto err_surface;
|
goto err_surface;
|
||||||
|
|
||||||
|
buffer_ref = weston_buffer_create_solid_rgba(compositor,
|
||||||
|
params->r,
|
||||||
|
params->g,
|
||||||
|
params->b,
|
||||||
|
params->a);
|
||||||
|
if (buffer_ref == NULL)
|
||||||
|
goto err_view;
|
||||||
|
|
||||||
|
curtain->view = view;
|
||||||
|
curtain->buffer_ref = buffer_ref;
|
||||||
|
|
||||||
|
weston_surface_set_label_func(surface, params->get_label);
|
||||||
surface->committed = params->surface_committed;
|
surface->committed = params->surface_committed;
|
||||||
surface->committed_private = params->surface_private;
|
surface->committed_private = params->surface_private;
|
||||||
|
|
||||||
curtain->view = view;
|
weston_surface_attach_solid(surface, buffer_ref, params->width,
|
||||||
|
params->height);
|
||||||
weston_surface_set_color(surface,
|
|
||||||
params->r, params->g, params->b, params->a);
|
|
||||||
weston_surface_set_label_func(surface, params->get_label);
|
|
||||||
|
|
||||||
pixman_region32_fini(&surface->opaque);
|
|
||||||
if (params->a == 1.0) {
|
|
||||||
pixman_region32_init_rect(&surface->opaque, 0, 0,
|
|
||||||
params->width, params->height);
|
|
||||||
} else {
|
|
||||||
pixman_region32_init(&surface->opaque);
|
|
||||||
}
|
|
||||||
|
|
||||||
pixman_region32_fini(&surface->input);
|
pixman_region32_fini(&surface->input);
|
||||||
if (params->capture_input) {
|
if (params->capture_input) {
|
||||||
@@ -183,11 +185,12 @@ weston_curtain_create(struct weston_compositor *compositor,
|
|||||||
pixman_region32_init(&surface->input);
|
pixman_region32_init(&surface->input);
|
||||||
}
|
}
|
||||||
|
|
||||||
weston_surface_set_size(surface, params->width, params->height);
|
|
||||||
weston_view_set_position(view, params->x, params->y);
|
weston_view_set_position(view, params->x, params->y);
|
||||||
|
|
||||||
return curtain;
|
return curtain;
|
||||||
|
|
||||||
|
err_view:
|
||||||
|
weston_view_destroy(view);
|
||||||
err_surface:
|
err_surface:
|
||||||
weston_surface_destroy(surface);
|
weston_surface_destroy(surface);
|
||||||
err_curtain:
|
err_curtain:
|
||||||
@@ -204,5 +207,6 @@ weston_curtain_destroy(struct weston_curtain *curtain)
|
|||||||
|
|
||||||
weston_view_destroy(curtain->view);
|
weston_view_destroy(curtain->view);
|
||||||
weston_surface_destroy(surface);
|
weston_surface_destroy(surface);
|
||||||
|
weston_buffer_destroy_solid(curtain->buffer_ref);
|
||||||
free(curtain);
|
free(curtain);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ struct weston_curtain_params {
|
|||||||
|
|
||||||
struct weston_curtain {
|
struct weston_curtain {
|
||||||
struct weston_view *view;
|
struct weston_view *view;
|
||||||
|
struct weston_buffer_reference *buffer_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct weston_output *
|
struct weston_output *
|
||||||
|
|||||||
Reference in New Issue
Block a user