/* * Draw color index image. */ static void draw_index_pixels( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels ) { const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; GLint row, skipPixels; struct sw_span span; INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); if (ctx->Depth.Test) _swrast_span_default_z(ctx, &span); if (ctx->Fog.Enabled) _swrast_span_default_fog(ctx, &span); /* * General solution */ skipPixels = 0; while (skipPixels < width) { const GLint spanX = x + (zoom ? 0 : skipPixels); GLint spanY = y; const GLint spanEnd = (width - skipPixels > MAX_WIDTH) ? MAX_WIDTH : (width - skipPixels); ASSERT(spanEnd <= MAX_WIDTH); for (row = 0; row < height; row++, spanY++) { const GLvoid *source = _mesa_image_address2d(unpack, pixels, width, height, GL_COLOR_INDEX, type, row, skipPixels); _mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT, span.array->index, type, source, unpack, ctx->_ImageTransferState); /* These may get changed during writing/clipping */ span.x = spanX; span.y = spanY; span.end = spanEnd; if (zoom) _swrast_write_zoomed_index_span(ctx, &span, y, skipPixels); else _swrast_write_index_span(ctx, &span); } skipPixels += spanEnd; } }
/* * Draw color index image. */ static void draw_index_pixels( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels ) { const GLint imgX = x, imgY = y; const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; GLint row, skipPixels; SWspan span; INIT_SPAN(span, GL_BITMAP); span.arrayMask = SPAN_INDEX; _swrast_span_default_attribs(ctx, &span); /* * General solution */ skipPixels = 0; while (skipPixels < width) { const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); ASSERT(spanWidth <= MAX_WIDTH); for (row = 0; row < height; row++) { const GLvoid *source = _mesa_image_address2d(unpack, pixels, width, height, GL_COLOR_INDEX, type, row, skipPixels); _mesa_unpack_index_span(ctx, spanWidth, GL_UNSIGNED_INT, span.array->index, type, source, unpack, ctx->_ImageTransferState); /* These may get changed during writing/clipping */ span.x = x + skipPixels; span.y = y + row; span.end = spanWidth; if (zoom) _swrast_write_zoomed_index_span(ctx, imgX, imgY, &span); else _swrast_write_index_span(ctx, &span); } skipPixels += spanWidth; } }
/* * Draw stencil image. */ static void draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels ) { const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLint desty = y; GLint row, skipPixels; if (type != GL_BYTE && type != GL_UNSIGNED_BYTE && type != GL_SHORT && type != GL_UNSIGNED_SHORT && type != GL_INT && type != GL_UNSIGNED_INT && type != GL_FLOAT && type != GL_BITMAP) { _mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(stencil type)"); return; } if (ctx->Visual.stencilBits == 0) { _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawPixels(no stencil buffer)"); return; } /* if width > MAX_WIDTH, have to process image in chunks */ skipPixels = 0; while (skipPixels < width) { const GLint spanX = x; GLint spanY = y; const GLint spanWidth = (width - skipPixels > MAX_WIDTH) ? MAX_WIDTH : (width - skipPixels); for (row = 0; row < height; row++, spanY++) { GLstencil values[MAX_WIDTH]; GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte)) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; const GLvoid *source = _mesa_image_address2d(unpack, pixels, width, height, GL_COLOR_INDEX, type, row, skipPixels); _mesa_unpack_index_span(ctx, spanWidth, destType, values, type, source, unpack, ctx->_ImageTransferState); if (ctx->_ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) { _mesa_shift_and_offset_stencil(ctx, spanWidth, values); } if (ctx->Pixel.MapStencilFlag) { _mesa_map_stencil(ctx, spanWidth, values); } if (zoom) { _swrast_write_zoomed_stencil_span(ctx, (GLuint) spanWidth, spanX, spanY, values, desty, 0); } else { _swrast_write_stencil_span(ctx, (GLuint) spanWidth, spanX, spanY, values); } } skipPixels += spanWidth; } }