Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / drivers / dri / ffb / ffb_clear.c
index 5285774f6f2a4fb53be995871d00b1d29830b432..aa3fa0a86c5961d894b81e858a117c1965a1e1e8 100644 (file)
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c,v 1.2 2002/02/22 21:32:58 dawes Exp $
+/* 
  *
  * GLX Hardware Device Driver for Sun Creator/Creator3D
  * Copyright (C) 2000 David S. Miller
  *    David S. Miller <davem@redhat.com>
  */
 
-#include "mtypes.h"
-#include "extensions.h"
+#include "main/mtypes.h"
 
-#include "mm.h"
+#include "main/mm.h"
 #include "ffb_dd.h"
 #include "ffb_span.h"
-#include "ffb_depth.h"
 #include "ffb_context.h"
 #include "ffb_vb.h"
-#include "ffb_tris.h"
 #include "ffb_clear.h"
 #include "ffb_lock.h"
 
@@ -79,7 +76,7 @@ struct ff_fixups {
 /* Compute fixups of non-page aligned areas after a page fill.
  * Return the number of fixups needed.
  */
-static __inline__ int
+static INLINE int
 CreatorComputePageFillFixups(struct ff_fixups *fixups,
                             int x, int y, int w, int h,
                             int paligned_x, int paligned_y,
@@ -123,16 +120,22 @@ CreatorComputePageFillFixups(struct ff_fixups *fixups,
 }
 
 static void
-ffb_do_clear(ffbContextPtr fmesa, __DRIdrawablePrivate *dPriv,
-            GLboolean all, GLint cx, GLint cy, GLint cwidth,
-            GLint cheight)
+ffb_do_clear(GLcontext *ctx, __DRIdrawable *dPriv)
 {
+       ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        FFBDRIPtr gDRIPriv = (FFBDRIPtr) fmesa->driScreen->pDevPriv;
        ffb_fbcPtr ffb = fmesa->regs;
-       XF86DRIClipRectPtr box = dPriv->pClipRects;
+       drm_clip_rect_t *box = dPriv->pClipRects;
        int nc = dPriv->numClipRects;
+       GLint cx, cy, cw, ch;
+
+       /* compute region after locking: */
+       cx = ctx->DrawBuffer->_Xmin;
+       cy = ctx->DrawBuffer->_Ymin;
+       cw = ctx->DrawBuffer->_Xmax - cx;
+       ch = ctx->DrawBuffer->_Ymax - cy;
 
-       cy  = dPriv->h - cy - cheight;
+       cy  = dPriv->h - cy - ch;
        cx += dPriv->x;
        cy += dPriv->y;
 
@@ -145,25 +148,6 @@ ffb_do_clear(ffbContextPtr fmesa, __DRIdrawablePrivate *dPriv,
                int paligned_h, paligned_w = 0;
                int extra_work;
 
-               if (!all) {
-                       if (x < cx) {
-                               width -= cx - x;
-                               x = cx;
-                       }
-                       if (y < cy) {
-                               height -= cy - y;
-                               y = cy;
-                       }
-                       if (x + width > cx + cwidth)
-                               width = cx + cwidth - x;
-                       if (y + height > cy + cheight)
-                               height = cy + cheight - y;
-                       if (width <= 0)
-                               continue;
-                       if (height <= 0)
-                               continue;
-               }
-
                if (BOX_AREA(width, height) < gDRIPriv->fastfill_small_area) {
                        FFBFifo(fmesa, 5);
                        ffb->drawop = FFB_DRAWOP_RECTANGLE;
@@ -262,22 +246,19 @@ ffb_do_clear(ffbContextPtr fmesa, __DRIdrawablePrivate *dPriv,
        }
 }
 
-void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
-               GLint cx, GLint cy, GLint cwidth, GLint cheight)
+void ffbDDClear(GLcontext *ctx, GLbitfield mask)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
-       unsigned int stcmask = DD_STENCIL_BIT;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
+       unsigned int stcmask = BUFFER_BIT_STENCIL;
 
 #ifdef CLEAR_TRACE
-       fprintf(stderr, "ffbDDClear: mask(%08x) all(%d) "
-               "[x(%x)y(%x)w(%x)h(%x)]\n",
-               mask, (int) all, cx, cy, cwidth, cheight);
+       fprintf(stderr, "ffbDDClear: mask(%08x) \n", mask);
 #endif
        if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS))
                stcmask = 0;
 
-       if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT | stcmask)) {
+       if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH | stcmask)) {
                ffb_fbcPtr ffb = fmesa->regs;
                unsigned int fbc, ppc;
 
@@ -288,20 +269,20 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
                       FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
 
                /* Y/X enables must be both on or both off. */
-               if (mask & (DD_DEPTH_BIT | stcmask)) {
+               if (mask & (BUFFER_BIT_DEPTH | stcmask)) {
                        fbc |= (FFB_FBC_ZE_ON | FFB_FBC_YE_ON | FFB_FBC_WB_C);
                } else
                        fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF;
 
                /* All RGB enables must be both on or both off. */
-               if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
-                       if (mask & DD_FRONT_LEFT_BIT) {
+               if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
+                       if (mask & BUFFER_BIT_FRONT_LEFT) {
                                if (fmesa->back_buffer == 0)
                                        fbc |= FFB_FBC_WB_B;
                                else
                                        fbc |= FFB_FBC_WB_A;
                        }
-                       if (mask & DD_BACK_LEFT_BIT) {
+                       if (mask & BUFFER_BIT_BACK_LEFT) {
                                if (fmesa->back_buffer == 0)
                                        fbc |= FFB_FBC_WB_A;
                                else
@@ -321,14 +302,14 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
                        ffb->cmp = 0x80808080;
                        ffb->rop = FFB_ROP_NEW;
 
-                       if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT))
+                       if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
                                ffb->fg = fmesa->clear_pixel;
-                       if (mask & DD_DEPTH_BIT)
+                       if (mask & BUFFER_BIT_DEPTH)
                                ffb->constz = fmesa->clear_depth;
                        if (mask & stcmask)
                                ffb->consty = fmesa->clear_stencil;
 
-                       ffb_do_clear(fmesa, dPriv, all, cx, cy, cwidth, cheight);
+                       ffb_do_clear(ctx, dPriv);
 
                        FFBFifo(fmesa, 6);
                        ffb->ppc = fmesa->ppc;
@@ -344,11 +325,11 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
 
                UNLOCK_HARDWARE(fmesa);
 
-               mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT |
-                         DD_DEPTH_BIT | stcmask);
+               mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
+                         BUFFER_BIT_DEPTH | stcmask);
        }
 
        if (mask) 
-               _swrast_Clear(ctx, mask, all, cx, cy, cwidth, cheight);
+               _swrast_Clear(ctx, mask);
 }