summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-10-29 18:12:14 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-10-29 18:12:14 +0000
commit699bc7b73d2fede77d3290f66c1ec355afd0373e (patch)
treee4db02b4dd9aa40fadf922c094014ed6541726c4 /src/mesa/main
parentc893a015d8a50a38cd3f727d99835e7e7e2ccea9 (diff)
More GLchan color channel changes.
Some header file re-org: Move matrix, vertex buffer structs to types.h to fix #include mess. Remove typedef, extern declarations from config.h
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c3
-rw-r--r--src/mesa/main/colormac.h10
-rw-r--r--src/mesa/main/colortab.c14
-rw-r--r--src/mesa/main/config.h33
-rw-r--r--src/mesa/main/context.h9
-rw-r--r--src/mesa/main/dd.h10
-rw-r--r--src/mesa/main/drawpix.c66
-rw-r--r--src/mesa/main/eval.c3
-rw-r--r--src/mesa/main/image.c560
-rw-r--r--src/mesa/main/image.h34
-rw-r--r--src/mesa/main/matrix.h77
-rw-r--r--src/mesa/main/pixel.c80
-rw-r--r--src/mesa/main/pixel.h12
-rw-r--r--src/mesa/main/state.c15
-rw-r--r--src/mesa/main/teximage.c118
-rw-r--r--src/mesa/main/texutil.c60
-rw-r--r--src/mesa/main/texutil.h6
17 files changed, 529 insertions, 581 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 2e970e9b08..7d4199e27f 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.29 2000/10/28 18:34:48 brianp Exp $ */
+/* $Id: attrib.c,v 1.30 2000/10/29 18:12:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,6 +34,7 @@
#include "context.h"
#include "enable.h"
#include "enums.h"
+#include "matrix.h"
#include "mem.h"
#include "simple_list.h"
#include "texstate.h"
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index 5d125e2725..b69f52fbbb 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,4 +1,4 @@
-/* $Id: colormac.h,v 1.1 2000/10/28 20:41:13 brianp Exp $ */
+/* $Id: colormac.h,v 1.2 2000/10/29 18:12:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -175,12 +175,20 @@ do { \
#define FLOAT_TO_CHAN(f) (f)
#define DOUBLE_TO_CHAN(f) ((GLfloat) (f))
+#define UNCLAMPED_FLOAT_TO_CHAN(f) (f)
+#define UNCLAMPED_DOUBLE_TO_CHAN(f) ((GLfloat) (f))
#else
#define FLOAT_TO_CHAN(f) ( (GLchan) FloatToInt((f) * CHAN_MAXF + 0.5F) )
#define DOUBLE_TO_CHAN(f) ( (GLchan) FloatToInt((f) * CHAN_MAXF + 0.5F) )
+#define UNCLAMPED_FLOAT_TO_CHAN(f) \
+ ( (GLchan) FloatToInt( CLAMP(f, 0.0, 1.0) * CHAN_MAXF + 0.5F) )
+
+#define UNCLAMPED_DOUBLE_TO_CHAN(f) \
+ ( (GLchan) FloatToInt( CLAMP(f, 0.0, 1.0) * CHAN_MAXF + 0.5F) )
+
#endif
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 06faa6279d..a06557266e 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.22 2000/10/28 18:34:48 brianp Exp $ */
+/* $Id: colortab.c,v 1.23 2000/10/29 18:12:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -422,10 +422,10 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
return;
}
- _mesa_unpack_ubyte_color_span(ctx, width, table->Format,
- table->Table, /* dest */
- format, type, data,
- &ctx->Unpack, 0);
+ _mesa_unpack_chan_color_span(ctx, width, table->Format,
+ table->Table, /* dest */
+ format, type, data,
+ &ctx->Unpack, 0);
} /* floatTable */
} /* proxy */
@@ -536,8 +536,8 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
if (!table->FloatTable) {
GLchan *dest = (GLchan *) table->Table + start * comps * sizeof(GLchan);
- _mesa_unpack_ubyte_color_span(ctx, count, table->Format, dest,
- format, type, data, &ctx->Unpack, 0);
+ _mesa_unpack_chan_color_span(ctx, count, table->Format, dest,
+ format, type, data, &ctx->Unpack, 0);
}
else {
GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 901d614b10..a45f652a3d 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -1,4 +1,4 @@
-/* $Id: config.h,v 1.21 2000/10/28 20:41:13 brianp Exp $ */
+/* $Id: config.h,v 1.22 2000/10/29 18:12:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -162,24 +162,6 @@
* Bits per color channel (must be 8 at this time!)
*/
#define CHAN_BITS 8
-#if CHAN_BITS == 8
- typedef GLubyte GLchan;
-#define CHAN_MAX 255
-#define CHAN_MAXF 255.0F
-#elif CHAN_BITS == 16
- typedef GLushort GLchan;
-#define CHAN_MAX 65535
-#define CHAN_MAXF 65535.0F
-#elif CHAN_BITS == 32
- typedef GLfloat GLchan;
-#define CHAN_MAX 1.0
-#define CHAN_MAXF 1.0F
-#else
-#error illegal number of color channel bits
-#endif
-
-
-
/*
@@ -215,13 +197,12 @@
#define VB_SIZE (VB_MAX + VB_MAX_CLIPPED_VERTS)
-typedef struct __GLcontextRec GLcontext;
-
-extern void
-gl_read_config_file(GLcontext *ctx);
-
-extern void
-gl_register_config_var(const char *name, void (*notify)( const char *, int ));
+/* Some compilers don't like some of Mesa's const usage */
+#ifdef NO_CONST
+# define CONST
+#else
+# define CONST const
+#endif
#endif
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 8345f9e70f..fe058c69d3 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -1,4 +1,4 @@
-/* $Id: context.h,v 1.19 2000/09/26 20:53:53 brianp Exp $ */
+/* $Id: context.h,v 1.20 2000/10/29 18:12:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -235,4 +235,11 @@ _mesa_Flush( void );
+extern void
+gl_read_config_file(GLcontext *ctx);
+
+extern void
+gl_register_config_var(const char *name, void (*notify)( const char *, int ));
+
+
#endif
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 14f83ebec4..287185f846 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.34 2000/10/28 18:34:48 brianp Exp $ */
+/* $Id: dd.h,v 1.35 2000/10/29 18:12:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -29,20 +29,16 @@
#ifndef DD_INCLUDED
#define DD_INCLUDED
-
-#include "macros.h"
+/* THIS FILE ONLY INCLUDED BY types.h !!!!! */
struct gl_pixelstore_attrib;
-
-
struct vertex_buffer;
struct immediate;
+struct gl_pipeline;
struct gl_pipeline_stage;
-/* THIS FILE ONLY INCLUDED BY types.h !!!!! */
-
/*
* Device Driver (DD) interface
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 6e1f6e0a09..4ccb128a48 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.40 2000/10/28 20:41:13 brianp Exp $ */
+/* $Id: drawpix.c,v 1.41 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -106,8 +106,8 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLenum format, GLenum type, const GLvoid *pixels)
{
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
- GLubyte rgb[MAX_WIDTH][3];
- GLubyte rgba[MAX_WIDTH][4];
+ GLchan rgb[MAX_WIDTH][3];
+ GLchan rgba[MAX_WIDTH][4];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glDrawPixels",
GL_FALSE);
@@ -210,10 +210,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
* skip "skipRows" rows and skip "skipPixels" pixels/row.
*/
- if (format==GL_RGBA && type==GL_UNSIGNED_BYTE
+ if (format == GL_RGBA && type == CHAN_TYPE
&& ctx->ImageTransferState==0) {
if (ctx->Visual.RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
+ GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels) * 4;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
@@ -248,10 +248,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
}
return GL_TRUE;
}
- else if (format==GL_RGB && type==GL_UNSIGNED_BYTE
- && ctx->ImageTransferState==0) {
+ else if (format == GL_RGB && type == CHAN_TYPE
+ && ctx->ImageTransferState == 0) {
if (ctx->Visual.RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
+ GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels) * 3;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
GLint row;
@@ -285,10 +285,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
}
return GL_TRUE;
}
- else if (format==GL_LUMINANCE && type==GL_UNSIGNED_BYTE
+ else if (format == GL_LUMINANCE && type == CHAN_TYPE
&& ctx->ImageTransferState==0) {
if (ctx->Visual.RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
+ GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels);
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
@@ -344,10 +344,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
}
return GL_TRUE;
}
- else if (format==GL_LUMINANCE_ALPHA && type==GL_UNSIGNED_BYTE
- && ctx->ImageTransferState==0) {
+ else if (format == GL_LUMINANCE_ALPHA && type == CHAN_TYPE
+ && ctx->ImageTransferState == 0) {
if (ctx->Visual.RGBAflag) {
- GLubyte *src = (GLubyte *) pixels
+ GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels)*2;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
@@ -355,7 +355,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
- GLubyte *ptr = src;
+ GLchan *ptr = src;
for (i=0;i<drawWidth;i++) {
rgba[i][0] = *ptr;
rgba[i][1] = *ptr;
@@ -374,7 +374,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
- GLubyte *ptr = src;
+ GLchan *ptr = src;
for (i=0;i<drawWidth;i++) {
rgba[i][0] = *ptr;
rgba[i][1] = *ptr;
@@ -392,7 +392,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
- GLubyte *ptr = src;
+ GLchan *ptr = src;
GLint i;
for (i=0;i<drawWidth;i++) {
rgba[i][0] = *ptr;
@@ -420,7 +420,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (const GLubyte (*)[4])rgba,
+ (const GLchan (*)[4]) rgba,
NULL);
src += rowLength;
destY++;
@@ -435,7 +435,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
destY--;
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (const GLubyte (*)[4])rgba,
+ (const GLchan (*)[4]) rgba,
NULL);
src += rowLength;
}
@@ -597,7 +597,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
- GLubyte rgba[MAX_WIDTH][4];
+ GLchan rgba[MAX_WIDTH][4];
GLuint ispan[MAX_WIDTH];
GLint drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
@@ -614,10 +614,10 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
/* Colors or indexes */
if (ctx->Visual.RGBAflag) {
- GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0F);
- GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0F);
- GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0F);
- GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0F);
+ GLint r = FLOAT_TO_CHAN(ctx->Current.RasterColor[0]);
+ GLint g = FLOAT_TO_CHAN(ctx->Current.RasterColor[1]);
+ GLint b = FLOAT_TO_CHAN(ctx->Current.RasterColor[2]);
+ GLint a = FLOAT_TO_CHAN(ctx->Current.RasterColor[3]);
GLint i;
for (i = 0; i < drawWidth; i++) {
rgba[i][RCOMP] = r;
@@ -669,7 +669,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
if (ctx->Visual.RGBAflag) {
if (zoom) {
gl_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0,
- (const GLubyte (*)[4])rgba, desty);
+ (const GLchan (*)[4]) rgba, desty);
}
else {
gl_write_rgba_span(ctx, width, x, y, zspan, 0, rgba, GL_BITMAP);
@@ -792,31 +792,31 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
* General solution
*/
{
- GLubyte rgba[MAX_WIDTH][4];
+ GLchan rgba[MAX_WIDTH][4];
GLint row;
if (width > MAX_WIDTH)
width = MAX_WIDTH;
for (row = 0; row < height; row++, y++) {
const GLvoid *source = _mesa_image_address(unpack,
pixels, width, height, format, type, 0, row, 0);
- _mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba,
- format, type, source, unpack,
- transferOps);
+ _mesa_unpack_chan_color_span(ctx, width, GL_RGBA, (void*) rgba,
+ format, type, source, unpack,
+ transferOps);
if ((ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) ||
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
- GLubyte primary_rgba[MAX_WIDTH][4];
+ GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
/* XXX not sure how multitexture is supposed to work here */
- MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLubyte));
+ MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit].ReallyEnabled) {
- _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
+ _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q);
gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
primary_rgba, rgba);
@@ -826,11 +826,11 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
if (quickDraw) {
(*ctx->Driver.WriteRGBASpan)( ctx, width, x, y,
- (CONST GLubyte (*)[]) rgba, NULL);
+ (CONST GLchan (*)[]) rgba, NULL);
}
else if (zoom) {
gl_write_zoomed_rgba_span( ctx, width, x, y, zspan, 0,
- (CONST GLubyte (*)[]) rgba, desty );
+ (CONST GLchan (*)[]) rgba, desty );
}
else {
gl_write_rgba_span( ctx, (GLuint) width, x, y, zspan, 0,
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 9a5bbc7c64..658fa0cbd6 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -1,4 +1,4 @@
-/* $Id: eval.c,v 1.12 2000/10/28 20:41:14 brianp Exp $ */
+/* $Id: eval.c,v 1.13 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,6 +49,7 @@
#include "mem.h"
#include "mmath.h"
#include "types.h"
+#include "vb.h"
#include "vbcull.h"
#include "vbfill.h"
#include "vbxform.h"
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 7c4fa88782..4cbf677072 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.44 2000/10/28 20:41:14 brianp Exp $ */
+/* $Id: image.c,v 1.45 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -596,73 +596,201 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
}
+/*
+ * Unpack bitmap data. Resulting data will be in most-significant-bit-first
+ * order with row alignment = 1 byte.
+ */
+GLvoid *
+_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ GLint bytes, row, width_in_bytes;
+ GLubyte *buffer, *dst;
+
+ if (!pixels)
+ return NULL;
+
+ /* Alloc dest storage */
+ bytes = ((width + 7) / 8 * height);
+ buffer = (GLubyte *) MALLOC( bytes );
+ if (!buffer)
+ return NULL;
+
+
+ width_in_bytes = CEILING( width, 8 );
+ dst = buffer;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = _mesa_image_address( packing, pixels, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 0, row, 0 );
+ if (!src) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ if (packing->SkipPixels == 0) {
+ MEMCPY( dst, src, width_in_bytes );
+ if (packing->LsbFirst) {
+ flip_bytes( dst, width_in_bytes );
+ }
+ }
+ else {
+ /* handling SkipPixels is a bit tricky (no pun intended!) */
+ GLint i;
+ if (packing->LsbFirst) {
+ GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
+ GLubyte dstMask = 128;
+ GLubyte *s = src;
+ GLubyte *d = dst;
+ *d = 0;
+ for (i = 0; i < width; i++) {
+ if (*s & srcMask) {
+ *d |= dstMask;
+ }
+ if (srcMask == 128) {
+ srcMask = 1;
+ s++;
+ }
+ else {
+ srcMask = srcMask << 1;
+ }
+ if (dstMask == 1) {
+ dstMask = 128;
+ d++;
+ *d = 0;
+ }
+ else {
+ dstMask = dstMask >> 1;
+ }
+ }
+ }
+ else {
+ GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7);
+ GLubyte dstMask = 128;
+ GLubyte *s = src;
+ GLubyte *d = dst;
+ *d = 0;
+ for (i = 0; i < width; i++) {
+ if (*s & srcMask) {
+ *d |= dstMask;
+ }
+ if (srcMask == 1) {
+ srcMask = 128;
+ s++;
+ }
+ else {
+ srcMask = srcMask >> 1;
+ }
+ if (dstMask == 1) {
+ dstMask = 128;
+ d++;
+ *d = 0;
+ }
+ else {
+ dstMask = dstMask >> 1;
+ }
+ }
+ }
+ }
+ dst += width_in_bytes;
+ }
+
+ return buffer;
+}
+
/*
- * Pack the given RGBA span into client memory at 'dest' address
- * in the given pixel format and type.
- * Optionally apply the enabled pixel transfer ops.
- * Pack into memory using the given packing params struct.
- * This is used by glReadPixels and glGetTexImage?D()
- * Input: ctx - the context
- * n - number of pixels in the span
- * rgba - the pixels
- * format - dest packing format
- * type - dest packing datatype
- * destination - destination packing address
- * packing - pixel packing parameters
- * transferOps - bitmask of IMAGE_*_BIT operations to apply
+ * Pack bitmap data.
*/
void
-_mesa_pack_rgba_span( GLcontext *ctx,
- GLuint n, CONST GLubyte srcRgba[][4],
- GLenum dstFormat, GLenum dstType,
- GLvoid *dstAddr,
- const struct gl_pixelstore_attrib *dstPacking,
- GLuint transferOps)
+_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
+ GLubyte *dest, const struct gl_pixelstore_attrib *packing )
{
- ASSERT(ctx->ImageTransferState != UPDATE_IMAGE_TRANSFER_STATE);
+ GLint row, width_in_bytes;
+ const GLubyte *src;
- /* Test for optimized case first */
- if (transferOps == 0 && dstFormat == GL_RGBA
- && dstType == GL_UNSIGNED_BYTE) {
- /* common simple case */
- MEMCPY(dstAddr, srcRgba, n * 4 * sizeof(GLubyte));
- }
- else if (transferOps == 0 && dstFormat == GL_RGB
- && dstType == GL_UNSIGNED_BYTE) {
- /* common simple case */
- GLint i;
- GLubyte *dest = (GLubyte *) dstAddr;
- for (i = 0; i < n; i++) {
- dest[0] = srcRgba[i][RCOMP];
- dest[1] = srcRgba[i][GCOMP];
- dest[2] = srcRgba[i][BCOMP];
- dest += 3;
+ if (!source)
+ return;
+
+ width_in_bytes = CEILING( width, 8 );
+ src = source;
+ for (row = 0; row < height; row++) {
+ GLubyte *dst = _mesa_image_address( packing, dest, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 0, row, 0 );
+ if (!dst)
+ return;
+
+ if (packing->SkipPixels == 0) {
+ MEMCPY( dst, src, width_in_bytes );
+ if (packing->LsbFirst) {
+ flip_bytes( dst, width_in_bytes );
+ }
}
- }
- else {
- /* general solution */
- GLfloat rgba[MAX_WIDTH][4];
- const GLfloat rscale = 1.0F / 255.0F;
- const GLfloat gscale = 1.0F / 255.0F;
- const GLfloat bscale = 1.0F / 255.0F;
- const GLfloat ascale = 1.0F / 255.0F;
- GLuint i;
- assert(n <= MAX_WIDTH);
- /* convert color components to floating point */
- for (i=0;i<n;i++) {
- rgba[i][RCOMP] = srcRgba[i][RCOMP] * rscale;
- rgba[i][GCOMP] = srcRgba[i][GCOMP] * gscale;
- rgba[i][BCOMP] = srcRgba[i][BCOMP] * bscale;
- rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale;
+ else {
+ /* handling SkipPixels is a bit tricky (no pun intended!) */
+ GLint i;
+ if (packing->LsbFirst) {
+ GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
+ GLubyte dstMask = 128;
+ const GLubyte *s = src;
+ GLubyte *d = dst;
+ *d = 0;
+ for (i = 0; i < width; i++) {
+ if (*s & srcMask) {
+ *d |= dstMask;
+ }
+ if (srcMask == 128) {
+ srcMask = 1;
+ s++;
+ }
+ else {
+ srcMask = srcMask << 1;
+ }
+ if (dstMask == 1) {
+ dstMask = 128;
+ d++;
+ *d = 0;
+ }
+ else {
+ dstMask = dstMask >> 1;
+ }
+ }
+ }
+ else {
+ GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7);
+ GLubyte dstMask = 128;
+ const GLubyte *s = src;
+ GLubyte *d = dst;
+ *d = 0;
+ for (i = 0; i < width; i++) {
+ if (*s & srcMask) {
+ *d |= dstMask;
+ }
+ if (srcMask == 1) {
+ srcMask = 128;
+ s++;
+ }
+ else {
+ srcMask = srcMask >> 1;
+ }
+ if (dstMask == 1) {
+ dstMask = 128;
+ d++;
+ *d = 0;
+ }
+ else {
+ dstMask = dstMask >> 1;
+ }
+ }
+ }
}
- _mesa_pack_float_rgba_span(ctx, n, (const GLfloat (*)[4]) rgba,
- dstFormat, dstType, dstAddr,
- dstPacking, transferOps);
+ src += width_in_bytes;
}
}
+
void
_mesa_pack_float_rgba_span( GLcontext *ctx,
GLuint n, CONST GLfloat rgbaIn[][4],
@@ -1549,6 +1677,66 @@ _mesa_pack_float_rgba_span( GLcontext *ctx,
+/*
+ * Pack the given RGBA span into client memory at 'dest' address
+ * in the given pixel format and type.
+ * Optionally apply the enabled pixel transfer ops.
+ * Pack into memory using the given packing params struct.
+ * This is used by glReadPixels and glGetTexImage?D()
+ * Input: ctx - the context
+ * n - number of pixels in the span
+ * rgba - the pixels
+ * format - dest packing format
+ * type - dest packing datatype
+ * destination - destination packing address
+ * packing - pixel packing parameters
+ * transferOps - bitmask of IMAGE_*_BIT operations to apply
+ */
+void
+_mesa_pack_rgba_span( GLcontext *ctx,
+ GLuint n, CONST GLchan srcRgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps)
+{
+ ASSERT(ctx->ImageTransferState != UPDATE_IMAGE_TRANSFER_STATE);
+
+ /* Test for optimized case first */
+ if (transferOps == 0 && dstFormat == GL_RGBA && dstType == CHAN_TYPE) {
+ /* common simple case */
+ MEMCPY(dstAddr, srcRgba, n * 4 * sizeof(GLchan));
+ }
+ else if (transferOps == 0 && dstFormat == GL_RGB && dstType == CHAN_TYPE) {
+ /* common simple case */
+ GLint i;
+ GLchan *dest = (GLchan *) dstAddr;
+ for (i = 0; i < n; i++) {
+ dest[0] = srcRgba[i][RCOMP];
+ dest[1] = srcRgba[i][GCOMP];
+ dest[2] = srcRgba[i][BCOMP];
+ dest += 3;
+ }
+ }
+ else {
+ /* general solution */
+ GLfloat rgba[MAX_WIDTH][4];
+ GLuint i;
+ assert(n <= MAX_WIDTH);
+ /* convert color components to floating point */
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = CHAN_TO_FLOAT(srcRgba[i][RCOMP]);
+ rgba[i][GCOMP] = CHAN_TO_FLOAT(srcRgba[i][GCOMP]);
+ rgba[i][BCOMP] = CHAN_TO_FLOAT(srcRgba[i][BCOMP]);
+ rgba[i][ACOMP] = CHAN_TO_FLOAT(srcRgba[i][ACOMP]);
+ }
+ _mesa_pack_float_rgba_span(ctx, n, (const GLfloat (*)[4]) rgba,
+ dstFormat, dstType, dstAddr,
+ dstPacking, transferOps);
+ }
+}
+
+
#define SWAP2BYTE(VALUE) \
{ \
GLubyte *bytes = (GLubyte *) &(VALUE); \
@@ -2251,12 +2439,12 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
* XXX perhaps expand this to process whole images someday.
*/
void
-_mesa_unpack_ubyte_color_span( GLcontext *ctx,
- GLuint n, GLenum dstFormat, GLubyte dest[],
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLuint transferOps )
+_mesa_unpack_chan_color_span( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLchan dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps )
{
ASSERT(dstFormat == GL_ALPHA ||
dstFormat == GL_LUMINANCE ||
@@ -2305,21 +2493,21 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
assert(ctx->Visual.RGBAflag);
/* Try simple cases first */
- if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE) {
+ if (transferOps == 0 && srcType == CHAN_TYPE) {
if (dstFormat == GL_RGBA) {
if (srcFormat == GL_RGBA) {
- MEMCPY( dest, source, n * 4 * sizeof(GLubyte) );
+ MEMCPY( dest, source, n * 4 * sizeof(GLchan) );
return;
}
else if (srcFormat == GL_RGB) {
GLuint i;
- const GLubyte *src = (const GLubyte *) source;
- GLubyte *dst = dest;
+ const GLchan *src = (const GLchan *) source;
+ GLchan *dst = dest;
for (i = 0; i < n; i++) {
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
- dst[3] = 255;
+ dst[3] = CHAN_MAX;
src += 3;
dst += 4;
}
@@ -2328,13 +2516,13 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
}
else if (dstFormat == GL_RGB) {
if (srcFormat == GL_RGB) {
- MEMCPY( dest, source, n * 3 * sizeof(GLubyte) );
+ MEMCPY( dest, source, n * 3 * sizeof(GLchan) );
return;
}
else if (srcFormat == GL_RGBA) {
GLuint i;
- const GLubyte *src = (const GLubyte *) source;
- GLubyte *dst = dest;
+ const GLchan *src = (const GLchan *) source;
+ GLchan *dst = dest;
for (i = 0; i < n; i++) {
dst[0] = src[0];
dst[1] = src[1];
@@ -2348,7 +2536,7 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
else if (dstFormat == srcFormat) {
GLint comps = _mesa_components_in_format(srcFormat);
assert(comps > 0);
- MEMCPY( dest, source, n * comps * sizeof(GLubyte) );
+ MEMCPY( dest, source, n * comps * sizeof(GLchan) );
return;
}
}
@@ -2383,10 +2571,10 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
}
if (dstFormat == GL_COLOR_INDEX) {
- /* convert to GLubyte and return */
+ /* convert to GLchan and return */
GLuint i;
for (i = 0; i < n; i++) {
- dest[i] = (GLubyte) (indexes[i] & 0xff);
+ dest[i] = (GLchan) (indexes[i] & 0xff);
}
return;
}
@@ -2490,67 +2678,67 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
dstLuminanceIndex = dstIntensityIndex = -1;
break;
default:
- gl_problem(ctx, "bad dstFormat in _mesa_unpack_ubyte_span()");
+ gl_problem(ctx, "bad dstFormat in _mesa_unpack_chan_span()");
return;
}
- /* Now return the GLubyte data in the requested dstFormat */
+ /* Now return the GLchan data in the requested dstFormat */
if (dstRedIndex >= 0) {
- GLubyte *dst = dest;
+ GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstRedIndex] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[dstRedIndex] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
dst += dstComponents;
}
}
if (dstGreenIndex >= 0) {
- GLubyte *dst = dest;
+ GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstGreenIndex] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[dstGreenIndex] = FLOAT_TO_CHAN(rgba[i][GCOMP]);
dst += dstComponents;
}
}
if (dstBlueIndex >= 0) {
- GLubyte *dst = dest;
+ GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstBlueIndex] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[dstBlueIndex] = FLOAT_TO_CHAN(rgba[i][BCOMP]);
dst += dstComponents;
}
}
if (dstAlphaIndex >= 0) {
- GLubyte *dst = dest;
+ GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstAlphaIndex] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ dst[dstAlphaIndex] = FLOAT_TO_CHAN(rgba[i][ACOMP]);
dst += dstComponents;
}
}
if (dstIntensityIndex >= 0) {
- GLubyte *dst = dest;
+ GLchan *dst = dest;
GLuint i;
assert(dstIntensityIndex == 0);
assert(dstComponents == 1);
for (i = 0; i < n; i++) {
/* Intensity comes from red channel */
- dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
}
}
if (dstLuminanceIndex >= 0) {
- GLubyte *dst = dest;
+ GLchan *dst = dest;
GLuint i;
assert(dstLuminanceIndex == 0);
for (i = 0; i < n; i++) {
/* Luminance comes from red channel */
- dst[0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[0] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
dst += dstComponents;
}
}
@@ -2641,10 +2829,10 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
}
if (dstFormat == GL_COLOR_INDEX) {
- /* convert to GLubyte and return */
+ /* convert to GLchan and return */
GLuint i;
for (i = 0; i < n; i++) {
- dest[i] = (GLubyte) (indexes[i] & 0xff);
+ dest[i] = (GLchan) (indexes[i] & 0xff);
}
return;
}
@@ -3186,197 +3374,3 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
return destBuffer;
}
}
-
-
-/*
- * Unpack bitmap data. Resulting data will be in most-significant-bit-first
- * order with row alignment = 1 byte.
- */
-GLvoid *
-_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
- const struct gl_pixelstore_attrib *packing )
-{
- GLint bytes, row, width_in_bytes;
- GLubyte *buffer, *dst;
-
- if (!pixels)
- return NULL;
-
- /* Alloc dest storage */
- bytes = ((width + 7) / 8 * height);
- buffer = (GLubyte *) MALLOC( bytes );
- if (!buffer)
- return NULL;
-
-
- width_in_bytes = CEILING( width, 8 );
- dst = buffer;
- for (row = 0; row < height; row++) {
- GLubyte *src = _mesa_image_address( packing, pixels, width, height,
- GL_COLOR_INDEX, GL_BITMAP,
- 0, row, 0 );
- if (!src) {
- FREE(buffer);
- return NULL;
- }
-
- if (packing->SkipPixels == 0) {
- MEMCPY( dst, src, width_in_bytes );
- if (packing->LsbFirst) {
- flip_bytes( dst, width_in_bytes );
- }
- }
- else {
- /* handling SkipPixels is a bit tricky (no pun intended!) */
- GLint i;
- if (packing->LsbFirst) {
- GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
- GLubyte dstMask = 128;
- GLubyte *s = src;
- GLubyte *d = dst;
- *d = 0;
- for (i = 0; i < width; i++) {
- if (*s & srcMask) {
- *d |= dstMask;
- }
- if (srcMask == 128) {
- srcMask = 1;
- s++;
- }
- else {
- srcMask = srcMask << 1;
- }
- if (dstMask == 1) {
- dstMask = 128;
- d++;
- *d = 0;
- }
- else {
- dstMask = dstMask >> 1;
- }
- }
- }
- else {
- GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7);
- GLubyte dstMask = 128;
- GLubyte *s = src;
- GLubyte *d = dst;
- *d = 0;
- for (i = 0; i < width; i++) {
- if (*s & srcMask) {
- *d |= dstMask;
- }
- if (srcMask == 1) {
- srcMask = 128;
- s++;
- }
- else {
- srcMask = srcMask >> 1;
- }
- if (dstMask == 1) {
- dstMask = 128;
- d++;
- *d = 0;
- }
- else {
- dstMask = dstMask >> 1;
- }
- }
- }
- }
- dst += width_in_bytes;
- }
-
- return buffer;
-}
-
-
-/*
- * Pack bitmap data.
- */
-void
-_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
- GLubyte *dest, const struct gl_pixelstore_attrib *packing )
-{
- GLint row, width_in_bytes;
- const GLubyte *src;
-
- if (!source)
- return;
-
- width_in_bytes = CEILING( width, 8 );
- src = source;
- for (row = 0; row < height; row++) {
- GLubyte *dst = _mesa_image_address( packing, dest, width, height,
- GL_COLOR_INDEX, GL_BITMAP,
- 0, row, 0 );
- if (!dst)
- return;
-
- if (packing->SkipPixels == 0) {
- MEMCPY( dst, src, width_in_bytes );
- if (packing->LsbFirst) {
- flip_bytes( dst, width_in_bytes );
- }
- }
- else {
- /* handling SkipPixels is a bit tricky (no pun intended!) */
- GLint i;
- if (packing->LsbFirst) {
- GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
- GLubyte dstMask = 128;
- const GLubyte *s = src;
- GLubyte *d = dst;
- *d = 0;
- for (i = 0; i < width; i++) {
- if (*s & srcMask) {
- *d |= dstMask;
- }
- if (srcMask == 128) {
- srcMask = 1;
- s++;
- }
- else {
- srcMask = srcMask << 1;
- }
- if (dstMask == 1) {
- dstMask = 128;
- d++;
- *d = 0;
- }
- else {
- dstMask = dstMask >> 1;
- }
- }
- }
- else {
- GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7);
- GLubyte dstMask = 128;
- const GLubyte *s = src;
- GLubyte *d = dst;
- *d = 0;
- for (i = 0; i < width; i++) {
- if (*s & srcMask) {
- *d |= dstMask;
- }
- if (srcMask == 1) {
- srcMask = 128;
- s++;
- }
- else {
- srcMask = srcMask >> 1;
- }
- if (dstMask == 1) {
- dstMask = 128;
- d++;
- *d = 0;
- }
- else {
- dstMask = dstMask >> 1;
- }
- }
- }
- }
- src += width_in_bytes;
- }
-}
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index e86e36f329..bd28ed4197 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -1,4 +1,4 @@
-/* $Id: image.h,v 1.12 2000/08/31 15:24:07 brianp Exp $ */
+/* $Id: image.h,v 1.13 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -79,6 +79,15 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
const struct gl_pixelstore_attrib *packing );
+extern GLvoid *
+_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
+ const struct gl_pixelstore_attrib *packing );
+
+extern void
+_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
+ GLubyte *dest, const struct gl_pixelstore_attrib *packing );
+
+
extern void
_mesa_pack_float_rgba_span( GLcontext *ctx,
GLuint n, CONST GLfloat rgba[][4],
@@ -89,19 +98,19 @@ _mesa_pack_float_rgba_span( GLcontext *ctx,
extern void
_mesa_pack_rgba_span( GLcontext *ctx,
- GLuint n, CONST GLubyte rgba[][4],
+ GLuint n, CONST GLchan rgba[][4],
GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
const struct gl_pixelstore_attrib *dstPacking,
GLuint transferOps );
extern void
-_mesa_unpack_ubyte_color_span( GLcontext *ctx,
- GLuint n, GLenum dstFormat, GLubyte dest[],
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLuint transferOps );
+_mesa_unpack_chan_color_span( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLchan dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps );
extern void
@@ -142,13 +151,4 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
const struct gl_pixelstore_attrib *unpack );
-extern GLvoid *
-_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
- const struct gl_pixelstore_attrib *packing );
-
-extern void
-_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
- GLubyte *dest, const struct gl_pixelstore_attrib *packing );
-
-
#endif
diff --git a/src/mesa/main/matrix.h b/src/mesa/main/matrix.h
index f35af5ee1c..db88b2857c 100644
--- a/src/mesa/main/matrix.h
+++ b/src/mesa/main/matrix.h
@@ -1,4 +1,4 @@
-/* $Id: matrix.h,v 1.7 2000/09/17 21:56:07 brianp Exp $ */
+/* $Id: matrix.h,v 1.8 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,81 +30,6 @@
#include "types.h"
-#include "config.h"
-
-
-/* Give symbolic names to some of the entries in the matrix to help
- * out with the rework of the viewport_map as a matrix transform.
- */
-#define MAT_SX 0
-#define MAT_SY 5
-#define MAT_SZ 10
-#define MAT_TX 12
-#define MAT_TY 13
-#define MAT_TZ 14
-
-
-/*
- * Different kinds of 4x4 transformation matrices:
- */
-#define MATRIX_GENERAL 0 /* general 4x4 matrix */
-#define MATRIX_IDENTITY 1 /* identity matrix */
-#define MATRIX_3D_NO_ROT 2 /* ortho projection and others... */
-#define MATRIX_PERSPECTIVE 3 /* perspective projection matrix */
-#define MATRIX_2D 4 /* 2-D transformation */
-#define MATRIX_2D_NO_ROT 5 /* 2-D scale & translate only */
-#define MATRIX_3D 6 /* 3-D transformation */
-
-#define MAT_FLAG_IDENTITY 0
-#define MAT_FLAG_GENERAL 0x1
-#define MAT_FLAG_ROTATION 0x2
-#define MAT_FLAG_TRANSLATION 0x4
-#define MAT_FLAG_UNIFORM_SCALE 0x8
-#define MAT_FLAG_GENERAL_SCALE 0x10
-#define MAT_FLAG_GENERAL_3D 0x20
-#define MAT_FLAG_PERSPECTIVE 0x40
-#define MAT_DIRTY_TYPE 0x80
-#define MAT_DIRTY_FLAGS 0x100
-#define MAT_DIRTY_INVERSE 0x200
-#define MAT_DIRTY_DEPENDENTS 0x400
-
-#define MAT_FLAGS_ANGLE_PRESERVING (MAT_FLAG_ROTATION | \
- MAT_FLAG_TRANSLATION | \
- MAT_FLAG_UNIFORM_SCALE)
-
-#define MAT_FLAGS_LENGTH_PRESERVING (MAT_FLAG_ROTATION | \
- MAT_FLAG_TRANSLATION)
-
-#define MAT_FLAGS_3D (MAT_FLAG_ROTATION | \
- MAT_FLAG_TRANSLATION | \
- MAT_FLAG_UNIFORM_SCALE | \
- MAT_FLAG_GENERAL_SCALE | \
- MAT_FLAG_GENERAL_3D)
-
-#define MAT_FLAGS_GEOMETRY (MAT_FLAG_GENERAL | \
- MAT_FLAG_ROTATION | \
- MAT_FLAG_TRANSLATION | \
- MAT_FLAG_UNIFORM_SCALE | \
- MAT_FLAG_GENERAL_SCALE | \
- MAT_FLAG_GENERAL_3D | \
- MAT_FLAG_PERSPECTIVE)
-
-#define MAT_DIRTY_ALL_OVER (MAT_DIRTY_TYPE | \
- MAT_DIRTY_DEPENDENTS | \
- MAT_DIRTY_FLAGS | \
- MAT_DIRTY_INVERSE)
-
-#define TEST_MAT_FLAGS(mat, a) ((MAT_FLAGS_GEOMETRY&(~(a))&((mat)->flags))==0)
-
-
-
-
-typedef struct {
- GLfloat *m; /* 16-byte aligned */
- GLfloat *inv; /* optional, 16-byte aligned */
- GLuint flags;
- GLuint type; /* one of the MATRIX_* values */
-} GLmatrix;
#ifdef VMS
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 8a1d598200..131db1dfdd 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.15 2000/10/28 20:41:14 brianp Exp $ */
+/* $Id: pixel.c,v 1.16 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -755,11 +755,11 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
/* replace RGBA with I */
if (!table->FloatTable) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = (const GLubyte *) table->Table;
+ const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLfloat c = lut[j] * (1.0F / 255.0F);
+ GLfloat c = CHAN_TO_FLOAT(lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
}
@@ -781,11 +781,11 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
/* replace RGB with L */
if (!table->FloatTable) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = (const GLubyte *) table->Table;
+ const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLfloat c = lut[j] * (1.0F / 255.0F);
+ GLfloat c = CHAN_TO_FLOAT(lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
@@ -804,11 +804,11 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
/* replace A with A */
if (!table->FloatTable) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = (const GLubyte *) table->Table;
+ const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
- rgba[i][ACOMP] = lut[j] * (1.0F / 255.0F);
+ rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[j]);
}
}
else {
@@ -825,13 +825,13 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
/* replace RGBA with LLLA */
if (!table->FloatTable) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = (const GLubyte *) table->Table;
+ const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
- GLfloat luminance = lut[jL * 2 + 0] * (1.0F / 255.0F);
- GLfloat alpha = lut[jA * 2 + 1] * (1.0F / 255.0F);
+ GLfloat luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]);
+ GLfloat alpha = CHAN_TO_FLOAT(lut[jA * 2 + 1]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;;
}
@@ -854,15 +854,15 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
/* replace RGB with RGB */
if (!table->FloatTable) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = (const GLubyte *) table->Table;
+ const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
- rgba[i][RCOMP] = lut[jR * 3 + 0] * (1.0F / 255.0F);
- rgba[i][GCOMP] = lut[jG * 3 + 1] * (1.0F / 255.0F);
- rgba[i][BCOMP] = lut[jB * 3 + 2] * (1.0F / 255.0F);
+ rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 3 + 0]);
+ rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 3 + 1]);
+ rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 3 + 2]);
}
}
else {
@@ -883,17 +883,17 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
/* replace RGBA with RGBA */
if (!table->FloatTable) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = (const GLubyte *) table->Table;
+ const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
- rgba[i][RCOMP] = lut[jR * 4 + 0] * (1.0F / 255.0F);
- rgba[i][GCOMP] = lut[jG * 4 + 1] * (1.0F / 255.0F);
- rgba[i][BCOMP] = lut[jB * 4 + 2] * (1.0F / 255.0F);
- rgba[i][ACOMP] = lut[jA * 4 + 3] * (1.0F / 255.0F);
+ rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 4 + 0]);
+ rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 4 + 1]);
+ rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 4 + 2]);
+ rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[jA * 4 + 3]);
}
}
else {
@@ -966,9 +966,10 @@ _mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] )
* Map color indexes to rgba values.
*/
void
-_mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n,
- const GLuint index[], GLubyte rgba[][4] )
+_mesa_map_ci_to_rgba_chan( const GLcontext *ctx, GLuint n,
+ const GLuint index[], GLchan rgba[][4] )
{
+#if CHAN_BITS == 8
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
GLuint bmask = ctx->Pixel.MapItoBsize - 1;
@@ -984,6 +985,23 @@ _mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n,
rgba[i][BCOMP] = bMap[index[i] & bmask];
rgba[i][ACOMP] = aMap[index[i] & amask];
}
+#else
+ GLuint rmask = ctx->Pixel.MapItoRsize - 1;
+ GLuint gmask = ctx->Pixel.MapItoGsize - 1;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLfloat *rMap = ctx->Pixel.MapItoR;
+ const GLfloat *gMap = ctx->Pixel.MapItoG;
+ const GLfloat *bMap = ctx->Pixel.MapItoB;
+ const GLfloat *aMap = ctx->Pixel.MapItoA;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]);
+ rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]);
+ rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]);
+ rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]);
+ }
+#endif
}
@@ -1017,8 +1035,9 @@ _mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n,
*/
void
_mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
- GLubyte rgba[][4] )
+ GLchan rgba[][4] )
{
+#if CHAN_BITS == 8
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
GLuint bmask = ctx->Pixel.MapItoBsize - 1;
@@ -1034,6 +1053,23 @@ _mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
rgba[i][BCOMP] = bMap[index[i] & bmask];
rgba[i][ACOMP] = aMap[index[i] & amask];
}
+#else
+ GLuint rmask = ctx->Pixel.MapItoRsize - 1;
+ GLuint gmask = ctx->Pixel.MapItoGsize - 1;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLfloat *rMap = ctx->Pixel.MapItoR8;
+ const GLfloat *gMap = ctx->Pixel.MapItoG8;
+ const GLfloat *bMap = ctx->Pixel.MapItoB8;
+ const GLfloat *aMap = ctx->Pixel.MapItoA8;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]);
+ rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]);
+ rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]);
+ rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]);
+ }
+#endif
}
diff --git a/src/mesa/main/pixel.h b/src/mesa/main/pixel.h
index 27d200825e..7eb0741aea 100644
--- a/src/mesa/main/pixel.h
+++ b/src/mesa/main/pixel.h
@@ -1,8 +1,8 @@
-/* $Id: pixel.h,v 1.5 2000/04/12 18:54:48 brianp Exp $ */
+/* $Id: pixel.h,v 1.6 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.5
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -103,9 +103,9 @@ _mesa_map_ci(const GLcontext *ctx, GLuint n, GLuint index[]);
extern void
-_mesa_map_ci_to_rgba_ubyte(const GLcontext *ctx,
- GLuint n, const GLuint index[],
- GLubyte rgba[][4]);
+_mesa_map_ci_to_rgba_chan(const GLcontext *ctx,
+ GLuint n, const GLuint index[],
+ GLchan rgba[][4]);
extern void
@@ -116,7 +116,7 @@ _mesa_map_ci_to_rgba(const GLcontext *ctx,
extern void
_mesa_map_ci8_to_rgba(const GLcontext *ctx,
GLuint n, const GLubyte index[],
- GLubyte rgba[][4]);
+ GLchan rgba[][4]);
extern void
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 149017a4a3..4338462984 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.35 2000/10/27 18:31:23 brianp Exp $ */
+/* $Id: state.c,v 1.36 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1107,17 +1107,14 @@ void gl_update_state( GLcontext *ctx )
}
ctx->rescale_factor = 1.0F;
-
if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE |
MAT_FLAG_GENERAL_SCALE |
MAT_FLAG_GENERAL_3D |
- MAT_FLAG_GENERAL) )
-
- {
- GLfloat *m = ctx->ModelView.inv;
- GLfloat f = m[2]*m[2] + m[6]*m[6] + m[10]*m[10];
- if (f > 1e-12 && (f-1)*(f-1) > 1e-12)
- ctx->rescale_factor = 1.0/GL_SQRT(f);
+ MAT_FLAG_GENERAL) ) {
+ const GLfloat *m = ctx->ModelView.inv;
+ const GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
+ if (f > 1e-12 && (f - 1.0) * (f - 1.0) > 1e-12)
+ ctx->rescale_factor = 1.0 / GL_SQRT(f);
}
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 6e20fe8776..718e561cf6 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.53 2000/10/28 18:34:48 brianp Exp $ */
+/* $Id: teximage.c,v 1.54 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,7 +45,7 @@
/*
* NOTES:
*
- * Mesa's native texture datatype is GLubyte. Native formats are
+ * Mesa's native texture datatype is GLchan. Native formats are
* GL_ALPHA, GL_LUMINANCE, GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, GL_RGBA,
* and GL_COLOR_INDEX.
* Device drivers are free to implement any internal format they want.
@@ -56,7 +56,7 @@
static void PrintTexture(const struct gl_texture_image *img)
{
int i, j, c;
- GLubyte *data = img->Data;
+ GLchan *data = img->Data;
if (!data) {
printf("No texture data\n");
@@ -676,11 +676,11 @@ adjust_texture_size_for_convolution(const GLcontext *ctx, GLuint dimensions,
* care of all image transfer operations here, including convolution.
* Input:
* dstXoffset, dstYoffset, dstZoffset - offsets in pixels
- * dstRowStride, dstImageStride - strides in bytes
+ * dstRowStride, dstImageStride - strides in GLchan's
*/
static void
fill_texture_image( GLcontext *ctx, GLuint dimensions,
- GLenum texFormat, GLubyte *texAddr,
+ GLenum texFormat, GLchan *texAddr,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride, GLint dstImageStride,
@@ -713,14 +713,14 @@ fill_texture_image( GLcontext *ctx, GLuint dimensions,
/* This will cover the common GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE_ALPHA, etc. texture formats. Use memcpy().
*/
- const GLubyte *src = (const GLubyte *) _mesa_image_address(
+ const GLchan *src = (const GLchan *) _mesa_image_address(
srcPacking, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, 0, 0, 0);
const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType);
- const GLint widthInBytes = srcWidth * texComponents;
- GLubyte *dst = texAddr + dstYoffset * dstRowStride
- + dstXoffset * texComponents * sizeof(GLubyte);
+ const GLint widthInBytes = srcWidth * texComponents * sizeof(GLchan);
+ GLchan *dst = texAddr + dstYoffset * dstRowStride
+ + dstXoffset * texComponents;
if (srcRowStride == widthInBytes && dstRowStride == widthInBytes) {
MEMCPY(dst, src, srcHeight * widthInBytes);
}
@@ -736,17 +736,17 @@ fill_texture_image( GLcontext *ctx, GLuint dimensions,
}
else if (srcFormat == GL_RGBA && texFormat == GL_RGB) {
/* commonly used by Quake */
- const GLubyte *src = (const GLubyte *) _mesa_image_address(
+ const GLchan *src = (const GLchan *) _mesa_image_address(
srcPacking, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, 0, 0, 0);
const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType);
- GLubyte *dst = texAddr + dstYoffset * dstRowStride
- + dstXoffset * texComponents * sizeof(GLubyte);
+ GLchan *dst = texAddr + dstYoffset * dstRowStride
+ + dstXoffset * texComponents;
GLint i, j;
for (i = 0; i < srcHeight; i++) {
- const GLubyte *s = src;
- GLubyte *d = dst;
+ const GLchan *s = src;
+ GLchan *d = dst;
for (j = 0; j < srcWidth; j++) {
*d++ = *s++; /*red*/
*d++ = *s++; /*green*/
@@ -767,11 +767,11 @@ fill_texture_image( GLcontext *ctx, GLuint dimensions,
/* color index texture */
const GLenum texType = GL_UNSIGNED_BYTE;
GLint img, row;
- GLubyte *dest = texAddr + dstZoffset * dstImageStride
+ GLchan *dest = texAddr + dstZoffset * dstImageStride
+ dstYoffset * dstRowStride
- + dstXoffset * texComponents * sizeof(GLubyte);
+ + dstXoffset * texComponents;
for (img = 0; img < srcDepth; img++) {
- GLubyte *destRow = dest;
+ GLchan *destRow = dest;
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -809,7 +809,7 @@ fill_texture_image( GLcontext *ctx, GLuint dimensions,
for (img = 0; img < srcDepth; img++) {
const GLfloat *srcf;
GLfloat *dstf = tmpImage;
- GLubyte *dest;
+ GLchan *dest;
/* unpack and do transfer ops up to convolution */
for (row = 0; row < srcHeight; row++) {
@@ -864,16 +864,16 @@ fill_texture_image( GLcontext *ctx, GLuint dimensions,
* no convolution
*/
GLint img, row;
- GLubyte *dest = texAddr + dstZoffset * dstImageStride
+ GLchan *dest = texAddr + dstZoffset * dstImageStride
+ dstYoffset * dstRowStride
- + dstXoffset * texComponents * sizeof(GLubyte);
+ + dstXoffset * texComponents;
for (img = 0; img < srcDepth; img++) {
- GLubyte *destRow = dest;
+ GLchan *destRow = dest;
for (row = 0; row < srcHeight; row++) {
const GLvoid *srcRow = _mesa_image_address(srcPacking,
srcAddr, srcWidth, srcHeight,
srcFormat, srcType, img, row, 0);
- _mesa_unpack_ubyte_color_span(ctx, srcWidth, texFormat, destRow,
+ _mesa_unpack_chan_color_span(ctx, srcWidth, texFormat, destRow,
srcFormat, srcType, srcRow, srcPacking,
ctx->ImageTransferState);
destRow += dstRowStride;
@@ -890,7 +890,7 @@ fill_texture_image( GLcontext *ctx, GLuint dimensions,
* X86 optimized code.
*/
#ifdef USE_X86_ASM
-# define EXTRA_BYTE 1
+# define EXTRA_BYTE sizeof(GLchan)
#else
# define EXTRA_BYTE 0
#endif
@@ -932,15 +932,15 @@ make_texture_image( GLcontext *ctx, GLuint dimensions,
&convWidth, &convHeight);
}
- texImage->Data = (GLubyte *) MALLOC(convWidth * convHeight * depth
- * components + EXTRA_BYTE);
+ texImage->Data = (GLchan *) MALLOC(convWidth * convHeight * depth
+ * components * sizeof(GLchan) + EXTRA_BYTE);
if (!texImage->Data)
return; /* out of memory */
fill_texture_image(ctx, dimensions, texImage->Format, texImage->Data,
width, height, depth, 0, 0, 0,
- convWidth * components * sizeof(GLubyte),
- convWidth * convHeight * components * sizeof(GLubyte),
+ convWidth * components * sizeof(GLchan),
+ convWidth * convHeight * components * sizeof(GLchan),
srcFormat, srcType, pixels, srcPacking);
}
@@ -963,7 +963,8 @@ make_null_texture( struct gl_texture_image *texImage )
components = components_in_intformat(texImage->IntFormat);
numPixels = texImage->Width * texImage->Height * texImage->Depth;
- texImage->Data = (GLubyte *) MALLOC( numPixels * components + EXTRA_BYTE );
+ texImage->Data = (GLchan *) MALLOC( numPixels * components * sizeof(GLchan)
+ + EXTRA_BYTE );
/*
* Let's see if anyone finds this. If glTexImage2D() is called with
@@ -982,7 +983,7 @@ make_null_texture( struct gl_texture_image *texImage )
" "
};
- GLubyte *imgPtr = texImage->Data;
+ GLchan *imgPtr = texImage->Data;
GLint i, j, k;
for (i = 0; i < texImage->Height; i++) {
GLint srcRow = 7 - i % 8;
@@ -990,7 +991,7 @@ make_null_texture( struct gl_texture_image *texImage )
GLint srcCol = j % 32;
GLint texel = (message[srcRow][srcCol]=='X') ? CHAN_MAX : 70;
for (k=0;k<components;k++) {
- *imgPtr++ = (GLubyte) texel;
+ *imgPtr++ = (GLchan) texel;
}
}
}
@@ -2059,7 +2060,8 @@ _mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
if (!texImage->Data) {
/* Allocate memory for the texture image data */
- texImage->Data = (GLubyte *) MALLOC(numPixels * destComponents + EXTRA_BYTE);
+ texImage->Data = (GLchan *) MALLOC(numPixels * destComponents
+ * sizeof(GLchan) + EXTRA_BYTE);
}
if (imgFormat == texImage->Format && imgType == GL_UNSIGNED_BYTE) {
@@ -2079,8 +2081,8 @@ _mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
const GLint srcBytesPerRow = width * srcBytesPerTexel;
const GLenum dstType = GL_UNSIGNED_BYTE;
const GLenum dstFormat = texImage->Format;
- const GLubyte *srcPtr = (const GLubyte *) image;
- GLubyte *destPtr = texImage->Data;
+ const GLchan *srcPtr = (const GLchan *) image;
+ GLchan *destPtr = texImage->Data;
if (texImage->Format == GL_COLOR_INDEX) {
/* color index texture */
@@ -2100,7 +2102,7 @@ _mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
GLint img, row;
for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) {
- _mesa_unpack_ubyte_color_span(ctx, width, dstFormat, destPtr,
+ _mesa_unpack_chan_color_span(ctx, width, dstFormat, destPtr,
imgFormat, imgType, srcPtr, &_mesa_native_packing, GL_FALSE);
destPtr += destBytesPerRow;
srcPtr += srcBytesPerRow;
@@ -2250,7 +2252,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
/* convert to GL_RGBA */
for (row = 0; row < height; row++) {
- const GLubyte *src = texImage->Data
+ const GLchan *src = texImage->Data
+ (img * height + row ) * width * comps;
GLfloat *dst = tmpImage + row * width * 4;
_mesa_unpack_float_color_span(ctx, width, GL_RGBA, dst,
@@ -2306,20 +2308,20 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
assert(dest);
if (texImage->Format == GL_RGBA) {
/* simple case */
- const GLubyte *src = texImage->Data
+ const GLchan *src = texImage->Data
+ (img * height + row ) * width * 4;
- _mesa_pack_rgba_span( ctx, width, (CONST GLubyte (*)[4]) src,
+ _mesa_pack_rgba_span( ctx, width, (CONST GLchan (*)[4]) src,
format, type, dest, &ctx->Pack,
ctx->ImageTransferState );
}
else {
/* general case: convert row to RGBA format */
- GLubyte rgba[MAX_WIDTH][4];
+ GLchan rgba[MAX_WIDTH][4];
GLint i;
- const GLubyte *src;
+ const GLchan *src;
switch (texImage->Format) {
case GL_ALPHA:
- src = texImage->Data + row * width * sizeof(GLubyte);
+ src = texImage->Data + row * width;
for (i = 0; i < width; i++) {
rgba[i][RCOMP] = CHAN_MAX;
rgba[i][GCOMP] = CHAN_MAX;
@@ -2328,7 +2330,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
}
break;
case GL_LUMINANCE:
- src = texImage->Data + row * width * sizeof(GLubyte);
+ src = texImage->Data + row * width;
for (i = 0; i < width; i++) {
rgba[i][RCOMP] = src[i];
rgba[i][GCOMP] = src[i];
@@ -2337,7 +2339,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
}
break;
case GL_LUMINANCE_ALPHA:
- src = texImage->Data + row * 2 * width * sizeof(GLubyte);
+ src = texImage->Data + row * 2 * width;
for (i = 0; i < width; i++) {
rgba[i][RCOMP] = src[i*2+0];
rgba[i][GCOMP] = src[i*2+0];
@@ -2346,7 +2348,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
}
break;
case GL_INTENSITY:
- src = texImage->Data + row * width * sizeof(GLubyte);
+ src = texImage->Data + row * width;
for (i = 0; i < width; i++) {
rgba[i][RCOMP] = src[i];
rgba[i][GCOMP] = src[i];
@@ -2355,7 +2357,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
}
break;
case GL_RGB:
- src = texImage->Data + row * 3 * width * sizeof(GLubyte);
+ src = texImage->Data + row * 3 * width;
for (i = 0; i < width; i++) {
rgba[i][RCOMP] = src[i*3+0];
rgba[i][GCOMP] = src[i*3+1];
@@ -2370,7 +2372,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
default:
gl_problem( ctx, "bad format in gl_GetTexImage" );
}
- _mesa_pack_rgba_span( ctx, width, (const GLubyte (*)[4])rgba,
+ _mesa_pack_rgba_span( ctx, width, (const GLchan (*)[4])rgba,
format, type, dest, &ctx->Pack,
ctx->ImageTransferState );
} /* format */
@@ -2499,7 +2501,7 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
if (!success) {
/* XXX if Driver.TexSubImage2D, unpack image and try again? */
const GLint texComps = components_in_intformat(texImage->Format);
- const GLint texRowStride = texImage->Width * texComps * sizeof(GLubyte);
+ const GLint texRowStride = texImage->Width * texComps;
GLboolean retain = GL_TRUE;
if (!texImage->Data) {
@@ -2582,7 +2584,7 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
if (!success) {
/* XXX if Driver.TexSubImage3D, unpack image and try again? */
const GLint texComps = components_in_intformat(texImage->Format);
- const GLint texRowStride = texImage->Width * texComps * sizeof(GLubyte);
+ const GLint texRowStride = texImage->Width * texComps;
const GLint texImgStride = texRowStride * texImage->Height;
GLboolean retain = GL_TRUE;
@@ -2622,16 +2624,16 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
* Input: ctx - the context
* x, y - lower left corner
* width, height - size of region to read
- * Return: pointer to block of GL_RGBA, GLubyte data.
+ * Return: pointer to block of GL_RGBA, GLchan data.
*/
-static GLubyte *
+static GLchan *
read_color_image( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
GLint stride, i;
- GLubyte *image, *dst;
+ GLchan *image, *dst;
- image = (GLubyte *) MALLOC(width * height * 4 * sizeof(GLubyte));
+ image = (GLchan *) MALLOC(width * height * 4 * sizeof(GLchan));
if (!image)
return NULL;
@@ -2640,10 +2642,10 @@ read_color_image( GLcontext *ctx, GLint x, GLint y,
ctx->Pixel.DriverReadBuffer );
dst = image;
- stride = width * 4 * sizeof(GLubyte);
+ stride = width * 4;
for (i = 0; i < height; i++) {
gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
- (GLubyte (*)[4]) dst );
+ (GLchan (*)[4]) dst );
dst += stride;
}
@@ -2678,7 +2680,7 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
struct gl_pixelstore_attrib unpackSave;
/* get image from framebuffer */
- GLubyte *image = read_color_image( ctx, x, y, width, 1 );
+ GLchan *image = read_color_image( ctx, x, y, width, 1 );
if (!image) {
gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D" );
return;
@@ -2718,7 +2720,7 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
struct gl_pixelstore_attrib unpackSave;
/* get image from framebuffer */
- GLubyte *image = read_color_image( ctx, x, y, width, height );
+ GLchan *image = read_color_image( ctx, x, y, width, height );
if (!image) {
gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D" );
return;
@@ -2757,7 +2759,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
struct gl_texture_unit *texUnit;
struct gl_texture_image *teximage;
struct gl_pixelstore_attrib unpackSave;
- GLubyte *image;
+ GLchan *image;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
teximage = texUnit->CurrentD[1]->Image[level];
@@ -2804,7 +2806,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
struct gl_texture_unit *texUnit;
struct gl_texture_image *teximage;
struct gl_pixelstore_attrib unpackSave;
- GLubyte *image;
+ GLchan *image;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
teximage = texUnit->CurrentD[2]->Image[level];
@@ -2851,7 +2853,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
struct gl_texture_unit *texUnit;
struct gl_texture_image *teximage;
struct gl_pixelstore_attrib unpackSave;
- GLubyte *image;
+ GLchan *image;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
teximage = texUnit->CurrentD[3]->Image[level];
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index 9628816795..597f7aba95 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -1,8 +1,8 @@
-/* $Id: texutil.c,v 1.7 2000/09/13 22:07:20 brianp Exp $ */
+/* $Id: texutil.c,v 1.8 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.4
+ * Version: 3.5
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -681,7 +681,7 @@ _mesa_convert_teximage(MesaIntTexFormat dstFormat,
GLubyte r = src[col3 + 0];
GLubyte g = src[col3 + 1];
GLubyte b = src[col3 + 2];
- GLubyte a = 255;
+ GLubyte a = CHAN_MAX;
dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
}
src += srcStride;
@@ -702,7 +702,7 @@ _mesa_convert_teximage(MesaIntTexFormat dstFormat,
GLubyte r = src[col3 + 0];
GLubyte g = src[col3 + 1];
GLubyte b = src[col3 + 2];
- GLubyte a = 255;
+ GLubyte a = CHAN_MAX;
dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
}
dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
@@ -1305,21 +1305,21 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat,
/*
- * Used to convert 16-bit texels into GLubyte color components.
+ * Used to convert 16-bit texels into GLchan color components.
*/
-static GLubyte R5G6B5toRed[0xffff];
-static GLubyte R5G6B5toGreen[0xffff];
-static GLubyte R5G6B5toBlue[0xffff];
+static GLchan R5G6B5toRed[0xffff];
+static GLchan R5G6B5toGreen[0xffff];
+static GLchan R5G6B5toBlue[0xffff];
-static GLubyte A4R4G4B4toRed[0xffff];
-static GLubyte A4R4G4B4toGreen[0xffff];
-static GLubyte A4R4G4B4toBlue[0xffff];
-static GLubyte A4R4G4B4toAlpha[0xffff];
+static GLchan A4R4G4B4toRed[0xffff];
+static GLchan A4R4G4B4toGreen[0xffff];
+static GLchan A4R4G4B4toBlue[0xffff];
+static GLchan A4R4G4B4toAlpha[0xffff];
-static GLubyte A1R5G5B5toRed[0xffff];
-static GLubyte A1R5G5B5toGreen[0xffff];
-static GLubyte A1R5G5B5toBlue[0xffff];
-static GLubyte A1R5G5B5toAlpha[0xffff];
+static GLchan A1R5G5B5toRed[0xffff];
+static GLchan A1R5G5B5toGreen[0xffff];
+static GLchan A1R5G5B5toBlue[0xffff];
+static GLchan A1R5G5B5toAlpha[0xffff];
static void
generate_lookup_tables(void)
@@ -1329,9 +1329,9 @@ generate_lookup_tables(void)
GLint r = (i >> 8) & 0xf8;
GLint g = (i >> 3) & 0xfc;
GLint b = (i << 3) & 0xf8;
- r = r * 255 / 0xf8;
- g = g * 255 / 0xfc;
- b = b * 255 / 0xf8;
+ r = r * CHAN_MAX / 0xf8;
+ g = g * CHAN_MAX / 0xfc;
+ b = b * CHAN_MAX / 0xf8;
R5G6B5toRed[i] = r;
R5G6B5toGreen[i] = g;
R5G6B5toBlue[i] = b;
@@ -1342,10 +1342,10 @@ generate_lookup_tables(void)
GLint g = (i >> 4) & 0xf;
GLint b = (i ) & 0xf;
GLint a = (i >> 12) & 0xf;
- r = r * 255 / 0xf;
- g = g * 255 / 0xf;
- b = b * 255 / 0xf;
- a = a * 255 / 0xf;
+ r = r * CHAN_MAX / 0xf;
+ g = g * CHAN_MAX / 0xf;
+ b = b * CHAN_MAX / 0xf;
+ a = a * CHAN_MAX / 0xf;
A4R4G4B4toRed[i] = r;
A4R4G4B4toGreen[i] = g;
A4R4G4B4toBlue[i] = b;
@@ -1357,10 +1357,10 @@ generate_lookup_tables(void)
GLint g = (i >> 5) & 0xf8;
GLint b = (i ) & 0xf8;
GLint a = (i >> 15) & 0x1;
- r = r * 255 / 0xf8;
- g = g * 255 / 0xf8;
- b = b * 255 / 0xf8;
- a = a * 255;
+ r = r * CHAN_MAX / 0xf8;
+ g = g * CHAN_MAX / 0xf8;
+ b = b * CHAN_MAX / 0xf8;
+ a = a * CHAN_MAX;
A1R5G5B5toRed[i] = r;
A1R5G5B5toGreen[i] = g;
A1R5G5B5toBlue[i] = b;
@@ -1393,7 +1393,7 @@ _mesa_unconvert_teximage(MesaIntTexFormat srcFormat,
GLint srcWidth, GLint srcHeight,
const GLvoid *srcImage, GLint srcRowStride,
GLint dstWidth, GLint dstHeight,
- GLenum dstFormat, GLubyte *dstImage)
+ GLenum dstFormat, GLchan *dstImage)
{
static GLboolean firstCall = GL_TRUE;
const GLint wScale = srcWidth / dstWidth; /* must be power of two */
@@ -1429,11 +1429,11 @@ _mesa_unconvert_teximage(MesaIntTexFormat srcFormat,
#endif
if (wScale == 1 && hScale == 1) {
/* easy! */
- MEMCPY(dstImage, srcImage, dstWidth * dstHeight * sizeof(GLubyte));
+ MEMCPY(dstImage, srcImage, dstWidth * dstHeight * sizeof(GLchan));
}
else {
/* rescale */
- const GLubyte *src8 = (const GLubyte *) srcImage;
+ const GLchan *src8 = (const GLchan *) srcImage;
GLint row, col;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row * hScale;
diff --git a/src/mesa/main/texutil.h b/src/mesa/main/texutil.h
index 23116bf5ce..23c2840bbc 100644
--- a/src/mesa/main/texutil.h
+++ b/src/mesa/main/texutil.h
@@ -1,8 +1,8 @@
-/* $Id: texutil.h,v 1.4 2000/08/29 23:30:53 brianp Exp $ */
+/* $Id: texutil.h,v 1.5 2000/10/29 18:12:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.4
+ * Version: 3.5
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -81,7 +81,7 @@ _mesa_unconvert_teximage(MesaIntTexFormat srcFormat,
GLint srcWidth, GLint srcHeight,
const GLvoid *srcImage, GLint srcRowStride,
GLint dstWidth, GLint dstHeight,
- GLenum dstFormat, GLubyte *dstImage);
+ GLenum dstFormat, GLchan *dstImage);
extern void