mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
scene: try to import buffers as textures before rendering
The wlroots APIs currently don't allow importing/uploading a buffer during rendering operations. Scene-graph buffer nodes need to turn their wlr_buffer into a wlr_texture at some point. It's not always possible to do so at wlr_scene_buffer creation time because the scene-graph may have zero outputs at this point, thus no way to grab a wlr_renderer. Instead, add scene-graph buffers to a pending list and try to import them in wlr_scene_output_commit. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3354
This commit is contained in:
parent
3cfe29b598
commit
3db1bcbe64
2 changed files with 18 additions and 0 deletions
|
@ -68,6 +68,9 @@ struct wlr_scene {
|
|||
// May be NULL
|
||||
struct wlr_presentation *presentation;
|
||||
struct wl_listener presentation_destroy;
|
||||
|
||||
// List of buffers which need to be imported as textures
|
||||
struct wl_list pending_buffers; // wlr_scene_buffer.pending_link
|
||||
};
|
||||
|
||||
/** A sub-tree in the scene-graph. */
|
||||
|
@ -114,6 +117,7 @@ struct wlr_scene_buffer {
|
|||
struct wlr_fbox src_box;
|
||||
int dst_width, dst_height;
|
||||
enum wl_output_transform transform;
|
||||
struct wl_list pending_link; // wlr_scene.pending_buffers
|
||||
};
|
||||
|
||||
/** A viewport for an output in the scene-graph */
|
||||
|
|
|
@ -130,6 +130,7 @@ void wlr_scene_node_destroy(struct wlr_scene_node *node) {
|
|||
break;
|
||||
case WLR_SCENE_NODE_BUFFER:;
|
||||
struct wlr_scene_buffer *scene_buffer = scene_buffer_from_node(node);
|
||||
wl_list_remove(&scene_buffer->pending_link);
|
||||
wlr_texture_destroy(scene_buffer->texture);
|
||||
wlr_buffer_unlock(scene_buffer->buffer);
|
||||
free(scene_buffer);
|
||||
|
@ -145,6 +146,7 @@ struct wlr_scene *wlr_scene_create(void) {
|
|||
scene_node_init(&scene->node, WLR_SCENE_NODE_ROOT, NULL);
|
||||
wl_list_init(&scene->outputs);
|
||||
wl_list_init(&scene->presentation_destroy.link);
|
||||
wl_list_init(&scene->pending_buffers);
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
@ -360,6 +362,9 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
|
|||
|
||||
scene_node_damage_whole(&scene_buffer->node);
|
||||
|
||||
struct wlr_scene *scene = scene_node_get_root(parent);
|
||||
wl_list_insert(&scene->pending_buffers, &scene_buffer->pending_link);
|
||||
|
||||
return scene_buffer;
|
||||
}
|
||||
|
||||
|
@ -1113,6 +1118,15 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Try to import new buffers as textures
|
||||
struct wlr_scene_buffer *scene_buffer, *scene_buffer_tmp;
|
||||
wl_list_for_each_safe(scene_buffer, scene_buffer_tmp,
|
||||
&scene_output->scene->pending_buffers, pending_link) {
|
||||
scene_buffer_get_texture(scene_buffer, renderer);
|
||||
wl_list_remove(&scene_buffer->pending_link);
|
||||
wl_list_init(&scene_buffer->pending_link);
|
||||
}
|
||||
|
||||
wlr_renderer_begin(renderer, output->width, output->height);
|
||||
|
||||
int nrects;
|
||||
|
|
Loading…
Reference in a new issue