From b1097f24a8410b623deb52069ad7e66bae35944c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 16 Aug 2000 20:51:53 +0000 Subject: [PATCH] optimized glDrawPixels for glPixelZoom(1,-1) (Andrew Gee) --- src/mesa/main/drawpix.c | 110 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index fdb290e720f..02d618fc2df 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -1,4 +1,4 @@ -/* $Id: drawpix.c,v 1.27 2000/08/16 17:32:42 brianp Exp $ */ +/* $Id: drawpix.c,v 1.28 2000/08/16 20:51:53 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -176,11 +176,35 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, zoomY0 = 0; /* not used - silence compiler warning */ } + else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { + /* upside-down image */ + /* horizontal clipping */ + if (destX < ctx->DrawBuffer->Xmin) { + skipPixels += (ctx->DrawBuffer->Xmin - destX); + drawWidth -= (ctx->DrawBuffer->Xmin - destX); + destX = ctx->DrawBuffer->Xmin; + } + if (destX + drawWidth > ctx->DrawBuffer->Xmax) + drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax - 1); + if (drawWidth <= 0) + return GL_TRUE; + + /* vertical clipping */ + if (destY > ctx->DrawBuffer->Ymax) { + skipRows += (destY - ctx->DrawBuffer->Ymax - 1); + drawHeight -= (destY - ctx->DrawBuffer->Ymax - 1); + destY = ctx->DrawBuffer->Ymax + 1; + } + if (destY - drawHeight < ctx->DrawBuffer->Ymin) + drawHeight -= (ctx->DrawBuffer->Ymin - (destY - drawHeight)); + if (drawHeight <= 0) + return GL_TRUE; + } else { /* setup array of fragment Z value to pass to zoom function */ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; - assert(drawWidth < MAX_WIDTH); + ASSERT(drawWidth < MAX_WIDTH); for (i=0; iPixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { + /* upside-down */ + GLint row; + for (row=0; rowDriver.WriteRGBASpan)(ctx, drawWidth, destX, destY, + (void *) src, NULL); + src += rowLength * 4; + } + } else { /* with zooming */ GLint row; @@ -237,6 +271,16 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, destY++; } } + else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { + /* upside-down */ + GLint row; + for (row=0; rowDriver.WriteRGBSpan)(ctx, drawWidth, destX, destY, + (void *) src, NULL); + src += rowLength * 3; + } + } else { /* with zooming */ GLint row; @@ -257,7 +301,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { /* no zooming */ GLint row; - assert(drawWidth < MAX_WIDTH); + ASSERT(drawWidth < MAX_WIDTH); for (row=0; rowPixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { + /* upside-down */ + GLint row; + ASSERT(drawWidth < MAX_WIDTH); + for (row=0; rowDriver.WriteRGBSpan)(ctx, drawWidth, destX, destY, + (void *) rgb, NULL); + src += rowLength; + } + } else { /* with zooming */ GLint row; - assert(drawWidth < MAX_WIDTH); + ASSERT(drawWidth < MAX_WIDTH); for (row=0; rowPixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { /* no zooming */ GLint row; - assert(drawWidth < MAX_WIDTH); + ASSERT(drawWidth < MAX_WIDTH); for (row=0; rowPixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { + /* upside-down */ + GLint row; + ASSERT(drawWidth < MAX_WIDTH); + for (row=0; rowDriver.WriteRGBASpan)(ctx, drawWidth, destX, destY, + (void *) rgba, NULL); + src += rowLength*2; + } + } else { /* with zooming */ GLint row; - assert(drawWidth < MAX_WIDTH); + ASSERT(drawWidth < MAX_WIDTH); for (row=0; rowDriver.WriteRGBASpan)(ctx, drawWidth, destX, destY, (const GLubyte (*)[4])rgba, @@ -354,11 +434,25 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, } return GL_TRUE; } + else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { + /* upside-down */ + GLint row; + for (row=0; rowDriver.WriteRGBASpan)(ctx, drawWidth, destX, destY, + (const GLubyte (*)[4])rgba, + NULL); + src += rowLength; + } + return GL_TRUE; + } else { /* with zooming */ GLint row; for (row=0; row