From 50b120927ddcf26c83b219ebe9351b143efebfad Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 9 Jan 2021 11:44:28 +0100 Subject: [PATCH] render/egl: remove wlr_egl_swap_buffers --- include/wlr/render/egl.h | 6 ---- render/egl.c | 67 ---------------------------------------- 2 files changed, 73 deletions(-) diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 3fa47cc9..67f32e42 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -37,7 +37,6 @@ struct wlr_egl_context { }; struct wlr_egl { - EGLenum platform; EGLDisplay display; EGLConfig config; // may be EGL_NO_CONFIG EGLContext context; @@ -51,7 +50,6 @@ struct wlr_egl { bool image_dma_buf_export_mesa; bool image_dmabuf_import_ext; bool image_dmabuf_import_modifiers_ext; - bool swap_buffers_with_damage; // Device extensions bool device_drm_ext; @@ -65,7 +63,6 @@ struct wlr_egl { PFNEGLQUERYWAYLANDBUFFERWL eglQueryWaylandBufferWL; PFNEGLBINDWAYLANDDISPLAYWL eglBindWaylandDisplayWL; PFNEGLUNBINDWAYLANDDISPLAYWL eglUnbindWaylandDisplayWL; - PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC eglSwapBuffersWithDamage; // KHR or EXT PFNEGLQUERYDMABUFFORMATSEXTPROC eglQueryDmaBufFormatsEXT; PFNEGLQUERYDMABUFMODIFIERSEXTPROC eglQueryDmaBufModifiersEXT; PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC eglExportDMABUFImageQueryMESA; @@ -170,9 +167,6 @@ void wlr_egl_save_context(struct wlr_egl_context *context); */ bool wlr_egl_restore_context(struct wlr_egl_context *context); -bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, - pixman_region32_t *damage); - bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface); int wlr_egl_dup_drm_fd(struct wlr_egl *egl); diff --git a/render/egl.c b/render/egl.c index 22feade3..57146a06 100644 --- a/render/egl.c +++ b/render/egl.c @@ -196,8 +196,6 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, goto error; } - egl->platform = platform; - EGLint major, minor; if (eglInitialize(egl->display, &major, &minor) == EGL_FALSE) { wlr_log(WLR_ERROR, "Failed to initialize EGL"); @@ -219,17 +217,6 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, egl->exts.buffer_age_ext = check_egl_ext(display_exts_str, "EGL_EXT_buffer_age"); - if (check_egl_ext(display_exts_str, "EGL_KHR_swap_buffers_with_damage")) { - egl->exts.swap_buffers_with_damage = true; - load_egl_proc(&egl->procs.eglSwapBuffersWithDamage, - "eglSwapBuffersWithDamageKHR"); - } else if (check_egl_ext(display_exts_str, - "EGL_EXT_swap_buffers_with_damage")) { - egl->exts.swap_buffers_with_damage = true; - load_egl_proc(&egl->procs.eglSwapBuffersWithDamage, - "eglSwapBuffersWithDamageEXT"); - } - egl->exts.image_dmabuf_import_ext = check_egl_ext(display_exts_str, "EGL_EXT_image_dma_buf_import"); if (check_egl_ext(display_exts_str, @@ -487,60 +474,6 @@ bool wlr_egl_restore_context(struct wlr_egl_context *context) { context->read_surface, context->context); } -bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, - pixman_region32_t *damage) { - // Never block when swapping buffers on Wayland - if (egl->platform == EGL_PLATFORM_WAYLAND_EXT) { - eglSwapInterval(egl->display, 0); - } - - EGLBoolean ret; - if (damage != NULL && egl->exts.swap_buffers_with_damage) { - 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(&flipped_damage, &nrects); - EGLint egl_damage[4 * nrects + 1]; - for (int i = 0; i < nrects; ++i) { - egl_damage[4*i] = rects[i].x1; - egl_damage[4*i + 1] = rects[i].y1; - egl_damage[4*i + 2] = rects[i].x2 - rects[i].x1; - egl_damage[4*i + 3] = rects[i].y2 - rects[i].y1; - } - - pixman_region32_fini(&flipped_damage); - - if (nrects == 0) { - // Swapping with no rects is the same as swapping with the entire - // surface damaged. To swap with no damage, we set the damage region - // to a single empty rectangle. - nrects = 1; - memset(egl_damage, 0, sizeof(egl_damage)); - } - - ret = egl->procs.eglSwapBuffersWithDamage(egl->display, surface, - egl_damage, nrects); - } else { - ret = eglSwapBuffers(egl->display, surface); - } - - if (!ret) { - wlr_log(WLR_ERROR, "eglSwapBuffers failed"); - return false; - } - - wlr_egl_unset_current(egl); - return true; -} - EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl, struct wl_resource *data, EGLint *fmt, int *width, int *height, bool *inverted_y) {