- /*
- * Ready to draw!
- * The window region at (destX, destY) of size (drawWidth, drawHeight)
- * will be written to.
- * We'll take pixel data from buffer pointed to by "pixels" but we'll
- * skip "skipRows" rows and skip "skipPixels" pixels/row.
- */
-
- if (format==GL_RGBA && type==GL_UNSIGNED_BYTE) {
- if (ctx->Visual->RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
- + (skipRows * rowLength + skipPixels) * 4;
- if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
- /* no zooming */
- GLint row;
- for (row=0; row<drawHeight; row++) {
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (void *) src, NULL);
- src += rowLength * 4;
- destY++;
- }
- }
- else {
- /* with zooming */
- GLint row;
- for (row=0; row<drawHeight; row++) {
- gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
- zSpan, (void *) src, zoomY0);
- src += rowLength * 4;
- destY++;
- }
- }
- }
- return GL_TRUE;
- }
- else if (format==GL_RGB && type==GL_UNSIGNED_BYTE) {
- if (ctx->Visual->RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
- + (skipRows * rowLength + skipPixels) * 3;
- if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
- GLint row;
- for (row=0; row<drawHeight; row++) {
- (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
- (void *) src, NULL);
- src += rowLength * 3;
- destY++;
- }
- }
- else {
- /* with zooming */
- GLint row;
- for (row=0; row<drawHeight; row++) {
- gl_write_zoomed_rgb_span(ctx, drawWidth, destX, destY,
- zSpan, (void *) src, zoomY0);
- src += rowLength * 3;
- destY++;
- }
- }
- }
- return GL_TRUE;
- }
- else if (format==GL_LUMINANCE && type==GL_UNSIGNED_BYTE) {
- if (ctx->Visual->RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
- + (skipRows * rowLength + skipPixels);
- if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
- /* no zooming */
- GLint row;
- assert(drawWidth < MAX_WIDTH);
- for (row=0; row<drawHeight; row++) {
- GLint i;
- for (i=0;i<drawWidth;i++) {
- rgb[i][0] = src[i];
- rgb[i][1] = src[i];
- rgb[i][2] = src[i];
- }
- (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
- (void *) rgb, NULL);
- src += rowLength;
- destY++;
- }
- }
- else {
- /* with zooming */
- GLint row;
- assert(drawWidth < MAX_WIDTH);
- for (row=0; row<drawHeight; row++) {
- GLint i;
- for (i=0;i<drawWidth;i++) {
- rgb[i][0] = src[i];
- rgb[i][1] = src[i];
- rgb[i][2] = src[i];
- }
- gl_write_zoomed_rgb_span(ctx, drawWidth, destX, destY,
- zSpan, (void *) rgb, zoomY0);
- src += rowLength;
- destY++;
- }
- }
- }
- return GL_TRUE;
- }
- else if (format==GL_LUMINANCE_ALPHA && type==GL_UNSIGNED_BYTE) {
- if (ctx->Visual->RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
- + (skipRows * rowLength + skipPixels)*2;
- if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
- /* no zooming */
- GLint row;
- assert(drawWidth < MAX_WIDTH);
- for (row=0; row<drawHeight; row++) {
- GLint i;
- GLubyte *ptr = src;
- for (i=0;i<drawWidth;i++) {
- rgba[i][0] = *ptr;
- rgba[i][1] = *ptr;
- rgba[i][2] = *ptr++;
- rgba[i][3] = *ptr++;
- }
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (void *) rgba, NULL);
- src += rowLength*2;
- destY++;
- }
- }
- else {
- /* with zooming */
- GLint row;
- assert(drawWidth < MAX_WIDTH);
- for (row=0; row<drawHeight; row++) {
- GLubyte *ptr = src;
- GLint i;
- for (i=0;i<drawWidth;i++) {
- rgba[i][0] = *ptr;
- rgba[i][1] = *ptr;
- rgba[i][2] = *ptr++;
- rgba[i][3] = *ptr++;
- }
- gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
- zSpan, (void *) rgba, zoomY0);
- src += rowLength*2;
- destY++;
- }
- }
- }
- return GL_TRUE;
- }
- else if (format==GL_COLOR_INDEX && type==GL_UNSIGNED_BYTE) {
- GLubyte *src = (GLubyte *) pixels + skipRows * rowLength + skipPixels;
- if (ctx->Visual->RGBAflag) {
- /* convert CI data to RGBA */
- if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
- /* no zooming */
- GLint row;
- for (row=0; row<drawHeight; row++) {
- assert(drawWidth < MAX_WIDTH);
- gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (const GLubyte (*)[4])rgba,
- NULL);
- src += rowLength;
- destY++;
- }
- return GL_TRUE;
- }
- else {
- /* with zooming */
- GLint row;
- for (row=0; row<drawHeight; row++) {
- assert(drawWidth < MAX_WIDTH);
- gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
- gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
- zSpan, (void *) rgba, zoomY0);
- src += rowLength;
- destY++;
- }
- return GL_TRUE;
- }
- }
- else {
- /* write CI data to CI frame buffer */
- GLint row;
- if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
- /* no zooming */
- for (row=0; row<drawHeight; row++) {
- (*ctx->Driver.WriteCI8Span)(ctx, drawWidth, destX, destY,
- src, NULL);
- src += rowLength;
- destY++;
- }
- return GL_TRUE;
- }
- else {
- /* with zooming */
- return GL_FALSE;
- }
- }
- }
- else {
- /* can't handle this pixel format and/or data type here */
- return GL_FALSE;