libobs-opengl: Remove unnecessary call to retrieve screen number
The code to retrieve the screen number was originally implemented for GLX but not necessary for EGL.master
parent
6c39b023ad
commit
f4854dccb4
|
@ -84,58 +84,7 @@ struct gl_platform {
|
||||||
EGLSurface pbuffer;
|
EGLSurface pbuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The following utility functions are copied verbatim from GLX code. */
|
/* The following utility function is copied verbatim from GLX code. */
|
||||||
|
|
||||||
/*
|
|
||||||
* Since we cannot take advantage of the asynchronous nature of xcb,
|
|
||||||
* all of the helper functions are synchronous but thread-safe.
|
|
||||||
*
|
|
||||||
* They check for errors and will return 0 on problems
|
|
||||||
* with the exception of when 0 is a valid return value... in which case
|
|
||||||
* read the specific function comments.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Returns -1 on invalid screen. */
|
|
||||||
static int get_screen_num_from_xcb_screen(xcb_connection_t *xcb_conn,
|
|
||||||
xcb_screen_t *screen)
|
|
||||||
{
|
|
||||||
xcb_screen_iterator_t iter =
|
|
||||||
xcb_setup_roots_iterator(xcb_get_setup(xcb_conn));
|
|
||||||
int screen_num = 0;
|
|
||||||
|
|
||||||
for (; iter.rem; xcb_screen_next(&iter), ++screen_num)
|
|
||||||
if (iter.data == screen)
|
|
||||||
return screen_num;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static xcb_screen_t *get_screen_from_root(xcb_connection_t *xcb_conn,
|
|
||||||
xcb_window_t root)
|
|
||||||
{
|
|
||||||
xcb_screen_iterator_t iter =
|
|
||||||
xcb_setup_roots_iterator(xcb_get_setup(xcb_conn));
|
|
||||||
|
|
||||||
while (iter.rem) {
|
|
||||||
if (iter.data->root == root)
|
|
||||||
return iter.data;
|
|
||||||
|
|
||||||
xcb_screen_next(&iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int get_screen_num_from_root(xcb_connection_t *xcb_conn,
|
|
||||||
xcb_window_t root)
|
|
||||||
{
|
|
||||||
xcb_screen_t *screen = get_screen_from_root(xcb_conn, root);
|
|
||||||
|
|
||||||
if (!screen)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return get_screen_num_from_xcb_screen(xcb_conn, screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn,
|
static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn,
|
||||||
xcb_drawable_t drawable)
|
xcb_drawable_t drawable)
|
||||||
|
@ -325,9 +274,6 @@ static Display *open_windowless_display(Display *platform_display)
|
||||||
{
|
{
|
||||||
Display *display;
|
Display *display;
|
||||||
xcb_connection_t *xcb_conn;
|
xcb_connection_t *xcb_conn;
|
||||||
xcb_screen_iterator_t screen_iterator;
|
|
||||||
xcb_screen_t *screen;
|
|
||||||
int screen_num;
|
|
||||||
|
|
||||||
if (platform_display)
|
if (platform_display)
|
||||||
display = platform_display;
|
display = platform_display;
|
||||||
|
@ -345,19 +291,6 @@ static Display *open_windowless_display(Display *platform_display)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(xcb_conn));
|
|
||||||
screen = screen_iterator.data;
|
|
||||||
if (!screen) {
|
|
||||||
blog(LOG_ERROR, "Unable to get screen root");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen_num = get_screen_num_from_root(xcb_conn, screen->root);
|
|
||||||
if (screen_num == -1) {
|
|
||||||
blog(LOG_ERROR, "Unable to get screen number from root");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gladLoadEGL()) {
|
if (!gladLoadEGL()) {
|
||||||
blog(LOG_ERROR, "Unable to load EGL entry functions.");
|
blog(LOG_ERROR, "Unable to load EGL entry functions.");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -461,17 +394,11 @@ static bool gl_x11_egl_platform_init_swapchain(struct gs_swap_chain *swap)
|
||||||
get_window_geometry(xcb_conn, parent);
|
get_window_geometry(xcb_conn, parent);
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
int screen_num;
|
|
||||||
int visual;
|
int visual;
|
||||||
|
|
||||||
if (!geometry)
|
if (!geometry)
|
||||||
goto fail_geometry_request;
|
goto fail_geometry_request;
|
||||||
|
|
||||||
screen_num = get_screen_num_from_root(xcb_conn, geometry->root);
|
|
||||||
if (screen_num == -1) {
|
|
||||||
goto fail_screen;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (!eglGetConfigAttrib(plat->edisplay, plat->config,
|
if (!eglGetConfigAttrib(plat->edisplay, plat->config,
|
||||||
EGL_NATIVE_VISUAL_ID,
|
EGL_NATIVE_VISUAL_ID,
|
||||||
|
@ -512,7 +439,6 @@ static bool gl_x11_egl_platform_init_swapchain(struct gs_swap_chain *swap)
|
||||||
|
|
||||||
fail_window_surface:
|
fail_window_surface:
|
||||||
fail_visual_id:
|
fail_visual_id:
|
||||||
fail_screen:
|
|
||||||
fail_geometry_request:
|
fail_geometry_request:
|
||||||
success:
|
success:
|
||||||
free(geometry);
|
free(geometry);
|
||||||
|
|
Loading…
Reference in New Issue