aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/pack.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-28 15:21:45 +0100
committermarha <marha@users.sourceforge.net>2012-01-28 15:21:45 +0100
commit59bda88ffb9deb72a727e7d6b4c141fd7d4678f4 (patch)
treea797879cc0fe54172dba50354b635b1f595081db /mesalib/src/mesa/main/pack.c
parent829194c926fa1e3bd45e4fe740e0bc42efe6ace6 (diff)
parent1aee8dafb5391e093f3a111f906ab0d8b6775510 (diff)
downloadvcxsrv-59bda88ffb9deb72a727e7d6b4c141fd7d4678f4.tar.gz
vcxsrv-59bda88ffb9deb72a727e7d6b4c141fd7d4678f4.tar.bz2
vcxsrv-59bda88ffb9deb72a727e7d6b4c141fd7d4678f4.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winkeynames.h xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwndproc.c
Diffstat (limited to 'mesalib/src/mesa/main/pack.c')
-rw-r--r--mesalib/src/mesa/main/pack.c61
1 files changed, 18 insertions, 43 deletions
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index f874ab21a..d07e2aaa8 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -462,7 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLushort
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) MIN2(x, 0xffff)
#define FN_NAME pack_ushort_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -470,7 +470,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLshort
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) CLAMP((int)x, -32768, 32767)
#define FN_NAME pack_short_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -478,7 +478,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLubyte
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) MIN2(x, 0xff)
#define FN_NAME pack_ubyte_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -486,7 +486,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLbyte
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) CLAMP((int)x, -128, 127)
#define FN_NAME pack_byte_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -2020,14 +2020,10 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
if (dstPacking->SwapBytes) {
GLint swapSize = _mesa_sizeof_packed_type(dstType);
if (swapSize == 2) {
- if (dstPacking->SwapBytes) {
- _mesa_swap2((GLushort *) dstAddr, n * comps);
- }
+ _mesa_swap2((GLushort *) dstAddr, n * comps);
}
else if (swapSize == 4) {
- if (dstPacking->SwapBytes) {
- _mesa_swap4((GLuint *) dstAddr, n * comps);
- }
+ _mesa_swap4((GLuint *) dstAddr, n * comps);
}
}
@@ -3008,27 +3004,6 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
static inline GLuint
-clamp_byte_to_uint(GLbyte b)
-{
- return b < 0 ? 0 : b;
-}
-
-
-static inline GLuint
-clamp_short_to_uint(GLshort s)
-{
- return s < 0 ? 0 : s;
-}
-
-
-static inline GLuint
-clamp_int_to_uint(GLint i)
-{
- return i < 0 ? 0 : i;
-}
-
-
-static inline GLuint
clamp_float_to_uint(GLfloat f)
{
return f < 0.0F ? 0 : IROUND(f);
@@ -3150,10 +3125,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint));
break;
case GL_BYTE:
- PROCESS(rSrc, RCOMP, 0, GLbyte, clamp_byte_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLbyte, clamp_byte_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLbyte, clamp_byte_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLbyte, clamp_byte_to_uint);
+ PROCESS(rSrc, RCOMP, 0, GLbyte, (GLuint));
+ PROCESS(gSrc, GCOMP, 0, GLbyte, (GLuint));
+ PROCESS(bSrc, BCOMP, 0, GLbyte, (GLuint));
+ PROCESS(aSrc, ACOMP, 1, GLbyte, (GLuint));
break;
case GL_UNSIGNED_SHORT:
PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint));
@@ -3162,10 +3137,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint));
break;
case GL_SHORT:
- PROCESS(rSrc, RCOMP, 0, GLshort, clamp_short_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLshort, clamp_short_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLshort, clamp_short_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLshort, clamp_short_to_uint);
+ PROCESS(rSrc, RCOMP, 0, GLshort, (GLuint));
+ PROCESS(gSrc, GCOMP, 0, GLshort, (GLuint));
+ PROCESS(bSrc, BCOMP, 0, GLshort, (GLuint));
+ PROCESS(aSrc, ACOMP, 1, GLshort, (GLuint));
break;
case GL_UNSIGNED_INT:
PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint));
@@ -3174,10 +3149,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint));
break;
case GL_INT:
- PROCESS(rSrc, RCOMP, 0, GLint, clamp_int_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLint, clamp_int_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLint, clamp_int_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLint, clamp_int_to_uint);
+ PROCESS(rSrc, RCOMP, 0, GLint, (GLuint));
+ PROCESS(gSrc, GCOMP, 0, GLint, (GLuint));
+ PROCESS(bSrc, BCOMP, 0, GLint, (GLuint));
+ PROCESS(aSrc, ACOMP, 1, GLint, (GLuint));
break;
case GL_FLOAT:
PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint);