head	3.15;
access;
symbols
	merge-1:3.14.2.1
	autoconf:3.14.0.4
	experimental-1:3.14.0.2
	mesa-3-1-with-kw3:3.13
	mesa-3-1-prior-to-kw3:3.12;
locks; strict;
comment	@ * @;


3.15
date	99.07.12.12.05.23;	author keithw;	state Exp;
branches;
next	3.14;

3.14
date	99.03.28.20.56.15;	author brianp;	state Exp;
branches
	3.14.2.1;
next	3.13;

3.13
date	99.02.25.14.12.30;	author keithw;	state Exp;
branches;
next	3.12;

3.12
date	99.02.24.22.48.05;	author jens;	state Exp;
branches;
next	3.11;

3.11
date	99.02.14.03.46.34;	author brianp;	state Exp;
branches;
next	3.10;

3.10
date	98.10.03.13.22.40;	author brianp;	state Exp;
branches;
next	3.9;

3.9
date	98.09.25.03.03.01;	author brianp;	state Exp;
branches;
next	3.8;

3.8
date	98.07.17.03.24.16;	author brianp;	state Exp;
branches;
next	3.7;

3.7
date	98.05.31.23.50.36;	author brianp;	state Exp;
branches;
next	3.6;

3.6
date	98.04.01.02.58.52;	author brianp;	state Exp;
branches;
next	3.5;

3.5
date	98.03.27.03.30.36;	author brianp;	state Exp;
branches;
next	3.4;

3.4
date	98.02.15.01.31.41;	author brianp;	state Exp;
branches;
next	3.3;

3.3
date	98.02.08.20.22.14;	author brianp;	state Exp;
branches;
next	3.2;

3.2
date	98.02.04.00.33.45;	author brianp;	state Exp;
branches;
next	3.1;

3.1
date	98.02.01.22.16.34;	author brianp;	state Exp;
branches;
next	3.0;

3.0
date	98.01.31.20.49.24;	author brianp;	state Exp;
branches;
next	;

3.14.2.1
date	99.05.21.21.29.25;	author keithw;	state Exp;
branches;
next	;


desc
@glCopyPixels
@


3.15
log
@merge from experimental branch upto merge-1 tag
@
text
@/* $Id: copypix.c,v 3.14.2.1 1999/05/21 21:29:25 keithw Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  3.1
 * 
 * Copyright (C) 1999  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.
 */





#ifdef PC_HEADER
#include "all.h"
#else
#include <string.h>
#include "context.h"
#include "copypix.h"
#include "depth.h"
#include "feedback.h"
#include "macros.h"
#include "mmath.h"
#include "pixel.h"
#include "span.h"
#include "stencil.h"
#include "types.h"
#include "zoom.h"
#ifdef XFree86Server
#include "GL/xf86glx.h"
#endif
#endif



