more color table and imaging work
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: colortab.c,v 1.15 2000/04/17 17:57:04 brianp Exp $ */
|
/* $Id: colortab.c,v 1.16 2000/04/18 14:32:10 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -153,6 +153,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
|||||||
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
|
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
|
||||||
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
|
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
|
||||||
GLboolean floatTable = GL_FALSE;
|
GLboolean floatTable = GL_FALSE;
|
||||||
|
GLint comps;
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable");
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable");
|
||||||
|
|
||||||
@@ -267,12 +268,14 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
table->Size = width;
|
table->Size = width;
|
||||||
table->IntFormat = internalFormat;
|
table->IntFormat = internalFormat;
|
||||||
table->Format = (GLenum) baseFormat;
|
table->Format = (GLenum) baseFormat;
|
||||||
set_component_sizes(table);
|
set_component_sizes(table);
|
||||||
|
|
||||||
|
comps = _mesa_components_in_format(table->Format);
|
||||||
|
assert(comps > 0); /* error should have been caught sooner */
|
||||||
|
|
||||||
if (!proxy) {
|
if (!proxy) {
|
||||||
/* free old table, if any */
|
/* free old table, if any */
|
||||||
if (table->Table) {
|
if (table->Table) {
|
||||||
@@ -289,7 +292,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
|||||||
&ctx->Unpack, GL_TRUE);
|
&ctx->Unpack, GL_TRUE);
|
||||||
|
|
||||||
table->TableType = GL_FLOAT;
|
table->TableType = GL_FLOAT;
|
||||||
table->Table = MALLOC(4 * width * sizeof(GLfloat));
|
table->Table = MALLOC(comps * width * sizeof(GLfloat));
|
||||||
if (!table->Table) {
|
if (!table->Table) {
|
||||||
gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
|
gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
|
||||||
return;
|
return;
|
||||||
@@ -349,7 +352,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
|||||||
else {
|
else {
|
||||||
/* store GLubyte table */
|
/* store GLubyte table */
|
||||||
table->TableType = GL_UNSIGNED_BYTE;
|
table->TableType = GL_UNSIGNED_BYTE;
|
||||||
table->Table = MALLOC(4 * width * sizeof(GLubyte));
|
table->Table = MALLOC(comps * width * sizeof(GLubyte));
|
||||||
if (!table->Table) {
|
if (!table->Table) {
|
||||||
gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
|
gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
|
||||||
return;
|
return;
|
||||||
@@ -367,7 +370,6 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
|||||||
(*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
|
(*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -382,7 +384,6 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
|
|||||||
struct gl_texture_object *texObj = NULL;
|
struct gl_texture_object *texObj = NULL;
|
||||||
struct gl_color_table *table = NULL;
|
struct gl_color_table *table = NULL;
|
||||||
GLint comps;
|
GLint comps;
|
||||||
GLubyte *dest;
|
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable");
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable");
|
||||||
|
|
||||||
@@ -442,17 +443,17 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table->TableType == GL_UNSIGNED_BYTE) {
|
if (table->TableType == GL_UNSIGNED_BYTE) {
|
||||||
dest = (GLubyte *) table->Table + start * comps * sizeof(GLubyte);
|
GLubyte *dest = (GLubyte *) table->Table + start * comps * sizeof(GLubyte);
|
||||||
_mesa_unpack_ubyte_color_span(ctx, count, table->Format, dest,
|
_mesa_unpack_ubyte_color_span(ctx, count, table->Format, dest,
|
||||||
format, type, data,
|
format, type, data, &ctx->Unpack, GL_TRUE);
|
||||||
&ctx->Unpack, GL_TRUE);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
GLfloat *dest = (GLfloat *) table->Table + start * comps * sizeof(GLfloat);
|
||||||
ASSERT(table->TableType == GL_FLOAT);
|
ASSERT(table->TableType == GL_FLOAT);
|
||||||
/* XXX todo */
|
_mesa_unpack_float_color_span(ctx, count, table->Format, dest,
|
||||||
|
format, type, data, &ctx->Unpack, GL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
|
if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
|
||||||
/* per-texture object palette */
|
/* per-texture object palette */
|
||||||
if (ctx->Driver.UpdateTexturePalette) {
|
if (ctx->Driver.UpdateTexturePalette) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: drawpix.c,v 1.20 2000/04/12 18:54:48 brianp Exp $ */
|
/* $Id: drawpix.c,v 1.21 2000/04/18 14:32:10 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -121,6 +121,8 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
|
|||||||
&& !ctx->Pixel.ScaleOrBiasRGBApcm
|
&& !ctx->Pixel.ScaleOrBiasRGBApcm
|
||||||
&& ctx->ColorMatrix.type == MATRIX_IDENTITY
|
&& ctx->ColorMatrix.type == MATRIX_IDENTITY
|
||||||
&& !ctx->Pixel.ColorTableEnabled
|
&& !ctx->Pixel.ColorTableEnabled
|
||||||
|
&& !ctx->Pixel.PostColorMatrixColorTableEnabled
|
||||||
|
&& !ctx->Pixel.MinMaxEnabled
|
||||||
&& ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0
|
&& ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0
|
||||||
&& ctx->Pixel.MapColorFlag==0
|
&& ctx->Pixel.MapColorFlag==0
|
||||||
&& ctx->Texture.ReallyEnabled == 0
|
&& ctx->Texture.ReallyEnabled == 0
|
||||||
@@ -650,6 +652,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
|
|||||||
pixels, width, height, format, type, 0, row, 0);
|
pixels, width, height, format, type, 0, row, 0);
|
||||||
_mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba,
|
_mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba,
|
||||||
format, type, source, unpack, GL_TRUE);
|
format, type, source, unpack, GL_TRUE);
|
||||||
|
if (ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
|
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
|
||||||
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
|
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: image.c,v 1.28 2000/04/17 15:13:53 brianp Exp $ */
|
/* $Id: image.c,v 1.29 2000/04/18 14:32:10 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "glheader.h"
|
#include "glheader.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "imaging.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "mmath.h"
|
#include "mmath.h"
|
||||||
@@ -602,7 +603,7 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
|
|||||||
* applyTransferOps - apply scale/bias/lookup-table ops?
|
* applyTransferOps - apply scale/bias/lookup-table ops?
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_mesa_pack_rgba_span( const GLcontext *ctx,
|
_mesa_pack_rgba_span( GLcontext *ctx,
|
||||||
GLuint n, CONST GLubyte srcRgba[][4],
|
GLuint n, CONST GLubyte srcRgba[][4],
|
||||||
GLenum format, GLenum type, GLvoid *destination,
|
GLenum format, GLenum type, GLvoid *destination,
|
||||||
const struct gl_pixelstore_attrib *packing,
|
const struct gl_pixelstore_attrib *packing,
|
||||||
@@ -613,7 +614,8 @@ _mesa_pack_rgba_span( const GLcontext *ctx,
|
|||||||
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
||||||
ctx->Pixel.ScaleOrBiasRGBApcm ||
|
ctx->Pixel.ScaleOrBiasRGBApcm ||
|
||||||
ctx->Pixel.ColorTableEnabled ||
|
ctx->Pixel.ColorTableEnabled ||
|
||||||
ctx->Pixel.PostColorMatrixColorTableEnabled);
|
ctx->Pixel.PostColorMatrixColorTableEnabled ||
|
||||||
|
ctx->Pixel.MinMaxEnabled);
|
||||||
|
|
||||||
/* Test for optimized case first */
|
/* Test for optimized case first */
|
||||||
if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
|
if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
|
||||||
@@ -680,6 +682,11 @@ _mesa_pack_rgba_span( const GLcontext *ctx,
|
|||||||
}
|
}
|
||||||
/* XXX histogram here */
|
/* XXX histogram here */
|
||||||
/* XXX min/max here */
|
/* XXX min/max here */
|
||||||
|
if (ctx->Pixel.MinMaxEnabled) {
|
||||||
|
_mesa_update_minmax(ctx, n, (const GLfloat (*)[4]) rgba);
|
||||||
|
if (ctx->MinMax.Sink)
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) {
|
if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) {
|
||||||
@@ -2128,7 +2135,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
|
|||||||
* XXX perhaps expand this to process whole images someday.
|
* XXX perhaps expand this to process whole images someday.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
_mesa_unpack_ubyte_color_span( GLcontext *ctx,
|
||||||
GLuint n, GLenum dstFormat, GLubyte dest[],
|
GLuint n, GLenum dstFormat, GLubyte dest[],
|
||||||
GLenum srcFormat, GLenum srcType,
|
GLenum srcFormat, GLenum srcType,
|
||||||
const GLvoid *source,
|
const GLvoid *source,
|
||||||
@@ -2186,7 +2193,8 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
|||||||
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
||||||
ctx->Pixel.ScaleOrBiasRGBApcm ||
|
ctx->Pixel.ScaleOrBiasRGBApcm ||
|
||||||
ctx->Pixel.ColorTableEnabled ||
|
ctx->Pixel.ColorTableEnabled ||
|
||||||
ctx->Pixel.PostColorMatrixColorTableEnabled);
|
ctx->Pixel.PostColorMatrixColorTableEnabled ||
|
||||||
|
ctx->Pixel.MinMaxEnabled);
|
||||||
|
|
||||||
/* Try simple cases first */
|
/* Try simple cases first */
|
||||||
if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) {
|
if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) {
|
||||||
@@ -2258,26 +2266,22 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
|||||||
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
|
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
|
||||||
unpacking);
|
unpacking);
|
||||||
|
|
||||||
/* shift and offset indexes */
|
if (applyTransferOps) {
|
||||||
_mesa_shift_and_offset_ci(ctx, n, indexes);
|
if (ctx->Pixel.MapColorFlag) {
|
||||||
|
_mesa_map_ci(ctx, n, indexes);
|
||||||
|
}
|
||||||
|
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
|
||||||
|
_mesa_shift_and_offset_ci(ctx, n, indexes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (dstFormat == GL_COLOR_INDEX) {
|
if (dstFormat == GL_COLOR_INDEX) {
|
||||||
if (applyTransferOps) {
|
|
||||||
if (ctx->Pixel.MapColorFlag) {
|
|
||||||
/* Apply lookup table */
|
|
||||||
_mesa_map_ci(ctx, n, indexes);
|
|
||||||
}
|
|
||||||
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
|
|
||||||
_mesa_shift_and_offset_ci(ctx, n, indexes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* convert to GLubyte and return */
|
/* convert to GLubyte and return */
|
||||||
{
|
GLuint i;
|
||||||
GLuint i;
|
for (i = 0; i < n; i++) {
|
||||||
for (i = 0; i < n; i++) {
|
dest[i] = (GLubyte) (indexes[i] & 0xff);
|
||||||
dest[i] = (GLubyte) (indexes[i] & 0xff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Convert indexes to RGBA */
|
/* Convert indexes to RGBA */
|
||||||
@@ -2290,28 +2294,36 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
|||||||
|
|
||||||
if (applyTransferOps) {
|
if (applyTransferOps) {
|
||||||
/* scale and bias colors */
|
/* scale and bias colors */
|
||||||
_mesa_scale_and_bias_rgba(ctx, n, rgba);
|
if (ctx->Pixel.ScaleOrBiasRGBA) {
|
||||||
|
_mesa_scale_and_bias_rgba(ctx, n, rgba);
|
||||||
|
}
|
||||||
/* color map lookup */
|
/* color map lookup */
|
||||||
if (ctx->Pixel.MapColorFlag) {
|
if (ctx->Pixel.MapColorFlag) {
|
||||||
_mesa_map_rgba(ctx, n, rgba);
|
_mesa_map_rgba(ctx, n, rgba);
|
||||||
}
|
}
|
||||||
/* GL_COLOR_TABLE lookup */
|
}
|
||||||
if (ctx->Pixel.ColorTableEnabled) {
|
}
|
||||||
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
|
|
||||||
}
|
if (applyTransferOps) {
|
||||||
/* XXX convolution here */
|
/* GL_COLOR_TABLE lookup */
|
||||||
/* XXX post-convolution color table look-up here */
|
if (ctx->Pixel.ColorTableEnabled) {
|
||||||
/* color matrix transform */
|
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
|
||||||
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
}
|
||||||
ctx->Pixel.ScaleOrBiasRGBApcm) {
|
/* XXX convolution here */
|
||||||
_mesa_transform_rgba(ctx, n, rgba);
|
/* XXX post-convolution color table look-up here */
|
||||||
}
|
/* color matrix transform */
|
||||||
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
|
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
||||||
if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
|
ctx->Pixel.ScaleOrBiasRGBApcm) {
|
||||||
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
|
_mesa_transform_rgba(ctx, n, rgba);
|
||||||
}
|
}
|
||||||
/* XXX histogram here */
|
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
|
||||||
/* XXX min/max here */
|
if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
|
||||||
|
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
|
||||||
|
}
|
||||||
|
/* XXX histogram here */
|
||||||
|
/* XXX min/max here */
|
||||||
|
if (ctx->Pixel.MinMaxEnabled) {
|
||||||
|
_mesa_update_minmax(ctx, n, (const GLfloat (*)[4]) rgba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2433,6 +2445,266 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_mesa_unpack_float_color_span( GLcontext *ctx,
|
||||||
|
GLuint n, GLenum dstFormat, GLfloat dest[],
|
||||||
|
GLenum srcFormat, GLenum srcType,
|
||||||
|
const GLvoid *source,
|
||||||
|
const struct gl_pixelstore_attrib *unpacking,
|
||||||
|
GLboolean applyTransferOps )
|
||||||
|
{
|
||||||
|
ASSERT(dstFormat == GL_ALPHA ||
|
||||||
|
dstFormat == GL_LUMINANCE ||
|
||||||
|
dstFormat == GL_LUMINANCE_ALPHA ||
|
||||||
|
dstFormat == GL_INTENSITY ||
|
||||||
|
dstFormat == GL_RGB ||
|
||||||
|
dstFormat == GL_RGBA ||
|
||||||
|
dstFormat == GL_COLOR_INDEX);
|
||||||
|
|
||||||
|
ASSERT(srcFormat == GL_RED ||
|
||||||
|
srcFormat == GL_GREEN ||
|
||||||
|
srcFormat == GL_BLUE ||
|
||||||
|
srcFormat == GL_ALPHA ||
|
||||||
|
srcFormat == GL_LUMINANCE ||
|
||||||
|
srcFormat == GL_LUMINANCE_ALPHA ||
|
||||||
|
srcFormat == GL_INTENSITY ||
|
||||||
|
srcFormat == GL_RGB ||
|
||||||
|
srcFormat == GL_BGR ||
|
||||||
|
srcFormat == GL_RGBA ||
|
||||||
|
srcFormat == GL_BGRA ||
|
||||||
|
srcFormat == GL_ABGR_EXT ||
|
||||||
|
srcFormat == GL_COLOR_INDEX);
|
||||||
|
|
||||||
|
ASSERT(srcType == GL_BITMAP ||
|
||||||
|
srcType == GL_UNSIGNED_BYTE ||
|
||||||
|
srcType == GL_BYTE ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT ||
|
||||||
|
srcType == GL_SHORT ||
|
||||||
|
srcType == GL_UNSIGNED_INT ||
|
||||||
|
srcType == GL_INT ||
|
||||||
|
srcType == GL_FLOAT ||
|
||||||
|
srcType == GL_UNSIGNED_BYTE_3_3_2 ||
|
||||||
|
srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT_5_6_5 ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT_5_6_5_REV ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT_4_4_4_4 ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT_5_5_5_1 ||
|
||||||
|
srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ||
|
||||||
|
srcType == GL_UNSIGNED_INT_8_8_8_8 ||
|
||||||
|
srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
|
||||||
|
srcType == GL_UNSIGNED_INT_10_10_10_2 ||
|
||||||
|
srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
|
||||||
|
|
||||||
|
/* this is intended for RGBA mode only */
|
||||||
|
assert(ctx->Visual->RGBAflag);
|
||||||
|
|
||||||
|
applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA ||
|
||||||
|
ctx->Pixel.MapColorFlag ||
|
||||||
|
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
||||||
|
ctx->Pixel.ScaleOrBiasRGBApcm ||
|
||||||
|
ctx->Pixel.ColorTableEnabled ||
|
||||||
|
ctx->Pixel.PostColorMatrixColorTableEnabled ||
|
||||||
|
ctx->Pixel.MinMaxEnabled);
|
||||||
|
|
||||||
|
/* general solution, no special cases, yet */
|
||||||
|
{
|
||||||
|
GLfloat rgba[MAX_WIDTH][4];
|
||||||
|
GLint dstComponents;
|
||||||
|
GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex;
|
||||||
|
GLint dstLuminanceIndex, dstIntensityIndex;
|
||||||
|
|
||||||
|
dstComponents = _mesa_components_in_format( dstFormat );
|
||||||
|
/* source & dest image formats should have been error checked by now */
|
||||||
|
assert(dstComponents > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extract image data and convert to RGBA floats
|
||||||
|
*/
|
||||||
|
assert(n <= MAX_WIDTH);
|
||||||
|
if (srcFormat == GL_COLOR_INDEX) {
|
||||||
|
GLuint indexes[MAX_WIDTH];
|
||||||
|
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
|
||||||
|
unpacking);
|
||||||
|
|
||||||
|
if (applyTransferOps) {
|
||||||
|
if (ctx->Pixel.MapColorFlag) {
|
||||||
|
_mesa_map_ci(ctx, n, indexes);
|
||||||
|
}
|
||||||
|
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
|
||||||
|
_mesa_shift_and_offset_ci(ctx, n, indexes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstFormat == GL_COLOR_INDEX) {
|
||||||
|
/* convert to GLubyte and return */
|
||||||
|
GLuint i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
dest[i] = (GLubyte) (indexes[i] & 0xff);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Convert indexes to RGBA */
|
||||||
|
_mesa_map_ci_to_rgba(ctx, n, indexes, rgba);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extract_float_rgba(n, rgba, srcFormat, srcType, source,
|
||||||
|
unpacking->SwapBytes);
|
||||||
|
|
||||||
|
if (applyTransferOps) {
|
||||||
|
/* scale and bias colors */
|
||||||
|
if (ctx->Pixel.ScaleOrBiasRGBA) {
|
||||||
|
_mesa_scale_and_bias_rgba(ctx, n, rgba);
|
||||||
|
}
|
||||||
|
/* color map lookup */
|
||||||
|
if (ctx->Pixel.MapColorFlag) {
|
||||||
|
_mesa_map_rgba(ctx, n, rgba);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (applyTransferOps) {
|
||||||
|
/* GL_COLOR_TABLE lookup */
|
||||||
|
if (ctx->Pixel.ColorTableEnabled) {
|
||||||
|
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
|
||||||
|
}
|
||||||
|
/* XXX convolution here */
|
||||||
|
/* XXX post-convolution color table look-up here */
|
||||||
|
/* color matrix transform */
|
||||||
|
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
|
||||||
|
ctx->Pixel.ScaleOrBiasRGBApcm) {
|
||||||
|
_mesa_transform_rgba(ctx, n, rgba);
|
||||||
|
}
|
||||||
|
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
|
||||||
|
if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
|
||||||
|
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
|
||||||
|
}
|
||||||
|
/* XXX histogram here */
|
||||||
|
/* XXX min/max here */
|
||||||
|
if (ctx->Pixel.MinMaxEnabled) {
|
||||||
|
_mesa_update_minmax(ctx, n, (const GLfloat (*)[4]) rgba);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clamp to [0,1] */
|
||||||
|
{
|
||||||
|
GLuint i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F);
|
||||||
|
rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F);
|
||||||
|
rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F);
|
||||||
|
rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now determine which color channels we need to produce.
|
||||||
|
* And determine the dest index (offset) within each color tuple.
|
||||||
|
*/
|
||||||
|
switch (dstFormat) {
|
||||||
|
case GL_ALPHA:
|
||||||
|
dstAlphaIndex = 0;
|
||||||
|
dstRedIndex = dstGreenIndex = dstBlueIndex = -1;
|
||||||
|
dstLuminanceIndex = dstIntensityIndex = -1;
|
||||||
|
break;
|
||||||
|
case GL_LUMINANCE:
|
||||||
|
dstLuminanceIndex = 0;
|
||||||
|
dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1;
|
||||||
|
dstIntensityIndex = -1;
|
||||||
|
break;
|
||||||
|
case GL_LUMINANCE_ALPHA:
|
||||||
|
dstLuminanceIndex = 0;
|
||||||
|
dstAlphaIndex = 1;
|
||||||
|
dstRedIndex = dstGreenIndex = dstBlueIndex = -1;
|
||||||
|
dstIntensityIndex = -1;
|
||||||
|
break;
|
||||||
|
case GL_INTENSITY:
|
||||||
|
dstIntensityIndex = 0;
|
||||||
|
dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1;
|
||||||
|
dstLuminanceIndex = -1;
|
||||||
|
break;
|
||||||
|
case GL_RGB:
|
||||||
|
dstRedIndex = 0;
|
||||||
|
dstGreenIndex = 1;
|
||||||
|
dstBlueIndex = 2;
|
||||||
|
dstAlphaIndex = dstLuminanceIndex = dstIntensityIndex = -1;
|
||||||
|
break;
|
||||||
|
case GL_RGBA:
|
||||||
|
dstRedIndex = 0;
|
||||||
|
dstGreenIndex = 1;
|
||||||
|
dstBlueIndex = 2;
|
||||||
|
dstAlphaIndex = 3;
|
||||||
|
dstLuminanceIndex = dstIntensityIndex = -1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gl_problem(ctx, "bad dstFormat in _mesa_unpack_float_span()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now pack results in teh requested dstFormat */
|
||||||
|
if (dstRedIndex >= 0) {
|
||||||
|
GLfloat *dst = dest;
|
||||||
|
GLuint i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
dst[dstRedIndex] = rgba[i][RCOMP];
|
||||||
|
dst += dstComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstGreenIndex >= 0) {
|
||||||
|
GLfloat *dst = dest;
|
||||||
|
GLuint i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
dst[dstGreenIndex] = rgba[i][GCOMP];
|
||||||
|
dst += dstComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstBlueIndex >= 0) {
|
||||||
|
GLfloat *dst = dest;
|
||||||
|
GLuint i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
dst[dstBlueIndex] = rgba[i][BCOMP];
|
||||||
|
dst += dstComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstAlphaIndex >= 0) {
|
||||||
|
GLfloat *dst = dest;
|
||||||
|
GLuint i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
dst[dstAlphaIndex] = rgba[i][ACOMP];
|
||||||
|
dst += dstComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstIntensityIndex >= 0) {
|
||||||
|
GLfloat *dst = dest;
|
||||||
|
GLuint i;
|
||||||
|
assert(dstIntensityIndex == 0);
|
||||||
|
assert(dstComponents == 1);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
/* Intensity comes from red channel */
|
||||||
|
dst[i] = rgba[i][RCOMP];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstLuminanceIndex >= 0) {
|
||||||
|
GLfloat *dst = dest;
|
||||||
|
GLuint i;
|
||||||
|
assert(dstLuminanceIndex == 0);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
/* Luminance comes from red channel */
|
||||||
|
dst[0] = rgba[i][RCOMP];
|
||||||
|
dst += dstComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unpack a row of color index data from a client buffer according to
|
* Unpack a row of color index data from a client buffer according to
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: image.h,v 1.7 2000/03/21 16:09:38 brianp Exp $ */
|
/* $Id: image.h,v 1.8 2000/04/18 14:32:10 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -80,7 +80,7 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
|
|||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_pack_rgba_span( const GLcontext *ctx,
|
_mesa_pack_rgba_span( GLcontext *ctx,
|
||||||
GLuint n, CONST GLubyte rgba[][4],
|
GLuint n, CONST GLubyte rgba[][4],
|
||||||
GLenum format, GLenum type, GLvoid *dest,
|
GLenum format, GLenum type, GLvoid *dest,
|
||||||
const struct gl_pixelstore_attrib *packing,
|
const struct gl_pixelstore_attrib *packing,
|
||||||
@@ -88,7 +88,7 @@ _mesa_pack_rgba_span( const GLcontext *ctx,
|
|||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
_mesa_unpack_ubyte_color_span( GLcontext *ctx,
|
||||||
GLuint n, GLenum dstFormat, GLubyte dest[],
|
GLuint n, GLenum dstFormat, GLubyte dest[],
|
||||||
GLenum srcFormat, GLenum srcType,
|
GLenum srcFormat, GLenum srcType,
|
||||||
const GLvoid *source,
|
const GLvoid *source,
|
||||||
@@ -96,6 +96,15 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
|
|||||||
GLboolean applyTransferOps );
|
GLboolean applyTransferOps );
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
_mesa_unpack_float_color_span( GLcontext *ctx,
|
||||||
|
GLuint n, GLenum dstFormat, GLfloat dest[],
|
||||||
|
GLenum srcFormat, GLenum srcType,
|
||||||
|
const GLvoid *source,
|
||||||
|
const struct gl_pixelstore_attrib *unpacking,
|
||||||
|
GLboolean applyTransferOps );
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
|
_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
|
||||||
GLenum dstType, GLvoid *dest,
|
GLenum dstType, GLvoid *dest,
|
||||||
|
Reference in New Issue
Block a user