aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/pack.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-17 16:37:26 +0100
committermarha <marha@users.sourceforge.net>2011-11-17 16:37:26 +0100
commitd41bc08d1ae8c4784c09d8977816c0fadab1ba52 (patch)
tree4dc3081a9af0316eeee02356a44fcc2419e1b15e /mesalib/src/mesa/main/pack.c
parent156e37d3879b316329e3e05579414031da2647e2 (diff)
downloadvcxsrv-d41bc08d1ae8c4784c09d8977816c0fadab1ba52.tar.gz
vcxsrv-d41bc08d1ae8c4784c09d8977816c0fadab1ba52.tar.bz2
vcxsrv-d41bc08d1ae8c4784c09d8977816c0fadab1ba52.zip
xserver mesa git update 17 nov 2011
Diffstat (limited to 'mesalib/src/mesa/main/pack.c')
-rw-r--r--mesalib/src/mesa/main/pack.c64
1 files changed, 18 insertions, 46 deletions
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 539a06c9a..6f48a2e7c 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -34,6 +34,7 @@
#include "enums.h"
#include "image.h"
#include "imports.h"
+#include "macros.h"
#include "mtypes.h"
#include "pack.h"
#include "pixeltransfer.h"
@@ -43,26 +44,6 @@
/**
- * NOTE:
- * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when
- * we later convert the float to a packed integer value (such as for
- * GL_RGB5_A1) because we'll wind up with a non-zero value.
- *
- * We redefine the macros here so zero is handled correctly.
- */
-#undef BYTE_TO_FLOAT
-#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F)))
-
-#undef SHORT_TO_FLOAT
-#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)))
-
-
-
-/** Compute ceiling of integer quotient of A divided by B. */
-#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
-
-
-/**
* Flip the 8 bits in each byte of the given array.
*
* \param p array.
@@ -2507,10 +2488,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
PROCESS(aSrc, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT);
break;
case GL_BYTE:
- PROCESS(rSrc, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT);
- PROCESS(gSrc, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT);
- PROCESS(bSrc, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT);
- PROCESS(aSrc, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(rSrc, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOATZ);
+ PROCESS(gSrc, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOATZ);
+ PROCESS(bSrc, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOATZ);
+ PROCESS(aSrc, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOATZ);
break;
case GL_UNSIGNED_SHORT:
PROCESS(rSrc, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT);
@@ -2519,10 +2500,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
PROCESS(aSrc, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT);
break;
case GL_SHORT:
- PROCESS(rSrc, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT);
- PROCESS(gSrc, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT);
- PROCESS(bSrc, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT);
- PROCESS(aSrc, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOAT);
+ PROCESS(rSrc, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOATZ);
+ PROCESS(gSrc, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOATZ);
+ PROCESS(bSrc, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOATZ);
+ PROCESS(aSrc, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOATZ);
break;
case GL_UNSIGNED_INT:
PROCESS(rSrc, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT);
@@ -4586,10 +4567,10 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
void
_mesa_pack_stencil_span( struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest, const GLstencil *source,
+ GLenum dstType, GLvoid *dest, const GLubyte *source,
const struct gl_pixelstore_attrib *dstPacking )
{
- GLstencil *stencil = (GLstencil *) malloc(n * sizeof(GLstencil));
+ GLubyte *stencil = (GLubyte *) malloc(n * sizeof(GLubyte));
if (!stencil) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing");
@@ -4599,23 +4580,14 @@ _mesa_pack_stencil_span( struct gl_context *ctx, GLuint n,
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset ||
ctx->Pixel.MapStencilFlag) {
/* make a copy of input */
- memcpy(stencil, source, n * sizeof(GLstencil));
+ memcpy(stencil, source, n * sizeof(GLubyte));
_mesa_apply_stencil_transfer_ops(ctx, n, stencil);
source = stencil;
}
switch (dstType) {
case GL_UNSIGNED_BYTE:
- if (sizeof(GLstencil) == 1) {
- memcpy( dest, source, n );
- }
- else {
- GLubyte *dst = (GLubyte *) dest;
- GLuint i;
- for (i=0;i<n;i++) {
- dst[i] = (GLubyte) source[i];
- }
- }
+ memcpy(dest, source, n);
break;
case GL_BYTE:
{
@@ -4834,14 +4806,14 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
*/
switch (srcType) {
case GL_BYTE:
- DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT);
+ DEPTH_VALUES(GLbyte, BYTE_TO_FLOATZ);
needClamp = GL_TRUE;
break;
case GL_UNSIGNED_BYTE:
DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT);
break;
case GL_SHORT:
- DEPTH_VALUES(GLshort, SHORT_TO_FLOAT);
+ DEPTH_VALUES(GLshort, SHORT_TO_FLOATZ);
needClamp = GL_TRUE;
break;
case GL_UNSIGNED_SHORT:
@@ -5120,11 +5092,11 @@ void
_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
GLenum dstType, GLuint *dest,
const GLfloat *depthVals,
- const GLstencil *stencilVals,
+ const GLubyte *stencilVals,
const struct gl_pixelstore_attrib *dstPacking)
{
GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat));
- GLstencil *stencilCopy = (GLstencil *) malloc(n * sizeof(GLstencil));
+ GLubyte *stencilCopy = (GLubyte *) malloc(n * sizeof(GLubyte));
GLuint i;
if (!depthCopy || !stencilCopy) {
@@ -5143,7 +5115,7 @@ _mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
if (ctx->Pixel.IndexShift ||
ctx->Pixel.IndexOffset ||
ctx->Pixel.MapStencilFlag) {
- memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil));
+ memcpy(stencilCopy, stencilVals, n * sizeof(GLubyte));
_mesa_apply_stencil_transfer_ops(ctx, n, stencilCopy);
stencilVals = stencilCopy;
}