static void copy_rgba_pixels( GLcontext* ctx,
                              GLint srcx, GLint srcy,
                              GLint width, GLint height,
                              GLint destx, GLint desty )
{
   GLdepth zspan[MAX_WIDTH];
   GLubyte rgba[MAX_WIDTH][4];
   GLboolean quick_draw;
   GLint sy, dy, stepy;
   GLint i, j;
   GLboolean changeBuffer;
   GLubyte *saveAlpha;
   const GLboolean zoom = ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F;

   /* Determine if copy should be done bottom-to-top or top-to-bottom */
   if (srcy<desty) {
      /* top-down  max-to-min */
      sy = srcy + height - 1;
      dy = desty + height - 1;
      stepy = -1;
   }
   else {
      /* bottom-up  min-to-max */
      sy = srcy;
      dy = desty;
      stepy = 1;
   }

   if (ctx->Depth.Test) {
      /* fill in array of z values */
      GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
      for (i=0;i<width;i++) {
         zspan[i] = z;
      }
   }

   if (ctx->RasterMask==0 && !zoom
       && destx>=0 && destx+width<=ctx->Buffer->Width) {
      quick_draw = GL_TRUE;
   }
   else {
      quick_draw = GL_FALSE;
   }

   /* If read and draw buffer are different we must do buffer switching */
   saveAlpha = ctx->Buffer->Alpha;
   changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer;
   for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
      if (changeBuffer) {
         (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.DriverReadBuffer );
         if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT)
            ctx->Buffer->Alpha = ctx->Buffer->FrontLeftAlpha;
         else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT)
            ctx->Buffer->Alpha = ctx->Buffer->BackLeftAlpha;
         else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT)
            ctx->Buffer->Alpha = ctx->Buffer->FrontRightAlpha;
         else
            ctx->Buffer->Alpha = ctx->Buffer->BackRightAlpha;
      }
      gl_read_rgba_span( ctx, width, srcx, sy, rgba );
      if (ctx->Pixel.ScaleOrBiasRGBA) {
         gl_scale_and_bias_rgba( ctx, width, rgba );
      }
      if (ctx->Pixel.MapColorFlag) {
         gl_map_rgba( ctx, width, rgba );
      }
      if (quick_draw && dy>=0 && dy<ctx->Buffer->Height) {
         (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy, 
				       (const GLubyte (*)[4])rgba, NULL );

      }
      else if (zoom) {
         gl_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 
				    (const GLubyte (*)[4])rgba, desty);
      }
      else {
         gl_write_rgba_span( ctx, width, destx, dy, zspan, rgba, GL_BITMAP );
      }
   }

   /* Restore current alpha buffer pointer */
   ctx->Buffer->Alpha = saveAlpha;
   if (changeBuffer)
      (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer );
}


static void copy_ci_pixels( GLcontext* ctx,
                            GLint srcx, GLint srcy, GLint width, GLint height,
                            GLint destx, GLint desty )
{
   GLdepth zspan[MAX_WIDTH];
   GLint sy, dy, stepy;
   GLint i, j;
   GLboolean changeBuffer;
   const GLboolean zoom = ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F;
   const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;

   /* Determine if copy should be bottom-to-top or top-to-bottom */
   if (srcy<desty) {
      /* top-down  max-to-min */
      sy = srcy + height - 1;
      dy = desty + height - 1;
      stepy = -1;
   }
   else {
      /* bottom-up  min-to-max */
      sy = srcy;
      dy = desty;
      stepy = 1;
   }

   if (ctx->Depth.Test) {
      /* fill in array of z values */
      GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
      for (i=0;i<width;i++) {
         zspan[i] = z;
      }
   }

   /* If read and draw buffer are different we must do buffer switching */
   changeBuffer = ctx->Pixel.ReadBuffer!=ctx->Color.DrawBuffer;

   for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
      GLuint indexes[MAX_WIDTH];
      if (changeBuffer) {
         (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.DriverReadBuffer );
      }
      gl_read_index_span( ctx, width, srcx, sy, indexes );

      if (shift_or_offset) {
         gl_shift_and_offset_ci( ctx, width, indexes );
      }
      if (ctx->Pixel.MapColorFlag) {
         gl_map_ci( ctx, width, indexes );
      }

      if (changeBuffer) {
         (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
      }
      if (zoom) {
         gl_write_zoomed_index_span( ctx, width, destx, dy, zspan, indexes, desty );
      }
      else {
         gl_write_index_span( ctx, width, destx, dy, zspan, indexes, GL_BITMAP );
      }
   }
   if (changeBuffer)
      (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer );
}



/*
 * TODO: Optimize!!!!
 */
