wlr_raster_from_surface: Implement surface invalidation

This commit is contained in:
Alexander Orzechowski 2024-02-24 08:22:50 -05:00
parent dbf10ebdf1
commit 9b2b9d1367

View file

@ -10,6 +10,7 @@
#include <wlr/types/wlr_linux_drm_syncobj_v1.h> #include <wlr/types/wlr_linux_drm_syncobj_v1.h>
#include <wlr/types/wlr_raster.h> #include <wlr/types/wlr_raster.h>
#include <wlr/render/drm_syncobj.h> #include <wlr/render/drm_syncobj.h>
#include <wlr/types/wlr_surface_invalidation_v1.h>
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/util/addon.h> #include <wlr/util/addon.h>
@ -507,6 +508,7 @@ struct surface_raster {
struct wlr_addon addon; struct wlr_addon addon;
struct wl_listener buffer_prerelease; struct wl_listener buffer_prerelease;
struct wl_listener raster_invalidated;
bool locking_buffer; bool locking_buffer;
}; };
@ -525,6 +527,7 @@ static void surface_raster_destroy(struct surface_raster *surface_raster) {
surface_raster_drop_raster(surface_raster); surface_raster_drop_raster(surface_raster);
wl_list_remove(&surface_raster->buffer_prerelease.link); wl_list_remove(&surface_raster->buffer_prerelease.link);
wl_list_remove(&surface_raster->raster_invalidated.link);
wlr_addon_finish(&surface_raster->addon); wlr_addon_finish(&surface_raster->addon);
free(surface_raster); free(surface_raster);
} }
@ -555,6 +558,14 @@ static void surface_raster_handle_buffer_prerelease(struct wl_listener *listener
wl_list_init(&surface_raster->buffer_prerelease.link); wl_list_init(&surface_raster->buffer_prerelease.link);
} }
static void surface_raster_handle_raster_invalidated(struct wl_listener *listener, void *data) {
struct surface_raster *surface_raster =
wl_container_of(listener, surface_raster, raster_invalidated);
wlr_surface_invalidation_manager_v1_send_surface_invalidation(
surface_raster->surface);
}
const struct wlr_addon_interface surface_raster_addon_impl = { const struct wlr_addon_interface surface_raster_addon_impl = {
.name = "wlr_raster_surface", .name = "wlr_raster_surface",
.destroy = surface_raster_handle_addon_destroy, .destroy = surface_raster_handle_addon_destroy,
@ -636,6 +647,8 @@ struct wlr_raster *wlr_raster_from_surface(struct wlr_surface *surface) {
surface_raster->buffer_prerelease.notify = surface_raster_handle_buffer_prerelease; surface_raster->buffer_prerelease.notify = surface_raster_handle_buffer_prerelease;
wl_list_init(&surface_raster->buffer_prerelease.link); wl_list_init(&surface_raster->buffer_prerelease.link);
surface_raster->raster_invalidated.notify = surface_raster_handle_raster_invalidated;
wl_list_init(&surface_raster->raster_invalidated.link);
} }
if (!surface->current.buffer) { if (!surface->current.buffer) {
@ -652,6 +665,9 @@ struct wlr_raster *wlr_raster_from_surface(struct wlr_surface *surface) {
wl_list_remove(&surface_raster->buffer_prerelease.link); wl_list_remove(&surface_raster->buffer_prerelease.link);
wl_list_init(&surface_raster->buffer_prerelease.link); wl_list_init(&surface_raster->buffer_prerelease.link);
wl_list_remove(&surface_raster->raster_invalidated.link);
wl_list_init(&surface_raster->raster_invalidated.link);
surface_raster_drop_raster(surface_raster); surface_raster_drop_raster(surface_raster);
return NULL; return NULL;
@ -694,6 +710,9 @@ struct wlr_raster *wlr_raster_from_surface(struct wlr_surface *surface) {
return NULL; return NULL;
} }
wl_list_remove(&surface_raster->raster_invalidated.link);
wl_signal_add(&raster->events.invalidated, &surface_raster->raster_invalidated);
surface_raster_drop_raster(surface_raster); surface_raster_drop_raster(surface_raster);
surface_raster->raster = wlr_raster_lock(raster); surface_raster->raster = wlr_raster_lock(raster);