101e04c3fSmrg#ifndef __glx_glvnd_dispatch_funcs_h__
201e04c3fSmrg#define __glx_glvnd_dispatch_funcs_h__
301e04c3fSmrg/*
401e04c3fSmrg * Helper functions used by g_glxglvnddispatchfuncs.c.
501e04c3fSmrg */
601e04c3fSmrg#include "glvnd/libglxabi.h"
701e04c3fSmrg#include "glxglvnd.h"
801e04c3fSmrg
901e04c3fSmrg#define __VND __glXGLVNDAPIExports
1001e04c3fSmrg
1101e04c3fSmrgstatic inline int AddFBConfigMapping(Display *dpy, GLXFBConfig config,
1201e04c3fSmrg                                     __GLXvendorInfo *vendor)
1301e04c3fSmrg{
1401e04c3fSmrg    return __VND->addVendorFBConfigMapping(dpy, config, vendor);
1501e04c3fSmrg}
1601e04c3fSmrg
1701e04c3fSmrgstatic inline int AddFBConfigsMapping(Display *dpy, const GLXFBConfig *ret,
1801e04c3fSmrg                                      int *nelements, __GLXvendorInfo *vendor)
1901e04c3fSmrg{
2001e04c3fSmrg    int i, r;
2101e04c3fSmrg
2201e04c3fSmrg    if (!nelements || !ret)
2301e04c3fSmrg        return 0;
2401e04c3fSmrg
2501e04c3fSmrg    for (i = 0; i < *nelements; i++) {
2601e04c3fSmrg        r = __VND->addVendorFBConfigMapping(dpy, ret[i], vendor);
2701e04c3fSmrg        if (r) {
2801e04c3fSmrg            for (; i >= 0; i--)
2901e04c3fSmrg                __VND->removeVendorFBConfigMapping(dpy, ret[i]);
3001e04c3fSmrg            break;
3101e04c3fSmrg        }
3201e04c3fSmrg    }
3301e04c3fSmrg    return r;
3401e04c3fSmrg}
3501e04c3fSmrg
3601e04c3fSmrgstatic inline int AddDrawableMapping(Display *dpy, GLXDrawable drawable,
3701e04c3fSmrg                                     __GLXvendorInfo *vendor)
3801e04c3fSmrg{
3901e04c3fSmrg    return __VND->addVendorDrawableMapping(dpy, drawable, vendor);
4001e04c3fSmrg}
4101e04c3fSmrg
4201e04c3fSmrgstatic inline int AddContextMapping(Display *dpy, GLXContext ctx,
4301e04c3fSmrg                                    __GLXvendorInfo *vendor)
4401e04c3fSmrg{
4501e04c3fSmrg    return __VND->addVendorContextMapping(dpy, ctx, vendor);
4601e04c3fSmrg}
4701e04c3fSmrg
4801e04c3fSmrgstatic inline __GLXvendorInfo *GetDispatchFromDrawable(Display *dpy,
4901e04c3fSmrg                                                       GLXDrawable drawable)
5001e04c3fSmrg{
5101e04c3fSmrg    return __VND->vendorFromDrawable(dpy, drawable);
5201e04c3fSmrg}
5301e04c3fSmrg
5401e04c3fSmrgstatic inline __GLXvendorInfo *GetDispatchFromContext(GLXContext ctx)
5501e04c3fSmrg{
5601e04c3fSmrg    return __VND->vendorFromContext(ctx);
5701e04c3fSmrg}
5801e04c3fSmrg
5901e04c3fSmrgstatic inline __GLXvendorInfo *GetDispatchFromFBConfig(Display *dpy, GLXFBConfig config)
6001e04c3fSmrg{
6101e04c3fSmrg    return __VND->vendorFromFBConfig(dpy, config);
6201e04c3fSmrg}
6301e04c3fSmrg
6401e04c3fSmrgstatic inline __GLXvendorInfo *GetDispatchFromVisual(Display *dpy,
6501e04c3fSmrg                                                     const XVisualInfo *visual)
6601e04c3fSmrg{
6701e04c3fSmrg    return __VND->getDynDispatch(dpy, visual->screen);
6801e04c3fSmrg}
6901e04c3fSmrg
7001e04c3fSmrg#endif // __glx_glvnd_dispatch_funcs_h__
71