summaryrefslogtreecommitdiff
path: root/surface.c
diff options
context:
space:
mode:
authorAlexander Orzechowski <[email protected]>2022-11-08 11:55:05 -0500
committerSimon Ser <[email protected]>2022-11-11 00:08:04 +0000
commit30b8729a52b0af02fa079f2e98f8ebb3ec10ddf5 (patch)
tree14ebae84f37eff0f44b3ad792b6f873f7505b125 /surface.c
parenta71111fdea69b3134b33fce899149ade274a8232 (diff)
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.
Diffstat (limited to 'surface.c')
-rw-r--r--surface.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/surface.c b/surface.c
index f8bb553..553cc42 100644
--- a/surface.c
+++ b/surface.c
@@ -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);