-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810ioctl.c,v 1.7 2002/10/30 12:51:33 alanh Exp $ */
#include <unistd.h> /* for usleep() */
-#include "glheader.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "dd.h"
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/dd.h"
#include "swrast/swrast.h"
-#include "mm.h"
+#include "main/mm.h"
#include "i810screen.h"
#include "i810_dri.h"
-#include "i810context.h"
+#include "main/context.h"
#include "i810ioctl.h"
#include "i810state.h"
#define DEPTH_SCALE ((1<<16)-1)
-static void i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch )
+static void i810Clear( struct gl_context *ctx, GLbitfield mask )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ __DRIdrawable *dPriv = imesa->driDrawable;
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask[0]);
drmI810Clear clear;
- int i;
+ unsigned int i;
clear.flags = 0;
clear.clear_color = imesa->ClearColor;
I810_FIREVERTICES( imesa );
- if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
+ if ((mask & BUFFER_BIT_FRONT_LEFT) && colorMask == ~0U) {
clear.flags |= I810_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) {
+ if ((mask & BUFFER_BIT_BACK_LEFT) && colorMask == ~0U) {
clear.flags |= I810_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if (mask & DD_DEPTH_BIT) {
+ if (mask & BUFFER_BIT_DEPTH) {
if (ctx->Depth.Mask)
clear.flags |= I810_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
if (clear.flags) {
+ GLint cx, cy, cw, ch;
+
LOCK_HARDWARE( imesa );
+ /* compute region after locking: */
+ cx = ctx->DrawBuffer->_Xmin;
+ cy = ctx->DrawBuffer->_Ymin;
+ cw = ctx->DrawBuffer->_Xmax - cx;
+ ch = ctx->DrawBuffer->_Ymax - cy;
+
/* flip top to bottom */
cy = dPriv->h-cy-ch;
cx += imesa->drawX;
for (i = 0 ; i < imesa->numClipRects ; )
{
- int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, imesa->numClipRects);
+ unsigned int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, imesa->numClipRects);
drm_clip_rect_t *box = imesa->pClipRects;
drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
int n = 0;
- if (!all) {
+ if (cw != dPriv->w || ch != dPriv->h) {
+ /* clear sub region */
for ( ; i < nr ; i++) {
GLint x = box[i].x1;
GLint y = box[i].y1;
n++;
}
} else {
+ /* clear whole buffer */
for ( ; i < nr ; i++) {
*b++ = box[i];
n++;
}
if (mask)
- _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+ _swrast_Clear( ctx, mask );
}
/*
* Copy the back buffer to the front buffer.
*/
-void i810CopyBuffer( const __DRIdrawablePrivate *dPriv )
+void i810CopyBuffer( const __DRIdrawable *dPriv )
{
i810ContextPtr imesa;
drm_clip_rect_t *pbox;
/*
* XXX implement when full-screen extension is done.
*/
-void i810PageFlip( const __DRIdrawablePrivate *dPriv )
+void i810PageFlip( const __DRIdrawable *dPriv )
{
i810ContextPtr imesa;
int tmp, ret;
}
/* i810SetDrawBuffer( imesa->glCtx, imesa->glCtx->Color.DriverDrawBuffer );*/
- i810DrawBuffer( imesa->glCtx, imesa->glCtx->Color.DrawBuffer );
+ i810DrawBuffer( imesa->glCtx, imesa->glCtx->Color.DrawBuffer[0] );
imesa->upload_cliprects = GL_TRUE;
imesa->lastSwap = tmp;
return;
return(drmCommandNone(fd, DRM_I810_DOCOPY));
}
-static void i810Flush( GLcontext *ctx )
+static void i810Flush( struct gl_context *ctx )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
I810_FIREVERTICES( imesa );
}
-static void i810Finish( GLcontext *ctx )
+static void i810Finish( struct gl_context *ctx )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
i810DmaFinish( imesa );