mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-21 01:38:23 +02:00
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 <post@arntzen-software.no> Acked-by: Emma Anholt <emma@anholt.net> Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39551>
This commit is contained in:
parent
2ed09c8b11
commit
36d77ef0f9
3 changed files with 77 additions and 53 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -29,36 +29,7 @@
|
|||
#include <c11/threads.h>
|
||||
#include "util/format/u_formats.h"
|
||||
|
||||
#ifdef HAVE_X11_PLATFORM
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/dri3.h>
|
||||
#include <xcb/present.h>
|
||||
|
||||
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 */
|
||||
|
|
|
|||
76
src/loader/loader_dri_helper_screen.h
Normal file
76
src/loader/loader_dri_helper_screen.h
Normal file
|
|
@ -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 <xcb/xcb.h>
|
||||
#include <xcb/dri3.h>
|
||||
#include <xcb/present.h>
|
||||
|
||||
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
|
||||
Loading…
Add table
Reference in a new issue