static void copy_depth_pixels( GLcontext* ctx, GLint srcx, GLint srcy,
                               GLint width, GLint height,
                               GLint destx, GLint desty )
{
   GLfloat depth[MAX_WIDTH];
   GLdepth zspan[MAX_WIDTH];
   GLuint indexes[MAX_WIDTH];
   GLubyte rgba[MAX_WIDTH][4];
   GLint sy, dy, stepy;
   GLint i, j;
   const GLboolean zoom = ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F;

   if (!ctx->Buffer->Depth) {
      gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
      return;
   }

   /* Determine if copy should be bottom-to-top or top-to-bottom */
   if (srcy<desty) {
      /* top-down  max-to-min */
      sy = srcy + height - 1;
      dy = desty + height - 1;
      stepy = -1;
   }
   else {
      /* bottom-up  min-to-max */
      sy = srcy;
      dy = desty;
      stepy = 1;
   }

   /* setup colors or indexes */
   if (ctx->Visual->RGBAflag) {
      GLuint *rgba32 = (GLuint *) rgba;
      GLuint color = *(GLuint*)( ctx->Current.ByteColor );
      for (i=0; i<width; i++) {
         rgba32[i] = color;
      }
   }
   else {
      for (i=0;i<width;i++) {
         indexes[i] = ctx->Current.Index;
      }
   }

   for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
      (*ctx->Driver.ReadDepthSpanFloat)( ctx, width, srcx, sy, depth );

      for (i=0;i<width;i++) {
         GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
         zspan[i] = (GLint) (CLAMP( d, 0.0F, 1.0F ) * DEPTH_SCALE);
      }

      if (ctx->Visual->RGBAflag) {
         if (zoom) {
            gl_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 
				       (const GLubyte (*)[4])rgba, desty );
         }
         else {
            gl_write_rgba_span( ctx, width, destx, dy, zspan, rgba, GL_BITMAP);
         }
      }
      else {
         if (zoom) {
            gl_write_zoomed_index_span( ctx, width, destx, dy,
                                        zspan, indexes, desty );
         }
         else {
            gl_write_index_span( ctx, width, destx, dy,
                                 zspan, indexes, GL_BITMAP );
         }
      }
   }
}



static void copy_stencil_pixels( GLcontext* ctx, GLint srcx, GLint srcy,
                                 GLint width, GLint height,
                                 GLint destx, GLint desty )
{
   GLint sy, dy, stepy;
   GLint j;
   const GLboolean zoom = (ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F);
   const GLboolean shift_or_offset = ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0;

   if (!ctx->Buffer->Stencil) {
      gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
      return;
   }

   /* Determine if copy should be bottom-to-top or top-to-bottom */
   if (srcy<desty) {
      /* top-down  max-to-min */
      sy = srcy + height - 1;
      dy = desty + height - 1;
      stepy = -1;
   }
   else {
      /* bottom-up  min-to-max */
      sy = srcy;
      dy = desty;
      stepy = 1;
   }

   for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
      GLstencil stencil[MAX_WIDTH];
      gl_read_stencil_span( ctx, width, srcx, sy, stencil );

      if (shift_or_offset) {
         gl_shift_and_offset_stencil( ctx, width, stencil );
      }
      if (ctx->Pixel.MapStencilFlag) {
         gl_map_stencil( ctx, width, stencil );
      }

      if (zoom) {
         gl_write_zoomed_stencil_span( ctx, width, destx, dy, stencil, desty );
      }
      else {
         gl_write_stencil_span( ctx, width, destx, dy, stencil );
      }
   }
}




void gl_CopyPixels( GLcontext* ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height,
		    GLenum type )
{
   GLint destx, desty;

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyPixels");

   if (width<0 || height<0) {
      gl_error( ctx, GL_INVALID_VALUE, "glCopyPixels" );
      return;
   }

   if (ctx->NewState) {
      gl_update_state(ctx);
   }

   if (ctx->RenderMode==GL_RENDER) {
      /* Destination of copy: */
      if (!ctx->Current.RasterPosValid) {
	 return;
      }
      destx = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
      desty = (GLint) (ctx->Current.RasterPos[1] + 0.5F);

      if (type==GL_COLOR && ctx->Visual->RGBAflag) {
         copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
      }
      else if (type==GL_COLOR && !ctx->Visual->RGBAflag) {
         copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty );
      }
      else if (type==GL_DEPTH) {
         copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty );
      }
      else if (type==GL_STENCIL) {
         copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty );
      }
      else {
	 gl_error( ctx, GL_INVALID_ENUM, "glCopyPixels" );
      }
   }
   else if (ctx->RenderMode==GL_FEEDBACK) {
      GLfloat color[4];
      UBYTE_RGBA_TO_FLOAT_RGBA(color, ctx->Current.ByteColor );
      FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN );
      gl_feedback_vertex( ctx, ctx->Current.RasterPos[0],
			  ctx->Current.RasterPos[1],
			  ctx->Current.RasterPos[2],
			  ctx->Current.RasterPos[3],
			  color, ctx->Current.Index,
			  ctx->Current.Texcoord[0] );
   }
   else if (ctx->RenderMode==GL_SELECT) {
      gl_update_hitflag( ctx, ctx->Current.RasterPos[2] );
   }

}


