glx: indent -br -i3 -npcs --no-tabs dri_glx.c

This commit is contained in:
RALOVICH, Kristóf 2008-10-13 13:40:09 +02:00 committed by Brian Paul
parent 09c889b318
commit 4e88ae5639
1 changed files with 414 additions and 403 deletions

View File

@ -51,7 +51,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
struct __GLXDRIdisplayPrivateRec { struct __GLXDRIdisplayPrivateRec
{
__GLXDRIdisplay base; __GLXDRIdisplay base;
/* /*
@ -62,7 +63,8 @@ struct __GLXDRIdisplayPrivateRec {
int driPatch; int driPatch;
}; };
struct __GLXDRIcontextPrivateRec { struct __GLXDRIcontextPrivateRec
{
__GLXDRIcontext base; __GLXDRIcontext base;
__DRIcontext *driContext; __DRIcontext *driContext;
XID hwContextID; XID hwContextID;
@ -74,7 +76,8 @@ struct __GLXDRIcontextPrivateRec {
* the DRI driver for the screen. (I.e. "r128", "tdfx", etc). * the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
* Return True for success, False for failure. * Return True for success, False for failure.
*/ */
static Bool driGetDriverName(Display *dpy, int scrNum, char **driverName) static Bool
driGetDriverName(Display * dpy, int scrNum, char **driverName)
{ {
int directCapable; int directCapable;
Bool b; Bool b;
@ -110,17 +113,19 @@ static Bool driGetDriverName(Display *dpy, int scrNum, char **driverName)
* The returned char pointer points to a static array that will be * The returned char pointer points to a static array that will be
* overwritten by subsequent calls. * overwritten by subsequent calls.
*/ */
PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) { PUBLIC const char *
glXGetScreenDriver(Display * dpy, int scrNum)
{
static char ret[32]; static char ret[32];
char *driverName; char *driverName;
if (driGetDriverName(dpy, scrNum, &driverName)) { if (driGetDriverName(dpy, scrNum, &driverName)) {
int len; int len;
if (!driverName) if (!driverName)
return NULL; return NULL;
len = strlen (driverName); len = strlen(driverName);
if (len >= 31) if (len >= 31)
return NULL; return NULL;
memcpy (ret, driverName, len+1); memcpy(ret, driverName, len + 1);
Xfree(driverName); Xfree(driverName);
return ret; return ret;
} }
@ -138,18 +143,20 @@ PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) {
* *
* Note: The driver remains opened after this function returns. * Note: The driver remains opened after this function returns.
*/ */
PUBLIC const char *glXGetDriverConfig (const char *driverName) PUBLIC const char *
glXGetDriverConfig(const char *driverName)
{ {
void *handle = driOpenDriver (driverName); void *handle = driOpenDriver(driverName);
if (handle) if (handle)
return dlsym (handle, "__driConfigOptions"); return dlsym(handle, "__driConfigOptions");
else else
return NULL; return NULL;
} }
#ifdef XDAMAGE_1_1_INTERFACE #ifdef XDAMAGE_1_1_INTERFACE
static GLboolean has_damage_post(Display *dpy) static GLboolean
has_damage_post(Display * dpy)
{ {
static GLboolean inited = GL_FALSE; static GLboolean inited = GL_FALSE;
static GLboolean has_damage; static GLboolean has_damage;
@ -158,10 +165,10 @@ static GLboolean has_damage_post(Display *dpy)
int major, minor; int major, minor;
if (XDamageQueryVersion(dpy, &major, &minor) && if (XDamageQueryVersion(dpy, &major, &minor) &&
major == 1 && minor >= 1) major == 1 && minor >= 1) {
{
has_damage = GL_TRUE; has_damage = GL_TRUE;
} else { }
else {
has_damage = GL_FALSE; has_damage = GL_FALSE;
} }
inited = GL_TRUE; inited = GL_TRUE;
@ -170,11 +177,11 @@ static GLboolean has_damage_post(Display *dpy)
return has_damage; return has_damage;
} }
static void __glXReportDamage(__DRIdrawable *driDraw, static void
__glXReportDamage(__DRIdrawable * driDraw,
int x, int y, int x, int y,
drm_clip_rect_t *rects, int num_rects, drm_clip_rect_t * rects, int num_rects,
GLboolean front_buffer, GLboolean front_buffer, void *loaderPrivate)
void *loaderPrivate)
{ {
XRectangle *xrects; XRectangle *xrects;
XserverRegion region; XserverRegion region;
@ -192,7 +199,8 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
x_off = x; x_off = x;
y_off = y; y_off = y;
drawable = RootWindow(dpy, psc->scr); drawable = RootWindow(dpy, psc->scr);
} else{ }
else {
x_off = 0; x_off = 0;
y_off = 0; y_off = 0;
drawable = glxDraw->xDrawable; drawable = glxDraw->xDrawable;
@ -215,19 +223,20 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
} }
static const __DRIdamageExtension damageExtension = { static const __DRIdamageExtension damageExtension = {
{ __DRI_DAMAGE, __DRI_DAMAGE_VERSION }, {__DRI_DAMAGE, __DRI_DAMAGE_VERSION},
__glXReportDamage, __glXReportDamage,
}; };
#endif #endif
static GLboolean static GLboolean
__glXDRIGetDrawableInfo(__DRIdrawable *drawable, __glXDRIGetDrawableInfo(__DRIdrawable * drawable,
unsigned int *index, unsigned int *stamp, unsigned int *index, unsigned int *stamp,
int *X, int *Y, int *W, int *H, int *X, int *Y, int *W, int *H,
int *numClipRects, drm_clip_rect_t ** pClipRects, int *numClipRects, drm_clip_rect_t ** pClipRects,
int *backX, int *backY, int *backX, int *backY,
int *numBackClipRects, drm_clip_rect_t **pBackClipRects, int *numBackClipRects,
drm_clip_rect_t ** pBackClipRects,
void *loaderPrivate) void *loaderPrivate)
{ {
__GLXDRIdrawable *glxDraw = loaderPrivate; __GLXDRIdrawable *glxDraw = loaderPrivate;
@ -242,7 +251,7 @@ __glXDRIGetDrawableInfo(__DRIdrawable *drawable,
} }
static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = { static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
{ __DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION }, {__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION},
__glXDRIGetDrawableInfo __glXDRIGetDrawableInfo
}; };
@ -271,7 +280,7 @@ static const __DRIextension *loader_extensions[] = {
* the client-side driver on success, or \c NULL on failure. * the client-side driver on success, or \c NULL on failure.
*/ */
static void * static void *
CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc, CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
__GLXDRIdisplayPrivate * driDpy) __GLXDRIdisplayPrivate * driDpy)
{ {
void *psp = NULL; void *psp = NULL;
@ -344,8 +353,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
if (!XF86DRIGetClientDriverName(dpy, scrn, if (!XF86DRIGetClientDriverName(dpy, scrn,
&ddx_version.major, &ddx_version.major,
&ddx_version.minor, &ddx_version.minor,
&ddx_version.patch, &ddx_version.patch, &driverName)) {
&driverName)) {
ErrorMessageF("XF86DRIGetClientDriverName failed\n"); ErrorMessageF("XF86DRIGetClientDriverName failed\n");
goto handle_error; goto handle_error;
} }
@ -360,7 +368,8 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
*/ */
if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk, if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk,
&framebuffer.size, &framebuffer.stride, &framebuffer.size, &framebuffer.stride,
&framebuffer.dev_priv_size, &framebuffer.dev_priv)) { &framebuffer.dev_priv_size,
&framebuffer.dev_priv)) {
ErrorMessageF("XF86DRIGetDeviceInfo failed"); ErrorMessageF("XF86DRIGetDeviceInfo failed");
goto handle_error; goto handle_error;
} }
@ -370,7 +379,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
/* Map the framebuffer region. */ /* Map the framebuffer region. */
status = drmMap(fd, hFB, framebuffer.size, status = drmMap(fd, hFB, framebuffer.size,
(drmAddressPtr)&framebuffer.base); (drmAddressPtr) & framebuffer.base);
if (status != 0) { if (status != 0) {
ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status)); ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status));
goto handle_error; goto handle_error;
@ -385,7 +394,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
goto handle_error; goto handle_error;
} }
psp = (*psc->legacy->createNewScreen)(scrn, psp = (*psc->legacy->createNewScreen) (scrn,
&ddx_version, &ddx_version,
&dri_version, &dri_version,
&drm_version, &drm_version,
@ -393,8 +402,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
pSAREA, pSAREA,
fd, fd,
loader_extensions, loader_extensions,
&driver_configs, &driver_configs, psc);
psc);
if (psp == NULL) { if (psp == NULL) {
ErrorMessageF("Calling driver entry point failed"); ErrorMessageF("Calling driver entry point failed");
@ -411,7 +419,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
drmUnmap(pSAREA, SAREA_MAX); drmUnmap(pSAREA, SAREA_MAX);
if (framebuffer.base != MAP_FAILED) if (framebuffer.base != MAP_FAILED)
drmUnmap((drmAddress)framebuffer.base, framebuffer.size); drmUnmap((drmAddress) framebuffer.base, framebuffer.size);
if (framebuffer.dev_priv != NULL) if (framebuffer.dev_priv != NULL)
Xfree(framebuffer.dev_priv); Xfree(framebuffer.dev_priv);
@ -429,7 +437,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
#else /* !GLX_USE_APPLEGL */ #else /* !GLX_USE_APPLEGL */
static void * static void *
CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc, CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
__GLXDRIdisplayPrivate * driDpy) __GLXDRIdisplayPrivate * driDpy)
{ {
return NULL; return NULL;
@ -437,40 +445,42 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
#endif /* !GLX_USE_APPLEGL */ #endif /* !GLX_USE_APPLEGL */
static void driDestroyContext(__GLXDRIcontext *context, static void
__GLXscreenConfigs *psc, Display *dpy) driDestroyContext(__GLXDRIcontext * context,
__GLXscreenConfigs * psc, Display * dpy)
{ {
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
(*psc->core->destroyContext)(pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);
XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
Xfree(pcp); Xfree(pcp);
} }
static Bool driBindContext(__GLXDRIcontext *context, static Bool
__GLXDRIdrawable *draw, __GLXDRIdrawable *read) driBindContext(__GLXDRIcontext * context,
__GLXDRIdrawable * draw, __GLXDRIdrawable * read)
{ {
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
const __DRIcoreExtension *core = pcp->psc->core; const __DRIcoreExtension *core = pcp->psc->core;
return (*core->bindContext)(pcp->driContext, return (*core->bindContext) (pcp->driContext,
draw->driDrawable, draw->driDrawable, read->driDrawable);
read->driDrawable);
} }
static void driUnbindContext(__GLXDRIcontext *context) static void
driUnbindContext(__GLXDRIcontext * context)
{ {
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
const __DRIcoreExtension *core = pcp->psc->core; const __DRIcoreExtension *core = pcp->psc->core;
(*core->unbindContext)(pcp->driContext); (*core->unbindContext) (pcp->driContext);
} }
static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc, static __GLXDRIcontext *
const __GLcontextModes *mode, driCreateContext(__GLXscreenConfigs * psc,
GLXContext gc, const __GLcontextModes * mode,
GLXContext shareList, int renderType) GLXContext gc, GLXContext shareList, int renderType)
{ {
__GLXDRIcontextPrivate *pcp, *pcp_shared; __GLXDRIcontextPrivate *pcp, *pcp_shared;
drm_context_t hwContext; drm_context_t hwContext;
@ -498,12 +508,9 @@ static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
} }
pcp->driContext = pcp->driContext =
(*psc->legacy->createNewContext)(psc->__driScreen, (*psc->legacy->createNewContext) (psc->__driScreen,
config->driConfig, config->driConfig,
renderType, renderType, shared, hwContext, pcp);
shared,
hwContext,
pcp);
if (pcp->driContext == NULL) { if (pcp->driContext == NULL) {
XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
Xfree(pcp); Xfree(pcp);
@ -517,19 +524,20 @@ static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
return &pcp->base; return &pcp->base;
} }
static void driDestroyDrawable(__GLXDRIdrawable *pdraw) static void
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{ {
__GLXscreenConfigs *psc = pdraw->psc; __GLXscreenConfigs *psc = pdraw->psc;
(*psc->core->destroyDrawable)(pdraw->driDrawable); (*psc->core->destroyDrawable) (pdraw->driDrawable);
XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable); XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);
Xfree(pdraw); Xfree(pdraw);
} }
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc, static __GLXDRIdrawable *
driCreateDrawable(__GLXscreenConfigs * psc,
XID xDrawable, XID xDrawable,
GLXDrawable drawable, GLXDrawable drawable, const __GLcontextModes * modes)
const __GLcontextModes *modes)
{ {
__GLXDRIdrawable *pdraw; __GLXDRIdrawable *pdraw;
drm_drawable_t hwDrawable; drm_drawable_t hwDrawable;
@ -552,12 +560,11 @@ static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
/* Create a new drawable */ /* Create a new drawable */
pdraw->driDrawable = pdraw->driDrawable =
(*psc->legacy->createNewDrawable)(psc->__driScreen, (*psc->legacy->createNewDrawable) (psc->__driScreen,
config->driConfig, config->driConfig,
hwDrawable, hwDrawable,
GLX_WINDOW_BIT, GLX_WINDOW_BIT,
empty_attribute_list, empty_attribute_list, pdraw);
pdraw);
if (!pdraw->driDrawable) { if (!pdraw->driDrawable) {
XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable); XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
@ -570,23 +577,26 @@ static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
return pdraw; return pdraw;
} }
static void driSwapBuffers(__GLXDRIdrawable *pdraw) static void
driSwapBuffers(__GLXDRIdrawable * pdraw)
{ {
(*pdraw->psc->core->swapBuffers)(pdraw->driDrawable); (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
} }
static void driDestroyScreen(__GLXscreenConfigs *psc) static void
driDestroyScreen(__GLXscreenConfigs * psc)
{ {
/* Free the direct rendering per screen data */ /* Free the direct rendering per screen data */
if (psc->__driScreen) if (psc->__driScreen)
(*psc->core->destroyScreen)(psc->__driScreen); (*psc->core->destroyScreen) (psc->__driScreen);
psc->__driScreen = NULL; psc->__driScreen = NULL;
if (psc->driver) if (psc->driver)
dlclose(psc->driver); dlclose(psc->driver);
} }
static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen, static __GLXDRIscreen *
__GLXdisplayPrivate *priv) driCreateScreen(__GLXscreenConfigs * psc, int screen,
__GLXdisplayPrivate * priv)
{ {
__GLXDRIdisplayPrivate *pdp; __GLXDRIdisplayPrivate *pdp;
__GLXDRIscreen *psp; __GLXDRIscreen *psp;
@ -633,8 +643,7 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
} }
pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay; pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay;
psc->__driScreen = psc->__driScreen = CallCreateNewScreen(psc->dpy, screen, psc, pdp);
CallCreateNewScreen(psc->dpy, screen, psc, pdp);
if (psc->__driScreen == NULL) { if (psc->__driScreen == NULL) {
dlclose(psc->driver); dlclose(psc->driver);
Xfree(psp); Xfree(psp);
@ -653,7 +662,8 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
/* Called from __glXFreeDisplayPrivate. /* Called from __glXFreeDisplayPrivate.
*/ */
static void driDestroyDisplay(__GLXDRIdisplay *dpy) static void
driDestroyDisplay(__GLXDRIdisplay * dpy)
{ {
Xfree(dpy); Xfree(dpy);
} }
@ -663,7 +673,8 @@ static void driDestroyDisplay(__GLXDRIdisplay *dpy)
* This is called from __glXInitialize() when we are given a new * This is called from __glXInitialize() when we are given a new
* display pointer. * display pointer.
*/ */
_X_HIDDEN __GLXDRIdisplay *driCreateDisplay(Display *dpy) _X_HIDDEN __GLXDRIdisplay *
driCreateDisplay(Display * dpy)
{ {
__GLXDRIdisplayPrivate *pdpyp; __GLXDRIdisplayPrivate *pdpyp;
int eventBase, errorBase; int eventBase, errorBase;