From 36d77ef0f93b292dceb05a0c8ba80eded74db4e7 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Fri, 5 Dec 2025 13:55:38 +0100 Subject: [PATCH] loader: Separate out X11 specific screen queries from dri_helper.h. Allows these helpers to be used for X11 WSI as well. Signed-off-by: Hans-Kristian Arntzen Acked-by: Emma Anholt Reviewed-by: Mario Kleiner Part-of: --- src/egl/drivers/dri2/platform_x11.c | 11 ---- src/loader/loader_dri_helper.h | 43 +-------------- src/loader/loader_dri_helper_screen.h | 76 +++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 53 deletions(-) create mode 100644 src/loader/loader_dri_helper_screen.h diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index b0e8a9d8fa7..a31a9d353ab 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -794,17 +794,6 @@ dri2_fourcc_for_depth(struct dri2_egl_display *dri2_dpy, uint32_t depth) } } -static int -box_intersection_area(int16_t a_x, int16_t a_y, int16_t a_width, - int16_t a_height, int16_t b_x, int16_t b_y, - int16_t b_width, int16_t b_height) -{ - int w = MIN2(a_x + a_width, b_x + b_width) - MAX2(a_x, b_x); - int h = MIN2(a_y + a_height, b_y + b_height) - MAX2(a_y, b_y); - - return (w < 0 || h < 0) ? 0 : w * h; -} - EGLBoolean dri2_x11_get_msc_rate(_EGLDisplay *display, _EGLSurface *surface, EGLint *numerator, EGLint *denominator) diff --git a/src/loader/loader_dri_helper.h b/src/loader/loader_dri_helper.h index 169e36b5d80..5837dde16cd 100644 --- a/src/loader/loader_dri_helper.h +++ b/src/loader/loader_dri_helper.h @@ -29,36 +29,7 @@ #include #include "util/format/u_formats.h" -#ifdef HAVE_X11_PLATFORM -#include -#include -#include - -struct loader_crtc_info { - xcb_randr_crtc_t id; - xcb_timestamp_t timestamp; - - int16_t x, y; - uint16_t width, height; - - unsigned refresh_numerator; - unsigned refresh_denominator; -}; - -struct loader_screen_resources { - mtx_t mtx; - - xcb_connection_t *conn; - xcb_screen_t *screen; - - xcb_timestamp_t config_timestamp; - - /* Number of CRTCs with an active mode set */ - unsigned num_crtcs; - struct loader_crtc_info *crtcs; -}; -#endif - +#include "loader_dri_helper_screen.h" /** * These formats are endian independent they result in the same layout @@ -110,16 +81,4 @@ loader_pipe_format_to_fourcc(enum pipe_format pipe); enum pipe_format loader_fourcc_to_pipe_format(uint32_t fourcc); -#ifdef HAVE_X11_PLATFORM -void -loader_init_screen_resources(struct loader_screen_resources *res, - xcb_connection_t *conn, - xcb_screen_t *screen); -bool -loader_update_screen_resources(struct loader_screen_resources *res); - -void -loader_destroy_screen_resources(struct loader_screen_resources *res); -#endif - #endif /* LOADER_DRI_HELPER_H */ diff --git a/src/loader/loader_dri_helper_screen.h b/src/loader/loader_dri_helper_screen.h new file mode 100644 index 00000000000..290e8dd111c --- /dev/null +++ b/src/loader/loader_dri_helper_screen.h @@ -0,0 +1,76 @@ +/* + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef LOADER_DRI_HELPER_SCREEN_H +#define LOADER_DRI_HELPER_SCREEN_H + +#ifdef HAVE_X11_PLATFORM +#include +#include +#include + +struct loader_crtc_info { + xcb_randr_crtc_t id; + xcb_timestamp_t timestamp; + + int16_t x, y; + uint16_t width, height; + + unsigned refresh_numerator; + unsigned refresh_denominator; +}; + +struct loader_screen_resources { + mtx_t mtx; + + xcb_connection_t *conn; + xcb_screen_t *screen; + + xcb_timestamp_t config_timestamp; + + /* Number of CRTCs with an active mode set */ + unsigned num_crtcs; + struct loader_crtc_info *crtcs; +}; + +void +loader_init_screen_resources(struct loader_screen_resources *res, + xcb_connection_t *conn, + xcb_screen_t *screen); +bool +loader_update_screen_resources(struct loader_screen_resources *res); + +void +loader_destroy_screen_resources(struct loader_screen_resources *res); + +#endif + +static inline int +box_intersection_area(int16_t a_x, int16_t a_y, int16_t a_width, + int16_t a_height, int16_t b_x, int16_t b_y, + int16_t b_width, int16_t b_height) +{ + int w = MIN2(a_x + a_width, b_x + b_width) - MAX2(a_x, b_x); + int h = MIN2(a_y + a_height, b_y + b_height) - MAX2(a_y, b_y); + + return (w < 0 || h < 0) ? 0 : w * h; +} + +#endif