浏览代码

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.
Norihiro Kamae 3 年之前
父节点
当前提交
f4854dccb4
共有 1 个文件被更改,包括 1 次插入75 次删除
  1. 1 75
      libobs-opengl/gl-x11-egl.c

+ 1 - 75
libobs-opengl/gl-x11-egl.c

@@ -84,58 +84,7 @@ struct gl_platform {
 	EGLSurface pbuffer;
 };
 
-/* The following utility functions are 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);
-}
+/* The following utility function is copied verbatim from GLX code. */
 
 static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn,
 						     xcb_drawable_t drawable)
@@ -325,9 +274,6 @@ static Display *open_windowless_display(Display *platform_display)
 {
 	Display *display;
 	xcb_connection_t *xcb_conn;
-	xcb_screen_iterator_t screen_iterator;
-	xcb_screen_t *screen;
-	int screen_num;
 
 	if (platform_display)
 		display = platform_display;
@@ -345,19 +291,6 @@ static Display *open_windowless_display(Display *platform_display)
 		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()) {
 		blog(LOG_ERROR, "Unable to load EGL entry functions.");
 		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);
 	bool status = false;
 
-	int screen_num;
 	int visual;
 
 	if (!geometry)
 		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,
 					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_visual_id:
-fail_screen:
 fail_geometry_request:
 success:
 	free(geometry);