-/* $Id: s_zoom.c,v 1.17 2002/08/07 00:45:07 brianp Exp $ */
+/* $Id: s_zoom.c,v 1.24 2003/03/25 02:23:48 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
#include "glheader.h"
#include "macros.h"
-#include "mem.h"
+#include "imports.h"
#include "colormac.h"
#include "s_context.h"
/*
- * Helper function called from _mesa_write_zoomed_rgba/rgb/index_span().
+ * Helper function called from _swrast_write_zoomed_rgba/rgb/index_span().
*/
static void
zoom_span( GLcontext *ctx, const struct sw_span *span,
- const GLvoid *src, GLint y0, GLenum format )
+ const GLvoid *src, GLint y0, GLenum format, GLint skipPixels )
{
GLint r0, r1, row;
GLint c0, c1, skipCol;
INIT_SPAN(zoomed, GL_BITMAP, 0, 0, 0);
zoomed.array = &zoomed_arrays;
+ zoomed.z = span->z;
+ zoomed.zStep = span->zStep; /* span->zStep == 0 */
+ zoomed.fog = span->fog;
+ zoomed.fogStep = span->fogStep;
if (format == GL_RGBA || format == GL_RGB) {
- zoomed.z = span->z;
- zoomed.zStep = span->z;
- zoomed.fog = span->fog;
- zoomed.fogStep = span->fogStep;
zoomed.interpMask = span->interpMask & ~SPAN_RGBA;
zoomed.arrayMask |= SPAN_RGBA;
}
else if (format == GL_COLOR_INDEX) {
- zoomed.z = span->z;
- zoomed.zStep = span->z;
- zoomed.fog = span->fog;
- zoomed.fogStep = span->fogStep;
zoomed.interpMask = span->interpMask & ~SPAN_INDEX;
zoomed.arrayMask |= SPAN_INDEX;
}
/*
* Compute which columns to draw: [c0, c1)
*/
+#if 0
c0 = (GLint) span->x;
c1 = (GLint) (span->x + span->end * ctx->Pixel.ZoomX);
+#else
+ c0 = (GLint) (span->x + skipPixels * ctx->Pixel.ZoomX);
+ c1 = (GLint) (span->x + (skipPixels + span->end) * ctx->Pixel.ZoomX);
+#endif
if (c0 == c1) {
return;
}
const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
i = (GLint) ((j + skipCol) * xscale);
- if (i < 0)
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
COPY_CHAN4(zoomed.array->rgba[j], rgba[i]);
}
}
const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
i = (GLint) ((j + skipCol) * xscale);
- if (i < 0)
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
zoomed.array->rgba[j][0] = rgb[i][0];
zoomed.array->rgba[j][1] = rgb[i][1];
zoomed.array->rgba[j][2] = rgb[i][2];
const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
i = (GLint) ((j + skipCol) * xscale);
- if (i < 0)
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
zoomed.array->index[j] = indexes[i];
}
}
/* write the span in rows [r0, r1) */
if (format == GL_RGBA || format == GL_RGB) {
/* Writing the span may modify the colors, so make a backup now if we're
- * going to call _mesa_write_zoomed_span() more than once.
+ * going to call _swrast_write_zoomed_span() more than once.
+ * Also, clipping may change the span end value, so store it as well.
*/
+ const GLint end = zoomed.end; /* save */
if (r1 - r0 > 1) {
MEMCPY(rgbaSave, zoomed.array->rgba, zoomed.end * 4 * sizeof(GLchan));
}
for (zoomed.y = r0; zoomed.y < r1; zoomed.y++) {
- _mesa_write_rgba_span(ctx, &zoomed);
+ _swrast_write_rgba_span(ctx, &zoomed);
+ zoomed.end = end; /* restore */
if (r1 - r0 > 1) {
/* restore the colors */
MEMCPY(zoomed.array->rgba, rgbaSave, zoomed.end*4 * sizeof(GLchan));
}
}
else if (format == GL_COLOR_INDEX) {
+ const GLint end = zoomed.end; /* save */
if (r1 - r0 > 1) {
MEMCPY(indexSave, zoomed.array->index, zoomed.end * sizeof(GLuint));
}
for (zoomed.y = r0; zoomed.y < r1; zoomed.y++) {
- _mesa_write_index_span(ctx, &zoomed);
+ _swrast_write_index_span(ctx, &zoomed);
+ zoomed.end = end; /* restore */
if (r1 - r0 > 1) {
/* restore the colors */
MEMCPY(zoomed.array->index, indexSave, zoomed.end * sizeof(GLuint));
void
-_mesa_write_zoomed_rgba_span( GLcontext *ctx, const struct sw_span *span,
- CONST GLchan rgba[][4], GLint y0 )
+_swrast_write_zoomed_rgba_span( GLcontext *ctx, const struct sw_span *span,
+ CONST GLchan rgba[][4], GLint y0,
+ GLint skipPixels )
{
- zoom_span(ctx, span, (const GLvoid *) rgba, y0, GL_RGBA);
+ zoom_span(ctx, span, (const GLvoid *) rgba, y0, GL_RGBA, skipPixels);
}
void
-_mesa_write_zoomed_rgb_span( GLcontext *ctx, const struct sw_span *span,
- CONST GLchan rgb[][3], GLint y0 )
+_swrast_write_zoomed_rgb_span( GLcontext *ctx, const struct sw_span *span,
+ CONST GLchan rgb[][3], GLint y0,
+ GLint skipPixels )
{
- zoom_span(ctx, span, (const GLvoid *) rgb, y0, GL_RGB);
+ zoom_span(ctx, span, (const GLvoid *) rgb, y0, GL_RGB, skipPixels);
}
void
-_mesa_write_zoomed_index_span( GLcontext *ctx, const struct sw_span *span,
- GLint y0 )
+_swrast_write_zoomed_index_span( GLcontext *ctx, const struct sw_span *span,
+ GLint y0, GLint skipPixels )
{
- zoom_span(ctx, span, (const GLvoid *) span->array->index, y0, GL_COLOR_INDEX);
+ zoom_span(ctx, span, (const GLvoid *) span->array->index, y0,
+ GL_COLOR_INDEX, skipPixels);
}
* As above, but write stencil values.
*/
void
-_mesa_write_zoomed_stencil_span( GLcontext *ctx,
+_swrast_write_zoomed_stencil_span( GLcontext *ctx,
GLuint n, GLint x, GLint y,
- const GLstencil stencil[], GLint y0 )
+ const GLstencil stencil[], GLint y0,
+ GLint skipPixels )
{
GLint m;
GLint r0, r1, row, r;
GLstencil zstencil[MAX_WIDTH]; /* zoomed stencil values */
GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+ (void) skipPixels; /* XXX this shouldn't be ignored */
+
/* compute width of output row */
- m = (GLint) ABSF( n * ctx->Pixel.ZoomX );
+ m = (GLint) FABSF( n * ctx->Pixel.ZoomX );
if (m==0) {
return;
}
}
/* compute which rows to draw */
- row = y-y0;
+ row = y - y0;
r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY);
r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY);
if (r0==r1) {
/* write the span */
for (r=r0; r<r1; r++) {
- _mesa_write_stencil_span( ctx, m, x+skipcol, r, zstencil );
+ _swrast_write_stencil_span( ctx, m, x+skipcol, r, zstencil );
}
}