In _mesa_pack_rgba_span_float() we don't need to make a temporary copy of
incoming colors when applying pixel transfer ops. In all cases, the caller either indicates there's no pixel transfer ops, or the incoming colors are coming from temporary storage already and can be safely modified.
This commit is contained in:
@@ -807,7 +807,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
|
|||||||
data = ADD_POINTERS(buf, data);
|
data = ADD_POINTERS(buf, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mesa_pack_rgba_span_float(ctx, table->Size, (const GLfloat (*)[4]) rgba,
|
_mesa_pack_rgba_span_float(ctx, table->Size, rgba,
|
||||||
format, type, data, &ctx->Pack, 0x0);
|
format, type, data, &ctx->Pack, 0x0);
|
||||||
|
|
||||||
if (ctx->Pack.BufferObj->Name) {
|
if (ctx->Pack.BufferObj->Name) {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
* Version: 6.3
|
* Version: 6.5.2
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -560,9 +560,10 @@ _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLi
|
|||||||
|
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image)
|
_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
|
||||||
|
GLvoid *image)
|
||||||
{
|
{
|
||||||
const struct gl_convolution_attrib *filter;
|
struct gl_convolution_attrib *filter;
|
||||||
GLuint row;
|
GLuint row;
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
@@ -623,10 +624,9 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im
|
|||||||
GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width,
|
GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width,
|
||||||
filter->Height, format, type,
|
filter->Height, format, type,
|
||||||
row, 0);
|
row, 0);
|
||||||
const GLfloat *src = filter->Filter + row * filter->Width * 4;
|
GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + row * filter->Width * 4);
|
||||||
_mesa_pack_rgba_span_float(ctx, filter->Width,
|
_mesa_pack_rgba_span_float(ctx, filter->Width, src,
|
||||||
(const GLfloat (*)[4]) src,
|
format, type, dst, &ctx->Pack, 0x0);
|
||||||
format, type, dst, &ctx->Pack, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Pack.BufferObj->Name) {
|
if (ctx->Pack.BufferObj->Name) {
|
||||||
@@ -768,10 +768,11 @@ _mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
|
|||||||
|
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span)
|
_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
|
||||||
|
GLvoid *row, GLvoid *column, GLvoid *span)
|
||||||
{
|
{
|
||||||
const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
|
const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
|
||||||
const struct gl_convolution_attrib *filter;
|
struct gl_convolution_attrib *filter;
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
@@ -785,7 +786,8 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
|
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)");
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glGetConvolutionFilter(format or type)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,18 +835,17 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
|
|||||||
GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width,
|
GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width,
|
||||||
format, type, 0);
|
format, type, 0);
|
||||||
_mesa_pack_rgba_span_float(ctx, filter->Width,
|
_mesa_pack_rgba_span_float(ctx, filter->Width,
|
||||||
(const GLfloat (*)[4]) filter->Filter,
|
(GLfloat (*)[4]) filter->Filter,
|
||||||
format, type, dst, &ctx->Pack, 0);
|
format, type, dst, &ctx->Pack, 0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Column filter */
|
/* Column filter */
|
||||||
if (column) {
|
if (column) {
|
||||||
GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height,
|
GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height,
|
||||||
format, type, 0);
|
format, type, 0);
|
||||||
const GLfloat *src = filter->Filter + colStart;
|
GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + colStart);
|
||||||
_mesa_pack_rgba_span_float(ctx, filter->Height,
|
_mesa_pack_rgba_span_float(ctx, filter->Height, src,
|
||||||
(const GLfloat (*)[4]) src,
|
format, type, dst, &ctx->Pack, 0x0);
|
||||||
format, type, dst, &ctx->Pack, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) span; /* unused at this time */
|
(void) span; /* unused at this time */
|
||||||
|
@@ -748,8 +748,8 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
|
|||||||
minmax[1][GCOMP] = CLAMP(ctx->MinMax.Max[GCOMP], 0.0F, 1.0F);
|
minmax[1][GCOMP] = CLAMP(ctx->MinMax.Max[GCOMP], 0.0F, 1.0F);
|
||||||
minmax[1][BCOMP] = CLAMP(ctx->MinMax.Max[BCOMP], 0.0F, 1.0F);
|
minmax[1][BCOMP] = CLAMP(ctx->MinMax.Max[BCOMP], 0.0F, 1.0F);
|
||||||
minmax[1][ACOMP] = CLAMP(ctx->MinMax.Max[ACOMP], 0.0F, 1.0F);
|
minmax[1][ACOMP] = CLAMP(ctx->MinMax.Max[ACOMP], 0.0F, 1.0F);
|
||||||
_mesa_pack_rgba_span_float(ctx, 2, (CONST GLfloat (*)[4]) minmax,
|
_mesa_pack_rgba_span_float(ctx, 2, minmax,
|
||||||
format, type, values, &ctx->Pack, 0);
|
format, type, values, &ctx->Pack, 0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Pack.BufferObj->Name) {
|
if (ctx->Pack.BufferObj->Name) {
|
||||||
|
@@ -1065,18 +1065,18 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
|
|||||||
* by the dstFormat, dstType and dstPacking. Used by glReadPixels,
|
* by the dstFormat, dstType and dstPacking. Used by glReadPixels,
|
||||||
* glGetConvolutionFilter(), etc.
|
* glGetConvolutionFilter(), etc.
|
||||||
* Incoming colors will be clamped to [0,1] if needed.
|
* Incoming colors will be clamped to [0,1] if needed.
|
||||||
|
* Note: the rgba values will be modified by this function when any pixel
|
||||||
|
* transfer ops are enabled.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_mesa_pack_rgba_span_float( GLcontext *ctx,
|
_mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||||
GLuint n, CONST GLfloat rgbaIn[][4],
|
GLenum dstFormat, GLenum dstType,
|
||||||
GLenum dstFormat, GLenum dstType,
|
GLvoid *dstAddr,
|
||||||
GLvoid *dstAddr,
|
const struct gl_pixelstore_attrib *dstPacking,
|
||||||
const struct gl_pixelstore_attrib *dstPacking,
|
GLbitfield transferOps)
|
||||||
GLbitfield transferOps )
|
|
||||||
{
|
{
|
||||||
|
GLfloat luminance[MAX_WIDTH];
|
||||||
const GLint comps = _mesa_components_in_format(dstFormat);
|
const GLint comps = _mesa_components_in_format(dstFormat);
|
||||||
GLfloat rgbaCopy[MAX_WIDTH][4], luminance[MAX_WIDTH];
|
|
||||||
const GLfloat (*rgba)[4];
|
|
||||||
GLuint i;
|
GLuint i;
|
||||||
|
|
||||||
if (dstType != GL_FLOAT) {
|
if (dstType != GL_FLOAT) {
|
||||||
@@ -1085,19 +1085,11 @@ _mesa_pack_rgba_span_float( GLcontext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (transferOps) {
|
if (transferOps) {
|
||||||
/* make copy of incoming data */
|
_mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba);
|
||||||
_mesa_memcpy(rgbaCopy, rgbaIn, n * 4 * sizeof(GLfloat));
|
|
||||||
_mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgbaCopy);
|
|
||||||
rgba = (const GLfloat (*)[4]) rgbaCopy;
|
|
||||||
|
|
||||||
if ((transferOps & IMAGE_MIN_MAX_BIT) && ctx->MinMax.Sink) {
|
if ((transferOps & IMAGE_MIN_MAX_BIT) && ctx->MinMax.Sink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/* use incoming data, not a copy */
|
|
||||||
rgba = (const GLfloat (*)[4]) rgbaIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
|
if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
|
||||||
/* compute luminance values */
|
/* compute luminance values */
|
||||||
|
@@ -116,8 +116,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
|
|||||||
GLuint n, GLfloat rgba[][4]);
|
GLuint n, GLfloat rgba[][4]);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_pack_rgba_span_float( GLcontext *ctx,
|
_mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||||
GLuint n, CONST GLfloat rgba[][4],
|
|
||||||
GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
|
GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
|
||||||
const struct gl_pixelstore_attrib *dstPacking,
|
const struct gl_pixelstore_attrib *dstPacking,
|
||||||
GLbitfield transferOps );
|
GLbitfield transferOps );
|
||||||
|
@@ -398,7 +398,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims,
|
|||||||
GLfloat *dst = tempImage + img * (convWidth * convHeight * 4);
|
GLfloat *dst = tempImage + img * (convWidth * convHeight * 4);
|
||||||
for (row = 0; row < convHeight; row++) {
|
for (row = 0; row < convHeight; row++) {
|
||||||
_mesa_pack_rgba_span_float(ctx, convWidth,
|
_mesa_pack_rgba_span_float(ctx, convWidth,
|
||||||
(const GLfloat (*)[4]) src,
|
(GLfloat (*)[4]) src,
|
||||||
logicalBaseFormat, GL_FLOAT,
|
logicalBaseFormat, GL_FLOAT,
|
||||||
dst, &ctx->DefaultPacking,
|
dst, &ctx->DefaultPacking,
|
||||||
postConvTransferOps);
|
postConvTransferOps);
|
||||||
@@ -3607,10 +3607,9 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
for (col = 0; col < width; col++) {
|
for (col = 0; col < width; col++) {
|
||||||
(*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
|
(*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
|
||||||
}
|
}
|
||||||
_mesa_pack_rgba_span_float(ctx, width,
|
_mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
|
||||||
(const GLfloat (*)[4]) rgba,
|
format, type, dest,
|
||||||
format, type, dest, &ctx->Pack,
|
&ctx->Pack, 0x0 /*image xfer ops*/);
|
||||||
0 /* no image transfer */);
|
|
||||||
} /* format */
|
} /* format */
|
||||||
} /* row */
|
} /* row */
|
||||||
} /* img */
|
} /* img */
|
||||||
|
@@ -377,8 +377,7 @@ read_rgba_pixels( GLcontext *ctx,
|
|||||||
GLvoid *dest;
|
GLvoid *dest;
|
||||||
dest = _mesa_image_address2d(packing, pixels, width, height,
|
dest = _mesa_image_address2d(packing, pixels, width, height,
|
||||||
format, type, row, 0);
|
format, type, row, 0);
|
||||||
_mesa_pack_rgba_span_float(ctx, width,
|
_mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) src,
|
||||||
(const GLfloat (*)[4]) src,
|
|
||||||
format, type, dest, packing,
|
format, type, dest, packing,
|
||||||
transferOps & IMAGE_POST_CONVOLUTION_BITS);
|
transferOps & IMAGE_POST_CONVOLUTION_BITS);
|
||||||
src += width * 4;
|
src += width * 4;
|
||||||
@@ -419,8 +418,7 @@ read_rgba_pixels( GLcontext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* pack the row of RGBA pixels into user's buffer */
|
/* pack the row of RGBA pixels into user's buffer */
|
||||||
_mesa_pack_rgba_span_float(ctx, width, (CONST GLfloat (*)[4]) rgba,
|
_mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
|
||||||
format, type, dst,
|
|
||||||
packing, ctx->_ImageTransferState);
|
packing, ctx->_ImageTransferState);
|
||||||
|
|
||||||
dst += dstStride;
|
dst += dstStride;
|
||||||
|
Reference in New Issue
Block a user