Refactor savageXMesaSet{Back,Front}ClipRects.
authorIan Romanick <idr@us.ibm.com>
Fri, 10 Nov 2006 18:57:30 +0000 (18:57 +0000)
committerIan Romanick <idr@us.ibm.com>
Fri, 10 Nov 2006 18:57:30 +0000 (18:57 +0000)
Refactor savageXMesaSetBackClipRects and savageXMesaSetFrontClipRects
into a single new routine called savageXMesaSetClipRects.  This allows
a few cleanups in the code.

src/mesa/drivers/dri/savage/savage_init.h
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagestate.c

index 9cf8e66b7c2a8b11919291a64847641a70b22adb..43fb969c693923eaf366b2a2a53bcee9c784aa42 100644 (file)
@@ -83,8 +83,7 @@ typedef struct {
 #include "savagecontext.h"
 
 extern void savageGetLock( savageContextPtr imesa, GLuint flags );
-extern void savageXMesaSetBackClipRects( savageContextPtr imesa );
-extern void savageXMesaSetFrontClipRects( savageContextPtr imesa );
+extern void savageXMesaSetClipRects(savageContextPtr imesa);
 
 
 #define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
index f8d68d7874eae519767766a010fab3072607e97b..f51e321a4a61277b2b228b5db2fba6d1d463c676 100644 (file)
@@ -724,34 +724,18 @@ void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
 }
 #endif
 
-void savageXMesaSetFrontClipRects( savageContextPtr imesa )
-{
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
-
-   imesa->numClipRects = dPriv->numClipRects;
-   imesa->pClipRects = dPriv->pClipRects;
-   imesa->drawX = dPriv->x;
-   imesa->drawY = dPriv->y;
-
-   savageCalcViewport( imesa->glCtx );
-}
-
 
-void savageXMesaSetBackClipRects( savageContextPtr imesa )
+void savageXMesaSetClipRects(savageContextPtr imesa)
 {
    __DRIdrawablePrivate *dPriv = imesa->driDrawable;
 
-   if (dPriv->numBackClipRects == 0) 
-   {
-
-
+   if ((dPriv->numBackClipRects == 0)
+       || (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)) {
       imesa->numClipRects = dPriv->numClipRects;
       imesa->pClipRects = dPriv->pClipRects;
       imesa->drawX = dPriv->x;
       imesa->drawY = dPriv->y;
    } else {
-
-
       imesa->numClipRects = dPriv->numBackClipRects;
       imesa->pClipRects = dPriv->pBackClipRects;
       imesa->drawX = dPriv->backX;
@@ -770,16 +754,7 @@ static void savageXMesaWindowMoved( savageContextPtr imesa )
    if (0)
       fprintf(stderr, "savageXMesaWindowMoved\n\n");
 
-   switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
-   case BUFFER_BIT_FRONT_LEFT:
-      savageXMesaSetFrontClipRects( imesa );
-      break;
-   case BUFFER_BIT_BACK_LEFT:
-      savageXMesaSetBackClipRects( imesa );
-      break;
-   default:
-       break;
-   }
+   savageXMesaSetClipRects(imesa);
 
    driUpdateFramebufferSize(imesa->glCtx, drawable);
    if (drawable != readable) {
index e554afdbb7ed30653f00feadb5f435b84c1436c4..2f20dc23b6efef3df934b74cbb7fb6722cf12a07 100644 (file)
@@ -647,23 +647,20 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
     case BUFFER_BIT_FRONT_LEFT:
         imesa->IsDouble = GL_FALSE;
        imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11;
-
-        imesa->NotFirstFrame = GL_FALSE;
-        savageXMesaSetFrontClipRects( imesa );
-       FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
        break;
     case BUFFER_BIT_BACK_LEFT:
         imesa->IsDouble = GL_TRUE;
        imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
-        imesa->NotFirstFrame = GL_FALSE;
-        savageXMesaSetBackClipRects( imesa );
-       FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
        break;
     default:
        FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_TRUE );
        return;
     }
     
+    imesa->NotFirstFrame = GL_FALSE;
+    savageXMesaSetClipRects(imesa);
+    FALLBACK(ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE);
+
     if (destCtrl != imesa->regs.s4.destCtrl.ui)
         imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
 }