mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-09 02:28:08 +02:00
compositor: Move repaint loop into a backend function
We've trimmed down the actual repaint loop to just iterating through the surface list and calling weston_surface_draw(), so we push that to the backend without too much code duplication.
This commit is contained in:
parent
32cdc384f4
commit
68c479af05
6 changed files with 52 additions and 3 deletions
|
|
@ -94,6 +94,19 @@ drm_output_prepare_render(struct weston_output *output_base)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
drm_output_repaint(struct weston_output *output)
|
||||
{
|
||||
struct weston_compositor *compositor = output->compositor;
|
||||
struct weston_surface *surface;
|
||||
|
||||
surface = container_of(compositor->surface_list.next,
|
||||
struct weston_surface, link);
|
||||
|
||||
wl_list_for_each_reverse(surface, &compositor->surface_list, link)
|
||||
weston_surface_draw(surface, output);
|
||||
}
|
||||
|
||||
static int
|
||||
drm_output_present(struct weston_output *output_base)
|
||||
{
|
||||
|
|
@ -554,6 +567,7 @@ create_output_for_connector(struct drm_compositor *ec,
|
|||
|
||||
output->pending_fs_surf_fb_id = 0;
|
||||
output->base.prepare_render = drm_output_prepare_render;
|
||||
output->base.repaint = drm_output_repaint;
|
||||
output->base.present = drm_output_present;
|
||||
output->base.prepare_scanout_surface =
|
||||
drm_output_prepare_scanout_surface;
|
||||
|
|
|
|||
|
|
@ -101,6 +101,16 @@ wfd_output_prepare_render(struct weston_output *output_base)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
wfd_output_repaint(struct weston_output *output)
|
||||
{
|
||||
struct weston_compositor *compositor;
|
||||
struct weston_surface *surface;
|
||||
|
||||
wl_list_for_each_reverse(surface, &compositor->surface_list, link)
|
||||
weston_surface_draw(surface, output);
|
||||
}
|
||||
|
||||
static int
|
||||
wfd_output_present(struct weston_output *output_base)
|
||||
{
|
||||
|
|
@ -407,6 +417,7 @@ create_output_for_port(struct wfd_compositor *ec,
|
|||
wfdDeviceCommit(ec->dev, WFD_COMMIT_ENTIRE_DEVICE, WFD_INVALID_HANDLE);
|
||||
|
||||
output->base.prepare_render = wfd_output_prepare_render;
|
||||
output->base.repaint = wfd_output_repaint;
|
||||
output->base.present = wfd_output_present;
|
||||
output->base.prepare_scanout_surface =
|
||||
wfd_output_prepare_scanout_surface;
|
||||
|
|
|
|||
|
|
@ -176,6 +176,16 @@ wayland_output_prepare_render(struct weston_output *output_base)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
wayland_output_repaint(struct weston_output *output)
|
||||
{
|
||||
struct weston_compositor *compositor = output->compositor;
|
||||
struct weston_surface *surface;
|
||||
|
||||
wl_list_for_each_reverse(surface, &compositor->surface_list, link)
|
||||
weston_surface_draw(surface, output);
|
||||
}
|
||||
|
||||
static void
|
||||
frame_done(void *data, struct wl_callback *wl_callback, uint32_t time)
|
||||
{
|
||||
|
|
@ -291,6 +301,7 @@ wayland_compositor_create_output(struct wayland_compositor *c,
|
|||
glClearColor(0, 0, 0, 0.5);
|
||||
|
||||
output->base.prepare_render = wayland_output_prepare_render;
|
||||
output->base.repaint = wayland_output_repaint;
|
||||
output->base.present = wayland_output_present;
|
||||
output->base.prepare_scanout_surface =
|
||||
wayland_output_prepare_scanout_surface;
|
||||
|
|
|
|||
|
|
@ -200,6 +200,16 @@ x11_output_prepare_render(struct weston_output *output_base)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_output_repaint(struct weston_output *output)
|
||||
{
|
||||
struct weston_compositor *compositor = output->compositor;
|
||||
struct weston_surface *surface;
|
||||
|
||||
wl_list_for_each_reverse(surface, &compositor->surface_list, link)
|
||||
weston_surface_draw(surface, output);
|
||||
}
|
||||
|
||||
static int
|
||||
finish_frame_handler(void *data)
|
||||
{
|
||||
|
|
@ -462,6 +472,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
|
|||
wl_event_loop_add_timer(loop, finish_frame_handler, output);
|
||||
|
||||
output->base.prepare_render = x11_output_prepare_render;
|
||||
output->base.repaint = x11_output_repaint;
|
||||
output->base.present = x11_output_present;
|
||||
output->base.prepare_scanout_surface =
|
||||
x11_output_prepare_scanout_surface;
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ texture_transformed_surface(struct weston_surface *es)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
WL_EXPORT void
|
||||
weston_surface_draw(struct weston_surface *es, struct weston_output *output)
|
||||
{
|
||||
struct weston_compositor *ec = es->compositor;
|
||||
|
|
@ -861,8 +861,7 @@ weston_output_repaint(struct weston_output *output)
|
|||
/* We're drawing nothing, just let the damage accumulate */
|
||||
return;
|
||||
|
||||
wl_list_for_each_reverse(es, &ec->surface_list, link)
|
||||
weston_surface_draw(es, output);
|
||||
output->repaint(output);
|
||||
|
||||
if (ec->fade.spring.current > 0.001)
|
||||
solid_surface_release(&solid);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ struct weston_output {
|
|||
struct wl_listener pending_scanout_buffer_destroy_listener;
|
||||
|
||||
int (*prepare_render)(struct weston_output *output);
|
||||
void (*repaint)(struct weston_output *output);
|
||||
int (*present)(struct weston_output *output);
|
||||
int (*prepare_scanout_surface)(struct weston_output *output,
|
||||
struct weston_surface *es);
|
||||
|
|
@ -276,6 +277,8 @@ weston_spring_done(struct weston_spring *spring);
|
|||
void
|
||||
weston_surface_activate(struct weston_surface *surface,
|
||||
struct weston_input_device *device, uint32_t time);
|
||||
void
|
||||
weston_surface_draw(struct weston_surface *es, struct weston_output *output);
|
||||
|
||||
void
|
||||
notify_motion(struct wl_input_device *device,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue