/* $Id: s_zoom.c,v 1.11 2002/01/28 03:42:28 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 4.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "glheader.h" #include "macros.h" #include "mem.h" #include "colormac.h" #include "s_context.h" #include "s_span.h" #include "s_stencil.h" #include "s_zoom.h" #ifdef DEBUG #define SAVE_SPAN(span) struct sw_span tmp_span = (span); #define RESTORE_SPAN(span) \ { \ GLint i; \ for (i=tmp_span.start; iDrawBuffer->Width, MAX_WIDTH ); struct sw_span zoomed; INIT_SPAN(zoomed); zoomed.arrayMask |= SPAN_RGBA; /* compute width of output row */ zoomed.end = (GLint) ABSF( n * ctx->Pixel.ZoomX ); if (zoomed.end == 0) { return; } /*here ok or better latter? like it was before */ else if (zoomed.end > maxwidth) { zoomed.end = maxwidth; } if (ctx->Pixel.ZoomX<0.0) { /* adjust x coordinate for left/right mirroring */ zoomed.x = x - zoomed.end; } else zoomed.x = x; /* compute which rows to draw */ row = y-y0; r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); if (r0==r1) { return; } else if (r1=ctx->DrawBuffer->Height && r1>=ctx->DrawBuffer->Height) { /* above window */ return; } /* check if left edge is outside window */ if (zoomed.x < 0) { zoomed.start = -x; } /* make sure span isn't too long or short */ /* if (m>maxwidth) { m = maxwidth; }*/ if (zoomed.end <= zoomed.start) { return; } ASSERT( zoomed.end <= MAX_WIDTH ); /* zoom the span horizontally */ if (ctx->Pixel.ZoomX==-1.0F) { /* n==m */ for (j=zoomed.start; jFog.Enabled) { for (j=zoomed.start; jPixel.ZoomX; for (j=zoomed.start; jFog.Enabled) { for (j=zoomed.start; jDrawBuffer->Width, MAX_WIDTH ); struct sw_span zoomed; INIT_SPAN(zoomed); zoomed.arrayMask |= SPAN_RGBA; if (fog && ctx->Fog.Enabled) zoomed.arrayMask |= SPAN_FOG; /* compute width of output row */ m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); if (m==0) { return; } if (ctx->Pixel.ZoomX<0.0) { /* adjust x coordinate for left/right mirroring */ x = x - m; } /* compute which rows to draw */ row = y-y0; r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); if (r0==r1) { return; } else if (r1=ctx->DrawBuffer->Height && r1>=ctx->DrawBuffer->Height) { /* above window */ return; } /* check if left edge is outside window */ skipcol = 0; if (x<0) { skipcol = -x; m += x; } /* make sure span isn't too long or short */ if (m>maxwidth) { m = maxwidth; } else if (m<=0) { return; } ASSERT( m <= MAX_WIDTH ); /* zoom the span horizontally */ if (ctx->Pixel.ZoomX==-1.0F) { /* n==m */ for (j=0;jPixel.ZoomX; for (j=0;jDrawBuffer->Width, MAX_WIDTH ); struct sw_span zoomed; INIT_SPAN(zoomed); zoomed.arrayMask |= SPAN_INDEX; /* compute width of output row */ m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); if (m==0) { return; } if (ctx->Pixel.ZoomX<0.0) { /* adjust x coordinate for left/right mirroring */ x = x - m; } /* compute which rows to draw */ row = y-y0; r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); if (r0==r1) { return; } else if (r1=ctx->DrawBuffer->Height && r1>=ctx->DrawBuffer->Height) { /* above window */ return; } /* check if left edge is outside window */ skipcol = 0; if (x<0) { skipcol = -x; m += x; } /* make sure span isn't too long or short */ if (m>maxwidth) { m = maxwidth; } else if (m<=0) { return; } ASSERT( m <= MAX_WIDTH ); /* zoom the span horizontally */ if (ctx->Pixel.ZoomX==-1.0F) { /* n==m */ for (j=0;jFog.Enabled) { for (j=0;jPixel.ZoomX; for (j=0;jFog.Enabled) { for (j=0;jDrawBuffer->Width, MAX_WIDTH ); /* compute width of output row */ m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); if (m==0) { return; } if (ctx->Pixel.ZoomX<0.0) { /* adjust x coordinate for left/right mirroring */ x = x - m; } /* compute which rows to draw */ row = y-y0; r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); if (r0==r1) { return; } else if (r1=ctx->DrawBuffer->Height && r1>=ctx->DrawBuffer->Height) { /* above window */ return; } /* check if left edge is outside window */ skipcol = 0; if (x<0) { skipcol = -x; m += x; } /* make sure span isn't too long or short */ if (m>maxwidth) { m = maxwidth; } else if (m<=0) { return; } ASSERT( m <= MAX_WIDTH ); /* zoom the span horizontally */ if (ctx->Pixel.ZoomX==-1.0F) { /* n==m */ for (j=0;jPixel.ZoomX; for (j=0;j