From 2548fd4aaeec419d769b23010c17a0f18b88f54b Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Thu, 25 Jul 2019 18:44:25 +0200 Subject: [PATCH] uwac: Make damage tracking more readable --- uwac/libuwac/uwac-priv.h | 1 + uwac/libuwac/uwac-window.c | 45 +++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/uwac/libuwac/uwac-priv.h b/uwac/libuwac/uwac-priv.h index 617908581..933f1b625 100644 --- a/uwac/libuwac/uwac-priv.h +++ b/uwac/libuwac/uwac-priv.h @@ -204,6 +204,7 @@ struct uwac_seat { /** @brief a buffer used for drawing a surface frame */ struct uwac_buffer { bool used; + bool dirty; #ifdef HAVE_PIXMAN_REGION pixman_region32_t damage; #else diff --git a/uwac/libuwac/uwac-window.c b/uwac/libuwac/uwac-window.c index a03f493ea..12e809c4d 100644 --- a/uwac/libuwac/uwac-window.c +++ b/uwac/libuwac/uwac-window.c @@ -617,37 +617,40 @@ static const struct wl_callback_listener frame_listener = }; -static void UwacSubmitBufferPtr(UwacWindow* window, UwacBuffer* buffer) +#ifdef HAVE_PIXMAN_REGION +static void damage_surface(UwacWindow* window, UwacBuffer* buffer) { UINT32 nrects, i; -#ifdef HAVE_PIXMAN_REGION - const pixman_box32_t* box; -#else - const RECTANGLE_16* box; -#endif - wl_surface_attach(window->surface, buffer->wayland_buffer, 0, 0); -#ifdef HAVE_PIXMAN_REGION - box = pixman_region32_rectangles(&buffer->damage, &nrects); + const pixman_box32_t* box = pixman_region32_rectangles(&buffer->damage, &nrects); for (i = 0; i < nrects; i++, box++) wl_surface_damage(window->surface, box->x1, box->y1, (box->x2 - box->x1), (box->y2 - box->y1)); + pixman_region32_clear(&buffer->damage); +} #else - box = region16_rects(&buffer->damage, &nrects); +static void damage_surface(UwacWindow* window, UwacBuffer* buffer) +{ + UINT32 nrects, i; + const RECTANGLE_16* box = region16_rects(&buffer->damage, &nrects); for (i = 0; i < nrects; i++, box++) wl_surface_damage(window->surface, box->left, box->top, (box->right - box->left), (box->bottom - box->top)); + region16_clear(&buffer->damage); +} #endif + +static void UwacSubmitBufferPtr(UwacWindow* window, UwacBuffer* buffer) +{ + wl_surface_attach(window->surface, buffer->wayland_buffer, 0, 0); + + damage_surface(window, buffer); + struct wl_callback* frame_callback = wl_surface_frame(window->surface); wl_callback_add_listener(frame_callback, &frame_listener, window); wl_surface_commit(window->surface); -#ifdef HAVE_PIXMAN_REGION - pixman_region32_clear(&buffer->damage); -#else - region16_clear(&buffer->damage); -#endif } @@ -665,14 +668,20 @@ static void frame_done_cb(void* data, struct wl_callback* callback, uint32_t tim } +#ifdef HAVE_PIXMAN_REGION UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { -#ifdef HAVE_PIXMAN_REGION - if (!pixman_region32_union_rect(&window->drawingBuffer->damage, &window->drawingBuffer->damage, x, y, width, height)) + return UWAC_ERROR_INTERNAL; + + return UWAC_SUCCESS; +} #else +UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, uint32_t width, + uint32_t height) +{ RECTANGLE_16 box; box.left = x; @@ -681,11 +690,11 @@ UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, u box.bottom = y + height; if (!region16_union_rect(&window->drawingBuffer->damage, &window->drawingBuffer->damage, &box)) -#endif return UWAC_ERROR_INTERNAL; return UWAC_SUCCESS; } +#endif UwacReturnCode UwacWindowGetDrawingBufferGeometry(UwacWindow* window, UwacSize* geometry, size_t* stride) {