@


3.14
log
@better handling of multi draw buffers, software alpha buffers
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.13 1999/02/25 14:12:30 keithw Exp $ */
d120 2
a121 1
         (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy, rgba, NULL );
d125 2
a126 1
         gl_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, rgba, desty);
d264 2
a265 1
            gl_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, rgba, desty );
d386 1
a386 1
			  ctx->Current.Texcoord[ctx->Current.TexSet] );
@


3.14.2.1
log
@Quake3 inspired optimizations
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.14 1999/03/28 20:56:15 brianp Exp $ */
d120 1
a120 2
         (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy, 
				       (const GLubyte (*)[4])rgba, NULL );
d124 1
a124 2
         gl_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 
				    (const GLubyte (*)[4])rgba, desty);
d262 1
a262 2
            gl_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 
				       (const GLubyte (*)[4])rgba, desty );
@


3.13
log
@Merged in kw3 patch
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.12 1999/02/24 22:48:05 jens Exp $ */
d63 1
a63 1
   GLboolean setbuffer;
d99 1
a99 1
   setbuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer;
d101 8
a108 4
      if (setbuffer) {
         (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer );
         if (ctx->Pixel.ReadBuffer == GL_FRONT)
            ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
d110 1
a110 1
            ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
a118 7
      if (setbuffer) {
         (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
         if (ctx->Color.DrawBuffer == GL_FRONT)
            ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
         else
            ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
      }
d133 2
d145 1
a145 1
   GLboolean setbuffer;
d172 1
a172 1
   setbuffer = ctx->Pixel.ReadBuffer!=ctx->Color.DrawBuffer;
d176 2
a177 2
      if (setbuffer) {
         (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer );
d188 1
a188 1
      if (setbuffer) {
d198 2
a201 11

#if 0
static GLuint pack_rgba( const GLfloat *c )
{
    GLuint a = 0;
    GLubyte ub[4];
    for (a = 0 ; a < 4 ; a++) 
	ub[a] = (GLubyte) (c[a] * 255.0);
    return *(GLuint *)ub;
}
#endif
@


3.12
log
@Added header file to get XMesa to compile standalone and inside XFree86
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.11 1999/02/14 03:46:34 brianp Exp $ */
d28 1
a28 39
/*
 * $Log: copypix.c,v $
 * Revision 3.11  1999/02/14 03:46:34  brianp
 * new copyright
 *
 * Revision 3.10  1998/10/03 13:22:40  brianp
 * stencil-related clean ups
 *
 * Revision 3.9  1998/09/25 03:03:01  brianp
 * fixed front/back alpha copy bug per Sam Jordan
 *
 * Revision 3.8  1998/07/17 03:24:16  brianp
 * added Pixel.ScaleOrBiasRGBA field
 *
 * Revision 3.7  1998/05/31 23:50:36  brianp
 * cleaned up a few Solaris compiler warnings
 *
 * Revision 3.6  1998/04/01 02:58:52  brianp
 * applied Miklos Fazekas's 3-31-98 Macintosh changes
 *
 * Revision 3.5  1998/03/27 03:30:36  brianp
 * fixed G++ warnings
 *
 * Revision 3.4  1998/02/15 01:31:41  brianp
 * removed unused variables
 *
 * Revision 3.3  1998/02/08 20:22:14  brianp
 * LOTS of clean-up and rewriting
 *
 * Revision 3.2  1998/02/04 00:33:45  brianp
 * fixed a few cast problems for Amiga StormC compiler
 *
 * Revision 3.1  1998/02/01 22:16:34  brianp
 * include different headers (zooming)
 *
 * Revision 3.0  1998/01/31 20:49:24  brianp
 * initial rev
 *
 */
d40 1
d130 1
a130 2
         gl_write_rgba_span( ctx, width, destx, dy, zspan, rgba, GL_BITMAP 
);
d202 11
d251 1
a251 1
      GLuint color = *((GLuint *) ctx->Current.ByteColor);
d349 1
a349 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
      return;
   }
d386 1
a386 4
      color[0] = (GLfloat) ctx->Current.ByteColor[0] / 255.0;
      color[1] = (GLfloat) ctx->Current.ByteColor[1] / 255.0;
      color[2] = (GLfloat) ctx->Current.ByteColor[2] / 255.0;
      color[3] = (GLfloat) ctx->Current.ByteColor[3] / 255.0;
d393 1
a393 1
			  ctx->Current.TexCoord );
@


3.11
log
@new copyright
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.10 1998/10/03 13:22:40 brianp Exp brianp $ */
d30 3
d83 3
@


3.10
log
@stencil-related clean ups
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.9 1998/09/25 03:03:01 brianp Exp brianp $ */
d6 19
a24 15
 * Copyright (C) 1995-1998  Brian Paul
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
d30 3
@


3.9
log
@fixed front/back alpha copy bug per Sam Jordan
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.8 1998/07/17 03:24:16 brianp Exp brianp $ */
d5 1
a5 1
 * Version:  3.0
d26 3
a310 1
   GLubyte stencil[MAX_WIDTH];
d336 1
@


3.8
log
@added Pixel.ScaleOrBiasRGBA field
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.7 1998/05/31 23:50:36 brianp Exp brianp $ */
d26 3
d74 4
a77 3
static void copy_rgb_pixels( GLcontext* ctx,
                             GLint srcx, GLint srcy, GLint width, GLint height,
                             GLint destx, GLint desty )
d85 1
d119 2
a120 2
   setbuffer = ctx->Pixel.ReadBuffer!=ctx->Color.DrawBuffer;

d124 4
a129 1

a135 1

d138 4
d145 1
d151 2
a152 1
         gl_write_rgba_span( ctx, width, destx, dy, zspan, rgba, GL_BITMAP );
d155 3
a160 1

d383 1
a383 1
         copy_rgb_pixels( ctx, srcx, srcy, width, height, destx, desty );
@


3.7
log
@cleaned up a few Solaris compiler warnings
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.6 1998/04/01 02:58:52 brianp Exp brianp $ */
d26 3
d77 1
a77 1
   GLboolean scale_or_bias, quick_draw;
a82 5
   scale_or_bias = ctx->Pixel.RedScale!=1.0 || ctx->Pixel.RedBias!=0.0
                || ctx->Pixel.GreenScale!=1.0 || ctx->Pixel.GreenBias!=0.0
		|| ctx->Pixel.BlueScale!=1.0 || ctx->Pixel.BlueBias!=0.0
		|| ctx->Pixel.AlphaScale!=1.0 || ctx->Pixel.AlphaBias!=0.0;

d122 1
a122 1
      if (scale_or_bias) {
@


3.6
log
@applied Miklos Fazekas's 3-31-98 Macintosh changes
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.5 1998/03/27 03:30:36 brianp Exp brianp $ */
d26 3
d387 4
a390 4
      color[0] = ctx->Current.ByteColor[0] / 255.0;
      color[1] = ctx->Current.ByteColor[1] / 255.0;
      color[2] = ctx->Current.ByteColor[2] / 255.0;
      color[3] = ctx->Current.ByteColor[3] / 255.0;
@


3.5
log
@fixed G++ warnings
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.4 1998/02/15 01:31:41 brianp Exp brianp $ */
d26 3
d69 1
a69 1
   DEFARRAY( GLdepth, zspan, MAX_WIDTH );
a140 1
   UNDEFARRAY( zspan );
@


3.4
log
@removed unused variables
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.3 1998/02/08 20:22:14 brianp Exp brianp $ */
d26 3
a244 1
      GLuint i;
a247 1

@


3.3
log
@LOTS of clean-up and rewriting
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.2 1998/02/04 00:33:45 brianp Exp brianp $ */
d26 3
d291 1
a291 1
   GLint i, j;
@


3.2
log
@fixed a few cast problems for Amiga StormC compiler
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.1 1998/02/01 22:16:34 brianp Exp brianp $ */
d26 3
d47 1
d62 1
a62 1
   GLboolean scale_or_bias, quick_draw, zoom;
d66 1
d68 4
a71 6
   if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
      zoom = GL_FALSE;
   }
   else {
      zoom = GL_TRUE;
   }
a86 5
   scale_or_bias = ctx->Pixel.RedScale!=1.0 || ctx->Pixel.RedBias!=0.0
                || ctx->Pixel.GreenScale!=1.0 || ctx->Pixel.GreenBias!=0.0
		|| ctx->Pixel.BlueScale!=1.0 || ctx->Pixel.BlueBias!=0.0
		|| ctx->Pixel.AlphaScale!=1.0 || ctx->Pixel.AlphaBias!=0.0;

a106 2
      /* read */

d113 1
a113 14
         GLfloat rbias = ctx->Pixel.RedBias   * 255.0F;
         GLfloat gbias = ctx->Pixel.GreenBias * 255.0F;
         GLfloat bbias = ctx->Pixel.BlueBias  * 255.0F;
         GLfloat abias = ctx->Pixel.AlphaBias * 255.0F;
         for (i=0;i<width;i++) {
            GLint r = rgba[i][RCOMP] * ctx->Pixel.RedScale   + rbias;
            GLint g = rgba[i][GCOMP] * ctx->Pixel.GreenScale + gbias;
            GLint b = rgba[i][BCOMP] * ctx->Pixel.BlueScale  + bbias;
            GLint a = rgba[i][ACOMP] * ctx->Pixel.AlphaScale + abias;
            rgba[i][RCOMP] = CLAMP( r, 0, 255 );
            rgba[i][GCOMP] = CLAMP( g, 0, 255 );
            rgba[i][BCOMP] = CLAMP( b, 0, 255 );
            rgba[i][ACOMP] = CLAMP( a, 0, 255 );
         }
a114 1

d116 1
a116 14
         GLfloat r = (ctx->Pixel.MapRtoRsize-1) / 255.0;
         GLfloat g = (ctx->Pixel.MapGtoGsize-1) / 255.0;
         GLfloat b = (ctx->Pixel.MapBtoBsize-1) / 255.0;
         GLfloat a = (ctx->Pixel.MapAtoAsize-1) / 255.0;
         for (i=0;i<width;i++) {
            GLint ir = rgba[i][RCOMP] * r;
            GLint ig = rgba[i][GCOMP] * g;
            GLint ib = rgba[i][BCOMP] * b;
            GLint ia = rgba[i][ACOMP] * a;
            rgba[i][RCOMP] = (GLint) (ctx->Pixel.MapRtoR[ir] * 255.0F);
            rgba[i][GCOMP] = (GLint) (ctx->Pixel.MapGtoG[ig] * 255.0F);
            rgba[i][BCOMP] = (GLint) (ctx->Pixel.MapBtoB[ib] * 255.0F);
            rgba[i][ACOMP] = (GLint) (ctx->Pixel.MapAtoA[ia] * 255.0F);
         }
a118 1
      /* write */
a141 1
   GLuint indx[MAX_WIDTH];
d144 3
a146 8
   GLboolean setbuffer, zoom;

   if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
      zoom = GL_FALSE;
   }
   else {
      zoom = GL_TRUE;
   }
d174 1
a174 1
      /* read */
d178 1
a178 1
      gl_read_index_span( ctx, width, srcx, sy, indx );
d180 2
a181 14
      /* shift, offset */
      if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
         if (ctx->Pixel.IndexShift<0) {
            for (i=0;i<width;i++) {
               indx[i] = (indx[i] >> -ctx->Pixel.IndexShift)
                         + ctx->Pixel.IndexOffset;
            }
         }
         else {
            for (i=0;i<width;i++) {
               indx[i] = (indx[i] << ctx->Pixel.IndexShift)
                         + ctx->Pixel.IndexOffset;
            }
         }
a182 2

      /* mapping */
d184 1
a184 5
         for (i=0;i<width;i++) {
            if (indx[i] < ctx->Pixel.MapItoIsize) {
               indx[i] = ctx->Pixel.MapItoI[ indx[i] ];
            }
         }
a186 1
      /* write */
d191 1
a191 1
         gl_write_zoomed_index_span( ctx, width, destx, dy, zspan, indx, desty );
d194 1
a194 1
         gl_write_index_span( ctx, width, destx, dy, zspan, indx, GL_BITMAP );
d210 1
a210 1
   GLuint indx[MAX_WIDTH];
d214 1
a214 1
   GLboolean zoom;
a220 7
   if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
      zoom = GL_FALSE;
   }
   else {
      zoom = GL_TRUE;
   }

