xlib: Remove the usage of global constructor in xlib.c, so the xm_public.h are removed

The usage of global constructor should be limited, only in absolutely needed case.
The call style of xlib_create_screen referenced to osmesa_create_screen

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19258>
This commit is contained in:
Yonggang Luo 2022-10-23 22:54:01 +08:00 committed by Marge Bot
parent 4117710ec1
commit 61342ea1a5
3 changed files with 8 additions and 78 deletions

View file

@ -73,15 +73,10 @@
#include "main/errors.h"
#include "main/mtypes.h"
#include "xm_public.h"
#include <GL/glx.h>
/* Driver interface routines, set up by xlib backend on library
* _init(). These are global in the same way that function names are
* global.
*/
static struct xm_driver driver;
extern struct pipe_screen *
xlib_create_screen(Display *display);
/* Default strict invalidate to false. This means we will not call
* XGetGeometry after every swapbuffers, which allows swapbuffers to
@ -111,12 +106,6 @@ xmesa_strict_invalidate(void)
return debug_get_option_xmesa_strict_invalidate();
}
void xmesa_set_driver( const struct xm_driver *templ )
{
driver = *templ;
}
static int
xmesa_get_param(struct st_manager *smapi,
enum st_manager_param param)
@ -245,7 +234,7 @@ xmesa_init_display( Display *display )
return NULL;
}
xmdpy->screen = driver.create_pipe_screen(display);
xmdpy->screen = xlib_create_screen(display);
if (!xmdpy->screen) {
free(xmdpy->smapi);
Xfree(info);

View file

@ -1,46 +0,0 @@
/**************************************************************************
*
* Copyright 2006 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef XM_PUBLIC_H
#define XM_PUBLIC_H
#include <X11/Xlib.h>
struct pipe_screen;
/* This is the driver interface required by the glx/xlib frontends.
*/
struct xm_driver {
struct pipe_screen *(*create_pipe_screen)( Display *display );
};
extern void
xmesa_set_driver( const struct xm_driver *driver );
#endif /* XM_PUBLIC_H */

View file

@ -33,7 +33,6 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
#include "sw/xlib/xlib_sw_winsys.h"
#include "xm_public.h"
#include "target-helpers/inline_sw_helper.h"
#include "target-helpers/inline_debug_helper.h"
@ -44,8 +43,11 @@
* one of the software rasterizers (llvmpipe, softpipe) and the
* xlib winsys.
*/
static struct pipe_screen *
swrast_xlib_create_screen( Display *display )
struct pipe_screen *
xlib_create_screen( Display *display );
struct pipe_screen *
xlib_create_screen( Display *display )
{
struct sw_winsys *winsys;
struct pipe_screen *screen = NULL;
@ -74,18 +76,3 @@ fail:
return NULL;
}
static struct xm_driver xlib_driver =
{
.create_pipe_screen = swrast_xlib_create_screen,
};
/* Build the rendering stack.
*/
static void _init( void ) __attribute__((constructor));
static void _init( void )
{
/* Initialize the xlib libgl code, pass in the winsys:
*/
xmesa_set_driver( &xlib_driver );
}