diff options
-rw-r--r-- | render/egl.c | 18 | ||||
-rw-r--r-- | types/wlr_output.c | 32 |
2 files changed, 31 insertions, 19 deletions
diff --git a/render/egl.c b/render/egl.c index 644f94ac..cc00dece 100644 --- a/render/egl.c +++ b/render/egl.c @@ -1,11 +1,12 @@ #include <assert.h> -#include <stdio.h> +#include <drm_fourcc.h> #include <EGL/egl.h> #include <EGL/eglext.h> +#include <stdio.h> #include <stdlib.h> -#include <drm_fourcc.h> #include <wlr/render/egl.h> #include <wlr/util/log.h> +#include <wlr/util/region.h> #include "glapi.h" static bool egl_get_config(EGLDisplay disp, EGLint *attribs, EGLConfig *out, @@ -329,9 +330,18 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, EGLBoolean ret; if (damage != NULL && (egl->exts.swap_buffers_with_damage_ext || egl->exts.swap_buffers_with_damage_khr)) { + EGLint width = 0, height = 0; + eglQuerySurface(egl->display, surface, EGL_WIDTH, &width); + eglQuerySurface(egl->display, surface, EGL_HEIGHT, &height); + + pixman_region32_t flipped_damage; + pixman_region32_init(&flipped_damage); + wlr_region_transform(&flipped_damage, damage, + WL_OUTPUT_TRANSFORM_FLIPPED_180, width, height); + int nrects; pixman_box32_t *rects = - pixman_region32_rectangles(damage, &nrects); + pixman_region32_rectangles(&flipped_damage, &nrects); EGLint egl_damage[4 * nrects]; for (int i = 0; i < nrects; ++i) { egl_damage[4*i] = rects[i].x1; @@ -340,6 +350,8 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, egl_damage[4*i + 3] = rects[i].y2 - rects[i].y1; } + pixman_region32_fini(&flipped_damage); + if (egl->exts.swap_buffers_with_damage_ext) { ret = eglSwapBuffersWithDamageEXT(egl->display, surface, egl_damage, nrects); diff --git a/types/wlr_output.c b/types/wlr_output.c index c4fc7096..71cb3eba 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -353,15 +353,6 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when, int width, height; wlr_output_transformed_resolution(output, &width, &height); - pixman_region32_t render_damage; - pixman_region32_init(&render_damage); - pixman_region32_union_rect(&render_damage, &render_damage, 0, 0, - width, height); - if (damage != NULL) { - // Damage tracking supported - pixman_region32_intersect(&render_damage, &render_damage, damage); - } - struct timespec now; if (when == NULL) { clock_gettime(CLOCK_MONOTONIC, &now); @@ -375,18 +366,29 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when, }; wlr_signal_emit_safe(&output->events.swap_buffers, &event); + pixman_region32_t render_damage; + pixman_region32_init(&render_damage); + pixman_region32_union_rect(&render_damage, &render_damage, 0, 0, + width, height); + if (damage != NULL) { + // Damage tracking supported + pixman_region32_intersect(&render_damage, &render_damage, damage); + } + // Transform damage into renderer coordinates, ie. upside down // TODO: take transformed coords, make the renderer flip the damage - enum wl_output_transform transform = wlr_output_transform_compose( - wlr_output_transform_invert(output->transform), - WL_OUTPUT_TRANSFORM_FLIPPED_180); - wlr_region_transform(&render_damage, &render_damage, transform, width, - height); + enum wl_output_transform transform = + wlr_output_transform_invert(output->transform); + wlr_region_transform(&render_damage, &render_damage, transform, + width, height); if (!output->impl->swap_buffers(output, damage ? &render_damage : NULL)) { + pixman_region32_fini(&render_damage); return false; } + pixman_region32_fini(&render_damage); + struct wlr_output_cursor *cursor; wl_list_for_each(cursor, &output->cursors, link) { if (!cursor->enabled || !cursor->visible || cursor->surface == NULL) { @@ -398,8 +400,6 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when, output->frame_pending = true; output->needs_swap = false; pixman_region32_clear(&output->damage); - - pixman_region32_fini(&render_damage); return true; } |