Add a paint list struct
This is an alternative to #3188 (closed) and #3252 (closed).
The scene-graph isn't a great data structure to consume from a renderer/backend PoV, it's a bit too high-level:
- The tree structure isn't useful at this level
- Some nodes might be disabled, out of the viewport, or hidden behind other nodes
The goal of this proposal is to expose a flat, low-level list of rendering operations to both renderers and backends. Renderers can paint a scene from the flat list, backends can use it as input for libliftoff or wl_subsurfaces
(alternative to !1985 (closed)).
The flat list has "dumb" entries which can get memcpy
'ed around.
enum wlr_paint_entry_type {
WLR_PAINT_ENTRY_BUFFER,
WLR_PAINT_ENTRY_RECT,
};
struct wlr_paint_entry {
enum wlr_paint_entry_type type;
union {
struct {
struct wlr_buffer *buffer;
struct wlr_box *dst;
struct wlr_fbox *src;
enum wl_output_transform transform;
} buffer;
struct {
float color[4];
struct wlr_box box;
} rect;
};
};
/**
* Flat list of rendering operations.
*
* Rendering operations can be appended via wlr_paint_list_add_buffer and
* wlr_paint_list_add_rect. The list can be re-used between multiple rendering
* operations via wlr_paint_list_reset.
*/
struct wlr_paint_list {
struct wlr_paint_entry *entries;
size_t len;
};
bool wlr_paint_list_add_buffer(struct wlr_paint_list *list,
struct wlr_buffer *buffer, const struct wlr_box *dst,
const struct wlr_fbox *src, enum wl_output_transform transform);
bool wlr_paint_list_add_rect(struct wlr_paint_list *list,
const float color[static 4], const struct wlr_box *box);
bool wlr_paint_list_reset(struct wlr_paint_list *list);
void wlr_render_paint_list(struct wlr_renderer *renderer,
const struct wlr_paint_list *list, pixman_region32_t *damage);
void wlr_output_attach_paint_list(struct wlr_output *output,
const struct wlr_paint_list *list);
Issues with this design:
- libliftoff would want to keep track of
wlr_paint_entry
across multiple frames, to figure out the priority of each layer. Maybe we could add astruct wlr_addon_set *
field to paint entries to allow renderers and backends to attach state. - How/when would the renderer turn a
wlr_buffer
into awlr_texture
? We want to avoid unnecessary re-imports and re-uploads.