pixman-renderer: add pixman_renderer_interface

Add a struct pixman_renderer_interface with output_create and
output_destroy vfuncs and store a pointer to it in struct
weston_renderer.

Make all backends access the pixman_renderer_output_create/destroy
functions through this interface and turn them static.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
This commit is contained in:
Philipp Zabel 2023-01-11 21:28:52 +01:00 committed by Daniel Stone
parent e3b64b6e76
commit 32c7629516
9 changed files with 41 additions and 21 deletions

View file

@ -1179,6 +1179,7 @@ make_connector_name(const drmModeConnector *con)
static int
drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
{
struct weston_renderer *renderer = output->base.compositor->renderer;
struct drm_device *device = output->device;
int w = output->base.current_mode->width;
int h = output->base.current_mode->height;
@ -1216,7 +1217,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
goto err;
}
if (pixman_renderer_output_create(&output->base, &options) < 0)
if (renderer->pixman->output_create(&output->base, &options) < 0)
goto err;
weston_log("DRM: output %s %s shadow framebuffer.\n", output->base.name,
@ -1244,6 +1245,7 @@ err:
static void
drm_output_fini_pixman(struct drm_output *output)
{
struct weston_renderer *renderer = output->base.compositor->renderer;
struct drm_backend *b = output->backend;
unsigned int i;
@ -1255,7 +1257,7 @@ drm_output_fini_pixman(struct drm_output *output)
drm_plane_reset_state(output->scanout_plane);
}
pixman_renderer_output_destroy(&output->base);
renderer->pixman->output_destroy(&output->base);
pixman_region32_fini(&output->previous_damage);
for (i = 0; i < ARRAY_LENGTH(output->dumb); i++) {

View file

@ -188,7 +188,9 @@ headless_output_disable_gl(struct headless_output *output)
static void
headless_output_disable_pixman(struct headless_output *output)
{
pixman_renderer_output_destroy(&output->base);
struct weston_renderer *renderer = output->base.compositor->renderer;
renderer->pixman->output_destroy(&output->base);
pixman_image_unref(output->image);
}
@ -289,6 +291,7 @@ headless_output_enable_gl(struct headless_output *output)
static int
headless_output_enable_pixman(struct headless_output *output)
{
const struct pixman_renderer_interface *pixman;
const struct pixel_format_info *pfmt;
const struct pixman_renderer_output_options options = {
.use_shadow = true,
@ -298,6 +301,7 @@ headless_output_enable_pixman(struct headless_output *output)
},
};
pixman = output->base.compositor->renderer->pixman;
pfmt = pixel_format_get_info(headless_formats[0]);
output->image =
@ -308,7 +312,7 @@ headless_output_enable_pixman(struct headless_output *output)
if (!output->image)
return -1;
if (pixman_renderer_output_create(&output->base, &options) < 0)
if (pixman->output_create(&output->base, &options) < 0)
goto err_renderer;
pixman_renderer_output_set_buffer(&output->base, output->image);

View file

@ -457,6 +457,7 @@ rdp_head_get_monitor(struct weston_head *base,
static int
rdp_output_enable(struct weston_output *base)
{
struct weston_renderer *renderer = base->compositor->renderer;
struct rdp_output *output = to_rdp_output(base);
struct rdp_backend *b;
struct wl_event_loop *loop;
@ -481,7 +482,7 @@ rdp_output_enable(struct weston_output *base)
return -1;
}
if (pixman_renderer_output_create(&output->base, &options) < 0) {
if (renderer->pixman->output_create(&output->base, &options) < 0) {
pixman_image_unref(output->shadow_surface);
return -1;
}
@ -495,6 +496,7 @@ rdp_output_enable(struct weston_output *base)
static int
rdp_output_disable(struct weston_output *base)
{
struct weston_renderer *renderer = base->compositor->renderer;
struct rdp_output *output = to_rdp_output(base);
assert(output);
@ -503,7 +505,7 @@ rdp_output_disable(struct weston_output *base)
return 0;
pixman_image_unref(output->shadow_surface);
pixman_renderer_output_destroy(&output->base);
renderer->pixman->output_destroy(&output->base);
wl_event_source_remove(output->finish_frame_timer);

View file

@ -600,6 +600,7 @@ finish_frame_handler(void *data)
static int
vnc_output_enable(struct weston_output *base)
{
struct weston_renderer *renderer = base->compositor->renderer;
struct vnc_output *output = to_vnc_output(base);
struct vnc_backend *backend;
struct wl_event_loop *loop;
@ -616,7 +617,7 @@ vnc_output_enable(struct weston_output *base)
backend = output->backend;
backend->output = output;
if (pixman_renderer_output_create(&output->base, &options) < 0)
if (renderer->pixman->output_create(&output->base, &options) < 0)
return -1;
loop = wl_display_get_event_loop(backend->compositor->wl_display);
@ -647,6 +648,7 @@ vnc_output_enable(struct weston_output *base)
static int
vnc_output_disable(struct weston_output *base)
{
struct weston_renderer *renderer = base->compositor->renderer;
struct vnc_output *output = to_vnc_output(base);
struct vnc_backend *backend;
@ -657,7 +659,7 @@ vnc_output_disable(struct weston_output *base)
if (!output->base.enabled)
return 0;
pixman_renderer_output_destroy(&output->base);
renderer->pixman->output_destroy(&output->base);
nvnc_display_unref(output->display);
nvnc_fb_pool_unref(output->fb_pool);

View file

@ -671,7 +671,7 @@ wayland_output_disable(struct weston_output *base)
return 0;
if (renderer->type == WESTON_RENDERER_PIXMAN) {
pixman_renderer_output_destroy(&output->base);
renderer->pixman->output_destroy(&output->base);
#ifdef ENABLE_EGL
} else {
weston_gl_borders_fini(&output->gl.borders, &output->base);
@ -761,6 +761,7 @@ cleanup_window:
static int
wayland_output_init_pixman_renderer(struct wayland_output *output)
{
struct weston_renderer *renderer = output->base.compositor->renderer;
const struct pixman_renderer_output_options options = {
.use_shadow = true,
.fb_size = {
@ -768,7 +769,7 @@ wayland_output_init_pixman_renderer(struct wayland_output *output)
.height = output->base.current_mode->height
},
};
return pixman_renderer_output_create(&output->base, &options);
return renderer->pixman->output_create(&output->base, &options);
}
static void
@ -996,6 +997,7 @@ static int
wayland_output_switch_mode(struct weston_output *output_base,
struct weston_mode *mode)
{
struct weston_renderer *renderer = output_base->compositor->renderer;
struct wayland_output *output;
struct wayland_backend *b;
struct wl_surface *old_surface;
@ -1055,7 +1057,7 @@ wayland_output_switch_mode(struct weston_output *output_base,
output->base.current_mode->flags |= WL_OUTPUT_MODE_CURRENT;
if (output_base->compositor->renderer->type == WESTON_RENDERER_PIXMAN) {
pixman_renderer_output_destroy(output_base);
renderer->pixman->output_destroy(output_base);
if (wayland_output_init_pixman_renderer(output) < 0)
goto err_output;
#ifdef ENABLE_EGL

View file

@ -886,7 +886,7 @@ x11_output_disable(struct weston_output *base)
wl_event_source_remove(output->finish_frame_timer);
if (renderer->type == WESTON_RENDERER_PIXMAN) {
pixman_renderer_output_destroy(&output->base);
renderer->pixman->output_destroy(&output->base);
x11_output_deinit_shm(backend, output);
} else {
renderer->gl->output_destroy(&output->base);
@ -1033,7 +1033,7 @@ x11_output_enable(struct weston_output *base)
weston_log("Failed to initialize SHM for the X11 output\n");
goto err;
}
if (pixman_renderer_output_create(&output->base, &options) < 0) {
if (renderer->pixman->output_create(&output->base, &options) < 0) {
weston_log("Failed to create pixman renderer for output\n");
x11_output_deinit_shm(b, output);
goto err;

View file

@ -88,6 +88,7 @@ struct weston_renderer {
enum weston_renderer_type type;
const struct gl_renderer_interface *gl;
const struct pixman_renderer_interface *pixman;
};
void

View file

@ -964,6 +964,8 @@ debug_binding(struct weston_keyboard *keyboard, const struct timespec *time,
}
}
static struct pixman_renderer_interface pixman_renderer_interface;
WL_EXPORT int
pixman_renderer_init(struct weston_compositor *ec)
{
@ -986,6 +988,7 @@ pixman_renderer_init(struct weston_compositor *ec)
renderer->base.surface_copy_content =
pixman_renderer_surface_copy_content;
renderer->base.type = WESTON_RENDERER_PIXMAN;
renderer->base.pixman = &pixman_renderer_interface;
ec->renderer = &renderer->base;
ec->capabilities |= WESTON_CAP_ROTATION_ANY;
ec->capabilities |= WESTON_CAP_VIEW_CLIP_MASK;
@ -1060,7 +1063,7 @@ pixman_renderer_output_set_hw_extra_damage(struct weston_output *output,
po->hw_extra_damage = extra_damage;
}
WL_EXPORT int
static int
pixman_renderer_output_create(struct weston_output *output,
const struct pixman_renderer_output_options *options)
{
@ -1090,7 +1093,7 @@ pixman_renderer_output_create(struct weston_output *output,
return 0;
}
WL_EXPORT void
static void
pixman_renderer_output_destroy(struct weston_output *output)
{
struct pixman_output_state *po = get_output_state(output);
@ -1106,3 +1109,8 @@ pixman_renderer_output_destroy(struct weston_output *output)
free(po);
}
static struct pixman_renderer_interface pixman_renderer_interface = {
.output_create = pixman_renderer_output_create,
.output_destroy = pixman_renderer_output_destroy,
};

View file

@ -39,10 +39,6 @@ struct pixman_renderer_output_options {
struct weston_size fb_size;
};
int
pixman_renderer_output_create(struct weston_output *output,
const struct pixman_renderer_output_options *options);
void
pixman_renderer_output_set_buffer(struct weston_output *output,
pixman_image_t *buffer);
@ -51,5 +47,8 @@ void
pixman_renderer_output_set_hw_extra_damage(struct weston_output *output,
pixman_region32_t *extra_damage);
void
pixman_renderer_output_destroy(struct weston_output *output);
struct pixman_renderer_interface {
int (*output_create)(struct weston_output *output,
const struct pixman_renderer_output_options *options);
void (*output_destroy)(struct weston_output *output);
};