d237 2
a238 1
      GLubyte r, g, b, a;
a239 5
      r = ctx->Current.ByteColor[0];
      g = ctx->Current.ByteColor[1];
      b = ctx->Current.ByteColor[2];
      a = ctx->Current.ByteColor[3];
      /* XXX OPTIMIZE */
d241 1
a241 4
         rgba[i][RCOMP] = r;
         rgba[i][GCOMP] = g;
         rgba[i][BCOMP] = b;
         rgba[i][ACOMP] = a;
d243 1
d247 1
a247 1
         indx[i] = ctx->Current.Index;
a251 1
      /* read */
d253 1
a253 1
      /* scale, bias, clamp */
d256 1
a256 1
         zspan[i] = (GLint) (CLAMP( d, 0.0, 1.0 ) * DEPTH_SCALE);
d258 1
a258 1
      /* write */
d270 1
a270 1
                                        zspan, indx, desty );
d274 1
a274 1
                                 zspan, indx, GL_BITMAP );
d289 2
a290 1
   GLboolean zoom;
a296 7
   if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
      zoom = GL_FALSE;
   }
   else {
      zoom = GL_TRUE;
   }

a311 1
      /* read */
d313 3
a315 6
      /* shift, offset */
      if (ctx->Pixel.IndexShift<0) {
         for (i=0;i<width;i++) {
            stencil[i] = (stencil[i] >> -ctx->Pixel.IndexShift)
                         + ctx->Pixel.IndexOffset;
         }
a316 7
      else {
         for (i=0;i<width;i++) {
            stencil[i] = (stencil[i] << ctx->Pixel.IndexShift)
			 + ctx->Pixel.IndexOffset;
         }
      }
      /* mapping */
d318 1
a318 5
         for (i=0;i<width;i++) {
            if ((GLint) stencil[i] < ctx->Pixel.MapStoSsize) {
               stencil[i] = ctx->Pixel.MapStoS[ stencil[i] ];
            }
         }
d320 1
a320 1
      /* write */
@


3.1
log
@include different headers (zooming)
@
text
@d1 1
a1 1
/* $Id: copypix.c,v 3.0 1998/01/31 20:49:24 brianp Exp brianp $ */
d26 3
d474 1
a474 1
      FEEDBACK_TOKEN( ctx, (GLfloat) GL_COPY_PIXEL_TOKEN );
@


3.0
log
@initial rev
@
text
@d1 1
a1 1
/* $Id$ */
d25 4
a28 1
 * $Log$
a40 1
#include "pixel.h"
d44 1
@
