From 005e31d3de04e7003f84a94d30f2b75a9636266e Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 15 Feb 2008 00:01:32 +0000 Subject: AIGLX: Refactor code common between __glXDRI{drawableDestroy,releaseTexImage}. --- GL/glx/glxdri.c | 101 +++++++++++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 63 deletions(-) (limited to 'GL/glx') diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c index e405ee06f..304fed2bd 100644 --- a/GL/glx/glxdri.c +++ b/GL/glx/glxdri.c @@ -180,46 +180,53 @@ __glXDRIenterServer(GLboolean rendering) DRIWakeupHandler(NULL, 0, NULL); } + static void -__glXDRIdrawableDestroy(__GLXdrawable *drawable) +__glXDRIdoReleaseTexImage(__GLXDRIscreen *screen, __GLXDRIdrawable *drawable) { - __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable; + GLuint lastOverride = screen->lastTexOffsetOverride; - int i; + if (lastOverride) { + __GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride; + int i; - for (i = 0; i < screenInfo.numScreens; i++) { - __GLXDRIscreen * const screen = (__GLXDRIscreen *) - glxGetScreen(screenInfo.screens[i]); + for (i = 0; i < lastOverride; i++) { + if (texOffsetOverride[i] == drawable) { - GLuint lastOverride = screen->lastTexOffsetOverride; + texOffsetOverride[i] = NULL; - if (lastOverride) { - __GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride; - int i; - - for (i = 0; i < lastOverride; i++) { - if (texOffsetOverride[i] == private) { - - texOffsetOverride[i] = NULL; - - if (i + 1 == lastOverride) { - lastOverride = 0; - - while (i--) { - if (texOffsetOverride[i]) { - lastOverride = i + 1; - break; - } + if (i + 1 == lastOverride) { + lastOverride = 0; + + while (i--) { + if (texOffsetOverride[i]) { + lastOverride = i + 1; + break; } - - screen->lastTexOffsetOverride = lastOverride; - - break; } + + screen->lastTexOffsetOverride = lastOverride; + + break; } } } } +} + + +static void +__glXDRIdrawableDestroy(__GLXdrawable *drawable) +{ + __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable; + + int i; + + for (i = 0; i < screenInfo.numScreens; i++) { + __glXDRIdoReleaseTexImage((__GLXDRIscreen *) + glxGetScreen(screenInfo.screens[i]), + private); + } (*private->driDrawable.destroyDrawable)(&private->driDrawable); @@ -561,41 +568,9 @@ __glXDRIreleaseTexImage(__GLXcontext *baseContext, int buffer, __GLXdrawable *pixmap) { - ScreenPtr pScreen = pixmap->pDraw->pScreen; - __GLXDRIdrawable *driDraw = - containerOf(pixmap, __GLXDRIdrawable, base); - __GLXDRIscreen * const screen = - (__GLXDRIscreen *) glxGetScreen(pScreen); - GLuint lastOverride = screen->lastTexOffsetOverride; - - if (lastOverride) { - __GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride; - int i; - - for (i = 0; i < lastOverride; i++) { - if (texOffsetOverride[i] == driDraw) { - if (screen->texOffsetFinish) - screen->texOffsetFinish((PixmapPtr)pixmap->pDraw); - - texOffsetOverride[i] = NULL; - - if (i + 1 == lastOverride) { - lastOverride = 0; - - while (i--) { - if (texOffsetOverride[i]) { - lastOverride = i + 1; - break; - } - } - - screen->lastTexOffsetOverride = lastOverride; - - break; - } - } - } - } + __glXDRIdoReleaseTexImage((__GLXDRIscreen *) + glxGetScreen(pixmap->pDraw->pScreen), + containerOf(pixmap, __GLXDRIdrawable, base)); return Success; } -- cgit v1.2.3