mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
wlr_scene: Fix texture reuse
Add private interface to ignore a buffer that's locking a client_buffer for damage tracking. This should eventually be replaced by wlr_raster.
This commit is contained in:
parent
eec95e3d5e
commit
ea40ba4f6a
3 changed files with 32 additions and 1 deletions
|
@ -151,6 +151,8 @@ struct wlr_client_buffer {
|
|||
// private state
|
||||
|
||||
struct wl_listener source_destroy;
|
||||
|
||||
size_t n_ignore_locks;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,7 +84,7 @@ struct wlr_client_buffer *wlr_client_buffer_create(struct wlr_buffer *buffer,
|
|||
|
||||
bool wlr_client_buffer_apply_damage(struct wlr_client_buffer *client_buffer,
|
||||
struct wlr_buffer *next, pixman_region32_t *damage) {
|
||||
if (client_buffer->base.n_locks > 1) {
|
||||
if (client_buffer->base.n_locks - client_buffer->n_ignore_locks > 1) {
|
||||
// Someone else still has a reference to the buffer
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_presentation_time.h>
|
||||
|
@ -55,6 +56,28 @@ static void scene_surface_handle_surface_destroy(
|
|||
wlr_scene_node_destroy(&surface->buffer->node);
|
||||
}
|
||||
|
||||
// This is used for wlr_scene where it unconditionally locks buffers preventing
|
||||
// reuse of the existing texture for shm clients. With the usage pattern of
|
||||
// wlr_scene surface handling, we can mark its locked buffer as safe
|
||||
// for mutation.
|
||||
static void client_buffer_mark_next_can_damage(struct wlr_client_buffer *buffer) {
|
||||
buffer->n_ignore_locks++;
|
||||
}
|
||||
|
||||
static void scene_buffer_unmark_client_buffer(struct wlr_scene_buffer *scene_buffer) {
|
||||
if (!scene_buffer->buffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_client_buffer *buffer = wlr_client_buffer_get(scene_buffer->buffer);
|
||||
if (!buffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(buffer->n_ignore_locks > 0);
|
||||
buffer->n_ignore_locks--;
|
||||
}
|
||||
|
||||
static void set_buffer_with_surface_state(struct wlr_scene_buffer *scene_buffer,
|
||||
struct wlr_surface *surface) {
|
||||
struct wlr_surface_state *state = &surface->current;
|
||||
|
@ -68,7 +91,11 @@ static void set_buffer_with_surface_state(struct wlr_scene_buffer *scene_buffer,
|
|||
wlr_scene_buffer_set_dest_size(scene_buffer, state->width, state->height);
|
||||
wlr_scene_buffer_set_transform(scene_buffer, state->transform);
|
||||
|
||||
scene_buffer_unmark_client_buffer(scene_buffer);
|
||||
|
||||
if (surface->buffer) {
|
||||
client_buffer_mark_next_can_damage(surface->buffer);
|
||||
|
||||
wlr_scene_buffer_set_buffer_with_damage(scene_buffer,
|
||||
&surface->buffer->base, &surface->buffer_damage);
|
||||
} else {
|
||||
|
@ -109,6 +136,8 @@ static bool scene_buffer_point_accepts_input(struct wlr_scene_buffer *scene_buff
|
|||
static void surface_addon_destroy(struct wlr_addon *addon) {
|
||||
struct wlr_scene_surface *surface = wl_container_of(addon, surface, addon);
|
||||
|
||||
scene_buffer_unmark_client_buffer(surface->buffer);
|
||||
|
||||
wlr_addon_finish(&surface->addon);
|
||||
|
||||
wl_list_remove(&surface->output_enter.link);
|
||||
|
|
Loading…
Reference in a new issue