aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast/s_readpix.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-04-12 09:53:17 +0000
committermarha <marha@users.sourceforge.net>2010-04-12 09:53:17 +0000
commit29b86f9852b2b7ecc31cdfee56679537e40bc6e2 (patch)
tree1e6ec8ccf2dbf773260a1953b8e13c49f9b7c5f5 /mesalib/src/mesa/swrast/s_readpix.c
parent529236591df7366479a6fac30b387667678fd1ba (diff)
downloadvcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.tar.gz
vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.tar.bz2
vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.zip
svn merge -r524:HEAD "^/branches/released" .
Diffstat (limited to 'mesalib/src/mesa/swrast/s_readpix.c')
-rw-r--r--mesalib/src/mesa/swrast/s_readpix.c96
1 files changed, 16 insertions, 80 deletions
diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c
index 44a11cd6d..368311e14 100644
--- a/mesalib/src/mesa/swrast/s_readpix.c
+++ b/mesalib/src/mesa/swrast/s_readpix.c
@@ -33,7 +33,6 @@
#include "main/image.h"
#include "main/macros.h"
#include "main/imports.h"
-#include "main/pixel.h"
#include "main/state.h"
#include "s_context.h"
@@ -42,42 +41,6 @@
#include "s_stencil.h"
-/*
- * Read a block of color index pixels.
- */
-static void
-read_index_pixels( GLcontext *ctx,
- GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum type, GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing )
-{
- struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
- GLint i;
-
- if (!rb)
- return;
-
- /* width should never be > MAX_WIDTH since we did clipping earlier */
- ASSERT(width <= MAX_WIDTH);
-
- /* process image row by row */
- for (i = 0; i < height; i++) {
- GLuint index[MAX_WIDTH];
- GLvoid *dest;
- ASSERT(rb->DataType == GL_UNSIGNED_INT);
- rb->GetRow(ctx, rb, width, x, y + i, index);
-
- dest = _mesa_image_address2d(packing, pixels, width, height,
- GL_COLOR_INDEX, type, i, 0);
-
- _mesa_pack_index_span(ctx, width, type, dest, index,
- &ctx->Pack, ctx->_ImageTransferState);
- }
-}
-
-
-
/**
* Read pixels for format=GL_DEPTH_COMPONENT.
*/
@@ -290,21 +253,21 @@ fast_read_rgba_pixels( GLcontext *ctx,
/**
* When we're using a low-precision color buffer (like 16-bit 5/6/5)
* we have to adjust our color values a bit to pass conformance.
- * The problem is when a 5 or 6-bit color value is convert to an 8-bit
+ * The problem is when a 5 or 6-bit color value is converted to an 8-bit
* value and then a floating point value, the floating point values don't
* increment uniformly as the 5 or 6-bit value is incremented.
*
* This function adjusts floating point values to compensate.
*/
static void
-adjust_colors(GLcontext *ctx, GLuint n, GLfloat rgba[][4])
+adjust_colors(const struct gl_framebuffer *fb, GLuint n, GLfloat rgba[][4])
{
- const GLuint rShift = 8 - ctx->Visual.redBits;
- const GLuint gShift = 8 - ctx->Visual.greenBits;
- const GLuint bShift = 8 - ctx->Visual.blueBits;
- const GLfloat rScale = 1.0F / (GLfloat) ((1 << ctx->Visual.redBits ) - 1);
- const GLfloat gScale = 1.0F / (GLfloat) ((1 << ctx->Visual.greenBits) - 1);
- const GLfloat bScale = 1.0F / (GLfloat) ((1 << ctx->Visual.blueBits ) - 1);
+ const GLuint rShift = 8 - fb->Visual.redBits;
+ const GLuint gShift = 8 - fb->Visual.greenBits;
+ const GLuint bShift = 8 - fb->Visual.blueBits;
+ const GLfloat rScale = 1.0F / (GLfloat) ((1 << fb->Visual.redBits ) - 1);
+ const GLfloat gScale = 1.0F / (GLfloat) ((1 << fb->Visual.greenBits) - 1);
+ const GLfloat bScale = 1.0F / (GLfloat) ((1 << fb->Visual.blueBits ) - 1);
GLuint i;
for (i = 0; i < n; i++) {
GLint r, g, b;
@@ -359,14 +322,14 @@ read_rgba_pixels( GLcontext *ctx,
GLfloat *dest, *src, *tmpImage, *convImage;
GLint row;
- tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
if (!tmpImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
return;
}
- convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
if (!convImage) {
- _mesa_free(tmpImage);
+ free(tmpImage);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
return;
}
@@ -374,18 +337,7 @@ read_rgba_pixels( GLcontext *ctx,
/* read full RGBA, FLOAT image */
dest = tmpImage;
for (row = 0; row < height; row++, y++) {
- if (fb->Visual.rgbMode) {
- _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest);
- }
- else {
- GLuint index[MAX_WIDTH];
- ASSERT(rb->DataType == GL_UNSIGNED_INT);
- rb->GetRow(ctx, rb, width, x, y, index);
- _mesa_apply_ci_transfer_ops(ctx,
- transferOps & IMAGE_SHIFT_OFFSET_BIT,
- width, index);
- _mesa_map_ci_to_rgba(ctx, width, index, (GLfloat (*)[4]) dest);
- }
+ _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest);
_mesa_apply_rgba_transfer_ops(ctx,
transferOps & IMAGE_PRE_CONVOLUTION_BITS,
width, (GLfloat (*)[4]) dest);
@@ -400,7 +352,7 @@ read_rgba_pixels( GLcontext *ctx,
ASSERT(ctx->Pixel.Separable2DEnabled);
_mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
}
- _mesa_free(tmpImage);
+ free(tmpImage);
/* finish transfer ops and pack the resulting image */
src = convImage;
@@ -413,7 +365,7 @@ read_rgba_pixels( GLcontext *ctx,
transferOps & IMAGE_POST_CONVOLUTION_BITS);
src += width * 4;
}
- _mesa_free(convImage);
+ free(convImage);
}
else {
/* no convolution */
@@ -432,25 +384,13 @@ read_rgba_pixels( GLcontext *ctx,
for (row = 0; row < height; row++, y++) {
/* Get float rgba pixels */
- if (fb->Visual.rgbMode) {
- _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba);
- }
- else {
- /* read CI and convert to RGBA */
- GLuint index[MAX_WIDTH];
- ASSERT(rb->DataType == GL_UNSIGNED_INT);
- rb->GetRow(ctx, rb, width, x, y, index);
- _mesa_apply_ci_transfer_ops(ctx,
- transferOps & IMAGE_SHIFT_OFFSET_BIT,
- width, index);
- _mesa_map_ci_to_rgba(ctx, width, index, rgba);
- }
+ _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba);
/* apply fudge factor for shallow color buffers */
if (fb->Visual.redBits < 8 ||
fb->Visual.greenBits < 8 ||
fb->Visual.blueBits < 8) {
- adjust_colors(ctx, width, rgba);
+ adjust_colors(fb, width, rgba);
}
/* pack the row of RGBA pixels into user's buffer */
@@ -593,10 +533,6 @@ _swrast_ReadPixels( GLcontext *ctx,
return;
switch (format) {
- case GL_COLOR_INDEX:
- read_index_pixels(ctx, x, y, width, height, type, pixels,
- &clippedPacking);
- break;
case GL_STENCIL_INDEX:
read_stencil_pixels(ctx, x, y, width, height, type, pixels,
&clippedPacking);