aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-12-12 14:26:41 +0100
committermarha <marha@users.sourceforge.net>2011-12-12 14:26:41 +0100
commit2b5652fc7742c5ac57aca701214b046626a729e9 (patch)
treea994b9e63a32a7c061bcfb563aa22369c217e49c
parent2331d6e4ac699e775ccee07a8a461cae0a98033a (diff)
parent5efb0a5e19b75137b7294b27f4e7878aeb8f0927 (diff)
downloadvcxsrv-2b5652fc7742c5ac57aca701214b046626a729e9.tar.gz
vcxsrv-2b5652fc7742c5ac57aca701214b046626a729e9.tar.bz2
vcxsrv-2b5652fc7742c5ac57aca701214b046626a729e9.zip
Merge remote-tracking branch 'origin/released'
-rw-r--r--X11/xtrans/Xtrans.c87
-rw-r--r--X11/xtrans/Xtranslcl.c55
-rw-r--r--X11/xtrans/Xtranssock.c55
-rw-r--r--X11/xtrans/Xtranstli.c38
-rw-r--r--X11/xtrans/Xtransutil.c15
-rw-r--r--X11/xtrans/transport.c4
-rw-r--r--libX11/modules/im/ximcp/imLcFlt.c52
-rw-r--r--libxcb/xcb-proto/src/dri2.xml430
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h4
-rw-r--r--mesalib/src/mesa/SConscript4
-rw-r--r--mesalib/src/mesa/drivers/common/driverfuncs.c12
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c15
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/wmesa.c15
-rw-r--r--mesalib/src/mesa/main/accum.c386
-rw-r--r--mesalib/src/mesa/main/accum.h18
-rw-r--r--mesalib/src/mesa/main/dd.h18
-rw-r--r--mesalib/src/mesa/main/depthstencil.c155
-rw-r--r--mesalib/src/mesa/main/depthstencil.h16
-rw-r--r--mesalib/src/mesa/main/format_pack.c2496
-rw-r--r--mesalib/src/mesa/main/format_pack.h98
-rw-r--r--mesalib/src/mesa/main/format_unpack.c8
-rw-r--r--mesalib/src/mesa/main/formats.c2
-rw-r--r--mesalib/src/mesa/main/formats.h8
-rw-r--r--mesalib/src/mesa/main/framebuffer.c1
-rw-r--r--mesalib/src/mesa/main/image.c104
-rw-r--r--mesalib/src/mesa/main/image.h7
-rw-r--r--mesalib/src/mesa/main/pack.c4
-rw-r--r--mesalib/src/mesa/main/pbo.c29
-rw-r--r--mesalib/src/mesa/main/readpix.c23
-rw-r--r--mesalib/src/mesa/main/renderbuffer.c2022
-rw-r--r--mesalib/src/mesa/main/renderbuffer.h57
-rw-r--r--mesalib/src/mesa/main/texobj.c23
-rw-r--r--mesalib/src/mesa/main/texparam.c6
-rw-r--r--mesalib/src/mesa/main/texstore.c17
-rw-r--r--mesalib/src/mesa/sources.mak4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_accum.c347
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_accum.h63
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c21
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c222
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp18
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c64
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c19
-rw-r--r--mesalib/src/mesa/swrast/s_accum.c598
-rw-r--r--mesalib/src/mesa/swrast/s_clear.c5
-rw-r--r--mesalib/src/mesa/swrast/s_context.c6
-rw-r--r--mesalib/src/mesa/swrast/s_context.h5
-rw-r--r--mesalib/src/mesa/swrast/s_copypix.c10
-rw-r--r--mesalib/src/mesa/swrast/s_renderbuffer.c2034
-rw-r--r--mesalib/src/mesa/swrast/s_renderbuffer.h (renamed from mesalib/src/mesa/swrast/s_accum.h)104
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch_tmp.h4
-rw-r--r--mesalib/src/mesa/swrast/s_zoom.c10
-rw-r--r--mesalib/src/mesa/swrast/swrast.h3
-rw-r--r--xorg-server/Xi/exevents.c88
-rw-r--r--xorg-server/Xi/ungrdevb.c32
-rw-r--r--xorg-server/Xi/ungrdevk.c31
-rw-r--r--xorg-server/Xi/xichangehierarchy.c15
-rw-r--r--xorg-server/Xi/xigrabdev.c15
-rw-r--r--xorg-server/Xi/xipassivegrab.c50
-rw-r--r--xorg-server/Xi/xiselectev.c5
-rw-r--r--xorg-server/dix/devices.c3
-rw-r--r--xorg-server/dix/events.c288
-rw-r--r--xorg-server/dix/grabs.c84
-rw-r--r--xorg-server/dix/inpututils.c181
-rw-r--r--xorg-server/hw/xfree86/common/xf86Module.h2
-rw-r--r--xorg-server/hw/xfree86/xaa/xaalocal.h3514
-rw-r--r--xorg-server/include/dix.h1
-rw-r--r--xorg-server/include/dixgrabs.h4
-rw-r--r--xorg-server/include/input.h1
-rw-r--r--xorg-server/include/inputstr.h22
-rw-r--r--xorg-server/include/inpututils.h12
-rw-r--r--xorg-server/include/list.h81
-rw-r--r--xorg-server/include/misc.h9
-rw-r--r--xorg-server/test/input.c67
-rw-r--r--xorg-server/test/list.c37
-rw-r--r--xorg-server/test/xi2/Makefile.am5
-rw-r--r--xorg-server/test/xi2/xi2.c129
-rw-r--r--xorg-server/xfixes/cursor.c4
80 files changed, 8514 insertions, 6007 deletions
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c
index f90bd47e8..1f37c4341 100644
--- a/X11/xtrans/Xtrans.c
+++ b/X11/xtrans/Xtrans.c
@@ -140,15 +140,15 @@ TRANS(FreeConnInfo) (XtransConnInfo ciptr)
prmsg (3,"FreeConnInfo(%p)\n", ciptr);
if (ciptr->addr)
- xfree (ciptr->addr);
+ free (ciptr->addr);
if (ciptr->peeraddr)
- xfree (ciptr->peeraddr);
+ free (ciptr->peeraddr);
if (ciptr->port)
- xfree (ciptr->port);
+ free (ciptr->port);
- xfree ((char *) ciptr);
+ free (ciptr);
}
@@ -217,8 +217,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
/* Copy the string so it can be changed */
- tmpptr = mybuf = (char *) xalloc (strlen (address) + 1);
- strcpy (mybuf, address);
+ tmpptr = mybuf = strdup (address);
/* Parse the string to get each component */
@@ -234,7 +233,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
*protocol = NULL;
*host = NULL;
*port = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
@@ -284,7 +283,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
*protocol = NULL;
*host = NULL;
*port = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
@@ -351,46 +350,40 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
* string space for them.
*/
- if ((*protocol = (char *) xalloc(strlen (_protocol) + 1)) == NULL)
+ if ((*protocol = strdup (_protocol)) == NULL)
{
/* Malloc failed */
*port = NULL;
*host = NULL;
*protocol = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
- else
- strcpy (*protocol, _protocol);
- if ((*host = (char *) xalloc (strlen (_host) + 1)) == NULL)
+ if ((*host = strdup (_host)) == NULL)
{
/* Malloc failed */
*port = NULL;
*host = NULL;
- xfree (*protocol);
+ free (*protocol);
*protocol = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
- }
- else
- strcpy (*host, _host);
+ }
- if ((*port = (char *) xalloc (strlen (_port) + 1)) == NULL)
+ if ((*port = strdup (_port)) == NULL)
{
/* Malloc failed */
*port = NULL;
- xfree (*host);
+ free (*host);
*host = NULL;
- xfree (*protocol);
+ free (*protocol);
*protocol = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
- else
- strcpy (*port, _port);
- xfree (tmpptr);
+ free (tmpptr);
return 1;
}
@@ -435,9 +428,9 @@ TRANS(Open) (int type, char *address)
prmsg (1,"Open: Unable to find transport for %s\n",
protocol);
- xfree (protocol);
- xfree (host);
- xfree (port);
+ free (protocol);
+ free (host);
+ free (port);
return NULL;
}
@@ -476,17 +469,17 @@ TRANS(Open) (int type, char *address)
prmsg (1,"Open: transport open failed for %s/%s:%s\n",
protocol, host, port);
}
- xfree (protocol);
- xfree (host);
- xfree (port);
+ free (protocol);
+ free (host);
+ free (port);
return NULL;
}
ciptr->transptr = thistrans;
ciptr->port = port; /* We need this for TRANS(Reopen) */
- xfree (protocol);
- xfree (host);
+ free (protocol);
+ free (host);
return ciptr;
}
@@ -528,15 +521,13 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port)
return NULL;
}
- if ((save_port = (char *) xalloc (strlen (port) + 1)) == NULL)
+ if ((save_port = strdup (port)) == NULL)
{
prmsg (1,"Reopen: Unable to malloc port string\n");
return NULL;
}
- strcpy (save_port, port);
-
/* Get a new XtransConnInfo object */
switch (type)
@@ -554,6 +545,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port)
if (ciptr == NULL)
{
prmsg (1,"Reopen: transport open failed\n");
+ free (save_port);
return NULL;
}
@@ -657,13 +649,10 @@ TRANS(GetReopenInfo) (XtransConnInfo ciptr,
*trans_id = Xtransports[i].transport_id;
*fd = ciptr->fd;
- if ((*port = (char *) xalloc (strlen (ciptr->port) + 1)) == NULL)
+ if ((*port = strdup (ciptr->port)) == NULL)
return 0;
else
- {
- strcpy (*port, ciptr->port);
return 1;
- }
}
return 0;
@@ -848,16 +837,16 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address)
{
prmsg (1,"Connect: Missing port specification in %s\n",
address);
- if (protocol) xfree (protocol);
- if (host) xfree (host);
+ if (protocol) free (protocol);
+ if (host) free (host);
return -1;
}
ret = ciptr->transptr->Connect (ciptr, host, port);
- if (protocol) xfree (protocol);
- if (host) xfree (host);
- if (port) xfree (port);
+ if (protocol) free (protocol);
+ if (host) free (host);
+ if (port) free (port);
return ret;
}
@@ -955,7 +944,7 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
*familyp = ciptr->family;
*addrlenp = ciptr->addrlen;
- if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL)
+ if ((*addrp = malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,"GetMyAddr: malloc failed\n");
return -1;
@@ -975,7 +964,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
*familyp = ciptr->family;
*addrlenp = ciptr->peeraddrlen;
- if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL)
+ if ((*addrp = malloc (ciptr->peeraddrlen)) == NULL)
{
prmsg (1,"GetPeerAddr: malloc failed\n");
return -1;
@@ -1144,7 +1133,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
if (*count_ret > 0)
{
- if ((*ciptrs_ret = (XtransConnInfo *) xalloc (
+ if ((*ciptrs_ret = malloc (
*count_ret * sizeof (XtransConnInfo))) == NULL)
{
return -1;
@@ -1242,7 +1231,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret,
if (*count_ret > 0)
{
- if ((*ciptrs_ret = (XtransConnInfo *) xalloc (
+ if ((*ciptrs_ret = malloc (
*count_ret * sizeof (XtransConnInfo))) == NULL)
{
return -1;
diff --git a/X11/xtrans/Xtranslcl.c b/X11/xtrans/Xtranslcl.c
index ddc5a3e81..242e07af1 100644
--- a/X11/xtrans/Xtranslcl.c
+++ b/X11/xtrans/Xtranslcl.c
@@ -158,7 +158,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
ciptr->family = AF_UNIX;
ciptr->addrlen = sizeof (struct sockaddr_un);
- if ((sunaddr = (struct sockaddr_un *) xalloc (ciptr->addrlen)) == NULL)
+ if ((sunaddr = malloc (ciptr->addrlen)) == NULL)
{
prmsg(1,"FillAddrInfo: failed to allocate memory for addr\n");
return 0;
@@ -168,7 +168,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
if (strlen(sun_path) > sizeof(sunaddr->sun_path) - 1) {
prmsg(1, "FillAddrInfo: path too long\n");
- xfree((char *) sunaddr);
+ free((char *) sunaddr);
return 0;
}
strcpy (sunaddr->sun_path, sun_path);
@@ -180,12 +180,11 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
ciptr->peeraddrlen = sizeof (struct sockaddr_un);
- if ((p_sunaddr = (struct sockaddr_un *) xalloc (
- ciptr->peeraddrlen)) == NULL)
+ if ((p_sunaddr = malloc (ciptr->peeraddrlen)) == NULL)
{
prmsg(1,
"FillAddrInfo: failed to allocate memory for peer addr\n");
- xfree ((char *) sunaddr);
+ free (sunaddr);
ciptr->addr = NULL;
return 0;
@@ -195,7 +194,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
if (strlen(peer_sun_path) > sizeof(p_sunaddr->sun_path) - 1) {
prmsg(1, "FillAddrInfo: peer path too long\n");
- xfree((char *) p_sunaddr);
+ free((char *) p_sunaddr);
return 0;
}
strcpy (p_sunaddr->sun_path, peer_sun_path);
@@ -619,7 +618,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
*/
newciptr->addrlen=ciptr->addrlen;
- if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n");
close(newfd);
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -629,9 +628,9 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
newciptr->peeraddrlen=sizeof(struct sockaddr_un);
- if( (sunaddr=(struct sockaddr_un *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ if( (sunaddr = malloc(newciptr->peeraddrlen)) == NULL ) {
prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n");
- xfree(newciptr->addr);
+ free(newciptr->addr);
close(newfd);
*status = TRANS_ACCEPT_BAD_MALLOC;
return -1;
@@ -891,7 +890,7 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
*/
newciptr->family=ciptr->family;
newciptr->addrlen=ciptr->addrlen;
- if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
prmsg(1,
"NAMEDAccept: failed to allocate memory for pipe addr\n");
close(str.fd);
@@ -902,10 +901,10 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
newciptr->peeraddrlen=newciptr->addrlen;
- if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {
prmsg(1,
"NAMEDAccept: failed to allocate memory for peer addr\n");
- xfree(newciptr->addr);
+ free(newciptr->addr);
close(str.fd);
*status = TRANS_ACCEPT_BAD_MALLOC;
return -1;
@@ -1229,7 +1228,7 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
*/
newciptr->addrlen=ciptr->addrlen;
- if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
prmsg(1,
"SCOAccept: failed to allocate memory for peer addr\n");
close(fd);
@@ -1243,10 +1242,10 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
#endif
newciptr->peeraddrlen=newciptr->addrlen;
- if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {
prmsg(1,
"SCOAccept: failed to allocate memory for peer addr\n");
- xfree(newciptr->addr);
+ free(newciptr->addr);
close(fd);
*status = TRANS_ACCEPT_BAD_MALLOC;
return -1;
@@ -1677,17 +1676,13 @@ TRANS(LocalInitTransports)(const char *protocol)
if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") )
{
- workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (protocol) + 1);
- if (workingXLOCAL)
- strcpy (workingXLOCAL, protocol);
+ workingXLOCAL = freeXLOCAL = strdup (protocol);
}
else {
XLOCAL=(char *)getenv("XLOCAL");
if(XLOCAL==NULL)
XLOCAL=DEF_XLOCAL;
- workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (XLOCAL) + 1);
- if (workingXLOCAL)
- strcpy (workingXLOCAL, XLOCAL);
+ workingXLOCAL = freeXLOCAL = strdup (XLOCAL);
}
}
@@ -1696,7 +1691,7 @@ TRANS(LocalEndTransports)(void)
{
prmsg(3,"LocalEndTransports()\n");
- xfree(freeXLOCAL);
+ free(freeXLOCAL);
}
#define TYPEBUFSIZE 32
@@ -1821,7 +1816,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port)
*/
#endif /* X11_t */
- if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1,"LocalOpenClient: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -1862,7 +1857,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port)
if( ciptr->fd < 0 )
{
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -1895,7 +1890,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por
*/
#endif /* X11_t */
- if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1,"LocalOpenServer: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -1931,7 +1926,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por
}
}
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -1949,7 +1944,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd);
- if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1,"LocalReopenServer: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -1978,7 +1973,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
return ciptr;
}
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -2181,7 +2176,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status)
transptr=(LOCALtrans2dev *)ciptr->priv;
- if( (newciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo)))==NULL )
+ if( (newciptr = calloc(1,sizeof(struct _XtransConnInfo)))==NULL )
{
prmsg(1,"LocalAccept: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -2193,7 +2188,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status)
if( newciptr->fd < 0 )
{
- xfree(newciptr);
+ free(newciptr);
return NULL;
}
diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c
index dff33f323..bb7ece4c2 100644
--- a/X11/xtrans/Xtranssock.c
+++ b/X11/xtrans/Xtranssock.c
@@ -323,7 +323,7 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
* Everything looks good: fill in the XtransConnInfo structure.
*/
- if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ if ((ciptr->addr = malloc (namelen)) == NULL)
{
prmsg (1,
"SocketINETGetAddr: Can't allocate space for the addr\n");
@@ -390,7 +390,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
* Everything looks good: fill in the XtransConnInfo structure.
*/
- if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ if ((ciptr->peeraddr = malloc (namelen)) == NULL)
{
prmsg (1,
"SocketINETGetPeerAddr: Can't allocate space for the addr\n");
@@ -412,8 +412,7 @@ TRANS(SocketOpen) (int i, int type)
prmsg (3,"SocketOpen(%d,%d)\n", i, type);
- if ((ciptr = (XtransConnInfo) xcalloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketOpen: malloc failed\n");
return NULL;
@@ -433,7 +432,7 @@ TRANS(SocketOpen) (int i, int type)
prmsg (2, "SocketOpen: socket() failed for %s\n",
Sockettrans2devtab[i].transname);
- xfree ((char *) ciptr);
+ free (ciptr);
return NULL;
}
@@ -489,8 +488,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
}
#endif /*SOCK_MAXADDRLEN*/
- if ((ciptr = (XtransConnInfo) xcalloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketReopen: malloc(ciptr) failed\n");
return NULL;
@@ -498,15 +496,18 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
ciptr->fd = fd;
- if ((addr = (struct sockaddr *) xcalloc (1, portlen + 2)) == NULL) {
+ if ((addr = calloc (1, portlen + 2)) == NULL) {
prmsg (1, "SocketReopen: malloc(addr) failed\n");
+ free (ciptr);
return NULL;
}
ciptr->addr = (char *) addr;
ciptr->addrlen = portlen + 2;
- if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) {
+ if ((ciptr->peeraddr = calloc (1, portlen + 2)) == NULL) {
prmsg (1, "SocketReopen: malloc(portaddr) failed\n");
+ free (addr);
+ free (ciptr);
return NULL;
}
ciptr->peeraddrlen = portlen + 2;
@@ -1143,7 +1144,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
namelen = sizeof (sockname); /* this will always make it the same size */
- if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ if ((ciptr->addr = malloc (namelen)) == NULL)
{
prmsg (1,
"SocketUNIXCreateListener: Can't allocate space for the addr\n");
@@ -1261,8 +1262,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd);
- if ((newciptr = (XtransConnInfo) xcalloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketINETAccept: malloc failed\n");
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -1276,7 +1276,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
errno = WSAGetLastError();
#endif
prmsg (1, "SocketINETAccept: accept() failed\n");
- xfree (newciptr);
+ free (newciptr);
*status = TRANS_ACCEPT_FAILED;
return NULL;
}
@@ -1303,7 +1303,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
prmsg (1,
"SocketINETAccept: ...SocketINETGetAddr() failed:\n");
close (newciptr->fd);
- xfree (newciptr);
+ free (newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
@@ -1313,8 +1313,8 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
prmsg (1,
"SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n");
close (newciptr->fd);
- if (newciptr->addr) xfree (newciptr->addr);
- xfree (newciptr);
+ if (newciptr->addr) free (newciptr->addr);
+ free (newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
@@ -1338,8 +1338,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
prmsg (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd);
- if ((newciptr = (XtransConnInfo) xcalloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketUNIXAccept: malloc() failed\n");
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -1350,7 +1349,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
(struct sockaddr *) &sockname, (void *)&namelen)) < 0)
{
prmsg (1, "SocketUNIXAccept: accept() failed\n");
- xfree (newciptr);
+ free (newciptr);
*status = TRANS_ACCEPT_FAILED;
return NULL;
}
@@ -1361,12 +1360,12 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
* since this is unix domain.
*/
- if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ if ((newciptr->addr = malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,
"SocketUNIXAccept: Can't allocate space for the addr\n");
close (newciptr->fd);
- xfree (newciptr);
+ free (newciptr);
*status = TRANS_ACCEPT_BAD_MALLOC;
return NULL;
}
@@ -1379,13 +1378,13 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
newciptr->addrlen = ciptr->addrlen;
memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
- if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ if ((newciptr->peeraddr = malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,
"SocketUNIXAccept: Can't allocate space for the addr\n");
close (newciptr->fd);
- if (newciptr->addr) xfree (newciptr->addr);
- xfree (newciptr);
+ if (newciptr->addr) free (newciptr->addr);
+ free (newciptr);
*status = TRANS_ACCEPT_BAD_MALLOC;
return NULL;
}
@@ -1563,7 +1562,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
" socketfor IPv4 address\n");
}
if (newciptr)
- xfree(newciptr);
+ free(newciptr);
} else {
socketaddr = NULL;
prmsg (4,"SocketINETConnect Skipping IPv4 address\n");
@@ -1599,7 +1598,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
"socket for IPv6 address\n");
}
if (newciptr)
- xfree(newciptr);
+ free(newciptr);
}
else
{
@@ -2062,8 +2061,8 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
* since this is unix domain.
*/
- if ((ciptr->addr = (char *) xalloc(namelen)) == NULL ||
- (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL)
+ if ((ciptr->addr = malloc(namelen)) == NULL ||
+ (ciptr->peeraddr = malloc(namelen)) == NULL)
{
prmsg (1,
"SocketUNIXCreateListener: Can't allocate space for the addr\n");
diff --git a/X11/xtrans/Xtranstli.c b/X11/xtrans/Xtranstli.c
index 8601c137b..397c946df 100644
--- a/X11/xtrans/Xtranstli.c
+++ b/X11/xtrans/Xtranstli.c
@@ -167,9 +167,9 @@ TRANS(TLIGetAddr)(XtransConnInfo ciptr)
*/
if( ciptr->addr )
- xfree(ciptr->addr);
+ free(ciptr->addr);
- if( (ciptr->addr=(char *)xalloc(netbuf.len)) == NULL )
+ if( (ciptr->addr = malloc(netbuf.len)) == NULL )
{
prmsg(1, "TLIGetAddr: Can't allocate space for the addr\n");
return -1;
@@ -216,9 +216,9 @@ TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr)
*/
if( ciptr->peeraddr )
- xfree(ciptr->peeraddr);
+ free(ciptr->peeraddr);
- if( (ciptr->peeraddr=(char *)xalloc(netbuf.len)) == NULL )
+ if( (ciptr->peeraddr = malloc(netbuf.len)) == NULL )
{
prmsg(1,
"TLIGetPeerAddr: Can't allocate space for the addr\n");
@@ -312,7 +312,7 @@ TRANS(TLIOpen)(char *device)
prmsg(3,"TLIOpen(%s)\n", device);
- if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1, "TLIOpen: calloc failed\n");
return NULL;
@@ -345,7 +345,7 @@ TRANS(TLIReopen)(char *device, int fd, char *port)
return NULL;
}
- if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1, "TLIReopen: calloc failed\n");
return NULL;
@@ -448,7 +448,7 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol,
"TLIOpenCOTSClient: ...TLITLIBindLocal() failed: %d\n",
errno);
t_close(ciptr->fd);
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -458,7 +458,7 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol,
"TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n",
errno);
t_close(ciptr->fd);
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -548,7 +548,7 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol,
"TLIOpenCLTSClient: ...TLITLIBindLocal() failed: %d\n",
errno);
t_close(ciptr->fd);
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -558,7 +558,7 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol,
"TLIOpenCLTSClient: ...TLIGetPeerAddr() failed: %d\n",
errno);
t_close(ciptr->fd);
- xfree(ciptr);
+ free(ciptr);
return NULL;
}
@@ -720,7 +720,7 @@ TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req)
* Everything looks good: fill in the XtransConnInfo structure.
*/
- if( (ciptr->addr=(char *)xalloc(ret->addr.len)) == NULL )
+ if( (ciptr->addr = malloc(ret->addr.len)) == NULL )
{
prmsg(1,
"TLICreateListener: Unable to allocate space for the address\n");
@@ -903,7 +903,7 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
errno);
t_free((char *)call,T_CALL);
t_close(newciptr->fd);
- xfree(newciptr);
+ free(newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
@@ -947,7 +947,7 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
"TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n",
errno);
t_close(newciptr->fd);
- xfree(newciptr);
+ free(newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
@@ -958,8 +958,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
"TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n",
errno);
t_close(newciptr->fd);
- xfree(newciptr->addr);
- xfree(newciptr);
+ free(newciptr->addr);
+ free(newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
@@ -969,8 +969,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
prmsg(1, "TLIAccept() ioctl(I_POP, \"timod\") failed %d\n",
errno);
t_close(newciptr->fd);
- xfree(newciptr->addr);
- xfree(newciptr);
+ free(newciptr->addr);
+ free(newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
@@ -980,8 +980,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
prmsg(1, "TLIAccept() ioctl(I_PUSH,\"tirdwr\") failed %d\n",
errno);
t_close(newciptr->fd);
- xfree(newciptr->addr);
- xfree(newciptr);
+ free(newciptr->addr);
+ free(newciptr);
*status = TRANS_ACCEPT_MISC_ERROR;
return NULL;
}
diff --git a/X11/xtrans/Xtransutil.c b/X11/xtrans/Xtransutil.c
index 5dd245307..52c937b04 100644
--- a/X11/xtrans/Xtransutil.c
+++ b/X11/xtrans/Xtransutil.c
@@ -197,11 +197,11 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
if (len > 0) {
if (*addrp && *addrlenp < (len + 1))
{
- xfree ((char *) *addrp);
+ free (*addrp);
*addrp = NULL;
}
if (!*addrp)
- *addrp = (Xtransaddr *) xalloc (len + 1);
+ *addrp = malloc (len + 1);
if (*addrp) {
strcpy ((char *) *addrp, hostnamebuf);
*addrlenp = len;
@@ -212,7 +212,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
else
{
if (*addrp)
- xfree ((char *) *addrp);
+ free (*addrp);
*addrp = NULL;
*addrlenp = 0;
}
@@ -255,7 +255,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
case AF_UNIX:
{
struct sockaddr_un *saddr = (struct sockaddr_un *) addr;
- networkId = (char *) xalloc (3 + strlen (transName) +
+ networkId = malloc (3 + strlen (transName) +
strlen (hostnamebuf) + strlen (saddr->sun_path));
sprintf (networkId, "%s/%s:%s", transName,
hostnamebuf, saddr->sun_path);
@@ -285,7 +285,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
portnum = ntohs (saddr->sin_port);
snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum);
- networkId = (char *) xalloc (3 + strlen (transName) +
+ networkId = malloc (3 + strlen (transName) +
strlen (hostnamebuf) + strlen (portnumbuf));
sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
break;
@@ -418,8 +418,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr)
}
- hostname = (char *) xalloc (
- strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
+ hostname = malloc (strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
strcpy (hostname, ciptr->transptr->TransName);
strcat (hostname, "/");
if (addr)
@@ -586,6 +585,7 @@ trans_mkdir(const char *path, int mode)
if (fstat(fd, &fbuf) == -1) {
prmsg(1, "mkdir: ERROR: fstat failed for %s (%d)\n",
path, errno);
+ close(fd);
return -1;
}
/*
@@ -597,6 +597,7 @@ trans_mkdir(const char *path, int mode)
buf.st_ino != fbuf.st_ino) {
prmsg(1, "mkdir: ERROR: inode for %s changed\n",
path);
+ close(fd);
return -1;
}
if (updateOwner && fchown(fd, 0, 0) == 0)
diff --git a/X11/xtrans/transport.c b/X11/xtrans/transport.c
index c14057dd3..2cb88825e 100644
--- a/X11/xtrans/transport.c
+++ b/X11/xtrans/transport.c
@@ -48,10 +48,6 @@ from The Open Group.
*/
#include <stdlib.h>
-#define xalloc(_size) malloc(_size)
-#define xcalloc(_num,_size) calloc(_num,_size)
-#define xrealloc(_ptr,_size) realloc(_ptr,_size)
-#define xfree(_ptr) free(_ptr)
#define XTRANS_TRANSPORT_C /* used to flag Xtransint.h that it's being used
here, not just #included in another file */
diff --git a/libX11/modules/im/ximcp/imLcFlt.c b/libX11/modules/im/ximcp/imLcFlt.c
index 06aa9980a..a7060903a 100644
--- a/libX11/modules/im/ximcp/imLcFlt.c
+++ b/libX11/modules/im/ximcp/imLcFlt.c
@@ -43,18 +43,17 @@ _XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
Xic ic = (Xic)client_data;
KeySym keysym;
static char buf[256];
+ static unsigned prevcode = 0, prevstate = 0;
+ unsigned currstate;
DefTree *b = ic->private.local.base.tree;
DTIndex t;
- Bool braille = False;
+ Bool braille = False, anymodifier = False;
if(ev->xkey.keycode == 0)
return (False);
XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
- if(IsModifierKey(keysym))
- return (False);
-
if(keysym >= XK_braille_dot_1 && keysym <= XK_braille_dot_8) {
if(ev->type == KeyPress) {
ic->private.local.brl_pressed |=
@@ -78,38 +77,71 @@ _XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
}
}
- if( (ev->type != KeyPress)
- || (((Xim)ic->core.im)->private.local.top == 0 ) )
+ if(((Xim)ic->core.im)->private.local.top == 0 )
goto emit_braille;
+ currstate = ev->xkey.state;
+ if(ev->type == KeyPress) {
+ prevcode = ev->xkey.keycode;
+ prevstate = currstate;
+
+ if(IsModifierKey(keysym))
+ return(False);
+ prevcode = 0;
+ } else {
+ if(prevcode != ev->xkey.keycode)
+ return False;
+
+ /* For lookup, we use the state at the time when the key was pressed, */
+ /* because this state was not affected by the modifier that is mapped */
+ /* to the key. */
+ ev->xkey.state = prevstate;
+ XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
+ }
+
for(t = ic->private.local.context; t; t = b[t].next) {
+ if(IsModifierKey(b[t].keysym))
+ anymodifier = True;
if(((ev->xkey.state & b[t].modifier_mask) == b[t].modifier) &&
(keysym == b[t].keysym))
break;
}
+ /* Restore the state */
+ ev->xkey.state = currstate;
+
if(t) { /* Matched */
if(b[t].succession) { /* Intermediate */
ic->private.local.context = b[t].succession;
- return(True);
+ return (ev->type == KeyPress);
} else { /* Terminate (reached to leaf) */
ic->private.local.composed = t;
ic->private.local.brl_committed = 0;
/* return back to client KeyPressEvent keycode == 0 */
ev->xkey.keycode = 0;
+ ev->xkey.type = KeyPress;
XPutBackEvent(d, ev);
+ if(prevcode){
+ /* For modifier key releases, restore the event, as we do not */
+ /* filter it. */
+ ev->xkey.type = KeyRelease;
+ ev->xkey.keycode = prevcode;
+ }
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
- return(True);
+ return (ev->type == KeyPress);
}
} else { /* Unmatched */
- if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) {
+ /* Unmatched modifier key releases abort matching only in the case that */
+ /* there was any modifier that would have matched */
+ if((ic->private.local.context == ((Xim)ic->core.im)->private.local.top) ||
+ (ev->type == KeyRelease && !anymodifier)) {
goto emit_braille;
}
/* Error (Sequence Unmatch occured) */
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
- return(True);
+ return (ev->type == KeyPress);
}
emit_braille:
diff --git a/libxcb/xcb-proto/src/dri2.xml b/libxcb/xcb-proto/src/dri2.xml
index 62e16ed17..3af160066 100644
--- a/libxcb/xcb-proto/src/dri2.xml
+++ b/libxcb/xcb-proto/src/dri2.xml
@@ -1,166 +1,264 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Copyright (C) 2005 Jeremy Kolb.
-Copyright © 2009 Intel Corporation
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the names of the authors or their
-institutions shall not be used in advertising or otherwise to promote the
-sale, use or other dealings in this Software without prior written
-authorization from the authors.
--->
-
-<xcb header="dri2" extension-xname="DRI2" extension-name="DRI2"
- major-version="1" minor-version="1">
- <import>xproto</import>
-
- <enum name="Attachment">
- <item name="BufferFrontLeft" />
- <item name="BufferBackLeft" />
- <item name="BufferFrontRight" />
- <item name="BufferBackRight" />
- <item name="BufferDepth" />
- <item name="BufferStencil" />
- <item name="BufferAccum" />
- <item name="BufferFakeFrontLeft" />
- <item name="BufferFakeFrontRight" />
- <item name="BufferDepthStencil" />
- </enum>
-
- <enum name="DriverType">
- <item name="DRI" />
- </enum>
-
- <!-- Types -->
-
- <struct name="DRI2Buffer">
- <field type="CARD32" name="attachment" enum="Attachment" />
- <field type="CARD32" name="name" />
- <field type="CARD32" name="pitch" />
- <field type="CARD32" name="cpp" />
- <field type="CARD32" name="flags" />
- </struct>
-
- <struct name="AttachFormat">
- <field type="CARD32" name="attachment" enum="Attachment" />
- <field type="CARD32" name="format" />
- </struct>
-
- <!-- Requests -->
- <request name="QueryVersion" opcode="0">
- <field type="CARD32" name="major_version" />
- <field type="CARD32" name="minor_version" />
- <reply>
- <pad bytes="1" />
- <field type="CARD32" name="major_version" />
- <field type="CARD32" name="minor_version" />
- </reply>
- </request>
-
- <request name="Connect" opcode="1">
- <field type="WINDOW" name="window" />
- <field type="CARD32" name="driver_type" enum="DriverType" />
- <reply>
- <pad bytes="1" />
- <field type="CARD32" name="driver_name_length" />
- <field type="CARD32" name="device_name_length" />
- <pad bytes="16" />
- <list type="char" name="driver_name">
- <fieldref>driver_name_length</fieldref>
- </list>
- <list type="void" name="alignment_pad">
- <op op="-">
- <op op="&amp;">
- <op op="+">
- <fieldref>driver_name_length</fieldref>
- <value> 3 </value>
- </op>
- <unop op="~">
- <value>3</value>
- </unop>
- </op>
- <fieldref>driver_name_length</fieldref>
- </op>
- </list>
- <list type="char" name="device_name">
- <fieldref>device_name_length</fieldref>
- </list>
- </reply>
- </request>
-
- <request name="Authenticate" opcode="2">
- <field type="WINDOW" name="window" />
- <field type="CARD32" name="magic" />
- <reply>
- <pad bytes="1" />
- <field type="CARD32" name="authenticated" />
- </reply>
- </request>
-
- <request name="CreateDrawable" opcode="3">
- <field type="DRAWABLE" name="drawable" />
- </request>
-
- <request name="DestroyDrawable" opcode="4">
- <field type="DRAWABLE" name="drawable" />
- </request>
-
- <request name="GetBuffers" opcode="5">
- <field type="DRAWABLE" name="drawable" />
- <field type="CARD32" name="count" />
- <list type="CARD32" name="attachments" />
- <reply>
- <pad bytes="1" />
- <field type="CARD32" name="width" />
- <field type="CARD32" name="height" />
- <field type="CARD32" name="count" />
- <pad bytes="12" />
- <list type="DRI2Buffer" name="buffers">
- <fieldref>count</fieldref>
- </list>
- </reply>
- </request>
-
- <request name="CopyRegion" opcode="6">
- <field type="DRAWABLE" name="drawable" />
- <field type="CARD32" name="region" />
- <field type="CARD32" name="dest" />
- <field type="CARD32" name="src" />
- <reply>
- <pad bytes="1" />
- </reply>
- </request>
-
- <request name="GetBuffersWithFormat" opcode="7">
- <field type="DRAWABLE" name="drawable" />
- <field type="CARD32" name="count" />
- <list type="AttachFormat" name="attachments" />
- <reply>
- <pad bytes="1" />
- <field type="CARD32" name="width" />
- <field type="CARD32" name="height" />
- <field type="CARD32" name="count" />
- <pad bytes="12" />
- <list type="DRI2Buffer" name="buffers">
- <fieldref>count</fieldref>
- </list>
- </reply>
- </request>
-</xcb>
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright (C) 2005 Jeremy Kolb.
+Copyright © 2009 Intel Corporation
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the authors or their
+institutions shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization from the authors.
+-->
+
+<xcb header="dri2" extension-xname="DRI2" extension-name="DRI2"
+ major-version="1" minor-version="3">
+ <import>xproto</import>
+
+ <enum name="Attachment">
+ <item name="BufferFrontLeft" />
+ <item name="BufferBackLeft" />
+ <item name="BufferFrontRight" />
+ <item name="BufferBackRight" />
+ <item name="BufferDepth" />
+ <item name="BufferStencil" />
+ <item name="BufferAccum" />
+ <item name="BufferFakeFrontLeft" />
+ <item name="BufferFakeFrontRight" />
+ <item name="BufferDepthStencil" />
+ <item name="BufferHiz" />
+ </enum>
+
+ <enum name="DriverType">
+ <item name="DRI" />
+ <item name="VDPAU" />
+ </enum>
+
+ <enum name="EventType">
+ <item name="ExchangeComplete"><value>1</value></item>
+ <item name="BlitComplete"> <value>2</value></item>
+ <item name="FlipComplete"> <value>3</value></item>
+ </enum>
+
+ <!-- Types -->
+
+ <struct name="DRI2Buffer">
+ <field type="CARD32" name="attachment" enum="Attachment" />
+ <field type="CARD32" name="name" />
+ <field type="CARD32" name="pitch" />
+ <field type="CARD32" name="cpp" />
+ <field type="CARD32" name="flags" />
+ </struct>
+
+ <struct name="AttachFormat">
+ <field type="CARD32" name="attachment" enum="Attachment" />
+ <field type="CARD32" name="format" />
+ </struct>
+
+ <!-- Requests -->
+ <request name="QueryVersion" opcode="0">
+ <field type="CARD32" name="major_version" />
+ <field type="CARD32" name="minor_version" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="major_version" />
+ <field type="CARD32" name="minor_version" />
+ </reply>
+ </request>
+
+ <request name="Connect" opcode="1">
+ <field type="WINDOW" name="window" />
+ <field type="CARD32" name="driver_type" enum="DriverType" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="driver_name_length" />
+ <field type="CARD32" name="device_name_length" />
+ <pad bytes="16" />
+ <list type="char" name="driver_name">
+ <fieldref>driver_name_length</fieldref>
+ </list>
+ <list type="void" name="alignment_pad">
+ <op op="-">
+ <op op="&amp;">
+ <op op="+">
+ <fieldref>driver_name_length</fieldref>
+ <value> 3 </value>
+ </op>
+ <unop op="~">
+ <value>3</value>
+ </unop>
+ </op>
+ <fieldref>driver_name_length</fieldref>
+ </op>
+ </list>
+ <list type="char" name="device_name">
+ <fieldref>device_name_length</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="Authenticate" opcode="2">
+ <field type="WINDOW" name="window" />
+ <field type="CARD32" name="magic" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="authenticated" />
+ </reply>
+ </request>
+
+ <request name="CreateDrawable" opcode="3">
+ <field type="DRAWABLE" name="drawable" />
+ </request>
+
+ <request name="DestroyDrawable" opcode="4">
+ <field type="DRAWABLE" name="drawable" />
+ </request>
+
+ <request name="GetBuffers" opcode="5">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="count" />
+ <list type="CARD32" name="attachments" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="width" />
+ <field type="CARD32" name="height" />
+ <field type="CARD32" name="count" />
+ <pad bytes="12" />
+ <list type="DRI2Buffer" name="buffers">
+ <fieldref>count</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="CopyRegion" opcode="6">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="region" />
+ <field type="CARD32" name="dest" />
+ <field type="CARD32" name="src" />
+ <reply>
+ <pad bytes="1" />
+ </reply>
+ </request>
+
+ <request name="GetBuffersWithFormat" opcode="7">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="count" />
+ <list type="AttachFormat" name="attachments" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="width" />
+ <field type="CARD32" name="height" />
+ <field type="CARD32" name="count" />
+ <pad bytes="12" />
+ <list type="DRI2Buffer" name="buffers">
+ <fieldref>count</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <!-- Version 1.2 -->
+
+ <request name="SwapBuffers" opcode="8">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="target_msc_hi" />
+ <field type="CARD32" name="target_msc_lo" />
+ <field type="CARD32" name="divisor_hi" />
+ <field type="CARD32" name="divisor_lo" />
+ <field type="CARD32" name="remainder_hi" />
+ <field type="CARD32" name="remainder_lo" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="swap_hi" />
+ <field type="CARD32" name="swap_lo" />
+ </reply>
+ </request>
+
+ <request name="GetMSC" opcode="9">
+ <field type="DRAWABLE" name="drawable" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="ust_hi" />
+ <field type="CARD32" name="ust_lo" />
+ <field type="CARD32" name="msc_hi" />
+ <field type="CARD32" name="msc_lo" />
+ <field type="CARD32" name="sbc_hi" />
+ <field type="CARD32" name="sbc_lo" />
+ </reply>
+ </request>
+
+ <request name="WaitMSC" opcode="10">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="target_msc_hi" />
+ <field type="CARD32" name="target_msc_lo" />
+ <field type="CARD32" name="divisor_hi" />
+ <field type="CARD32" name="divisor_lo" />
+ <field type="CARD32" name="remainder_hi" />
+ <field type="CARD32" name="remainder_lo" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="ust_hi" />
+ <field type="CARD32" name="ust_lo" />
+ <field type="CARD32" name="msc_hi" />
+ <field type="CARD32" name="msc_lo" />
+ <field type="CARD32" name="sbc_hi" />
+ <field type="CARD32" name="sbc_lo" />
+ </reply>
+ </request>
+
+ <request name="WaitSBC" opcode="11">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="target_sbc_hi" />
+ <field type="CARD32" name="target_sbc_lo" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="ust_hi" />
+ <field type="CARD32" name="ust_lo" />
+ <field type="CARD32" name="msc_hi" />
+ <field type="CARD32" name="msc_lo" />
+ <field type="CARD32" name="sbc_hi" />
+ <field type="CARD32" name="sbc_lo" />
+ </reply>
+ </request>
+
+ <request name="SwapInterval" opcode="12">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="interval" />
+ </request>
+
+ <!-- Events -->
+
+ <event name="BufferSwapComplete" number="0">
+ <pad bytes="1" />
+ <field type="CARD16" name="event_type" enum="EventType" />
+ <pad bytes="2" />
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="ust_hi" />
+ <field type="CARD32" name="ust_lo" />
+ <field type="CARD32" name="msc_hi" />
+ <field type="CARD32" name="msc_lo" />
+ <field type="CARD32" name="sbc" />
+ </event>
+
+ <!-- Version 1.3 -->
+
+ <event name="InvalidateBuffers" number="1">
+ <pad bytes="1" />
+ <field type="DRAWABLE" name="drawable" />
+ </event>
+</xcb>
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index f908341f6..404bd21e1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -51,6 +51,10 @@ extern "C" {
#include <math.h>
#include <stdarg.h>
+#ifdef PIPE_OS_UNIX
+#include <strings.h> /* for ffs */
+#endif
+
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript
index bcb6a2491..da4d9b185 100644
--- a/mesalib/src/mesa/SConscript
+++ b/mesalib/src/mesa/SConscript
@@ -74,6 +74,7 @@ main_sources = [
'main/ffvertex_prog.c',
'main/fog.c',
'main/formats.c',
+ 'main/format_pack.c',
'main/format_unpack.c',
'main/framebuffer.c',
'main/get.c',
@@ -152,7 +153,6 @@ math_sources = [
swrast_sources = [
'swrast/s_aaline.c',
'swrast/s_aatriangle.c',
- 'swrast/s_accum.c',
'swrast/s_alpha.c',
'swrast/s_atifragshader.c',
'swrast/s_bitmap.c',
@@ -170,6 +170,7 @@ swrast_sources = [
'swrast/s_logic.c',
'swrast/s_masking.c',
'swrast/s_points.c',
+ 'swrast/s_renderbuffer.c',
'swrast/s_span.c',
'swrast/s_stencil.c',
'swrast/s_texcombine.c',
@@ -240,7 +241,6 @@ statetracker_sources = [
'state_tracker/st_atom_stipple.c',
'state_tracker/st_atom_texture.c',
'state_tracker/st_atom_viewport.c',
- 'state_tracker/st_cb_accum.c',
'state_tracker/st_cb_bitmap.c',
'state_tracker/st_cb_blit.c',
'state_tracker/st_cb_bufferobjects.c',
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c
index 5e25d7fda..c6b42a21d 100644
--- a/mesalib/src/mesa/drivers/common/driverfuncs.c
+++ b/mesalib/src/mesa/drivers/common/driverfuncs.c
@@ -25,6 +25,7 @@
#include "main/glheader.h"
#include "main/imports.h"
+#include "main/accum.h"
#include "main/arrayobj.h"
#include "main/context.h"
#include "main/framebuffer.h"
@@ -49,6 +50,7 @@
#include "program/program.h"
#include "tnl/tnl.h"
#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
#include "driverfuncs.h"
#include "meta.h"
@@ -80,7 +82,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
/* framebuffer/image functions */
driver->Clear = _swrast_Clear;
- driver->Accum = _swrast_Accum;
+ driver->Accum = _mesa_accum;
driver->RasterPos = _tnl_RasterPos;
driver->DrawPixels = _swrast_DrawPixels;
driver->ReadPixels = _mesa_readpixels;
@@ -119,8 +121,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->UnmapTextureImage = _swrast_unmap_teximage;
driver->MapTexture = NULL;
driver->UnmapTexture = NULL;
- driver->TextureMemCpy = memcpy;
- driver->IsTextureResident = NULL;
driver->DrawTex = _mesa_meta_DrawTex;
/* Vertex/fragment programs */
@@ -180,9 +180,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
_mesa_init_sync_object_functions(driver);
driver->NewFramebuffer = _mesa_new_framebuffer;
- driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
- driver->MapRenderbuffer = _mesa_map_soft_renderbuffer;
- driver->UnmapRenderbuffer = _mesa_unmap_soft_renderbuffer;
+ driver->NewRenderbuffer = _swrast_new_soft_renderbuffer;
+ driver->MapRenderbuffer = _swrast_map_soft_renderbuffer;
+ driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
driver->RenderTexture = _swrast_render_texture;
driver->FinishRenderTexture = _swrast_finish_render_texture;
driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index f4c656d01..b31700d10 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -43,6 +43,7 @@
#include "main/imports.h"
#include "main/renderbuffer.h"
#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
@@ -495,13 +496,13 @@ dri_create_buffer(__DRIscreen * sPriv,
}
/* add software renderbuffers */
- _mesa_add_soft_renderbuffers(fb,
- GL_FALSE, /* color */
- visual->haveDepthBuffer,
- visual->haveStencilBuffer,
- visual->haveAccumBuffer,
- GL_FALSE, /* alpha */
- GL_FALSE /* aux bufs */);
+ _swrast_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ visual->haveDepthBuffer,
+ visual->haveStencilBuffer,
+ visual->haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux bufs */);
return GL_TRUE;
diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
index 14d15ed6c..675ffdaaa 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
@@ -16,6 +16,7 @@
#include "drivers/common/meta.h"
#include "vbo/vbo.h"
#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
@@ -1610,13 +1611,13 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc)
wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 0);
/* Let Mesa own the Depth, Stencil, and Accum buffers */
- _mesa_add_soft_renderbuffers(&pwfb->Base,
- GL_FALSE, /* color */
- visual->depthBits > 0,
- visual->stencilBits > 0,
- visual->accumRedBits > 0,
- visual->alphaBits >0,
- GL_FALSE);
+ _swrast_add_soft_renderbuffers(&pwfb->Base,
+ GL_FALSE, /* color */
+ visual->depthBits > 0,
+ visual->stencilBits > 0,
+ visual->accumRedBits > 0,
+ visual->alphaBits >0,
+ GL_FALSE);
}
if (c && pwfb)
diff --git a/mesalib/src/mesa/main/accum.c b/mesalib/src/mesa/main/accum.c
index d7ed3a849..eb06bbb6e 100644
--- a/mesalib/src/mesa/main/accum.c
+++ b/mesalib/src/mesa/main/accum.c
@@ -24,7 +24,10 @@
#include "glheader.h"
#include "accum.h"
+#include "condrender.h"
#include "context.h"
+#include "format_unpack.h"
+#include "format_pack.h"
#include "imports.h"
#include "macros.h"
#include "mfeatures.h"
@@ -101,7 +104,7 @@ _mesa_Accum( GLenum op, GLfloat value )
return;
if (ctx->RenderMode == GL_RENDER) {
- ctx->Driver.Accum(ctx, op, value);
+ _mesa_accum(ctx, op, value);
}
}
@@ -123,3 +126,384 @@ _mesa_init_accum( struct gl_context *ctx )
/* Accumulate buffer group */
ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
}
+
+
+
+
+/**
+ * Clear the accumulation buffer by mapping the renderbuffer and
+ * writing the clear color to it. Called by the driver's implementation
+ * of the glClear function.
+ */
+void
+_mesa_clear_accum_buffer(struct gl_context *ctx)
+{
+ GLuint x, y, width, height;
+ GLubyte *accMap;
+ GLint accRowStride;
+ struct gl_renderbuffer *accRb;
+
+ if (!ctx->DrawBuffer)
+ return;
+
+ accRb = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ if (!accRb)
+ return; /* missing accum buffer, not an error */
+
+ /* bounds, with scissor */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ ctx->Driver.MapRenderbuffer(ctx, accRb, x, y, width, height,
+ GL_MAP_WRITE_BIT, &accMap, &accRowStride);
+
+ if (!accMap) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ return;
+ }
+
+ if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+ const GLshort clearR = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]);
+ const GLshort clearG = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]);
+ const GLshort clearB = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]);
+ const GLshort clearA = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
+ GLuint i, j;
+
+ for (j = 0; j < height; j++) {
+ GLshort *row = (GLshort *) accMap;
+
+ for (i = 0; i < width; i++) {
+ row[i * 4 + 0] = clearR;
+ row[i * 4 + 1] = clearG;
+ row[i * 4 + 2] = clearB;
+ row[i * 4 + 3] = clearA;
+ }
+ accMap += accRowStride;
+ }
+ }
+ else {
+ /* other types someday? */
+ _mesa_warning(ctx, "unexpected accum buffer type");
+ }
+
+ ctx->Driver.UnmapRenderbuffer(ctx, accRb);
+}
+
+
+/**
+ * if (bias)
+ * Accum += value
+ * else
+ * Accum *= value
+ */
+static void
+accum_scale_or_bias(struct gl_context *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height,
+ GLboolean bias)
+{
+ struct gl_renderbuffer *accRb =
+ ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ GLubyte *accMap;
+ GLint accRowStride;
+
+ assert(accRb);
+
+ ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
+ &accMap, &accRowStride);
+
+ if (!accMap) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ return;
+ }
+
+ if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+ const GLshort incr = (GLshort) (value * 32767.0f);
+ GLuint i, j;
+ if (bias) {
+ for (j = 0; j < height; j++) {
+ GLshort *acc = (GLshort *) accMap;
+ for (i = 0; i < 4 * width; i++) {
+ acc[i] += incr;
+ }
+ accMap += accRowStride;
+ }
+ }
+ else {
+ /* scale */
+ for (j = 0; j < height; j++) {
+ GLshort *acc = (GLshort *) accMap;
+ for (i = 0; i < 4 * width; i++) {
+ acc[i] = (GLshort) (acc[i] * value);
+ }
+ accMap += accRowStride;
+ }
+ }
+ }
+ else {
+ /* other types someday? */
+ }
+
+ ctx->Driver.UnmapRenderbuffer(ctx, accRb);
+}
+
+
+/**
+ * if (load)
+ * Accum = ColorBuf * value
+ * else
+ * Accum += ColorBuf * value
+ */
+static void
+accum_or_load(struct gl_context *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height,
+ GLboolean load)
+{
+ struct gl_renderbuffer *accRb =
+ ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ struct gl_renderbuffer *colorRb = ctx->ReadBuffer->_ColorReadBuffer;
+ GLubyte *accMap, *colorMap;
+ GLint accRowStride, colorRowStride;
+ GLbitfield mappingFlags;
+
+ if (!colorRb) {
+ /* no read buffer - OK */
+ return;
+ }
+
+ assert(accRb);
+
+ mappingFlags = GL_MAP_WRITE_BIT;
+ if (!load) /* if we're accumulating */
+ mappingFlags |= GL_MAP_READ_BIT;
+
+ /* Map accum buffer */
+ ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height,
+ mappingFlags, &accMap, &accRowStride);
+ if (!accMap) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ return;
+ }
+
+ /* Map color buffer */
+ ctx->Driver.MapRenderbuffer(ctx, colorRb, xpos, ypos, width, height,
+ GL_MAP_READ_BIT,
+ &colorMap, &colorRowStride);
+ if (!colorMap) {
+ ctx->Driver.UnmapRenderbuffer(ctx, accRb);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ return;
+ }
+
+ if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+ const GLfloat scale = value * 32767.0f;
+ GLuint i, j;
+ GLfloat (*rgba)[4];
+
+ rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
+ if (rgba) {
+ for (j = 0; j < height; j++) {
+ GLshort *acc = (GLshort *) accMap;
+
+ /* read colors from source color buffer */
+ _mesa_unpack_rgba_row(colorRb->Format, width, colorMap, rgba);
+
+ if (load) {
+ for (i = 0; i < width; i++) {
+ acc[i * 4 + 0] = (GLshort) (rgba[i][RCOMP] * scale);
+ acc[i * 4 + 1] = (GLshort) (rgba[i][GCOMP] * scale);
+ acc[i * 4 + 2] = (GLshort) (rgba[i][BCOMP] * scale);
+ acc[i * 4 + 3] = (GLshort) (rgba[i][ACOMP] * scale);
+ }
+ }
+ else {
+ /* accumulate */
+ for (i = 0; i < width; i++) {
+ acc[i * 4 + 0] += (GLshort) (rgba[i][RCOMP] * scale);
+ acc[i * 4 + 1] += (GLshort) (rgba[i][GCOMP] * scale);
+ acc[i * 4 + 2] += (GLshort) (rgba[i][BCOMP] * scale);
+ acc[i * 4 + 3] += (GLshort) (rgba[i][ACOMP] * scale);
+ }
+ }
+
+ colorMap += colorRowStride;
+ accMap += accRowStride;
+ }
+
+ free(rgba);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ }
+ }
+ else {
+ /* other types someday? */
+ }
+
+ ctx->Driver.UnmapRenderbuffer(ctx, accRb);
+ ctx->Driver.UnmapRenderbuffer(ctx, colorRb);
+}
+
+
+/**
+ * ColorBuffer = Accum * value
+ */
+static void
+accum_return(struct gl_context *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *accRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer;
+ GLubyte *accMap, *colorMap;
+ GLint accRowStride, colorRowStride;
+ GLuint buffer;
+
+ /* Map accum buffer */
+ ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height,
+ GL_MAP_READ_BIT,
+ &accMap, &accRowStride);
+ if (!accMap) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ return;
+ }
+
+ /* Loop over destination buffers */
+ for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) {
+ struct gl_renderbuffer *colorRb = fb->_ColorDrawBuffers[buffer];
+ const GLboolean masking = (!ctx->Color.ColorMask[buffer][RCOMP] ||
+ !ctx->Color.ColorMask[buffer][GCOMP] ||
+ !ctx->Color.ColorMask[buffer][BCOMP] ||
+ !ctx->Color.ColorMask[buffer][ACOMP]);
+ GLbitfield mappingFlags = GL_MAP_WRITE_BIT;
+
+ if (masking)
+ mappingFlags |= GL_MAP_READ_BIT;
+
+ /* Map color buffer */
+ ctx->Driver.MapRenderbuffer(ctx, colorRb, xpos, ypos, width, height,
+ mappingFlags, &colorMap, &colorRowStride);
+ if (!colorMap) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ continue;
+ }
+
+ if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+ const GLfloat scale = value / 32767.0f;
+ GLint i, j;
+ GLfloat (*rgba)[4], (*dest)[4];
+
+ rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
+ dest = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
+
+ if (rgba && dest) {
+ for (j = 0; j < height; j++) {
+ GLshort *acc = (GLshort *) accMap;
+
+ for (i = 0; i < width; i++) {
+ rgba[i][0] = acc[i * 4 + 0] * scale;
+ rgba[i][1] = acc[i * 4 + 1] * scale;
+ rgba[i][2] = acc[i * 4 + 2] * scale;
+ rgba[i][3] = acc[i * 4 + 3] * scale;
+ }
+
+ if (masking) {
+
+ /* get existing colors from dest buffer */
+ _mesa_unpack_rgba_row(colorRb->Format, width, colorMap, dest);
+
+ /* use the dest colors where mask[channel] = 0 */
+ if (ctx->Color.ColorMask[buffer][RCOMP] == 0) {
+ for (i = 0; i < width; i++)
+ rgba[i][RCOMP] = dest[i][RCOMP];
+ }
+ if (ctx->Color.ColorMask[buffer][GCOMP] == 0) {
+ for (i = 0; i < width; i++)
+ rgba[i][GCOMP] = dest[i][GCOMP];
+ }
+ if (ctx->Color.ColorMask[buffer][BCOMP] == 0) {
+ for (i = 0; i < width; i++)
+ rgba[i][BCOMP] = dest[i][BCOMP];
+ }
+ if (ctx->Color.ColorMask[buffer][ACOMP] == 0) {
+ for (i = 0; i < width; i++)
+ rgba[i][ACOMP] = dest[i][ACOMP];
+ }
+ }
+
+ _mesa_pack_float_rgba_row(colorRb->Format, width,
+ (const GLfloat (*)[4]) rgba, colorMap);
+
+ accMap += accRowStride;
+ colorMap += colorRowStride;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
+ }
+ free(rgba);
+ free(dest);
+ }
+ else {
+ /* other types someday? */
+ }
+
+ ctx->Driver.UnmapRenderbuffer(ctx, colorRb);
+ }
+
+ ctx->Driver.UnmapRenderbuffer(ctx, accRb);
+}
+
+
+
+/**
+ * Software fallback for glAccum. A hardware driver that supports
+ * signed 16-bit color channels could implement hardware accumulation
+ * operations, but no driver does so at this time.
+ */
+void
+_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
+{
+ GLint xpos, ypos, width, height;
+
+ if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) {
+ _mesa_warning(ctx, "Calling glAccum() without an accumulation buffer");
+ return;
+ }
+
+ if (!_mesa_check_conditional_render(ctx))
+ return;
+
+ xpos = ctx->DrawBuffer->_Xmin;
+ ypos = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ switch (op) {
+ case GL_ADD:
+ if (value != 0.0F) {
+ accum_scale_or_bias(ctx, value, xpos, ypos, width, height, GL_TRUE);
+ }
+ break;
+ case GL_MULT:
+ if (value != 1.0F) {
+ accum_scale_or_bias(ctx, value, xpos, ypos, width, height, GL_FALSE);
+ }
+ break;
+ case GL_ACCUM:
+ if (value != 0.0F) {
+ accum_or_load(ctx, value, xpos, ypos, width, height, GL_FALSE);
+ }
+ break;
+ case GL_LOAD:
+ accum_or_load(ctx, value, xpos, ypos, width, height, GL_TRUE);
+ break;
+ case GL_RETURN:
+ accum_return(ctx, value, xpos, ypos, width, height);
+ break;
+ default:
+ _mesa_problem(ctx, "invalid mode in _mesa_accum()");
+ break;
+ }
+}
diff --git a/mesalib/src/mesa/main/accum.h b/mesalib/src/mesa/main/accum.h
index f16378cc1..5b3f06aa9 100644
--- a/mesalib/src/mesa/main/accum.h
+++ b/mesalib/src/mesa/main/accum.h
@@ -42,6 +42,7 @@
struct _glapi_table;
struct gl_context;
+struct gl_renderbuffer;
#if FEATURE_accum
@@ -51,6 +52,12 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
extern void
_mesa_init_accum_dispatch(struct _glapi_table *disp);
+extern void
+_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value);
+
+extern void
+_mesa_clear_accum_buffer(struct gl_context *ctx);
+
#else /* FEATURE_accum */
#include "main/compiler.h"
@@ -67,6 +74,17 @@ _mesa_init_accum_dispatch(struct _glapi_table *disp)
{
}
+static inline void
+_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
+{
+}
+
+static inline void
+_mesa_clear_accum_buffer(struct gl_context *ctx)
+{
+}
+
+
#endif /* FEATURE_accum */
extern void
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 9842540da..d6f70d1c4 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -532,24 +532,6 @@ struct dd_function_table {
void (*UnmapRenderbuffer)(struct gl_context *ctx,
struct gl_renderbuffer *rb);
- /**
- * Note: no context argument. This function doesn't initially look
- * like it belongs here, except that the driver is the only entity
- * that knows for sure how the texture memory is allocated - via
- * the above callbacks. There is then an argument that the driver
- * knows what memcpy paths might be fast. Typically this is invoked with
- *
- * to -- a pointer into texture memory allocated by NewTextureImage() above.
- * from -- a pointer into client memory or a mesa temporary.
- * sz -- nr bytes to copy.
- */
- void* (*TextureMemCpy)( void *to, const void *from, size_t sz );
-
- /**
- * Called by glAreTextureResident().
- */
- GLboolean (*IsTextureResident)( struct gl_context *ctx,
- struct gl_texture_object *t );
/*@}*/
diff --git a/mesalib/src/mesa/main/depthstencil.c b/mesalib/src/mesa/main/depthstencil.c
index 40d6c9612..af5c12f67 100644
--- a/mesalib/src/mesa/main/depthstencil.c
+++ b/mesalib/src/mesa/main/depthstencil.c
@@ -957,158 +957,3 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer
return s8rb;
}
-
-
-
-/**
- ** The following functions are useful for hardware drivers that only
- ** implement combined depth/stencil buffers.
- ** The GL_EXT_framebuffer_object extension allows indepedent depth and
- ** stencil buffers to be used in any combination.
- ** Therefore, we sometimes have to merge separate depth and stencil
- ** renderbuffers into a single depth+stencil renderbuffer. And sometimes
- ** we have to split combined depth+stencil renderbuffers into separate
- ** renderbuffers.
- **/
-
-
-/**
- * Extract stencil values from the combined depth/stencil renderbuffer, storing
- * the values into a separate stencil renderbuffer.
- * \param dsRb the source depth/stencil renderbuffer
- * \param stencilRb the destination stencil renderbuffer
- * (either 8-bit or 32-bit)
- */
-void
-_mesa_extract_stencil(struct gl_context *ctx,
- struct gl_renderbuffer *dsRb,
- struct gl_renderbuffer *stencilRb)
-{
- GLuint row, width, height;
-
- ASSERT(dsRb);
- ASSERT(stencilRb);
-
- ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8);
- ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 ||
- stencilRb->Format == MESA_FORMAT_S8);
- ASSERT(dsRb->Width == stencilRb->Width);
- ASSERT(dsRb->Height == stencilRb->Height);
-
- width = dsRb->Width;
- height = dsRb->Height;
-
- for (row = 0; row < height; row++) {
- GLuint depthStencil[MAX_WIDTH];
- dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil);
- if (stencilRb->Format == MESA_FORMAT_S8) {
- /* 8bpp stencil */
- GLubyte stencil[MAX_WIDTH];
- GLuint i;
- for (i = 0; i < width; i++) {
- stencil[i] = depthStencil[i] & 0xff;
- }
- stencilRb->PutRow(ctx, stencilRb, width, 0, row, stencil, NULL);
- }
- else {
- /* 32bpp stencil */
- /* the 24 depth bits will be ignored */
- ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8);
- ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL);
- }
- }
-}
-
-
-/**
- * Copy stencil values from a stencil renderbuffer into a combined
- * depth/stencil renderbuffer.
- * \param dsRb the destination depth/stencil renderbuffer
- * \param stencilRb the source stencil buffer (either 8-bit or 32-bit)
- */
-void
-_mesa_insert_stencil(struct gl_context *ctx,
- struct gl_renderbuffer *dsRb,
- struct gl_renderbuffer *stencilRb)
-{
- GLuint row, width, height;
-
- ASSERT(dsRb);
- ASSERT(stencilRb);
-
- ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8);
- ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 ||
- stencilRb->Format == MESA_FORMAT_S8);
-
- ASSERT(dsRb->Width == stencilRb->Width);
- ASSERT(dsRb->Height == stencilRb->Height);
-
- width = dsRb->Width;
- height = dsRb->Height;
-
- for (row = 0; row < height; row++) {
- GLuint depthStencil[MAX_WIDTH];
-
- dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil);
-
- if (stencilRb->Format == MESA_FORMAT_S8) {
- /* 8bpp stencil */
- GLubyte stencil[MAX_WIDTH];
- GLuint i;
- stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil);
- for (i = 0; i < width; i++) {
- depthStencil[i] = (depthStencil[i] & 0xffffff00) | stencil[i];
- }
- }
- else {
- /* 32bpp stencil buffer */
- GLuint stencil[MAX_WIDTH], i;
- ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8);
- ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil);
- for (i = 0; i < width; i++) {
- depthStencil[i]
- = (depthStencil[i] & 0xffffff00) | (stencil[i] & 0xff);
- }
- }
-
- dsRb->PutRow(ctx, dsRb, width, 0, row, depthStencil, NULL);
- }
-}
-
-
-/**
- * Convert the stencil buffer from 8bpp to 32bpp depth/stencil.
- * \param stencilRb the stencil renderbuffer to promote
- */
-void
-_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb)
-{
- const GLsizei width = stencilRb->Width;
- const GLsizei height = stencilRb->Height;
- GLubyte *data;
- GLint i, j, k;
-
- ASSERT(stencilRb->Format == MESA_FORMAT_S8);
- ASSERT(stencilRb->Data);
-
- data = (GLubyte *) stencilRb->Data;
- stencilRb->Data = NULL;
- stencilRb->AllocStorage(ctx, stencilRb, GL_DEPTH24_STENCIL8_EXT,
- width, height);
-
- ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
-
- k = 0;
- for (i = 0; i < height; i++) {
- GLuint depthStencil[MAX_WIDTH];
- for (j = 0; j < width; j++) {
- depthStencil[j] = data[k++];
- }
- stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL);
- }
- free(data);
-}
diff --git a/mesalib/src/mesa/main/depthstencil.h b/mesalib/src/mesa/main/depthstencil.h
index b47a2e482..c3871d805 100644
--- a/mesalib/src/mesa/main/depthstencil.h
+++ b/mesalib/src/mesa/main/depthstencil.h
@@ -43,20 +43,4 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx,
struct gl_renderbuffer *dsrb);
-extern void
-_mesa_extract_stencil(struct gl_context *ctx,
- struct gl_renderbuffer *dsRb,
- struct gl_renderbuffer *stencilRb);
-
-
-extern void
-_mesa_insert_stencil(struct gl_context *ctx,
- struct gl_renderbuffer *dsRb,
- struct gl_renderbuffer *stencilRb);
-
-
-extern void
-_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb);
-
-
#endif /* DEPTHSTENCIL_H */
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
new file mode 100644
index 000000000..390b494c0
--- /dev/null
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -0,0 +1,2496 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (c) 2011 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * Color, depth, stencil packing functions.
+ * Used to pack basic color, depth and stencil formats to specific
+ * hardware formats.
+ *
+ * There are both per-pixel and per-row packing functions:
+ * - The former will be used by swrast to write values to the color, depth,
+ * stencil buffers when drawing points, lines and masked spans.
+ * - The later will be used for image-oriented functions like glDrawPixels,
+ * glAccum, and glTexImage.
+ */
+
+
+#include "colormac.h"
+#include "format_pack.h"
+#include "macros.h"
+#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
+#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+
+
+typedef void (*pack_ubyte_rgba_row_func)(GLuint n,
+ const GLubyte src[][4], void *dst);
+
+typedef void (*pack_float_rgba_row_func)(GLuint n,
+ const GLfloat src[][4], void *dst);
+
+
+
+static inline GLfloat
+linear_to_srgb(GLfloat cl)
+{
+ if (cl < 0.0f)
+ return 0.0f;
+ else if (cl < 0.0031308f)
+ return 12.92f * cl;
+ else if (cl < 1.0f)
+ return 1.055f * powf(cl, 0.41666f) - 0.055f;
+ else
+ return 1.0f;
+}
+
+
+static inline GLubyte
+linear_float_to_srgb_ubyte(GLfloat cl)
+{
+ GLubyte res = FLOAT_TO_UBYTE(linear_to_srgb(cl));
+ return res;
+}
+
+
+static inline GLubyte
+linear_ubyte_to_srgb_ubyte(GLubyte cl)
+{
+ GLubyte res = FLOAT_TO_UBYTE(linear_to_srgb(cl / 255.0f));
+ return res;
+}
+
+
+
+
+/*
+ * MESA_FORMAT_RGBA8888
+ */
+
+static void
+pack_ubyte_RGBA8888(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = PACK_COLOR_8888(src[RCOMP], src[GCOMP], src[BCOMP], src[ACOMP]);
+}
+
+static void
+pack_float_RGBA8888(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_RGBA8888(v, dst);
+}
+
+static void
+pack_row_ubyte_RGBA8888(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = PACK_COLOR_8888(src[i][RCOMP], src[i][GCOMP],
+ src[i][BCOMP], src[i][ACOMP]);
+ }
+}
+
+static void
+pack_row_float_RGBA8888(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_RGBA8888(v, d + i);
+ }
+}
+
+
+
+/*
+ * MESA_FORMAT_RGBA8888_REV
+ */
+
+static void
+pack_ubyte_RGBA8888_REV(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = PACK_COLOR_8888(src[ACOMP], src[BCOMP], src[GCOMP], src[RCOMP]);
+}
+
+static void
+pack_float_RGBA8888_REV(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_RGBA8888_REV(v, dst);
+}
+
+static void
+pack_row_ubyte_RGBA8888_REV(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = PACK_COLOR_8888(src[i][ACOMP], src[i][BCOMP],
+ src[i][GCOMP], src[i][RCOMP]);
+ }
+}
+
+static void
+pack_row_float_RGBA8888_REV(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_RGBA8888_REV(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_ARGB8888
+ */
+
+static void
+pack_ubyte_ARGB8888(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = PACK_COLOR_8888(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_ARGB8888(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_ARGB8888(v, dst);
+}
+
+static void
+pack_row_ubyte_ARGB8888(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = PACK_COLOR_8888(src[i][ACOMP], src[i][RCOMP],
+ src[i][GCOMP], src[i][BCOMP]);
+ }
+}
+
+static void
+pack_row_float_ARGB8888(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_ARGB8888(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_ARGB8888_REV
+ */
+
+static void
+pack_ubyte_ARGB8888_REV(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = PACK_COLOR_8888(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]);
+}
+
+static void
+pack_float_ARGB8888_REV(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_ARGB8888_REV(v, dst);
+}
+
+static void
+pack_row_ubyte_ARGB8888_REV(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = PACK_COLOR_8888(src[i][BCOMP], src[i][GCOMP],
+ src[i][RCOMP], src[i][ACOMP]);
+ }
+}
+
+static void
+pack_row_float_ARGB8888_REV(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_ARGB8888_REV(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_XRGB8888
+ */
+
+static void
+pack_ubyte_XRGB8888(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = PACK_COLOR_8888(0x0, src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_XRGB8888(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_XRGB8888(v, dst);
+}
+
+static void
+pack_row_ubyte_XRGB8888(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = PACK_COLOR_8888(0, src[i][RCOMP], src[i][GCOMP], src[i][BCOMP]);
+ }
+}
+
+static void
+pack_row_float_XRGB8888(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_XRGB8888(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_XRGB8888_REV
+ */
+
+static void
+pack_ubyte_XRGB8888_REV(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = PACK_COLOR_8888(src[BCOMP], src[GCOMP], src[RCOMP], 0);
+}
+
+static void
+pack_float_XRGB8888_REV(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_XRGB8888_REV(v, dst);
+}
+
+static void
+pack_row_ubyte_XRGB8888_REV(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = PACK_COLOR_8888(src[i][BCOMP], src[i][GCOMP], src[i][RCOMP], 0);
+ }
+}
+
+static void
+pack_row_float_XRGB8888_REV(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_XRGB8888_REV(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_RGB888
+ */
+
+static void
+pack_ubyte_RGB888(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ d[2] = src[RCOMP];
+ d[1] = src[GCOMP];
+ d[0] = src[BCOMP];
+}
+
+static void
+pack_float_RGB888(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[2], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[1], src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[BCOMP]);
+}
+
+static void
+pack_row_ubyte_RGB888(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i*3+2] = src[i][RCOMP];
+ d[i*3+1] = src[i][GCOMP];
+ d[i*3+0] = src[i][BCOMP];
+ }
+}
+
+static void
+pack_row_float_RGB888(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ d[i*3+2] = v[RCOMP];
+ d[i*3+1] = v[GCOMP];
+ d[i*3+0] = v[BCOMP];
+ }
+}
+
+
+/*
+ * MESA_FORMAT_BGR888
+ */
+
+static void
+pack_ubyte_BGR888(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ d[2] = src[BCOMP];
+ d[1] = src[GCOMP];
+ d[0] = src[RCOMP];
+}
+
+static void
+pack_float_BGR888(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[2], src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[1], src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[RCOMP]);
+}
+
+static void
+pack_row_ubyte_BGR888(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i*3+2] = src[i][BCOMP];
+ d[i*3+1] = src[i][GCOMP];
+ d[i*3+0] = src[i][RCOMP];
+ }
+}
+
+static void
+pack_row_float_BGR888(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ d[i*3+2] = v[BCOMP];
+ d[i*3+1] = v[GCOMP];
+ d[i*3+0] = v[RCOMP];
+ }
+}
+
+
+/*
+ * MESA_FORMAT_RGB565
+ */
+
+static void
+pack_ubyte_RGB565(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_565(src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_RGB565(const GLfloat src[4], void *dst)
+{
+ GLubyte v[3];
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], src[BCOMP]);
+ pack_ubyte_RGB565(v, dst);
+}
+
+static void
+pack_row_ubyte_RGB565(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ pack_ubyte_RGB565(src[i], d + i);
+ }
+}
+
+static void
+pack_row_float_RGB565(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_RGB565(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_RGB565_REV
+ */
+
+static void
+pack_ubyte_RGB565_REV(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_565_REV(src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_RGB565_REV(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte r, g, b;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, src[BCOMP]);
+ *d = PACK_COLOR_565_REV(r, g, b);
+}
+
+static void
+pack_row_ubyte_RGB565_REV(GLuint n, const GLubyte src[][4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ pack_ubyte_RGB565_REV(src[i], d + i);
+ }
+}
+
+static void
+pack_row_float_RGB565_REV(GLuint n, const GLfloat src[][4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src[i]);
+ pack_ubyte_RGB565_REV(v, d + i);
+ }
+}
+
+
+/*
+ * MESA_FORMAT_ARGB4444
+ */
+
+static void
+pack_ubyte_ARGB4444(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_4444(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_ARGB4444(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_ARGB4444(v, dst);
+}
+
+/* use fallback row packing functions */
+
+
+/*
+ * MESA_FORMAT_ARGB4444_REV
+ */
+
+static void
+pack_ubyte_ARGB4444_REV(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_4444(src[GCOMP], src[BCOMP], src[ACOMP], src[RCOMP]);
+}
+
+static void
+pack_float_ARGB4444_REV(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_ARGB4444_REV(v, dst);
+}
+
+/* use fallback row packing functions */
+
+
+/*
+ * MESA_FORMAT_RGBA5551
+ */
+
+static void
+pack_ubyte_RGBA5551(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_5551(src[RCOMP], src[GCOMP], src[BCOMP], src[ACOMP]);
+}
+
+static void
+pack_float_RGBA5551(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_RGBA5551(v, dst);
+}
+
+/* use fallback row packing functions */
+
+
+/*
+ * MESA_FORMAT_ARGB1555
+ */
+
+static void
+pack_ubyte_ARGB1555(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_1555(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_ARGB1555(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_ARGB1555(v, dst);
+}
+
+
+/* MESA_FORMAT_ARGB1555_REV */
+
+static void
+pack_ubyte_ARGB1555_REV(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst), tmp;
+ tmp = PACK_COLOR_1555(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]);
+ *d = (tmp >> 8) | (tmp << 8);
+}
+
+static void
+pack_float_ARGB1555_REV(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ _mesa_unclamped_float_rgba_to_ubyte(v, src);
+ pack_ubyte_ARGB1555_REV(v, dst);
+}
+
+
+/* MESA_FORMAT_AL44 */
+
+static void
+pack_ubyte_AL44(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_44(src[ACOMP], src[RCOMP]);
+}
+
+static void
+pack_float_AL44(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]);
+ pack_ubyte_AL44(v, dst);
+}
+
+
+/* MESA_FORMAT_AL88 */
+
+static void
+pack_ubyte_AL88(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_88(src[ACOMP], src[RCOMP]);
+}
+
+static void
+pack_float_AL88(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]);
+ pack_ubyte_AL88(v, dst);
+}
+
+
+/* MESA_FORMAT_AL88_REV */
+
+static void
+pack_ubyte_AL88_REV(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_88(src[RCOMP], src[ACOMP]);
+}
+
+static void
+pack_float_AL88_REV(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]);
+ pack_ubyte_AL88_REV(v, dst);
+}
+
+
+/* MESA_FORMAT_AL1616 */
+
+static void
+pack_ubyte_AL1616(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort l = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+ *d = PACK_COLOR_1616(a, l);
+}
+
+static void
+pack_float_AL1616(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort l, a;
+ UNCLAMPED_FLOAT_TO_USHORT(l, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ *d = PACK_COLOR_1616(a, l);
+}
+
+
+/* MESA_FORMAT_AL1616_REV */
+
+static void
+pack_ubyte_AL1616_REV(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort l = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+ *d = PACK_COLOR_1616(l, a);
+}
+
+static void
+pack_float_AL1616_REV(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort l, a;
+ UNCLAMPED_FLOAT_TO_USHORT(l, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ *d = PACK_COLOR_1616(l, a);
+}
+
+
+/* MESA_FORMAT_RGB332 */
+
+static void
+pack_ubyte_RGB332(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = PACK_COLOR_332(src[RCOMP], src[GCOMP], src[BCOMP]);
+}
+
+static void
+pack_float_RGB332(const GLfloat src[4], void *dst)
+{
+ GLubyte v[4];
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], src[BCOMP]);
+ pack_ubyte_RGB332(v, dst);
+}
+
+
+/* MESA_FORMAT_A8 */
+
+static void
+pack_ubyte_A8(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = src[ACOMP];
+}
+
+static void
+pack_float_A8(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[ACOMP]);
+}
+
+
+/* MESA_FORMAT_A16 */
+
+static void
+pack_ubyte_A16(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = UBYTE_TO_USHORT(src[ACOMP]);
+}
+
+static void
+pack_float_A16(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ UNCLAMPED_FLOAT_TO_USHORT(d[0], src[ACOMP]);
+}
+
+
+/* MESA_FORMAT_L8 */
+
+static void
+pack_ubyte_L8(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = src[RCOMP];
+}
+
+static void
+pack_float_L8(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[RCOMP]);
+}
+
+
+/* MESA_FORMAT_L16 */
+
+static void
+pack_ubyte_L16(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = UBYTE_TO_USHORT(src[RCOMP]);
+}
+
+static void
+pack_float_L16(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]);
+}
+
+
+/* MESA_FORMAT_YCBCR */
+
+static void
+pack_ubyte_YCBCR(const GLubyte src[4], void *dst)
+{
+ /* todo */
+}
+
+static void
+pack_float_YCBCR(const GLfloat src[4], void *dst)
+{
+ /* todo */
+}
+
+
+/* MESA_FORMAT_YCBCR_REV */
+
+static void
+pack_ubyte_YCBCR_REV(const GLubyte src[4], void *dst)
+{
+ /* todo */
+}
+
+static void
+pack_float_YCBCR_REV(const GLfloat src[4], void *dst)
+{
+ /* todo */
+}
+
+
+/* MESA_FORMAT_R8 */
+
+static void
+pack_ubyte_R8(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = src[RCOMP];
+}
+
+static void
+pack_float_R8(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ GLubyte r;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, src[RCOMP]);
+ d[0] = r;
+}
+
+
+/* MESA_FORMAT_GR88 */
+
+static void
+pack_ubyte_GR88(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = PACK_COLOR_88(src[GCOMP], src[RCOMP]);
+}
+
+static void
+pack_float_GR88(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte r, g;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, src[GCOMP]);
+ *d = PACK_COLOR_88(g, r);
+}
+
+
+/* MESA_FORMAT_RG88 */
+
+static void
+pack_ubyte_RG88(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = PACK_COLOR_88(src[RCOMP], src[GCOMP]);
+}
+
+static void
+pack_float_RG88(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte r, g;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, src[GCOMP]);
+ *d = PACK_COLOR_88(r, g);
+}
+
+
+/* MESA_FORMAT_R16 */
+
+static void
+pack_ubyte_R16(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = UBYTE_TO_USHORT(src[RCOMP]);
+}
+
+static void
+pack_float_R16(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]);
+}
+
+
+/* MESA_FORMAT_RG1616 */
+
+static void
+pack_ubyte_RG1616(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+ *d = PACK_COLOR_1616(g, r);
+}
+
+static void
+pack_float_RG1616(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r, g;
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ *d = PACK_COLOR_1616(g, r);
+}
+
+
+/* MESA_FORMAT_RG1616_REV */
+
+static void
+pack_ubyte_RG1616_REV(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+ *d = PACK_COLOR_1616(r, g);
+}
+
+
+static void
+pack_float_RG1616_REV(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r, g;
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ *d = PACK_COLOR_1616(r, g);
+}
+
+
+/* MESA_FORMAT_ARGB2101010 */
+
+static void
+pack_ubyte_ARGB2101010(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+ GLushort b = UBYTE_TO_USHORT(src[BCOMP]);
+ GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, r, g, b);
+}
+
+static void
+pack_float_ARGB2101010(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r, g, b, a;
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, r, g, b);
+}
+
+
+/* MESA_FORMAT_SRGB8 */
+
+static void
+pack_ubyte_SRGB8(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ d[2] = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ d[1] = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ d[0] = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+}
+
+static void
+pack_float_SRGB8(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ d[2] = linear_float_to_srgb_ubyte(src[RCOMP]);
+ d[1] = linear_float_to_srgb_ubyte(src[GCOMP]);
+ d[0] = linear_float_to_srgb_ubyte(src[BCOMP]);
+}
+
+
+/* MESA_FORMAT_SRGBA8 */
+
+static void
+pack_ubyte_SRGBA8(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ GLubyte g = linear_ubyte_to_srgb_ubyte(src[GCOMP]);
+ GLubyte b = linear_ubyte_to_srgb_ubyte(src[BCOMP]);
+ *d = PACK_COLOR_8888(r, g, b, src[ACOMP]);
+}
+
+static void
+pack_float_SRGBA8(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLubyte r, g, b, a;
+ r = linear_float_to_srgb_ubyte(src[RCOMP]);
+ g = linear_float_to_srgb_ubyte(src[GCOMP]);
+ b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
+ *d = PACK_COLOR_8888(r, g, b, a);
+}
+
+
+/* MESA_FORMAT_SARGB8 */
+
+static void
+pack_ubyte_SARGB8(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ GLubyte g = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ GLubyte b = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ *d = PACK_COLOR_8888(src[ACOMP], r, g, b);
+}
+
+static void
+pack_float_SARGB8(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLubyte r, g, b, a;
+ r = linear_float_to_srgb_ubyte(src[RCOMP]);
+ g = linear_float_to_srgb_ubyte(src[GCOMP]);
+ b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
+ *d = PACK_COLOR_8888(a, r, g, b);
+}
+
+
+/* MESA_FORMAT_SL8 */
+
+static void
+pack_ubyte_SL8(const GLubyte src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ *d = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+}
+
+static void
+pack_float_SL8(const GLfloat src[4], void *dst)
+{
+ GLubyte *d = ((GLubyte *) dst);
+ GLubyte l = linear_float_to_srgb_ubyte(src[RCOMP]);
+ *d = l;
+}
+
+
+/* MESA_FORMAT_SLA8 */
+
+static void
+pack_ubyte_SLA8(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte l = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ *d = PACK_COLOR_88(src[ACOMP], l);
+}
+
+static void
+pack_float_SLA8(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte a, l = linear_float_to_srgb_ubyte(src[RCOMP]);
+ CLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
+ *d = PACK_COLOR_88(a, l);
+}
+
+
+/* MESA_FORMAT_RGBA_FLOAT32 */
+
+static void
+pack_ubyte_RGBA_FLOAT32(const GLubyte src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = UBYTE_TO_FLOAT(src[0]);
+ d[1] = UBYTE_TO_FLOAT(src[1]);
+ d[2] = UBYTE_TO_FLOAT(src[2]);
+ d[3] = UBYTE_TO_FLOAT(src[3]);
+}
+
+static void
+pack_float_RGBA_FLOAT32(const GLfloat src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = src[0];
+ d[1] = src[1];
+ d[2] = src[2];
+ d[3] = src[3];
+}
+
+
+/* MESA_FORMAT_RGBA_FLOAT16 */
+
+static void
+pack_ubyte_RGBA_FLOAT16(const GLubyte src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[0]));
+ d[1] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[1]));
+ d[2] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[2]));
+ d[3] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[3]));
+}
+
+static void
+pack_float_RGBA_FLOAT16(const GLfloat src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(src[0]);
+ d[1] = _mesa_float_to_half(src[1]);
+ d[2] = _mesa_float_to_half(src[2]);
+ d[3] = _mesa_float_to_half(src[3]);
+}
+
+
+/* MESA_FORMAT_RGB_FLOAT32 */
+
+static void
+pack_ubyte_RGB_FLOAT32(const GLubyte src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = UBYTE_TO_FLOAT(src[0]);
+ d[1] = UBYTE_TO_FLOAT(src[1]);
+ d[2] = UBYTE_TO_FLOAT(src[2]);
+}
+
+static void
+pack_float_RGB_FLOAT32(const GLfloat src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = src[0];
+ d[1] = src[1];
+ d[2] = src[2];
+}
+
+
+/* MESA_FORMAT_RGB_FLOAT16 */
+
+static void
+pack_ubyte_RGB_FLOAT16(const GLubyte src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[0]));
+ d[1] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[1]));
+ d[2] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[2]));
+}
+
+static void
+pack_float_RGB_FLOAT16(const GLfloat src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(src[0]);
+ d[1] = _mesa_float_to_half(src[1]);
+ d[2] = _mesa_float_to_half(src[2]);
+}
+
+
+/* MESA_FORMAT_ALPHA_FLOAT32 */
+
+static void
+pack_ubyte_ALPHA_FLOAT32(const GLubyte src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = UBYTE_TO_FLOAT(src[ACOMP]);
+}
+
+static void
+pack_float_ALPHA_FLOAT32(const GLfloat src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = src[ACOMP];
+}
+
+
+/* MESA_FORMAT_ALPHA_FLOAT16 */
+
+static void
+pack_ubyte_ALPHA_FLOAT16(const GLubyte src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[ACOMP]));
+}
+
+static void
+pack_float_ALPHA_FLOAT16(const GLfloat src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(src[ACOMP]);
+}
+
+
+/* MESA_FORMAT_LUMINANCE_FLOAT32 (and INTENSITY_FLOAT32, R_FLOAT32) */
+
+static void
+pack_ubyte_LUMINANCE_FLOAT32(const GLubyte src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = UBYTE_TO_FLOAT(src[RCOMP]);
+}
+
+static void
+pack_float_LUMINANCE_FLOAT32(const GLfloat src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = src[RCOMP];
+}
+
+
+/* MESA_FORMAT_LUMINANCE_FLOAT16 (and INTENSITY_FLOAT16, R_FLOAT32) */
+
+static void
+pack_ubyte_LUMINANCE_FLOAT16(const GLubyte src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[RCOMP]));
+}
+
+static void
+pack_float_LUMINANCE_FLOAT16(const GLfloat src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(src[RCOMP]);
+}
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 */
+
+static void
+pack_ubyte_LUMINANCE_ALPHA_FLOAT32(const GLubyte src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = UBYTE_TO_FLOAT(src[RCOMP]);
+ d[1] = UBYTE_TO_FLOAT(src[ACOMP]);
+}
+
+static void
+pack_float_LUMINANCE_ALPHA_FLOAT32(const GLfloat src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = src[RCOMP];
+ d[1] = src[ACOMP];
+}
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 */
+
+static void
+pack_ubyte_LUMINANCE_ALPHA_FLOAT16(const GLubyte src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[RCOMP]));
+ d[1] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[ACOMP]));
+}
+
+static void
+pack_float_LUMINANCE_ALPHA_FLOAT16(const GLfloat src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(src[RCOMP]);
+ d[1] = _mesa_float_to_half(src[ACOMP]);
+}
+
+
+/* MESA_FORMAT_RG_FLOAT32 */
+
+static void
+pack_ubyte_RG_FLOAT32(const GLubyte src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = UBYTE_TO_FLOAT(src[RCOMP]);
+ d[1] = UBYTE_TO_FLOAT(src[GCOMP]);
+}
+
+static void
+pack_float_RG_FLOAT32(const GLfloat src[4], void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[0] = src[RCOMP];
+ d[1] = src[GCOMP];
+}
+
+
+/* MESA_FORMAT_RG_FLOAT16 */
+
+static void
+pack_ubyte_RG_FLOAT16(const GLubyte src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[RCOMP]));
+ d[1] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[GCOMP]));
+}
+
+static void
+pack_float_RG_FLOAT16(const GLfloat src[4], void *dst)
+{
+ GLhalfARB *d = ((GLhalfARB *) dst);
+ d[0] = _mesa_float_to_half(src[RCOMP]);
+ d[1] = _mesa_float_to_half(src[GCOMP]);
+}
+
+
+/* MESA_FORMAT_DUDV8 */
+
+static void
+pack_ubyte_DUDV8(const GLubyte src[4], void *dst)
+{
+ /* XXX is this ever used? */
+ GLushort *d = ((GLushort *) dst);
+ *d = PACK_COLOR_88(src[0], src[1]);
+}
+
+static void
+pack_float_DUDV8(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLbyte du, dv;
+ du = FLOAT_TO_BYTE(CLAMP(src[0], 0.0F, 1.0F));
+ dv = FLOAT_TO_BYTE(CLAMP(src[1], 0.0F, 1.0F));
+ *d = PACK_COLOR_88(du, dv);
+}
+
+
+/* MESA_FORMAT_RGBA_16 */
+
+static void
+pack_ubyte_RGBA_16(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ d[0] = UBYTE_TO_USHORT(src[RCOMP]);
+ d[1] = UBYTE_TO_USHORT(src[GCOMP]);
+ d[2] = UBYTE_TO_USHORT(src[BCOMP]);
+ d[3] = UBYTE_TO_USHORT(src[ACOMP]);
+}
+
+static void
+pack_float_RGBA_16(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(d[1], src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(d[2], src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(d[3], src[ACOMP]);
+}
+
+
+
+/*
+ * MESA_FORMAT_SIGNED_R8
+ */
+
+static void
+pack_float_SIGNED_R8(const GLfloat src[4], void *dst)
+{
+ GLbyte *d = (GLbyte *) dst;
+ *d = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_RG88_REV
+ */
+
+static void
+pack_float_SIGNED_RG88_REV(const GLfloat src[4], void *dst)
+{
+ GLushort *d = (GLushort *) dst;
+ GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ *d = (g << 8) | r;
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_RGBX8888
+ */
+
+static void
+pack_float_SIGNED_RGBX8888(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ GLbyte b = FLOAT_TO_BYTE(CLAMP(src[BCOMP], -1.0f, 1.0f));
+ GLbyte a = 127;
+ *d = PACK_COLOR_8888(r, g, b, a);
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_RGBA8888
+ */
+
+static void
+pack_float_SIGNED_RGBA8888(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ GLbyte b = FLOAT_TO_BYTE(CLAMP(src[BCOMP], -1.0f, 1.0f));
+ GLbyte a = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f));
+ *d = PACK_COLOR_8888(r, g, b, a);
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_RGBA8888_REV
+ */
+
+static void
+pack_float_SIGNED_RGBA8888_REV(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ GLbyte b = FLOAT_TO_BYTE(CLAMP(src[BCOMP], -1.0f, 1.0f));
+ GLbyte a = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f));
+ *d = PACK_COLOR_8888(a, b, g, r);
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_R16
+ */
+
+static void
+pack_float_SIGNED_R16(const GLfloat src[4], void *dst)
+{
+ GLshort *d = (GLshort *) dst;
+ *d = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_GR1616
+ */
+
+static void
+pack_float_SIGNED_GR1616(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLshort r = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLshort g = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ *d = (g << 16) | (r & 0xffff);
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_RGB_16
+ */
+
+static void
+pack_float_SIGNED_RGB_16(const GLfloat src[4], void *dst)
+{
+ GLshort *d = (GLshort *) dst;
+ d[0] = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ d[1] = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ d[2] = FLOAT_TO_SHORT(CLAMP(src[BCOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_RGBA_16
+ */
+
+static void
+pack_float_SIGNED_RGBA_16(const GLfloat src[4], void *dst)
+{
+ GLshort *d = (GLshort *) dst;
+ d[0] = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ d[1] = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ d[2] = FLOAT_TO_SHORT(CLAMP(src[BCOMP], -1.0f, 1.0f));
+ d[3] = FLOAT_TO_SHORT(CLAMP(src[ACOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_A8
+ */
+
+static void
+pack_float_SIGNED_A8(const GLfloat src[4], void *dst)
+{
+ GLbyte *d = (GLbyte *) dst;
+ *d = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_L8
+ */
+
+static void
+pack_float_SIGNED_L8(const GLfloat src[4], void *dst)
+{
+ GLbyte *d = (GLbyte *) dst;
+ *d = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_AL88
+ */
+
+static void
+pack_float_SIGNED_AL88(const GLfloat src[4], void *dst)
+{
+ GLushort *d = (GLushort *) dst;
+ GLbyte l = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte a = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f));
+ *d = (a << 8) | l;
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_A16
+ */
+
+static void
+pack_float_SIGNED_A16(const GLfloat src[4], void *dst)
+{
+ GLshort *d = (GLshort *) dst;
+ *d = FLOAT_TO_SHORT(CLAMP(src[ACOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_L16
+ */
+
+static void
+pack_float_SIGNED_L16(const GLfloat src[4], void *dst)
+{
+ GLshort *d = (GLshort *) dst;
+ *d = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+}
+
+
+/*
+ * MESA_FORMAT_SIGNED_AL1616
+ */
+
+static void
+pack_float_SIGNED_AL1616(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLshort l = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLshort a = FLOAT_TO_SHORT(CLAMP(src[ACOMP], -1.0f, 1.0f));
+ *d = PACK_COLOR_1616(a, l);
+}
+
+
+/*
+ * MESA_FORMAT_RGB9_E5_FLOAT;
+ */
+
+static void
+pack_float_RGB9_E5_FLOAT(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ *d = float3_to_rgb9e5(src);
+}
+
+static void
+pack_ubyte_RGB9_E5_FLOAT(const GLubyte src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLfloat rgb[3];
+ rgb[0] = UBYTE_TO_FLOAT(src[RCOMP]);
+ rgb[1] = UBYTE_TO_FLOAT(src[GCOMP]);
+ rgb[2] = UBYTE_TO_FLOAT(src[BCOMP]);
+ *d = float3_to_rgb9e5(rgb);
+}
+
+
+
+/*
+ * MESA_FORMAT_R11_G11_B10_FLOAT;
+ */
+
+static void
+pack_ubyte_R11_G11_B10_FLOAT(const GLubyte src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLfloat rgb[3];
+ rgb[0] = UBYTE_TO_FLOAT(src[RCOMP]);
+ rgb[1] = UBYTE_TO_FLOAT(src[GCOMP]);
+ rgb[2] = UBYTE_TO_FLOAT(src[BCOMP]);
+ *d = float3_to_r11g11b10f(rgb);
+}
+
+static void
+pack_float_R11_G11_B10_FLOAT(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ *d = float3_to_r11g11b10f(src);
+}
+
+
+
+/**
+ * Return a function that can pack a GLubyte rgba[4] color.
+ */
+gl_pack_ubyte_rgba_func
+_mesa_get_pack_ubyte_rgba_function(gl_format format)
+{
+ static gl_pack_ubyte_rgba_func table[MESA_FORMAT_COUNT];
+ static GLboolean initialized = GL_FALSE;
+
+ if (!initialized) {
+ memset(table, 0, sizeof(table));
+
+ table[MESA_FORMAT_NONE] = NULL;
+
+ table[MESA_FORMAT_RGBA8888] = pack_ubyte_RGBA8888;
+ table[MESA_FORMAT_RGBA8888_REV] = pack_ubyte_RGBA8888_REV;
+ table[MESA_FORMAT_ARGB8888] = pack_ubyte_ARGB8888;
+ table[MESA_FORMAT_ARGB8888_REV] = pack_ubyte_ARGB8888_REV;
+ table[MESA_FORMAT_RGBX8888] = pack_ubyte_RGBA8888; /* reused */
+ table[MESA_FORMAT_RGBX8888_REV] = pack_ubyte_RGBA8888_REV; /* reused */
+ table[MESA_FORMAT_XRGB8888] = pack_ubyte_XRGB8888;
+ table[MESA_FORMAT_XRGB8888_REV] = pack_ubyte_XRGB8888_REV;
+ table[MESA_FORMAT_RGB888] = pack_ubyte_RGB888;
+ table[MESA_FORMAT_BGR888] = pack_ubyte_BGR888;
+ table[MESA_FORMAT_RGB565] = pack_ubyte_RGB565;
+ table[MESA_FORMAT_RGB565_REV] = pack_ubyte_RGB565_REV;
+ table[MESA_FORMAT_ARGB4444] = pack_ubyte_ARGB4444;
+ table[MESA_FORMAT_ARGB4444_REV] = pack_ubyte_ARGB4444_REV;
+ table[MESA_FORMAT_RGBA5551] = pack_ubyte_RGBA5551;
+ table[MESA_FORMAT_ARGB1555] = pack_ubyte_ARGB1555;
+ table[MESA_FORMAT_ARGB1555_REV] = pack_ubyte_ARGB1555_REV;
+ table[MESA_FORMAT_AL44] = pack_ubyte_AL44;
+ table[MESA_FORMAT_AL88] = pack_ubyte_AL88;
+ table[MESA_FORMAT_AL88_REV] = pack_ubyte_AL88_REV;
+ table[MESA_FORMAT_AL1616] = pack_ubyte_AL1616;
+ table[MESA_FORMAT_AL1616_REV] = pack_ubyte_AL1616_REV;
+ table[MESA_FORMAT_RGB332] = pack_ubyte_RGB332;
+ table[MESA_FORMAT_A8] = pack_ubyte_A8;
+ table[MESA_FORMAT_A16] = pack_ubyte_A16;
+ table[MESA_FORMAT_L8] = pack_ubyte_L8;
+ table[MESA_FORMAT_L16] = pack_ubyte_L16;
+ table[MESA_FORMAT_I8] = pack_ubyte_L8; /* reuse pack_ubyte_L8 */
+ table[MESA_FORMAT_I16] = pack_ubyte_L16; /* reuse pack_ubyte_L16 */
+ table[MESA_FORMAT_YCBCR] = pack_ubyte_YCBCR;
+ table[MESA_FORMAT_YCBCR_REV] = pack_ubyte_YCBCR_REV;
+ table[MESA_FORMAT_R8] = pack_ubyte_R8;
+ table[MESA_FORMAT_GR88] = pack_ubyte_GR88;
+ table[MESA_FORMAT_RG88] = pack_ubyte_RG88;
+ table[MESA_FORMAT_R16] = pack_ubyte_R16;
+ table[MESA_FORMAT_RG1616] = pack_ubyte_RG1616;
+ table[MESA_FORMAT_RG1616_REV] = pack_ubyte_RG1616_REV;
+ table[MESA_FORMAT_ARGB2101010] = pack_ubyte_ARGB2101010;
+
+ /* should never convert RGBA to these formats */
+ table[MESA_FORMAT_Z24_S8] = NULL;
+ table[MESA_FORMAT_S8_Z24] = NULL;
+ table[MESA_FORMAT_Z16] = NULL;
+ table[MESA_FORMAT_X8_Z24] = NULL;
+ table[MESA_FORMAT_Z24_X8] = NULL;
+ table[MESA_FORMAT_Z32] = NULL;
+ table[MESA_FORMAT_S8] = NULL;
+
+ /* sRGB */
+ table[MESA_FORMAT_SRGB8] = pack_ubyte_SRGB8;
+ table[MESA_FORMAT_SRGBA8] = pack_ubyte_SRGBA8;
+ table[MESA_FORMAT_SARGB8] = pack_ubyte_SARGB8;
+ table[MESA_FORMAT_SL8] = pack_ubyte_SL8;
+ table[MESA_FORMAT_SLA8] = pack_ubyte_SLA8;
+
+ /* n/a */
+ table[MESA_FORMAT_SRGB_DXT1] = NULL; /* pack_ubyte_SRGB_DXT1; */
+ table[MESA_FORMAT_SRGBA_DXT1] = NULL; /* pack_ubyte_SRGBA_DXT1; */
+ table[MESA_FORMAT_SRGBA_DXT3] = NULL; /* pack_ubyte_SRGBA_DXT3; */
+ table[MESA_FORMAT_SRGBA_DXT5] = NULL; /* pack_ubyte_SRGBA_DXT5; */
+
+ table[MESA_FORMAT_RGB_FXT1] = NULL; /* pack_ubyte_RGB_FXT1; */
+ table[MESA_FORMAT_RGBA_FXT1] = NULL; /* pack_ubyte_RGBA_FXT1; */
+ table[MESA_FORMAT_RGB_DXT1] = NULL; /* pack_ubyte_RGB_DXT1; */
+ table[MESA_FORMAT_RGBA_DXT1] = NULL; /* pack_ubyte_RGBA_DXT1; */
+ table[MESA_FORMAT_RGBA_DXT3] = NULL; /* pack_ubyte_RGBA_DXT3; */
+ table[MESA_FORMAT_RGBA_DXT5] = NULL; /* pack_ubyte_RGBA_DXT5; */
+
+ table[MESA_FORMAT_RGBA_FLOAT32] = pack_ubyte_RGBA_FLOAT32;
+ table[MESA_FORMAT_RGBA_FLOAT16] = pack_ubyte_RGBA_FLOAT16;
+ table[MESA_FORMAT_RGB_FLOAT32] = pack_ubyte_RGB_FLOAT32;
+ table[MESA_FORMAT_RGB_FLOAT16] = pack_ubyte_RGB_FLOAT16;
+ table[MESA_FORMAT_ALPHA_FLOAT32] = pack_ubyte_ALPHA_FLOAT32;
+ table[MESA_FORMAT_ALPHA_FLOAT16] = pack_ubyte_ALPHA_FLOAT16;
+ table[MESA_FORMAT_LUMINANCE_FLOAT32] = pack_ubyte_LUMINANCE_FLOAT32;
+ table[MESA_FORMAT_LUMINANCE_FLOAT16] = pack_ubyte_LUMINANCE_FLOAT16;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32] = pack_ubyte_LUMINANCE_ALPHA_FLOAT32;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = pack_ubyte_LUMINANCE_ALPHA_FLOAT16;
+ table[MESA_FORMAT_INTENSITY_FLOAT32] = pack_ubyte_LUMINANCE_FLOAT32;
+ table[MESA_FORMAT_INTENSITY_FLOAT16] = pack_ubyte_LUMINANCE_FLOAT16;
+ table[MESA_FORMAT_R_FLOAT32] = pack_ubyte_LUMINANCE_FLOAT32;
+ table[MESA_FORMAT_R_FLOAT16] = pack_ubyte_LUMINANCE_FLOAT16;
+ table[MESA_FORMAT_RG_FLOAT32] = pack_ubyte_RG_FLOAT32;
+ table[MESA_FORMAT_RG_FLOAT16] = pack_ubyte_RG_FLOAT16;
+
+ /* n/a */
+ table[MESA_FORMAT_RGBA_INT8] = NULL; /* pack_ubyte_RGBA_INT8 */
+ table[MESA_FORMAT_RGBA_INT16] = NULL; /* pack_ubyte_RGBA_INT16 */
+ table[MESA_FORMAT_RGBA_INT32] = NULL; /* pack_ubyte_RGBA_INT32 */
+ table[MESA_FORMAT_RGBA_UINT8] = NULL; /* pack_ubyte_RGBA_UINT8 */
+ table[MESA_FORMAT_RGBA_UINT16] = NULL; /* pack_ubyte_RGBA_UINT16 */
+ table[MESA_FORMAT_RGBA_UINT32] = NULL; /* pack_ubyte_RGBA_UINT32 */
+
+ table[MESA_FORMAT_DUDV8] = pack_ubyte_DUDV8;
+
+ table[MESA_FORMAT_RGBA_16] = pack_ubyte_RGBA_16;
+
+ /* n/a */
+ table[MESA_FORMAT_SIGNED_R8] = NULL;
+ table[MESA_FORMAT_SIGNED_RG88_REV] = NULL;
+ table[MESA_FORMAT_SIGNED_RGBX8888] = NULL;
+ table[MESA_FORMAT_SIGNED_RGBA8888] = NULL;
+ table[MESA_FORMAT_SIGNED_RGBA8888_REV] = NULL;
+ table[MESA_FORMAT_SIGNED_R16] = NULL;
+ table[MESA_FORMAT_SIGNED_GR1616] = NULL;
+ table[MESA_FORMAT_SIGNED_RGB_16] = NULL;
+ table[MESA_FORMAT_SIGNED_RGBA_16] = NULL;
+ table[MESA_FORMAT_SIGNED_A8] = NULL;
+ table[MESA_FORMAT_SIGNED_L8] = NULL;
+ table[MESA_FORMAT_SIGNED_AL88] = NULL;
+ table[MESA_FORMAT_SIGNED_I8] = NULL;
+ table[MESA_FORMAT_SIGNED_A16] = NULL;
+ table[MESA_FORMAT_SIGNED_L16] = NULL;
+ table[MESA_FORMAT_SIGNED_AL1616] = NULL;
+ table[MESA_FORMAT_SIGNED_I16] = NULL;
+
+
+ table[MESA_FORMAT_RGBA_16] = pack_ubyte_RGBA_16;
+
+ table[MESA_FORMAT_RGB9_E5_FLOAT] = pack_ubyte_RGB9_E5_FLOAT;
+ table[MESA_FORMAT_R11_G11_B10_FLOAT] = pack_ubyte_R11_G11_B10_FLOAT;
+
+ initialized = GL_TRUE;
+ }
+
+ return table[format];
+}
+
+
+
+/**
+ * Return a function that can pack a GLfloat rgba[4] color.
+ */
+gl_pack_float_rgba_func
+_mesa_get_pack_float_rgba_function(gl_format format)
+{
+ static gl_pack_float_rgba_func table[MESA_FORMAT_COUNT];
+ static GLboolean initialized = GL_FALSE;
+
+ if (!initialized) {
+ memset(table, 0, sizeof(table));
+
+ table[MESA_FORMAT_NONE] = NULL;
+
+ table[MESA_FORMAT_RGBA8888] = pack_float_RGBA8888;
+ table[MESA_FORMAT_RGBA8888_REV] = pack_float_RGBA8888_REV;
+ table[MESA_FORMAT_ARGB8888] = pack_float_ARGB8888;
+ table[MESA_FORMAT_ARGB8888_REV] = pack_float_ARGB8888_REV;
+ table[MESA_FORMAT_RGBX8888] = pack_float_RGBA8888; /* reused */
+ table[MESA_FORMAT_RGBX8888_REV] = pack_float_RGBA8888_REV; /* reused */
+ table[MESA_FORMAT_XRGB8888] = pack_float_XRGB8888;
+ table[MESA_FORMAT_XRGB8888_REV] = pack_float_XRGB8888_REV;
+ table[MESA_FORMAT_RGB888] = pack_float_RGB888;
+ table[MESA_FORMAT_BGR888] = pack_float_BGR888;
+ table[MESA_FORMAT_RGB565] = pack_float_RGB565;
+ table[MESA_FORMAT_RGB565_REV] = pack_float_RGB565_REV;
+ table[MESA_FORMAT_ARGB4444] = pack_float_ARGB4444;
+ table[MESA_FORMAT_ARGB4444_REV] = pack_float_ARGB4444_REV;
+ table[MESA_FORMAT_RGBA5551] = pack_float_RGBA5551;
+ table[MESA_FORMAT_ARGB1555] = pack_float_ARGB1555;
+ table[MESA_FORMAT_ARGB1555_REV] = pack_float_ARGB1555_REV;
+
+ table[MESA_FORMAT_AL44] = pack_float_AL44;
+ table[MESA_FORMAT_AL88] = pack_float_AL88;
+ table[MESA_FORMAT_AL88_REV] = pack_float_AL88_REV;
+ table[MESA_FORMAT_AL1616] = pack_float_AL1616;
+ table[MESA_FORMAT_AL1616_REV] = pack_float_AL1616_REV;
+ table[MESA_FORMAT_RGB332] = pack_float_RGB332;
+ table[MESA_FORMAT_A8] = pack_float_A8;
+ table[MESA_FORMAT_A16] = pack_float_A16;
+ table[MESA_FORMAT_L8] = pack_float_L8;
+ table[MESA_FORMAT_L16] = pack_float_L16;
+ table[MESA_FORMAT_I8] = pack_float_L8; /* reuse pack_float_L8 */
+ table[MESA_FORMAT_I16] = pack_float_L16; /* reuse pack_float_L16 */
+ table[MESA_FORMAT_YCBCR] = pack_float_YCBCR;
+ table[MESA_FORMAT_YCBCR_REV] = pack_float_YCBCR_REV;
+ table[MESA_FORMAT_R8] = pack_float_R8;
+ table[MESA_FORMAT_GR88] = pack_float_GR88;
+ table[MESA_FORMAT_RG88] = pack_float_RG88;
+ table[MESA_FORMAT_R16] = pack_float_R16;
+ table[MESA_FORMAT_RG1616] = pack_float_RG1616;
+ table[MESA_FORMAT_RG1616_REV] = pack_float_RG1616_REV;
+ table[MESA_FORMAT_ARGB2101010] = pack_float_ARGB2101010;
+
+ /* should never convert RGBA to these formats */
+ table[MESA_FORMAT_Z24_S8] = NULL;
+ table[MESA_FORMAT_S8_Z24] = NULL;
+ table[MESA_FORMAT_Z16] = NULL;
+ table[MESA_FORMAT_X8_Z24] = NULL;
+ table[MESA_FORMAT_Z24_X8] = NULL;
+ table[MESA_FORMAT_Z32] = NULL;
+ table[MESA_FORMAT_S8] = NULL;
+
+ table[MESA_FORMAT_SRGB8] = pack_float_SRGB8;
+ table[MESA_FORMAT_SRGBA8] = pack_float_SRGBA8;
+ table[MESA_FORMAT_SARGB8] = pack_float_SARGB8;
+ table[MESA_FORMAT_SL8] = pack_float_SL8;
+ table[MESA_FORMAT_SLA8] = pack_float_SLA8;
+
+ /* n/a */
+ table[MESA_FORMAT_SRGB_DXT1] = NULL;
+ table[MESA_FORMAT_SRGBA_DXT1] = NULL;
+ table[MESA_FORMAT_SRGBA_DXT3] = NULL;
+ table[MESA_FORMAT_SRGBA_DXT5] = NULL;
+
+ table[MESA_FORMAT_RGB_FXT1] = NULL;
+ table[MESA_FORMAT_RGBA_FXT1] = NULL;
+ table[MESA_FORMAT_RGB_DXT1] = NULL;
+ table[MESA_FORMAT_RGBA_DXT1] = NULL;
+ table[MESA_FORMAT_RGBA_DXT3] = NULL;
+ table[MESA_FORMAT_RGBA_DXT5] = NULL;
+
+ table[MESA_FORMAT_RGBA_FLOAT32] = pack_float_RGBA_FLOAT32;
+ table[MESA_FORMAT_RGBA_FLOAT16] = pack_float_RGBA_FLOAT16;
+ table[MESA_FORMAT_RGB_FLOAT32] = pack_float_RGB_FLOAT32;
+ table[MESA_FORMAT_RGB_FLOAT16] = pack_float_RGB_FLOAT16;
+ table[MESA_FORMAT_ALPHA_FLOAT32] = pack_float_ALPHA_FLOAT32;
+ table[MESA_FORMAT_ALPHA_FLOAT16] = pack_float_ALPHA_FLOAT16;
+ table[MESA_FORMAT_LUMINANCE_FLOAT32] = pack_float_LUMINANCE_FLOAT32;
+ table[MESA_FORMAT_LUMINANCE_FLOAT16] = pack_float_LUMINANCE_FLOAT16;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32] = pack_float_LUMINANCE_ALPHA_FLOAT32;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = pack_float_LUMINANCE_ALPHA_FLOAT16;
+
+ table[MESA_FORMAT_INTENSITY_FLOAT32] = pack_float_LUMINANCE_FLOAT32;
+ table[MESA_FORMAT_INTENSITY_FLOAT16] = pack_float_LUMINANCE_FLOAT16;
+ table[MESA_FORMAT_R_FLOAT32] = pack_float_LUMINANCE_FLOAT32;
+ table[MESA_FORMAT_R_FLOAT16] = pack_float_LUMINANCE_FLOAT16;
+ table[MESA_FORMAT_RG_FLOAT32] = pack_float_RG_FLOAT32;
+ table[MESA_FORMAT_RG_FLOAT16] = pack_float_RG_FLOAT16;
+
+ /* n/a */
+ table[MESA_FORMAT_RGBA_INT8] = NULL;
+ table[MESA_FORMAT_RGBA_INT16] = NULL;
+ table[MESA_FORMAT_RGBA_INT32] = NULL;
+ table[MESA_FORMAT_RGBA_UINT8] = NULL;
+ table[MESA_FORMAT_RGBA_UINT16] = NULL;
+ table[MESA_FORMAT_RGBA_UINT32] = NULL;
+
+ table[MESA_FORMAT_DUDV8] = pack_float_DUDV8;
+
+ table[MESA_FORMAT_RGBA_16] = pack_float_RGBA_16;
+
+ table[MESA_FORMAT_SIGNED_R8] = pack_float_SIGNED_R8;
+ table[MESA_FORMAT_SIGNED_RG88_REV] = pack_float_SIGNED_RG88_REV;
+ table[MESA_FORMAT_SIGNED_RGBX8888] = pack_float_SIGNED_RGBX8888;
+ table[MESA_FORMAT_SIGNED_RGBA8888] = pack_float_SIGNED_RGBA8888;
+ table[MESA_FORMAT_SIGNED_RGBA8888_REV] = pack_float_SIGNED_RGBA8888_REV;
+ table[MESA_FORMAT_SIGNED_R16] = pack_float_SIGNED_R16;
+ table[MESA_FORMAT_SIGNED_GR1616] = pack_float_SIGNED_GR1616;
+ table[MESA_FORMAT_SIGNED_RGB_16] = pack_float_SIGNED_RGB_16;
+ table[MESA_FORMAT_SIGNED_RGBA_16] = pack_float_SIGNED_RGBA_16;
+ table[MESA_FORMAT_SIGNED_A8] = pack_float_SIGNED_A8;
+ table[MESA_FORMAT_SIGNED_L8] = pack_float_SIGNED_L8;
+ table[MESA_FORMAT_SIGNED_AL88] = pack_float_SIGNED_AL88;
+ table[MESA_FORMAT_SIGNED_I8] = pack_float_SIGNED_L8; /* reused */
+ table[MESA_FORMAT_SIGNED_A16] = pack_float_SIGNED_A16;
+ table[MESA_FORMAT_SIGNED_L16] = pack_float_SIGNED_L16;
+ table[MESA_FORMAT_SIGNED_AL1616] = pack_float_SIGNED_AL1616;
+ table[MESA_FORMAT_SIGNED_I16] = pack_float_SIGNED_L16; /* reused */
+
+ table[MESA_FORMAT_RGB9_E5_FLOAT] = pack_float_RGB9_E5_FLOAT;
+ table[MESA_FORMAT_R11_G11_B10_FLOAT] = pack_float_R11_G11_B10_FLOAT;
+
+ initialized = GL_TRUE;
+ }
+
+ return table[format];
+}
+
+
+
+static pack_float_rgba_row_func
+get_pack_float_rgba_row_function(gl_format format)
+{
+ static pack_float_rgba_row_func table[MESA_FORMAT_COUNT];
+ static GLboolean initialized = GL_FALSE;
+
+ if (!initialized) {
+ /* We don't need a special row packing function for each format.
+ * There's a generic fallback which uses a per-pixel packing function.
+ */
+ memset(table, 0, sizeof(table));
+
+ table[MESA_FORMAT_RGBA8888] = pack_row_float_RGBA8888;
+ table[MESA_FORMAT_RGBA8888_REV] = pack_row_float_RGBA8888_REV;
+ table[MESA_FORMAT_ARGB8888] = pack_row_float_ARGB8888;
+ table[MESA_FORMAT_ARGB8888_REV] = pack_row_float_ARGB8888_REV;
+ table[MESA_FORMAT_RGBX8888] = pack_row_float_RGBA8888; /* reused */
+ table[MESA_FORMAT_RGBX8888_REV] = pack_row_float_RGBA8888_REV; /* reused */
+ table[MESA_FORMAT_XRGB8888] = pack_row_float_XRGB8888;
+ table[MESA_FORMAT_XRGB8888_REV] = pack_row_float_XRGB8888_REV;
+ table[MESA_FORMAT_RGB888] = pack_row_float_RGB888;
+ table[MESA_FORMAT_BGR888] = pack_row_float_BGR888;
+ table[MESA_FORMAT_RGB565] = pack_row_float_RGB565;
+ table[MESA_FORMAT_RGB565_REV] = pack_row_float_RGB565_REV;
+
+ initialized = GL_TRUE;
+ }
+
+ return table[format];
+}
+
+
+
+static pack_ubyte_rgba_row_func
+get_pack_ubyte_rgba_row_function(gl_format format)
+{
+ static pack_ubyte_rgba_row_func table[MESA_FORMAT_COUNT];
+ static GLboolean initialized = GL_FALSE;
+
+ if (!initialized) {
+ /* We don't need a special row packing function for each format.
+ * There's a generic fallback which uses a per-pixel packing function.
+ */
+ memset(table, 0, sizeof(table));
+
+ table[MESA_FORMAT_RGBA8888] = pack_row_ubyte_RGBA8888;
+ table[MESA_FORMAT_RGBA8888_REV] = pack_row_ubyte_RGBA8888_REV;
+ table[MESA_FORMAT_ARGB8888] = pack_row_ubyte_ARGB8888;
+ table[MESA_FORMAT_ARGB8888_REV] = pack_row_ubyte_ARGB8888_REV;
+ table[MESA_FORMAT_RGBX8888] = pack_row_ubyte_RGBA8888; /* reused */
+ table[MESA_FORMAT_RGBX8888_REV] = pack_row_ubyte_RGBA8888_REV; /* reused */
+ table[MESA_FORMAT_XRGB8888] = pack_row_ubyte_XRGB8888;
+ table[MESA_FORMAT_XRGB8888_REV] = pack_row_ubyte_XRGB8888_REV;
+ table[MESA_FORMAT_RGB888] = pack_row_ubyte_RGB888;
+ table[MESA_FORMAT_BGR888] = pack_row_ubyte_BGR888;
+ table[MESA_FORMAT_RGB565] = pack_row_ubyte_RGB565;
+ table[MESA_FORMAT_RGB565_REV] = pack_row_ubyte_RGB565_REV;
+
+ initialized = GL_TRUE;
+ }
+
+ return table[format];
+}
+
+
+
+/**
+ * Pack a row of GLfloat rgba[4] values to the destination.
+ */
+void
+_mesa_pack_float_rgba_row(gl_format format, GLuint n,
+ const GLfloat src[][4], void *dst)
+{
+ pack_float_rgba_row_func packrow = get_pack_float_rgba_row_function(format);
+ if (packrow) {
+ /* use "fast" function */
+ packrow(n, src, dst);
+ }
+ else {
+ /* slower fallback */
+ gl_pack_float_rgba_func pack = _mesa_get_pack_float_rgba_function(format);
+ GLuint dstStride = _mesa_get_format_bytes(format);
+ GLubyte *dstPtr = (GLubyte *) dst;
+ GLuint i;
+
+ assert(pack);
+ if (!pack)
+ return;
+
+ for (i = 0; i < n; i++) {
+ pack(src[i], dstPtr);
+ dstPtr += dstStride;
+ }
+ }
+}
+
+
+/**
+ * Pack a row of GLubyte rgba[4] values to the destination.
+ */
+void
+_mesa_pack_ubyte_rgba_row(gl_format format, GLuint n,
+ const GLubyte src[][4], void *dst)
+{
+ pack_ubyte_rgba_row_func packrow = get_pack_ubyte_rgba_row_function(format);
+ if (packrow) {
+ /* use "fast" function */
+ packrow(n, src, dst);
+ }
+ else {
+ /* slower fallback */
+ gl_pack_ubyte_rgba_func pack = _mesa_get_pack_ubyte_rgba_function(format);
+ const GLuint stride = _mesa_get_format_bytes(format);
+ GLubyte *d = ((GLubyte *) dst);
+ GLuint i;
+
+ assert(pack);
+ if (!pack)
+ return;
+
+ for (i = 0; i < n; i++) {
+ pack(src[i], d);
+ d += stride;
+ }
+ }
+}
+
+
+/**
+ ** Pack float Z pixels
+ **/
+
+static void
+pack_float_z_Z24_S8(const GLfloat *src, void *dst)
+{
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = (GLdouble) 0xffffff;
+ GLuint s = *d & 0xff;
+ GLuint z = (GLuint) (*src * scale);
+ assert(z <= 0xffffff);
+ *d = (z << 8) | s;
+}
+
+static void
+pack_float_z_S8_Z24(const GLfloat *src, void *dst)
+{
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = (GLdouble) 0xffffff;
+ GLuint s = *d & 0xff000000;
+ GLuint z = (GLuint) (*src * scale);
+ assert(z <= 0xffffff);
+ *d = s | z;
+}
+
+static void
+pack_float_z_Z16(const GLfloat *src, void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ const GLfloat scale = (GLfloat) 0xffff;
+ *d = (GLushort) (*src * scale);
+}
+
+static void
+pack_float_z_Z32(const GLfloat *src, void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = (GLdouble) 0xffffffff;
+ *d = (GLuint) (*src * scale);
+}
+
+static void
+pack_float_z_Z32_FLOAT(const GLfloat *src, void *dst)
+{
+ GLfloat *d = (GLfloat *) dst;
+ *d = *src;
+}
+
+gl_pack_float_z_func
+_mesa_get_pack_float_z_func(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_Z24_X8:
+ return pack_float_z_Z24_S8;
+ case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_X8_Z24:
+ return pack_float_z_S8_Z24;
+ case MESA_FORMAT_Z16:
+ return pack_float_z_Z16;
+ case MESA_FORMAT_Z32:
+ return pack_float_z_Z32;
+ case MESA_FORMAT_Z32_FLOAT:
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return pack_float_z_Z32_FLOAT;
+ default:
+ _mesa_problem(NULL,
+ "unexpected format in _mesa_get_pack_float_z_func()");
+ return NULL;
+ }
+}
+
+
+
+/**
+ ** Pack uint Z pixels. The incoming src value is always in
+ ** the range [0, 2^32-1].
+ **/
+
+static void
+pack_uint_z_Z24_S8(const GLuint *src, void *dst)
+{
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint s = *d & 0xff;
+ GLuint z = *src & 0xffffff00;
+ *d = z | s;
+}
+
+static void
+pack_uint_z_S8_Z24(const GLuint *src, void *dst)
+{
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint s = *d & 0xff000000;
+ GLuint z = *src >> 8;
+ *d = s | z;
+}
+
+static void
+pack_uint_z_Z16(const GLuint *src, void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ *d = *src >> 16;
+}
+
+static void
+pack_uint_z_Z32(const GLuint *src, void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ *d = *src;
+}
+
+static void
+pack_uint_z_Z32_FLOAT(const GLuint *src, void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
+ *d = *src * scale;
+ assert(*d >= 0.0f);
+ assert(*d <= 1.0f);
+}
+
+static void
+pack_uint_z_Z32_FLOAT_X24S8(const GLuint *src, void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
+ *d = *src * scale;
+ assert(*d >= 0.0f);
+ assert(*d <= 1.0f);
+}
+
+gl_pack_uint_z_func
+_mesa_get_pack_uint_z_func(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_Z24_X8:
+ return pack_uint_z_Z24_S8;
+ case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_X8_Z24:
+ return pack_uint_z_S8_Z24;
+ case MESA_FORMAT_Z16:
+ return pack_uint_z_Z16;
+ case MESA_FORMAT_Z32:
+ return pack_uint_z_Z32;
+ case MESA_FORMAT_Z32_FLOAT:
+ return pack_uint_z_Z32_FLOAT;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return pack_uint_z_Z32_FLOAT_X24S8;
+ default:
+ _mesa_problem(NULL, "unexpected format in _mesa_get_pack_uint_z_func()");
+ return NULL;
+ }
+}
+
+
+/**
+ ** Pack ubyte stencil pixels
+ **/
+
+static void
+pack_ubyte_stencil_Z24_S8(const GLubyte *src, void *dst)
+{
+ /* don't disturb the Z values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint s = *src;
+ GLuint z = *d & 0xffffff00;
+ *d = z | s;
+}
+
+static void
+pack_ubyte_stencil_S8_Z24(const GLubyte *src, void *dst)
+{
+ /* don't disturb the Z values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint s = *src << 24;
+ GLuint z = *d & 0xffffff;
+ *d = s | z;
+}
+
+static void
+pack_ubyte_stencil_S8(const GLubyte *src, void *dst)
+{
+ GLubyte *d = (GLubyte *) dst;
+ *d = *src;
+}
+
+static void
+pack_ubyte_stencil_Z32_FLOAT_X24S8(const GLubyte *src, void *dst)
+{
+ GLfloat *d = ((GLfloat *) dst);
+ d[1] = *src;
+}
+
+
+gl_pack_ubyte_stencil_func
+_mesa_get_pack_ubyte_stencil_func(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ return pack_ubyte_stencil_Z24_S8;
+ case MESA_FORMAT_S8_Z24:
+ return pack_ubyte_stencil_S8_Z24;
+ case MESA_FORMAT_S8:
+ return pack_ubyte_stencil_S8;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return pack_ubyte_stencil_Z32_FLOAT_X24S8;
+ default:
+ _mesa_problem(NULL,
+ "unexpected format in _mesa_pack_ubyte_stencil_func()");
+ return NULL;
+ }
+}
+
+
+
+void
+_mesa_pack_float_z_row(gl_format format, GLuint n,
+ const GLfloat *src, void *dst)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_Z24_X8:
+ {
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = (GLdouble) 0xffffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = d[i] & 0xff;
+ GLuint z = (GLuint) (src[i] * scale);
+ assert(z <= 0xffffff);
+ d[i] = (z << 8) | s;
+ }
+ }
+ break;
+ case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_X8_Z24:
+ {
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = (GLdouble) 0xffffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = d[i] & 0xff000000;
+ GLuint z = (GLuint) (src[i] * scale);
+ assert(z <= 0xffffff);
+ d[i] = s | z;
+ }
+ }
+ break;
+ case MESA_FORMAT_Z16:
+ {
+ GLushort *d = ((GLushort *) dst);
+ const GLfloat scale = (GLfloat) 0xffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = (GLushort) (src[i] * scale);
+ }
+ }
+ break;
+ case MESA_FORMAT_Z32:
+ {
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = (GLdouble) 0xffffffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = (GLuint) (src[i] * scale);
+ }
+ }
+ break;
+ case MESA_FORMAT_Z32_FLOAT:
+ memcpy(dst, src, n * sizeof(GLfloat));
+ break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ {
+ GLfloat *d = ((GLfloat *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i * 2] = src[i];
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in _mesa_pack_float_z_row()");
+ }
+}
+
+
+/**
+ * The incoming Z values are always in the range [0, 0xffffffff].
+ */
+void
+_mesa_pack_uint_z_row(gl_format format, GLuint n,
+ const GLuint *src, void *dst)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_Z24_X8:
+ {
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = d[i] & 0xff;
+ GLuint z = src[i] & 0xffffff00;
+ d[i] = z | s;
+ }
+ }
+ break;
+ case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_X8_Z24:
+ {
+ /* don't disturb the stencil values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = d[i] & 0xff000000;
+ GLuint z = src[i] >> 8;
+ d[i] = s | z;
+ }
+ }
+ break;
+ case MESA_FORMAT_Z16:
+ {
+ GLushort *d = ((GLushort *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = src[i] >> 16;
+ }
+ }
+ break;
+ case MESA_FORMAT_Z32:
+ memcpy(dst, src, n * sizeof(GLfloat));
+ break;
+ case MESA_FORMAT_Z32_FLOAT:
+ {
+ GLuint *d = ((GLuint *) dst);
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i] = src[i] * scale;
+ assert(d[i] >= 0.0f);
+ assert(d[i] <= 1.0f);
+ }
+ }
+ break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ {
+ GLfloat *d = ((GLfloat *) dst);
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i * 2] = src[i] * scale;
+ assert(d[i * 2] >= 0.0f);
+ assert(d[i * 2] <= 1.0f);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in _mesa_pack_uint_z_row()");
+ }
+}
+
+
+void
+_mesa_pack_ubyte_stencil_row(gl_format format, GLuint n,
+ const GLubyte *src, void *dst)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ {
+ /* don't disturb the Z values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = src[i];
+ GLuint z = d[i] & 0xffffff00;
+ d[i] = z | s;
+ }
+ }
+ break;
+ case MESA_FORMAT_S8_Z24:
+ {
+ /* don't disturb the Z values */
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = src[i] << 24;
+ GLuint z = d[i] & 0xffffff;
+ d[i] = s | z;
+ }
+ }
+ break;
+ case MESA_FORMAT_S8:
+ memcpy(dst, src, n * sizeof(GLubyte));
+ break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ {
+ GLfloat *d = ((GLfloat *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ d[i * 2 + 1] = src[i];
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in _mesa_pack_ubyte_stencil_row()");
+ }
+}
+
+
+/**
+ * Incoming Z/stencil values are always in uint_24_8 format.
+ */
+void
+_mesa_pack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
+ const GLuint *src, void *dst)
+{
+ switch (format) {
+ case MESA_FORMAT_Z24_S8:
+ memcpy(dst, src, n * sizeof(GLuint));
+ break;
+ case MESA_FORMAT_S8_Z24:
+ {
+ GLuint *d = ((GLuint *) dst);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint s = src[i] << 24;
+ GLuint z = src[i] >> 8;
+ d[i] = s | z;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "bad format %s in _mesa_pack_ubyte_s_row",
+ _mesa_get_format_name(format));
+ return;
+ }
+}
diff --git a/mesalib/src/mesa/main/format_pack.h b/mesalib/src/mesa/main/format_pack.h
new file mode 100644
index 000000000..7df135632
--- /dev/null
+++ b/mesalib/src/mesa/main/format_pack.h
@@ -0,0 +1,98 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (c) 2011 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef FORMAT_PACK_H
+#define FORMAT_PACK_H
+
+
+#include "formats.h"
+
+
+/** Pack a GLubyte rgba[4] color to dest address */
+typedef void (*gl_pack_ubyte_rgba_func)(const GLubyte src[4], void *dst);
+
+/** Pack a GLfloat rgba[4] color to dest address */
+typedef void (*gl_pack_float_rgba_func)(const GLfloat src[4], void *dst);
+
+/** Pack a GLfloat Z value to dest address */
+typedef void (*gl_pack_float_z_func)(const GLfloat *src, void *dst);
+
+/** Pack a GLuint Z value to dest address */
+typedef void (*gl_pack_uint_z_func)(const GLuint *src, void *dst);
+
+/** Pack a GLubyte stencil value to dest address */
+typedef void (*gl_pack_ubyte_stencil_func)(const GLubyte *src, void *dst);
+
+
+
+
+extern gl_pack_ubyte_rgba_func
+_mesa_get_pack_ubyte_rgba_function(gl_format format);
+
+
+extern gl_pack_float_rgba_func
+_mesa_get_pack_float_rgba_function(gl_format format);
+
+
+extern gl_pack_float_z_func
+_mesa_get_pack_float_z_func(gl_format format);
+
+
+extern gl_pack_uint_z_func
+_mesa_get_pack_uint_z_func(gl_format format);
+
+
+extern gl_pack_ubyte_stencil_func
+_mesa_get_pack_ubyte_stencil_func(gl_format format);
+
+
+
+extern void
+_mesa_pack_float_rgba_row(gl_format format, GLuint n,
+ const GLfloat src[][4], void *dst);
+
+extern void
+_mesa_pack_ubyte_rgba_row(gl_format format, GLuint n,
+ const GLubyte src[][4], void *dst);
+
+
+
+extern void
+_mesa_pack_float_z_row(gl_format format, GLuint n,
+ const GLfloat *src, void *dst);
+
+extern void
+_mesa_pack_uint_z_row(gl_format format, GLuint n,
+ const GLuint *src, void *dst);
+
+extern void
+_mesa_pack_ubyte_stencil_row(gl_format format, GLuint n,
+ const GLubyte *src, void *dst);
+
+extern void
+_mesa_pack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
+ const GLuint *src, void *dst);
+
+
+#endif
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index f821c2be4..4f23f3dec 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -587,7 +587,7 @@ unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n)
{
/* only return Z, not stencil data */
const GLuint *s = ((const GLuint *) src);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
GLuint i;
for (i = 0; i < n; i++) {
dst[i][0] =
@@ -604,7 +604,7 @@ unpack_S8_Z24(const void *src, GLfloat dst[][4], GLuint n)
{
/* only return Z, not stencil data */
const GLuint *s = ((const GLuint *) src);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
GLuint i;
for (i = 0; i < n; i++) {
dst[i][0] =
@@ -1761,7 +1761,7 @@ unpack_float_z_Z24_X8(GLuint n, const void *src, GLfloat *dst)
{
/* only return Z, not stencil data */
const GLuint *s = ((const GLuint *) src);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
GLuint i;
for (i = 0; i < n; i++) {
dst[i] = (s[i] >> 8) * scale;
@@ -1775,7 +1775,7 @@ unpack_float_z_X8_Z24(GLuint n, const void *src, GLfloat *dst)
{
/* only return Z, not stencil data */
const GLuint *s = ((const GLuint *) src);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
GLuint i;
for (i = 0; i < n; i++) {
dst[i] = (s[i] & 0x00ffffff) * scale;
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 595da773b..1f83a5368 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1553,6 +1553,8 @@ _mesa_get_format_bytes(gl_format format)
{
const struct gl_format_info *info = _mesa_get_format_info(format);
ASSERT(info->BytesPerBlock);
+ ASSERT(info->BytesPerBlock <= MAX_PIXEL_BYTES ||
+ _mesa_is_format_compressed(format));
return info->BytesPerBlock;
}
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 3960f028e..e6b429d5f 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -47,6 +47,14 @@ extern "C" {
/**
+ * Max number of bytes for any non-compressed pixel format below, or for
+ * intermediate pixel storage in Mesa. This should never be less than
+ * 16. Maybe 32 someday?
+ */
+#define MAX_PIXEL_BYTES 16
+
+
+/**
* Mesa texture/renderbuffer image formats.
*/
typedef enum
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index 8d0763db3..e30f31a39 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -879,6 +879,7 @@ renderbuffer_exists(struct gl_context *ctx,
case GL_BGRA:
case GL_ABGR_EXT:
case GL_RED_INTEGER_EXT:
+ case GL_RG_INTEGER:
case GL_GREEN_INTEGER_EXT:
case GL_BLUE_INTEGER_EXT:
case GL_ALPHA_INTEGER_EXT:
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index b266e26c6..b37cd7e7d 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -238,6 +238,7 @@ _mesa_components_in_format( GLenum format )
case GL_DEPTH_STENCIL_EXT:
case GL_DUDV_ATI:
case GL_DU8DV8_ATI:
+ case GL_RG_INTEGER:
return 2;
case GL_RGB:
@@ -527,6 +528,7 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_GREEN_INTEGER_EXT:
case GL_BLUE_INTEGER_EXT:
case GL_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
@@ -751,6 +753,7 @@ _mesa_is_color_format(GLenum format)
case GL_RGBA_INTEGER_EXT:
case GL_BGR_INTEGER_EXT:
case GL_BGRA_INTEGER_EXT:
+ case GL_RG_INTEGER:
case GL_LUMINANCE_INTEGER_EXT:
case GL_LUMINANCE_ALPHA_INTEGER_EXT:
/* sized integer formats */
@@ -954,6 +957,7 @@ _mesa_is_integer_format(GLenum format)
case GL_BGRA_INTEGER_EXT:
case GL_LUMINANCE_INTEGER_EXT:
case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
/* specific integer formats */
case GL_RGBA32UI_EXT:
case GL_RGB32UI_EXT:
@@ -1160,32 +1164,30 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
/**
- * Return the address of a specific pixel in an image (1D, 2D or 3D).
+ * Return the byte offset of a specific pixel in an image (1D, 2D or 3D).
*
* Pixel unpacking/packing parameters are observed according to \p packing.
*
* \param dimensions either 1, 2 or 3 to indicate dimensionality of image
- * \param image starting address of image data
- * \param width the image width
- * \param height theimage height
- * \param format the pixel format
- * \param type the pixel data type
* \param packing the pixelstore attributes
+ * \param width the image width
+ * \param height the image height
+ * \param format the pixel format (must be validated beforehand)
+ * \param type the pixel data type (must be validated beforehand)
* \param img which image in the volume (0 for 1D or 2D images)
* \param row row of pixel in the image (0 for 1D images)
* \param column column of pixel in the image
- *
- * \return address of pixel on success, or NULL on error.
+ *
+ * \return offset of pixel.
*
* \sa gl_pixelstore_attrib.
*/
-GLvoid *
-_mesa_image_address( GLuint dimensions,
- const struct gl_pixelstore_attrib *packing,
- const GLvoid *image,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- GLint img, GLint row, GLint column )
+GLintptr
+_mesa_image_offset( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
{
GLint alignment; /* 1, 2 or 4 */
GLint pixels_per_row;
@@ -1193,7 +1195,7 @@ _mesa_image_address( GLuint dimensions,
GLint skiprows;
GLint skippixels;
GLint skipimages; /* for 3-D volume images */
- GLubyte *pixel_addr;
+ GLintptr offset;
ASSERT(dimensions >= 1 && dimensions <= 3);
@@ -1219,30 +1221,20 @@ _mesa_image_address( GLuint dimensions,
if (type == GL_BITMAP) {
/* BITMAP data */
- GLint comp_per_pixel; /* components per pixel */
- GLint bytes_per_comp; /* bytes per component */
GLint bytes_per_row;
GLint bytes_per_image;
+ /* components per pixel for color or stencil index: */
+ const GLint comp_per_pixel = 1;
- /* Compute bytes per component */
- bytes_per_comp = _mesa_sizeof_packed_type( type );
- if (bytes_per_comp < 0) {
- return NULL;
- }
-
- /* Compute number of components per pixel */
- comp_per_pixel = _mesa_components_in_format( format );
- if (comp_per_pixel < 0) {
- return NULL;
- }
+ /* The pixel type and format should have been error checked earlier */
+ assert(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX);
bytes_per_row = alignment
* CEILING( comp_per_pixel*pixels_per_row, 8*alignment );
bytes_per_image = bytes_per_row * rows_per_image;
- pixel_addr = (GLubyte *) image
- + (skipimages + img) * bytes_per_image
+ offset = (skipimages + img) * bytes_per_image
+ (skiprows + row) * bytes_per_row
+ (skippixels + column) / 8;
}
@@ -1275,14 +1267,50 @@ _mesa_image_address( GLuint dimensions,
}
/* compute final pixel address */
- pixel_addr = (GLubyte *) image
- + (skipimages + img) * bytes_per_image
+ offset = (skipimages + img) * bytes_per_image
+ topOfImage
+ (skiprows + row) * bytes_per_row
+ (skippixels + column) * bytes_per_pixel;
}
- return (GLvoid *) pixel_addr;
+ return offset;
+}
+
+
+/**
+ * Return the address of a specific pixel in an image (1D, 2D or 3D).
+ *
+ * Pixel unpacking/packing parameters are observed according to \p packing.
+ *
+ * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
+ * \param packing the pixelstore attributes
+ * \param image starting address of image data
+ * \param width the image width
+ * \param height the image height
+ * \param format the pixel format (must be validated beforehand)
+ * \param type the pixel data type (must be validated beforehand)
+ * \param img which image in the volume (0 for 1D or 2D images)
+ * \param row row of pixel in the image (0 for 1D images)
+ * \param column column of pixel in the image
+ *
+ * \return address of pixel.
+ *
+ * \sa gl_pixelstore_attrib.
+ */
+GLvoid *
+_mesa_image_address( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
+{
+ const GLubyte *addr = (const GLubyte *) image;
+
+ addr += _mesa_image_offset(dimensions, packing, width, height,
+ format, type, img, row, column);
+
+ return (GLvoid *) addr;
}
@@ -1520,9 +1548,13 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src,
GLenum dstType, GLvoid *dst,
GLuint count, const GLubyte mask[])
{
- GLuint tempBuffer[MAX_WIDTH][4];
+ GLuint *tempBuffer;
const GLboolean useTemp = (src == dst);
+ tempBuffer = malloc(count * MAX_PIXEL_BYTES);
+ if (!tempBuffer)
+ return;
+
ASSERT(srcType != dstType);
switch (srcType) {
@@ -1624,6 +1656,8 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src,
default:
_mesa_problem(NULL, "Invalid datatype in _mesa_convert_colors");
}
+
+ free(tempBuffer);
}
diff --git a/mesalib/src/mesa/main/image.h b/mesalib/src/mesa/main/image.h
index b606545b7..e4961ed3d 100644
--- a/mesalib/src/mesa/main/image.h
+++ b/mesalib/src/mesa/main/image.h
@@ -87,6 +87,13 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
extern GLboolean
_mesa_base_format_has_channel(GLenum base_format, GLenum pname);
+extern GLintptr
+_mesa_image_offset( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column );
+
extern GLvoid *
_mesa_image_address( GLuint dimensions,
const struct gl_pixelstore_attrib *packing,
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 0bd4ff199..2933ff638 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -467,6 +467,7 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
case GL_GREEN_INTEGER_EXT:
case GL_BLUE_INTEGER_EXT:
case GL_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
case GL_RGB_INTEGER_EXT:
case GL_RGBA_INTEGER_EXT:
case GL_BGR_INTEGER_EXT:
@@ -490,6 +491,7 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
case GL_GREEN_INTEGER_EXT:
case GL_BLUE_INTEGER_EXT:
case GL_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
case GL_RGB_INTEGER_EXT:
case GL_RGBA_INTEGER_EXT:
case GL_BGR_INTEGER_EXT:
@@ -3021,6 +3023,7 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
srcFormat == GL_DU8DV8_ATI ||
srcFormat == GL_DUDV_ATI ||
srcFormat == GL_RED_INTEGER_EXT ||
+ srcFormat == GL_RG_INTEGER ||
srcFormat == GL_GREEN_INTEGER_EXT ||
srcFormat == GL_BLUE_INTEGER_EXT ||
srcFormat == GL_ALPHA_INTEGER_EXT ||
@@ -3980,6 +3983,7 @@ _mesa_unpack_color_span_uint(struct gl_context *ctx,
srcFormat == GL_GREEN_INTEGER_EXT ||
srcFormat == GL_BLUE_INTEGER_EXT ||
srcFormat == GL_ALPHA_INTEGER_EXT ||
+ srcFormat == GL_RG_INTEGER ||
srcFormat == GL_RGB_INTEGER_EXT ||
srcFormat == GL_RGBA_INTEGER_EXT ||
srcFormat == GL_BGR_INTEGER_EXT ||
diff --git a/mesalib/src/mesa/main/pbo.c b/mesalib/src/mesa/main/pbo.c
index 41ff2ff44..d8fa9191d 100644
--- a/mesalib/src/mesa/main/pbo.c
+++ b/mesalib/src/mesa/main/pbo.c
@@ -68,8 +68,8 @@ _mesa_validate_pbo_access(GLuint dimensions,
GLenum format, GLenum type, GLsizei clientMemSize,
const GLvoid *ptr)
{
- const GLvoid *start, *end, *offset;
- const GLubyte *sizeAddr; /* buffer size, cast to a pointer */
+ /* unsigned, to detect overflow/wrap-around */
+ uintptr_t start, end, offset, size;
/* If no PBO is bound, 'ptr' is a pointer to client memory containing
'clientMemSize' bytes.
@@ -78,10 +78,10 @@ _mesa_validate_pbo_access(GLuint dimensions,
*/
if (!_mesa_is_bufferobj(pack->BufferObj)) {
offset = 0;
- sizeAddr = ((const GLubyte *) 0) + clientMemSize;
+ size = clientMemSize;
} else {
- offset = ptr;
- sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size;
+ offset = (uintptr_t)ptr;
+ size = pack->BufferObj->Size;
/* The ARB_pixel_buffer_object spec says:
* "INVALID_OPERATION is generated by ColorTable, ColorSubTable,
* ConvolutionFilter2D, ConvolutionFilter1D, SeparableFilter2D,
@@ -93,27 +93,30 @@ _mesa_validate_pbo_access(GLuint dimensions,
* parameter."
*/
if (type != GL_BITMAP &&
- ((GLintptr)offset % _mesa_sizeof_packed_type(type)))
+ (offset % _mesa_sizeof_packed_type(type)))
return GL_FALSE;
}
- if (sizeAddr == 0)
+ if (size == 0)
/* no buffer! */
return GL_FALSE;
/* get the offset to the first pixel we'll read/write */
- start = _mesa_image_address(dimensions, pack, offset, width, height,
- format, type, 0, 0, 0);
+ start = _mesa_image_offset(dimensions, pack, width, height,
+ format, type, 0, 0, 0);
/* get the offset to just past the last pixel we'll read/write */
- end = _mesa_image_address(dimensions, pack, offset, width, height,
- format, type, depth-1, height-1, width);
+ end = _mesa_image_offset(dimensions, pack, width, height,
+ format, type, depth-1, height-1, width);
- if ((const GLubyte *) start > sizeAddr) {
+ start += offset;
+ end += offset;
+
+ if (start > size) {
/* This will catch negative values / wrap-around */
return GL_FALSE;
}
- if ((const GLubyte *) end > sizeAddr) {
+ if (end > size) {
/* Image read/write goes beyond end of buffer */
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index a7b7ed7f2..38b9c64ed 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -252,10 +252,7 @@ slow_read_rgba_pixels( struct gl_context *ctx,
{
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
const gl_format rbFormat = _mesa_get_srgb_format_linear(rb->Format);
- union {
- float f[MAX_WIDTH][4];
- unsigned int i[MAX_WIDTH][4];
- } rgba;
+ void *rgba;
GLubyte *dst, *map;
int dstStride, stride, j;
@@ -270,19 +267,27 @@ slow_read_rgba_pixels( struct gl_context *ctx,
return;
}
+ rgba = malloc(width * MAX_PIXEL_BYTES);
+ if (!rgba)
+ goto done;
+
for (j = 0; j < height; j++) {
if (_mesa_is_integer_format(format)) {
- _mesa_unpack_int_rgba_row(rbFormat, width, map, rgba.i);
- _mesa_pack_rgba_span_int(ctx, width, rgba.i, format, type, dst);
+ _mesa_unpack_int_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba);
+ _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4]) rgba, format,
+ type, dst);
} else {
- _mesa_unpack_rgba_row(rbFormat, width, map, rgba.f);
- _mesa_pack_rgba_span_float(ctx, width, rgba.f, format, type, dst,
- packing, transferOps);
+ _mesa_unpack_rgba_row(rbFormat, width, map, (GLfloat (*)[4]) rgba);
+ _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format,
+ type, dst, packing, transferOps);
}
dst += dstStride;
map += stride;
}
+ free(rgba);
+
+done:
ctx->Driver.UnmapRenderbuffer(ctx, rb);
}
diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c
index 24060e695..d82b19ad5 100644
--- a/mesalib/src/mesa/main/renderbuffer.c
+++ b/mesalib/src/mesa/main/renderbuffer.c
@@ -23,18 +23,6 @@
*/
-/**
- * Functions for allocating/managing renderbuffers.
- * Also, routines for reading/writing software-based renderbuffer data as
- * ubytes, ushorts, uints, etc.
- *
- * Down the road we'll use this for run-time support of 8, 16 and 32-bit
- * color channels. For example, Mesa may use 32-bit/float color channels
- * internally (swrast) and use wrapper renderbuffers to convert 32-bit
- * values down to 16 or 8-bit values for whatever kind of framebuffer we have.
- */
-
-
#include "glheader.h"
#include "imports.h"
#include "context.h"
@@ -44,1700 +32,6 @@
#include "renderbuffer.h"
-/*
- * Routines for get/put values in common buffer formats follow.
- */
-
-/* Returns a bytes per pixel of the DataType in the get/put span
- * functions for at least a subset of the available combinations a
- * renderbuffer can have.
- *
- * It would be nice to see gl_renderbuffer start talking about a
- * gl_format instead of a GLenum DataType.
- */
-static int
-get_datatype_bytes(struct gl_renderbuffer *rb)
-{
- int component_size;
-
- switch (rb->DataType) {
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- component_size = 8;
- break;
- case GL_FLOAT:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_24_8_EXT:
- component_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- component_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- component_size = 1;
- break;
- default:
- component_size = 1;
- assert(0);
- }
-
- switch (rb->_BaseFormat) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_STENCIL:
- return component_size;
- default:
- return 4 * component_size;
- }
-}
-
-/* This is commonly used by most of the accessors. */
-static void *
-get_pointer_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
-
- return ((char *) rb->Data +
- (y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format));
-}
-
-/* GetRow() implementation for formats where DataType matches the rb->Format.
- */
-static void
-get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- void *src = rb->GetPointer(ctx, rb, x, y);
- memcpy(values, src, count * _mesa_get_format_bytes(rb->Format));
-}
-
-/* Only used for float textures currently, but might also be used for
- * RGBA8888, RGBA16, etc.
- */
-static void
-get_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values)
-{
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const void *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- char *dst = (char *) values + i * format_bytes;
- memcpy(dst, src, format_bytes);
- }
-}
-
-/* For the GL_RED/GL_RG/GL_RGB format/DataType combinations (and
- * GL_LUMINANCE/GL_INTENSITY?), the Put functions are a matter of
- * storing those initial components of the value per pixel into the
- * destination.
- */
-static void
-put_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *values, const GLubyte *mask)
-{
- void *row = rb->GetPointer(ctx, rb, x, y);
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- int datatype_bytes = get_datatype_bytes(rb);
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- const char *src = (const char *) values + i * datatype_bytes;
-
- if (mask[i]) {
- memcpy(dst, src, format_bytes);
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- const char *src = (const char *) values + i * datatype_bytes;
- memcpy(dst, src, format_bytes);
- }
- }
-}
-
-static void
-put_mono_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *value, const GLubyte *mask)
-{
- void *row = rb->GetPointer(ctx, rb, x, y);
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- if (mask[i]) {
- memcpy(dst, value, format_bytes);
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- memcpy(dst, value, format_bytes);
- }
- }
-}
-
-
-static void
-put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- int datatype_bytes = get_datatype_bytes(rb);
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- void *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
- const char *src = (const char *) values + i * datatype_bytes;
- memcpy(dst, src, format_bytes);
- }
- }
-}
-
-
-static void
-put_mono_values_generic(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- void *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
- memcpy(dst, value, format_bytes);
- }
- }
-}
-
-/**********************************************************************
- * Functions for buffers of 1 X GLubyte values.
- * Typically stencil.
- */
-
-static void
-get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, values, count * sizeof(GLubyte));
- }
-}
-
-
-static void
-put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLubyte val = *((const GLubyte *) value);
- GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
-static void
-put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLubyte val = *((const GLubyte *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLushort values.
- * Typically depth/Z.
- */
-
-static void
-get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = (GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- const GLushort *src = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLushort val = *((const GLushort *) value);
- GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
-static void
-put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLushort val = *((const GLushort *) value);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLuint values.
- * Typically depth/Z or color index.
- */
-
-static void
-get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- const GLuint *src = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLuint *src = (const GLuint *) values;
- GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, count * sizeof(GLuint));
- }
-}
-
-
-static void
-put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLuint val = *((const GLuint *) value);
- GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
-static void
-put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLuint *src = (const GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *value,
- const GLubyte *mask)
-{
- const GLuint val = *((const GLuint *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 3 X GLubyte (or GLbyte) values.
- * Typically color buffers.
- * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming
- * alpha values and return 255 for outgoing alpha values.
- */
-
-static void *
-get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- /* No direct access since this buffer is RGB but caller will be
- * treating it as if it were RGBA.
- */
- return NULL;
-}
-
-
-static void
-get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = ((const GLubyte *) rb->Data) +
- 3 * (y * rb->RowStride + x);
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 255;
- }
-}
-
-
-static void
-get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- const GLubyte *src
- = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]);
- dst[i * 4 + 0] = src[0];
- dst[i * 4 + 1] = src[1];
- dst[i * 4 + 2] = src[2];
- dst[i * 4 + 3] = 255;
- }
-}
-
-
-static void
-put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = src[i * 4 + 0];
- dst[i * 3 + 1] = src[i * 4 + 1];
- dst[i * 3 + 2] = src[i * 4 + 2];
- }
- }
-}
-
-
-static void
-put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = src[i * 3 + 0];
- dst[i * 3 + 1] = src[i * 3 + 1];
- dst[i * 3 + 2] = src[i * 3 + 2];
- }
- }
-}
-
-
-static void
-put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- /* note: incoming value is RGB+A! */
- const GLubyte val0 = ((const GLubyte *) value)[0];
- const GLubyte val1 = ((const GLubyte *) value)[1];
- const GLubyte val2 = ((const GLubyte *) value)[2];
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (!mask && val0 == val1 && val1 == val2) {
- /* optimized case */
- memset(dst, val0, 3 * count);
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = val0;
- dst[i * 3 + 1] = val1;
- dst[i * 3 + 2] = val2;
- }
- }
- }
-}
-
-
-static void
-put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]);
- dst[0] = src[i * 4 + 0];
- dst[1] = src[i * 4 + 1];
- dst[2] = src[i * 4 + 2];
- }
- }
-}
-
-
-static void
-put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- /* note: incoming value is RGB+A! */
- const GLubyte val0 = ((const GLubyte *) value)[0];
- const GLubyte val1 = ((const GLubyte *) value)[1];
- const GLubyte val2 = ((const GLubyte *) value)[2];
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = ((GLubyte *) rb->Data) +
- 3 * (y[i] * rb->RowStride + x[i]);
- dst[0] = val0;
- dst[1] = val1;
- dst[2] = val2;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 4 X GLubyte (or GLbyte) values.
- * Typically color buffers.
- */
-
-static void
-get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- /* treat 4*GLubyte as 1*GLuint */
- GLuint *dst = (GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint *src = (const GLuint *) values;
- GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLubyte));
- }
-}
-
-
-static void
-put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* Store RGB values in RGBA buffer */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->RowStride + x);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 0xff;
- }
- }
-}
-
-
-static void
-put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint val = *((const GLuint *) value);
- GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- if (!mask && val == 0) {
- /* common case */
- memset(dst, 0, count * 4 * sizeof(GLubyte));
- }
- else {
- /* general case */
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
- }
-}
-
-
-static void
-put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint *src = (const GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint val = *((const GLuint *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 4 X GLushort (or GLshort) values.
- * Typically accum buffer.
- */
-
-static void
-get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = (GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- const GLushort *src
- = (GLushort *) rb->Data + 4 * (y[i] * rb->RowStride + x[i]);
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i * 4 + 0] = src[i * 4 + 0];
- dst[i * 4 + 1] = src[i * 4 + 1];
- dst[i * 4 + 2] = src[i * 4 + 2];
- dst[i * 4 + 3] = src[i * 4 + 3];
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* Put RGB values in RGBA buffer */
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 0xffff;
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLushort val0 = ((const GLushort *) value)[0];
- const GLushort val1 = ((const GLushort *) value)[1];
- const GLushort val2 = ((const GLushort *) value)[2];
- const GLushort val3 = ((const GLushort *) value)[3];
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) {
- /* common case for clearing accum buffer */
- memset(dst, 0, count * 4 * sizeof(GLushort));
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 4 + 0] = val0;
- dst[i * 4 + 1] = val1;
- dst[i * 4 + 2] = val2;
- dst[i * 4 + 3] = val3;
- }
- }
- }
-}
-
-
-static void
-put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst =
- ((GLushort *) rb->Data) + 4 * (y[i] * rb->RowStride + x[i]);
- dst[0] = src[i * 4 + 0];
- dst[1] = src[i * 4 + 1];
- dst[2] = src[i * 4 + 2];
- dst[3] = src[i * 4 + 3];
- }
- }
-}
-
-
-static void
-put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLushort val0 = ((const GLushort *) value)[0];
- const GLushort val1 = ((const GLushort *) value)[1];
- const GLushort val2 = ((const GLushort *) value)[2];
- const GLushort val3 = ((const GLushort *) value)[3];
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = ((GLushort *) rb->Data) +
- 4 * (y[i] * rb->RowStride + x[i]);
- dst[0] = val0;
- dst[1] = val1;
- dst[2] = val2;
- dst[3] = val3;
- }
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_R8.
- */
-static void
-get_row_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = rb->GetPointer(ctx, rb, x, y);
- GLuint *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i] = 0xff000000 | src[i];
- }
-}
-
-static void
-get_values_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLubyte *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i] = 0xff000000 | *src;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_GR88.
- */
-static void
-get_row_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLushort *src = rb->GetPointer(ctx, rb, x, y);
- GLuint *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i] = 0xff000000 | src[i];
- }
-}
-
-static void
-get_values_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i] = 0xff000000 | *src;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_R16.
- */
-static void
-get_row_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLushort *src = rb->GetPointer(ctx, rb, x, y);
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i];
- dst[i * 4 + GCOMP] = 0;
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-static void
-get_values_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLushort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = *src;
- dst[i * 4 + GCOMP] = 0;
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_RG1616.
- */
-static void
-get_row_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLushort *src = rb->GetPointer(ctx, rb, x, y);
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i * 2];
- dst[i * 4 + GCOMP] = src[i * 2 + 1];
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-static void
-get_values_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = src[0];
- dst[i * 4 + GCOMP] = src[1];
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_INTENSITY_FLOAT32.
- */
-static void
-get_row_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] =
- dst[i * 4 + ACOMP] = src[i];
- }
-}
-
-static void
-get_values_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] =
- dst[i * 4 + ACOMP] = src[0];
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_LUMINANCE_FLOAT32.
- */
-static void
-get_row_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] = src[i];
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-static void
-get_values_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] = src[0];
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_ALPHA_FLOAT32.
- */
-static void
-get_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = 0.0;
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = src[i];
- }
-}
-
-static void
-get_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = 0.0;
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = src[0];
- }
-}
-
-static void
-put_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *values, const GLubyte *mask)
-{
- float *dst = rb->GetPointer(ctx, rb, x, y);
- const float *src = values;
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i * 4 + ACOMP];
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- dst[i] = src[i * 4 + ACOMP];
- }
- }
-}
-
-static void
-put_mono_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *value, const GLubyte *mask)
-{
- float *dst = rb->GetPointer(ctx, rb, x, y);
- const float *src = value;
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[ACOMP];
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- dst[i] = src[ACOMP];
- }
- }
-}
-
-static void
-put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- const float *src = values;
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- float *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
-
- *dst = src[i * 4 + ACOMP];
- }
- }
-}
-
-static void
-put_mono_values_a_float32(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const float *src = value;
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- float *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
- *dst = src[ACOMP];
- }
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_R_FLOAT32.
- */
-static void
-get_row_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i];
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-static void
-get_values_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = src[0];
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_RG_FLOAT32.
- */
-static void
-get_row_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i * 2 + 0];
- dst[i * 4 + GCOMP] = src[i * 2 + 1];
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-static void
-get_values_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = src[0];
- dst[i * 4 + GCOMP] = src[1];
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-/**
- * This is the default software fallback for gl_renderbuffer's span
- * access functions.
- *
- * The assumptions are that rb->Data will be a pointer to (0,0), that pixels
- * are packed in the type of rb->Format, and that subsequent rows appear
- * rb->RowStride pixels later.
- */
-void
-_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
-{
- rb->GetPointer = get_pointer_generic;
- rb->GetRow = get_row_generic;
-
- switch (rb->Format) {
- case MESA_FORMAT_RGB888:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetPointer = get_pointer_ubyte3;
- rb->GetRow = get_row_ubyte3;
- rb->GetValues = get_values_ubyte3;
- rb->PutRow = put_row_ubyte3;
- rb->PutRowRGB = put_row_rgb_ubyte3;
- rb->PutMonoRow = put_mono_row_ubyte3;
- rb->PutValues = put_values_ubyte3;
- rb->PutMonoValues = put_mono_values_ubyte3;
- break;
-
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_RGBA8888_REV:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_ubyte4;
- rb->PutRow = put_row_ubyte4;
- rb->PutRowRGB = put_row_rgb_ubyte4;
- rb->PutMonoRow = put_mono_row_ubyte4;
- rb->PutValues = put_values_ubyte4;
- rb->PutMonoValues = put_mono_values_ubyte4;
- break;
-
- case MESA_FORMAT_R8:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_r8;
- rb->GetRow = get_row_r8;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_GR88:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_rg88;
- rb->GetRow = get_row_rg88;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_R16:
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetValues = get_values_r16;
- rb->GetRow = get_row_r16;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_RG1616:
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetValues = get_values_rg1616;
- rb->GetRow = get_row_rg1616;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_SIGNED_RGBA_16:
- rb->DataType = GL_SHORT;
- rb->GetValues = get_values_ushort4;
- rb->PutRow = put_row_ushort4;
- rb->PutRowRGB = put_row_rgb_ushort4;
- rb->PutMonoRow = put_mono_row_ushort4;
- rb->PutValues = put_values_ushort4;
- rb->PutMonoValues = put_mono_values_ushort4;
- break;
-
- case MESA_FORMAT_S8:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_ubyte;
- rb->PutRow = put_row_ubyte;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ubyte;
- rb->PutValues = put_values_ubyte;
- rb->PutMonoValues = put_mono_values_ubyte;
- break;
-
- case MESA_FORMAT_Z16:
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetValues = get_values_ushort;
- rb->PutRow = put_row_ushort;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ushort;
- rb->PutValues = put_values_ushort;
- rb->PutMonoValues = put_mono_values_ushort;
- break;
-
- case MESA_FORMAT_Z32:
- case MESA_FORMAT_X8_Z24:
- case MESA_FORMAT_Z24_X8:
- rb->DataType = GL_UNSIGNED_INT;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
- rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
- break;
-
- case MESA_FORMAT_Z24_S8:
- case MESA_FORMAT_S8_Z24:
- rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
- rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
- break;
-
- case MESA_FORMAT_RGBA_FLOAT32:
- rb->GetRow = get_row_generic;
- rb->GetValues = get_values_generic;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_INTENSITY_FLOAT32:
- rb->GetRow = get_row_i_float32;
- rb->GetValues = get_values_i_float32;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_LUMINANCE_FLOAT32:
- rb->GetRow = get_row_l_float32;
- rb->GetValues = get_values_l_float32;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_ALPHA_FLOAT32:
- rb->GetRow = get_row_a_float32;
- rb->GetValues = get_values_a_float32;
- rb->PutRow = put_row_a_float32;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_a_float32;
- rb->PutValues = put_values_a_float32;
- rb->PutMonoValues = put_mono_values_a_float32;
- break;
-
- case MESA_FORMAT_RG_FLOAT32:
- rb->GetRow = get_row_rg_float32;
- rb->GetValues = get_values_rg_float32;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- case MESA_FORMAT_R_FLOAT32:
- rb->GetRow = get_row_r_float32;
- rb->GetValues = get_values_r_float32;
- rb->PutRow = put_row_generic;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
- rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
- break;
-
- default:
- break;
- }
-}
-
-/**
- * This is a software fallback for the gl_renderbuffer->AllocStorage
- * function.
- * Device drivers will typically override this function for the buffers
- * which it manages (typically color buffers, Z and stencil).
- * Other buffers (like software accumulation and aux buffers) which the driver
- * doesn't manage can be handled with this function.
- *
- * This one multi-purpose function can allocate stencil, depth, accum, color
- * or color-index buffers!
- *
- * This function also plugs in the appropriate GetPointer, Get/PutRow and
- * Get/PutValues functions.
- */
-GLboolean
-_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLenum internalFormat,
- GLuint width, GLuint height)
-{
- switch (internalFormat) {
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- rb->Format = MESA_FORMAT_RGB888;
- break;
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
-#if 1
- case GL_RGB10_A2:
- case GL_RGBA12:
-#endif
- if (_mesa_little_endian())
- rb->Format = MESA_FORMAT_RGBA8888_REV;
- else
- rb->Format = MESA_FORMAT_RGBA8888;
- break;
- case GL_RGBA16:
- case GL_RGBA16_SNORM:
- /* for accum buffer */
- rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
- break;
- case GL_STENCIL_INDEX:
- case GL_STENCIL_INDEX1_EXT:
- case GL_STENCIL_INDEX4_EXT:
- case GL_STENCIL_INDEX8_EXT:
- case GL_STENCIL_INDEX16_EXT:
- rb->Format = MESA_FORMAT_S8;
- break;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- rb->Format = MESA_FORMAT_Z16;
- break;
- case GL_DEPTH_COMPONENT24:
- rb->Format = MESA_FORMAT_X8_Z24;
- break;
- case GL_DEPTH_COMPONENT32:
- rb->Format = MESA_FORMAT_Z32;
- break;
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- rb->Format = MESA_FORMAT_Z24_S8;
- break;
- default:
- /* unsupported format */
- return GL_FALSE;
- }
-
- _mesa_set_renderbuffer_accessors(rb);
-
- ASSERT(rb->DataType);
- ASSERT(rb->GetPointer);
- ASSERT(rb->GetRow);
- ASSERT(rb->GetValues);
- ASSERT(rb->PutRow);
- ASSERT(rb->PutMonoRow);
- ASSERT(rb->PutValues);
- ASSERT(rb->PutMonoValues);
-
- /* free old buffer storage */
- if (rb->Data) {
- free(rb->Data);
- rb->Data = NULL;
- }
-
- rb->RowStride = width;
-
- if (width > 0 && height > 0) {
- /* allocate new buffer storage */
- rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format));
-
- if (rb->Data == NULL) {
- rb->Width = 0;
- rb->Height = 0;
- rb->RowStride = 0;
- _mesa_error(ctx, GL_OUT_OF_MEMORY,
- "software renderbuffer allocation (%d x %d x %d)",
- width, height, _mesa_get_format_bytes(rb->Format));
- return GL_FALSE;
- }
- }
-
- rb->Width = width;
- rb->Height = height;
- rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
-
- if (rb->Name == 0 &&
- internalFormat == GL_RGBA16_SNORM &&
- rb->_BaseFormat == 0) {
- /* NOTE: This is a special case just for accumulation buffers.
- * This is a very limited use case- there's no snorm texturing or
- * rendering going on.
- */
- rb->_BaseFormat = GL_RGBA;
- }
- else {
- /* the internalFormat should have been error checked long ago */
- ASSERT(rb->_BaseFormat);
- }
-
- return GL_TRUE;
-}
-
-
-void
-_mesa_map_soft_renderbuffer(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint x, GLuint y, GLuint w, GLuint h,
- GLbitfield mode,
- GLubyte **out_map,
- GLint *out_stride)
-{
- GLubyte *map = rb->Data;
- int cpp = _mesa_get_format_bytes(rb->Format);
- int stride = rb->RowStride * cpp;
-
- ASSERT(rb->Data);
-
- map += y * stride;
- map += x * cpp;
-
- *out_map = map;
- *out_stride = stride;
-}
-
-void
-_mesa_unmap_soft_renderbuffer(struct gl_context *ctx,
- struct gl_renderbuffer *rb)
-{
-}
-
-
-
-/**********************************************************************/
-/**********************************************************************/
-/**********************************************************************/
-
-
/**
* Default GetPointer routine. Always return NULL to indicate that
* direct buffer access is not supported.
@@ -1821,310 +115,6 @@ _mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
/**
- * Allocate a software-based renderbuffer. This is called via the
- * ctx->Driver.NewRenderbuffer() function when the user creates a new
- * renderbuffer.
- * This would not be used for hardware-based renderbuffers.
- */
-struct gl_renderbuffer *
-_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name)
-{
- struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
- if (rb) {
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- /* Normally, one would setup the PutRow, GetRow, etc functions here.
- * But we're doing that in the _mesa_soft_renderbuffer_storage() function
- * instead.
- */
- }
- return rb;
-}
-
-
-/**
- * Add software-based color renderbuffers to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint rgbBits, GLuint alphaBits,
- GLboolean frontLeft, GLboolean backLeft,
- GLboolean frontRight, GLboolean backRight)
-{
- gl_buffer_index b;
-
- if (rgbBits > 16 || alphaBits > 16) {
- _mesa_problem(ctx,
- "Unsupported bit depth in _mesa_add_color_renderbuffers");
- return GL_FALSE;
- }
-
- assert(MAX_COLOR_ATTACHMENTS >= 4);
-
- for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
- struct gl_renderbuffer *rb;
-
- if (b == BUFFER_FRONT_LEFT && !frontLeft)
- continue;
- else if (b == BUFFER_BACK_LEFT && !backLeft)
- continue;
- else if (b == BUFFER_FRONT_RIGHT && !frontRight)
- continue;
- else if (b == BUFFER_BACK_RIGHT && !backRight)
- continue;
-
- assert(fb->Attachment[b].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
- return GL_FALSE;
- }
-
- rb->InternalFormat = GL_RGBA;
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, b, rb);
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * Add a software-based depth renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint depthBits)
-{
- struct gl_renderbuffer *rb;
-
- if (depthBits > 32) {
- _mesa_problem(ctx,
- "Unsupported depthBits in _mesa_add_depth_renderbuffer");
- return GL_FALSE;
- }
-
- assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer");
- return GL_FALSE;
- }
-
- if (depthBits <= 16) {
- rb->InternalFormat = GL_DEPTH_COMPONENT16;
- }
- else if (depthBits <= 24) {
- rb->InternalFormat = GL_DEPTH_COMPONENT24;
- }
- else {
- rb->InternalFormat = GL_DEPTH_COMPONENT32;
- }
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
-
- return GL_TRUE;
-}
-
-
-/**
- * Add a software-based stencil renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint stencilBits)
-{
- struct gl_renderbuffer *rb;
-
- if (stencilBits > 16) {
- _mesa_problem(ctx,
- "Unsupported stencilBits in _mesa_add_stencil_renderbuffer");
- return GL_FALSE;
- }
-
- assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
- return GL_FALSE;
- }
-
- assert(stencilBits <= 8);
- rb->InternalFormat = GL_STENCIL_INDEX8;
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
-
- return GL_TRUE;
-}
-
-
-/**
- * Add a software-based accumulation renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint redBits, GLuint greenBits,
- GLuint blueBits, GLuint alphaBits)
-{
- struct gl_renderbuffer *rb;
-
- if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) {
- _mesa_problem(ctx,
- "Unsupported accumBits in _mesa_add_accum_renderbuffer");
- return GL_FALSE;
- }
-
- assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
- return GL_FALSE;
- }
-
- rb->InternalFormat = GL_RGBA16_SNORM;
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
-
- return GL_TRUE;
-}
-
-
-
-/**
- * Add a software-based aux renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- *
- * NOTE: color-index aux buffers not supported.
- */
-GLboolean
-_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint colorBits, GLuint numBuffers)
-{
- GLuint i;
-
- if (colorBits > 16) {
- _mesa_problem(ctx,
- "Unsupported accumBits in _mesa_add_aux_renderbuffers");
- return GL_FALSE;
- }
-
- assert(numBuffers <= MAX_AUX_BUFFERS);
-
- for (i = 0; i < numBuffers; i++) {
- struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
-
- assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL);
-
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer");
- return GL_FALSE;
- }
-
- assert (colorBits <= 8);
- rb->InternalFormat = GL_RGBA;
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Create/attach software-based renderbuffers to the given framebuffer.
- * This is a helper routine for device drivers. Drivers can just as well
- * call the individual _mesa_add_*_renderbuffer() routines directly.
- */
-void
-_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
- GLboolean color,
- GLboolean depth,
- GLboolean stencil,
- GLboolean accum,
- GLboolean alpha,
- GLboolean aux)
-{
- GLboolean frontLeft = GL_TRUE;
- GLboolean backLeft = fb->Visual.doubleBufferMode;
- GLboolean frontRight = fb->Visual.stereoMode;
- GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
-
- if (color) {
- assert(fb->Visual.redBits == fb->Visual.greenBits);
- assert(fb->Visual.redBits == fb->Visual.blueBits);
- _mesa_add_color_renderbuffers(NULL, fb,
- fb->Visual.redBits,
- fb->Visual.alphaBits,
- frontLeft, backLeft,
- frontRight, backRight);
- }
-
- if (depth) {
- assert(fb->Visual.depthBits > 0);
- _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
- }
-
- if (stencil) {
- assert(fb->Visual.stencilBits > 0);
- _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
- }
-
- if (accum) {
- assert(fb->Visual.accumRedBits > 0);
- assert(fb->Visual.accumGreenBits > 0);
- assert(fb->Visual.accumBlueBits > 0);
- _mesa_add_accum_renderbuffer(NULL, fb,
- fb->Visual.accumRedBits,
- fb->Visual.accumGreenBits,
- fb->Visual.accumBlueBits,
- fb->Visual.accumAlphaBits);
- }
-
- if (aux) {
- assert(fb->Visual.numAuxBuffers > 0);
- _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
- fb->Visual.numAuxBuffers);
- }
-
-#if 0
- if (multisample) {
- /* maybe someday */
- }
-#endif
-}
-
-
-/**
* Attach a renderbuffer to a framebuffer.
* \param bufferName one of the BUFFER_x tokens
*/
@@ -2166,17 +156,9 @@ void
_mesa_remove_renderbuffer(struct gl_framebuffer *fb,
gl_buffer_index bufferName)
{
- struct gl_renderbuffer *rb;
-
assert(bufferName < BUFFER_COUNT);
-
- rb = fb->Attachment[bufferName].Renderbuffer;
- if (!rb)
- return;
-
- _mesa_reference_renderbuffer(&rb, NULL);
-
- fb->Attachment[bufferName].Renderbuffer = NULL;
+ _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer,
+ NULL);
}
diff --git a/mesalib/src/mesa/main/renderbuffer.h b/mesalib/src/mesa/main/renderbuffer.h
index 3194fc3fe..0934d85df 100644
--- a/mesalib/src/mesa/main/renderbuffer.h
+++ b/mesalib/src/mesa/main/renderbuffer.h
@@ -42,63 +42,6 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name);
extern void
_mesa_delete_renderbuffer(struct gl_renderbuffer *rb);
-
-extern struct gl_renderbuffer *
-_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name);
-
-void
-_mesa_map_soft_renderbuffer(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint x, GLuint y, GLuint w, GLuint h,
- GLbitfield mode,
- GLubyte **out_map,
- GLint *out_stride);
-
-void
-_mesa_unmap_soft_renderbuffer(struct gl_context *ctx,
- struct gl_renderbuffer *rb);
-
-extern void
-_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb);
-
-extern GLboolean
-_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLenum internalFormat,
- GLuint width, GLuint height);
-
-extern GLboolean
-_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint rgbBits, GLuint alphaBits,
- GLboolean frontLeft, GLboolean backLeft,
- GLboolean frontRight, GLboolean backRight);
-
-extern GLboolean
-_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint depthBits);
-
-extern GLboolean
-_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint stencilBits);
-
-
-extern GLboolean
-_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint redBits, GLuint greenBits,
- GLuint blueBits, GLuint alphaBits);
-
-extern GLboolean
-_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint bits, GLuint numBuffers);
-
-extern void
-_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
- GLboolean color,
- GLboolean depth,
- GLboolean stencil,
- GLboolean accum,
- GLboolean alpha,
- GLboolean aux);
-
extern void
_mesa_add_renderbuffer(struct gl_framebuffer *fb,
gl_buffer_index bufferName, struct gl_renderbuffer *rb);
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 17c78ce3e..8e447cabd 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -1184,10 +1184,7 @@ _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
*
* \return GL_TRUE if all textures are resident and \p residences is left unchanged,
*
- * \sa glAreTexturesResident().
- *
- * Looks up each texture in the hash and calls
- * dd_function_table::IsTextureResident.
+ * Note: we assume all textures are always resident
*/
GLboolean GLAPIENTRY
_mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
@@ -1195,7 +1192,7 @@ _mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
{
GET_CURRENT_CONTEXT(ctx);
GLboolean allResident = GL_TRUE;
- GLint i, j;
+ GLint i;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (n < 0) {
@@ -1206,6 +1203,7 @@ _mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
if (!texName || !residences)
return GL_FALSE;
+ /* We only do error checking on the texture names */
for (i = 0; i < n; i++) {
struct gl_texture_object *t;
if (texName[i] == 0) {
@@ -1217,21 +1215,6 @@ _mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
_mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident");
return GL_FALSE;
}
- if (!ctx->Driver.IsTextureResident ||
- ctx->Driver.IsTextureResident(ctx, t)) {
- /* The texture is resident */
- if (!allResident)
- residences[i] = GL_TRUE;
- }
- else {
- /* The texture is not resident */
- if (allResident) {
- allResident = GL_FALSE;
- for (j = 0; j < i; j++)
- residences[j] = GL_TRUE;
- }
- residences[i] = GL_FALSE;
- }
}
return allResident;
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index f4ec63388..0f92a5b98 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -1114,8 +1114,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
}
break;
case GL_TEXTURE_RESIDENT:
- *params = ctx->Driver.IsTextureResident ?
- ctx->Driver.IsTextureResident(ctx, obj) : 1.0F;
+ *params = 1.0F;
break;
case GL_TEXTURE_PRIORITY:
*params = obj->Priority;
@@ -1261,8 +1260,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
}
break;;
case GL_TEXTURE_RESIDENT:
- *params = ctx->Driver.IsTextureResident ?
- ctx->Driver.IsTextureResident(ctx, obj) : 1;
+ *params = 1;
break;;
case GL_TEXTURE_PRIORITY:
*params = FLOAT_TO_INT(obj->Priority);
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 37fea2156..a57a38e12 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -954,8 +954,7 @@ memcpy_texture(struct gl_context *ctx,
GLubyte *dstImage = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
- ctx->Driver.TextureMemCpy(dstImage, srcImage,
- bytesPerRow * srcHeight);
+ memcpy(dstImage, srcImage, bytesPerRow * srcHeight);
srcImage += srcImageStride;
}
}
@@ -968,7 +967,7 @@ memcpy_texture(struct gl_context *ctx,
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
- ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
+ memcpy(dstRow, srcRow, bytesPerRow);
dstRow += dstRowStride;
srcRow += srcRowStride;
}
@@ -3569,6 +3568,8 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT8);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
@@ -3639,6 +3640,8 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT16);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
@@ -3709,6 +3712,8 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT32);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
@@ -3779,6 +3784,8 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT8);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
@@ -3847,6 +3854,8 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT16);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
@@ -3915,6 +3924,8 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT32);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak
index 1f109fb36..a3ce85535 100644
--- a/mesalib/src/mesa/sources.mak
+++ b/mesalib/src/mesa/sources.mak
@@ -42,6 +42,7 @@ MAIN_SOURCES = \
main/ffvertex_prog.c \
main/fog.c \
main/formats.c \
+ main/format_pack.c \
main/format_unpack.c \
main/framebuffer.c \
main/get.c \
@@ -124,7 +125,6 @@ MATH_XFORM_SOURCES = \
SWRAST_SOURCES = \
swrast/s_aaline.c \
swrast/s_aatriangle.c \
- swrast/s_accum.c \
swrast/s_alpha.c \
swrast/s_atifragshader.c \
swrast/s_bitmap.c \
@@ -142,6 +142,7 @@ SWRAST_SOURCES = \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_points.c \
+ swrast/s_renderbuffer.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texcombine.c \
@@ -208,7 +209,6 @@ STATETRACKER_SOURCES = \
state_tracker/st_atom_stipple.c \
state_tracker/st_atom_texture.c \
state_tracker/st_atom_viewport.c \
- state_tracker/st_cb_accum.c \
state_tracker/st_cb_bitmap.c \
state_tracker/st_cb_blit.c \
state_tracker/st_cb_bufferobjects.c \
diff --git a/mesalib/src/mesa/state_tracker/st_cb_accum.c b/mesalib/src/mesa/state_tracker/st_cb_accum.c
deleted file mode 100644
index 3e3659d15..000000000
--- a/mesalib/src/mesa/state_tracker/st_cb_accum.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Brian Paul
- */
-
-#include "main/imports.h"
-#include "main/image.h"
-#include "main/macros.h"
-#include "main/mfeatures.h"
-
-#include "st_debug.h"
-#include "st_context.h"
-#include "st_cb_accum.h"
-#include "st_cb_fbo.h"
-#include "st_texture.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "util/u_format.h"
-#include "util/u_inlines.h"
-#include "util/u_tile.h"
-
-
-#if FEATURE_accum
-
-/**
- * For hardware that supports deep color buffers, we could accelerate
- * most/all the accum operations with blending/texturing.
- * For now, just use the get/put_tile() functions and do things in software.
- */
-
-
-void
-st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
-{
- struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
- const GLint xpos = ctx->DrawBuffer->_Xmin;
- const GLint ypos = ctx->DrawBuffer->_Ymin;
- const GLint width = ctx->DrawBuffer->_Xmax - xpos;
- const GLint height = ctx->DrawBuffer->_Ymax - ypos;
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
-
- if(!data)
- return;
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- GLshort r = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]);
- GLshort g = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]);
- GLshort b = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]);
- GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *dst = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width; j++) {
- dst[0] = r;
- dst[1] = g;
- dst[2] = b;
- dst[3] = a;
- dst += 4;
- }
- }
- }
- break;
- default:
- _mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()");
- }
-}
-
-
-/** For ADD/MULT */
-static void
-accum_mad(struct gl_context *ctx, GLfloat scale, GLfloat bias,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb)
-{
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width * 4; j++) {
- float val = SHORT_TO_FLOAT(*acc) * scale + bias;
- *acc++ = FLOAT_TO_SHORT(val);
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-}
-
-
-static void
-accum_accum(struct st_context *st, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb,
- struct st_renderbuffer *color_strb)
-{
- struct pipe_context *pipe = st->pipe;
- struct pipe_transfer *color_trans;
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
- GLfloat *buf;
-
- if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
-
- color_trans = pipe_get_transfer(st->pipe,
- color_strb->texture,
- 0, 0,
- PIPE_TRANSFER_READ, xpos, ypos,
- width, height);
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- util_format_linear(color_strb->texture->format),
- buf);
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const GLfloat *color = buf;
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width * 4; j++) {
- float val = *color++ * value;
- *acc++ += FLOAT_TO_SHORT(val);
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-
- free(buf);
- pipe->transfer_destroy(pipe, color_trans);
-}
-
-
-static void
-accum_load(struct st_context *st, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb,
- struct st_renderbuffer *color_strb)
-{
- struct pipe_context *pipe = st->pipe;
- struct pipe_transfer *color_trans;
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
- GLfloat *buf;
-
- if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
-
- color_trans = pipe_get_transfer(st->pipe, color_strb->texture,
- 0, 0,
- PIPE_TRANSFER_READ, xpos, ypos,
- width, height);
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- util_format_linear(color_strb->texture->format),
- buf);
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const GLfloat *color = buf;
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width * 4; j++) {
- float val = *color++ * value;
- *acc++ = FLOAT_TO_SHORT(val);
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-
- free(buf);
- pipe->transfer_destroy(pipe, color_trans);
-}
-
-
-static void
-accum_return(struct gl_context *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb,
- struct st_renderbuffer *color_strb)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- const GLubyte *colormask = ctx->Color.ColorMask[0];
- enum pipe_transfer_usage usage;
- struct pipe_transfer *color_trans;
- size_t stride = acc_strb->stride;
- const GLubyte *data = acc_strb->data;
- GLfloat *buf;
- enum pipe_format format = util_format_linear(color_strb->texture->format);
-
- if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3])
- usage = PIPE_TRANSFER_READ_WRITE;
- else
- usage = PIPE_TRANSFER_WRITE;
-
- color_trans = pipe_get_transfer(pipe,
- color_strb->texture, 0, 0,
- usage,
- xpos, ypos,
- width, height);
-
- if (usage & PIPE_TRANSFER_READ)
- pipe_get_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- format, buf);
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- GLfloat *color = buf;
- int i, j, ch;
- for (i = 0; i < height; i++) {
- const GLshort *acc = (const GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width; j++) {
- for (ch = 0; ch < 4; ch++) {
- if (colormask[ch]) {
- GLfloat val = SHORT_TO_FLOAT(*acc * value);
- *color = CLAMP(val, 0.0f, 1.0f);
- }
- else {
- /* No change */
- }
- ++acc;
- ++color;
- }
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-
- pipe_put_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- format, buf);
-
- free(buf);
- pipe->transfer_destroy(pipe, color_trans);
-}
-
-
-static void
-st_Accum(struct gl_context *ctx, GLenum op, GLfloat value)
-{
- struct st_context *st = st_context(ctx);
- struct st_renderbuffer *acc_strb
- = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
- struct st_renderbuffer *color_strb
- = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
-
- const GLint xpos = ctx->DrawBuffer->_Xmin;
- const GLint ypos = ctx->DrawBuffer->_Ymin;
- const GLint width = ctx->DrawBuffer->_Xmax - xpos;
- const GLint height = ctx->DrawBuffer->_Ymax - ypos;
-
- if(!acc_strb->data)
- return;
-
- switch (op) {
- case GL_ADD:
- if (value != 0.0F) {
- accum_mad(ctx, 1.0, value, xpos, ypos, width, height, acc_strb);
- }
- break;
- case GL_MULT:
- if (value != 1.0F) {
- accum_mad(ctx, value, 0.0, xpos, ypos, width, height, acc_strb);
- }
- break;
- case GL_ACCUM:
- if (value != 0.0F) {
- accum_accum(st, value, xpos, ypos, width, height, acc_strb, color_strb);
- }
- break;
- case GL_LOAD:
- accum_load(st, value, xpos, ypos, width, height, acc_strb, color_strb);
- break;
- case GL_RETURN:
- accum_return(ctx, value, xpos, ypos, width, height, acc_strb, color_strb);
- break;
- default:
- assert(0);
- }
-}
-
-
-
-void st_init_accum_functions(struct dd_function_table *functions)
-{
- functions->Accum = st_Accum;
-}
-
-#endif /* FEATURE_accum */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_accum.h b/mesalib/src/mesa/state_tracker/st_cb_accum.h
deleted file mode 100644
index 90feddd6f..000000000
--- a/mesalib/src/mesa/state_tracker/st_cb_accum.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef ST_CB_ACCUM_H
-#define ST_CB_ACCUM_H
-
-
-#include "main/mfeatures.h"
-
-struct dd_function_table;
-struct gl_context;
-struct gl_renderbuffer;
-
-#if FEATURE_accum
-
-extern void
-st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
-
-extern void st_init_accum_functions(struct dd_function_table *functions);
-
-#else
-
-#include "main/compiler.h"
-
-static INLINE void
-st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
-{
- ASSERT_NO_FEATURE();
-}
-
-static INLINE void
-st_init_accum_functions(struct dd_function_table *functions)
-{
-}
-
-#endif /* FEATURE_accum */
-
-#endif /* ST_CB_ACCUM_H */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 89273e28e..61d98aeb9 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -34,12 +34,12 @@
*/
#include "main/glheader.h"
+#include "main/accum.h"
#include "main/formats.h"
#include "main/macros.h"
#include "program/prog_instruction.h"
#include "st_context.h"
#include "st_atom.h"
-#include "st_cb_accum.h"
#include "st_cb_clear.h"
#include "st_cb_fbo.h"
#include "st_format.h"
@@ -599,8 +599,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
ctx->Depth.Clear, ctx->Stencil.Clear);
}
if (mask & BUFFER_BIT_ACCUM)
- st_clear_accum_buffer(ctx,
- ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
+ _mesa_clear_accum_buffer(ctx);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 2a60ed4df..ec40a2b70 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -667,6 +667,22 @@ st_MapRenderbuffer(struct gl_context *ctx,
unsigned usage;
GLuint y2;
+ if (strb->software) {
+ /* software-allocated renderbuffer (probably an accum buffer) */
+ GLubyte *map = (GLubyte *) strb->data;
+ if (strb->data) {
+ map += strb->stride * y;
+ map += util_format_get_blocksize(strb->format) * x;
+ *mapOut = map;
+ *rowStrideOut = strb->stride;
+ }
+ else {
+ *mapOut = NULL;
+ *rowStrideOut = 0;
+ }
+ return;
+ }
+
usage = 0x0;
if (mode & GL_MAP_READ_BIT)
usage |= PIPE_TRANSFER_READ;
@@ -716,6 +732,11 @@ st_UnmapRenderbuffer(struct gl_context *ctx,
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_context *pipe = st->pipe;
+ if (strb->software) {
+ /* software-allocated renderbuffer (probably an accum buffer) */
+ return;
+ }
+
pipe_transfer_unmap(pipe, strb->transfer);
pipe->transfer_destroy(pipe, strb->transfer);
strb->transfer = NULL;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index c58a9df56..52f654d7d 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -214,56 +214,6 @@ st_UnmapTextureImage(struct gl_context *ctx,
/**
- * From linux kernel i386 header files, copes with odd sizes better
- * than COPY_DWORDS would:
- * XXX Put this in src/mesa/main/imports.h ???
- */
-#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
-static INLINE void *
-__memcpy(void *to, const void *from, size_t n)
-{
- int d0, d1, d2;
- __asm__ __volatile__("rep ; movsl\n\t"
- "testb $2,%b4\n\t"
- "je 1f\n\t"
- "movsw\n"
- "1:\ttestb $1,%b4\n\t"
- "je 2f\n\t"
- "movsb\n" "2:":"=&c"(d0), "=&D"(d1), "=&S"(d2)
- :"0"(n / 4), "q"(n), "1"((long) to), "2"((long) from)
- :"memory");
- return (to);
-}
-#else
-#define __memcpy(a,b,c) memcpy(a,b,c)
-#endif
-
-
-/**
- * The system memcpy (at least on ubuntu 5.10) has problems copying
- * to agp (writecombined) memory from a source which isn't 64-byte
- * aligned - there is a 4x performance falloff.
- *
- * The x86 __memcpy is immune to this but is slightly slower
- * (10%-ish) than the system memcpy.
- *
- * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
- * isn't much faster than x86_memcpy for agp copies.
- *
- * TODO: switch dynamically.
- */
-static void *
-do_memcpy(void *dest, const void *src, size_t n)
-{
- if ((((unsigned long) src) & 63) || (((unsigned long) dest) & 63)) {
- return __memcpy(dest, src, n);
- }
- else
- return memcpy(dest, src, n);
-}
-
-
-/**
* Return default texture resource binding bitmask for the given format.
*/
static GLuint
@@ -1420,11 +1370,13 @@ st_copy_texsubimage(struct gl_context *ctx,
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
enum pipe_format dest_format, src_format;
- GLboolean use_fallback = GL_TRUE;
GLboolean matching_base_formats;
GLuint format_writemask, sample_count;
struct pipe_surface *dest_surface = NULL;
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
+ struct pipe_surface surf_tmpl;
+ unsigned int dst_usage;
+ GLint srcY0, srcY1;
/* make sure finalize_textures has been called?
*/
@@ -1472,99 +1424,105 @@ st_copy_texsubimage(struct gl_context *ctx,
matching_base_formats =
(_mesa_get_format_base_format(strb->Base.Format) ==
_mesa_get_format_base_format(texImage->TexFormat));
- format_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
- if (ctx->_ImageTransferState == 0x0) {
+ if (ctx->_ImageTransferState) {
+ goto fallback;
+ }
+
+ if (matching_base_formats &&
+ src_format == dest_format &&
+ !do_flip) {
+ /* use surface_copy() / blit */
+ struct pipe_box src_box;
+ u_box_2d_zslice(srcX, srcY, strb->surface->u.tex.first_layer,
+ width, height, &src_box);
+
+ /* for resource_copy_region(), y=0=top, always */
+ pipe->resource_copy_region(pipe,
+ /* dest */
+ stImage->pt,
+ stImage->base.Level,
+ destX, destY, destZ + stImage->base.Face,
+ /* src */
+ strb->texture,
+ strb->surface->u.tex.level,
+ &src_box);
+ return;
+ }
- if (matching_base_formats &&
- src_format == dest_format &&
- !do_flip)
- {
- /* use surface_copy() / blit */
- struct pipe_box src_box;
- u_box_2d_zslice(srcX, srcY, strb->surface->u.tex.first_layer,
- width, height, &src_box);
-
- /* for resource_copy_region(), y=0=top, always */
- pipe->resource_copy_region(pipe,
- /* dest */
- stImage->pt,
- stImage->base.Level,
- destX, destY, destZ + stImage->base.Face,
- /* src */
- strb->texture,
- strb->surface->u.tex.level,
- &src_box);
- use_fallback = GL_FALSE;
- }
- else if (format_writemask &&
- texBaseFormat != GL_DEPTH_COMPONENT &&
- texBaseFormat != GL_DEPTH_STENCIL &&
- screen->is_format_supported(screen, src_format,
- PIPE_TEXTURE_2D, sample_count,
- PIPE_BIND_SAMPLER_VIEW) &&
- screen->is_format_supported(screen, dest_format,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_RENDER_TARGET)) {
- /* draw textured quad to do the copy */
- GLint srcY0, srcY1;
- struct pipe_surface surf_tmpl;
- memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = util_format_linear(stImage->pt->format);
- surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
- surf_tmpl.u.tex.level = stImage->base.Level;
- surf_tmpl.u.tex.first_layer = stImage->base.Face + destZ;
- surf_tmpl.u.tex.last_layer = stImage->base.Face + destZ;
-
- dest_surface = pipe->create_surface(pipe, stImage->pt,
- &surf_tmpl);
-
- if (do_flip) {
- srcY1 = strb->Base.Height - srcY - height;
- srcY0 = srcY1 + height;
- }
- else {
- srcY0 = srcY;
- srcY1 = srcY0 + height;
- }
+ if (texBaseFormat == GL_DEPTH_STENCIL) {
+ goto fallback;
+ }
- /* Disable conditional rendering. */
- if (st->render_condition) {
- pipe->render_condition(pipe, NULL, 0);
- }
+ if (texBaseFormat == GL_DEPTH_COMPONENT) {
+ format_writemask = TGSI_WRITEMASK_XYZW;
+ dst_usage = PIPE_BIND_DEPTH_STENCIL;
+ }
+ else {
+ format_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
+ dst_usage = PIPE_BIND_RENDER_TARGET;
+ }
- util_blit_pixels_writemask(st->blit,
- strb->texture,
- strb->surface->u.tex.level,
- srcX, srcY0,
- srcX + width, srcY1,
- strb->surface->u.tex.first_layer,
- dest_surface,
- destX, destY,
- destX + width, destY + height,
- 0.0, PIPE_TEX_MIPFILTER_NEAREST,
- format_writemask);
-
- /* Restore conditional rendering state. */
- if (st->render_condition) {
- pipe->render_condition(pipe, st->render_condition,
- st->condition_mode);
- }
+ if (!format_writemask ||
+ !screen->is_format_supported(screen, src_format,
+ PIPE_TEXTURE_2D, sample_count,
+ PIPE_BIND_SAMPLER_VIEW) ||
+ !screen->is_format_supported(screen, dest_format,
+ PIPE_TEXTURE_2D, 0,
+ dst_usage)) {
+ goto fallback;
+ }
- use_fallback = GL_FALSE;
- }
+ if (do_flip) {
+ srcY1 = strb->Base.Height - srcY - height;
+ srcY0 = srcY1 + height;
+ }
+ else {
+ srcY0 = srcY;
+ srcY1 = srcY0 + height;
+ }
+
+ /* Disable conditional rendering. */
+ if (st->render_condition) {
+ pipe->render_condition(pipe, NULL, 0);
+ }
+
+ memset(&surf_tmpl, 0, sizeof(surf_tmpl));
+ surf_tmpl.format = util_format_linear(stImage->pt->format);
+ surf_tmpl.usage = dst_usage;
+ surf_tmpl.u.tex.level = stImage->base.Level;
+ surf_tmpl.u.tex.first_layer = stImage->base.Face + destZ;
+ surf_tmpl.u.tex.last_layer = stImage->base.Face + destZ;
+
+ dest_surface = pipe->create_surface(pipe, stImage->pt,
+ &surf_tmpl);
+ util_blit_pixels_writemask(st->blit,
+ strb->texture,
+ strb->surface->u.tex.level,
+ srcX, srcY0,
+ srcX + width, srcY1,
+ strb->surface->u.tex.first_layer,
+ dest_surface,
+ destX, destY,
+ destX + width, destY + height,
+ 0.0, PIPE_TEX_MIPFILTER_NEAREST,
+ format_writemask);
+ pipe_surface_reference(&dest_surface, NULL);
- if (dest_surface)
- pipe_surface_reference(&dest_surface, NULL);
+ /* Restore conditional rendering state. */
+ if (st->render_condition) {
+ pipe->render_condition(pipe, st->render_condition,
+ st->condition_mode);
}
- if (use_fallback) {
+ return;
+
+fallback:
/* software fallback */
fallback_copy_texsubimage(ctx, target, level,
strb, stImage, texBaseFormat,
destX, destY, destZ,
srcX, srcY, width, height);
- }
}
@@ -1937,8 +1895,6 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->MapTextureImage = st_MapTextureImage;
functions->UnmapTextureImage = st_UnmapTextureImage;
- functions->TextureMemCpy = do_memcpy;
-
/* XXX Temporary until we can query pipe's texture sizes */
functions->TestProxyTexImage = _mesa_test_proxy_teximage;
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index a1817720d..dc1d33f1d 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -26,6 +26,7 @@
**************************************************************************/
#include "main/imports.h"
+#include "main/accum.h"
#include "main/context.h"
#include "main/samplerobj.h"
#include "main/shaderobj.h"
@@ -34,7 +35,6 @@
#include "glapi/glapi.h"
#include "st_context.h"
#include "st_debug.h"
-#include "st_cb_accum.h"
#include "st_cb_bitmap.h"
#include "st_cb_blit.h"
#include "st_cb_bufferobjects.h"
@@ -276,7 +276,8 @@ void st_init_driver_functions(struct dd_function_table *functions)
_mesa_init_shader_object_functions(functions);
_mesa_init_sampler_object_functions(functions);
- st_init_accum_functions(functions);
+ functions->Accum = _mesa_accum;
+
st_init_blit_functions(functions);
st_init_bufferobject_functions(functions);
st_init_clear_functions(functions);
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 37fb3e7fd..9e39729e9 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -210,12 +210,10 @@ void st_init_limits(struct st_context *st)
options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
}
- /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
- * and is set in MaxNativeAttribs. It's always 2 colors + N generic
- * attributes. The GLSL compiler never uses COLORn for varyings, so we
- * subtract the 2 colors to get the maximum number of varyings (generic
- * attributes) supported by a driver. */
- c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2;
+ /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
+ * of inputs. It's always 2 colors + N generic inputs. */
+ c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_MAX_INPUTS);
c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
c->MinProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET);
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 59b5ffd4c..6cc655d70 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3514,25 +3514,23 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
break;
case TGSI_OPCODE_ENDIF:
- --level;
- break;
-
case TGSI_OPCODE_ELSE:
- /* Clear all channels written inside the preceding if block from the
- * write array, but leave those that were not touched.
- *
- * FIXME: This destroys opportunities to remove dead code inside of
- * IF blocks that are followed by an ELSE block.
+ /* Promote the recorded level all channels written inside the preceding
+ * if or else block to the level above the if/else block.
*/
for (int r = 0; r < this->next_temp; r++) {
for (int c = 0; c < 4; c++) {
if (!writes[4 * r + c])
continue;
- if (write_level[4 * r + c] >= level)
- writes[4 * r + c] = NULL;
+ if (write_level[4 * r + c] == level)
+ write_level[4 * r + c] = level-1;
}
}
+
+ if(inst->op == TGSI_OPCODE_ENDIF)
+ --level;
+
break;
case TGSI_OPCODE_IF:
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index d5228d387..55699e721 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -404,54 +404,6 @@ st_visual_to_context_mode(const struct st_visual *visual,
}
/**
- * Determine the default draw or read buffer from a visual.
- */
-static void
-st_visual_to_default_buffer(const struct st_visual *visual,
- GLenum *buffer, GLint *index)
-{
- enum st_attachment_type statt;
- GLenum buf;
- gl_buffer_index idx;
-
- statt = visual->render_buffer;
- /* do nothing if an invalid render buffer is specified */
- if (statt == ST_ATTACHMENT_INVALID ||
- !st_visual_have_buffers(visual, 1 << statt))
- return;
-
- switch (statt) {
- case ST_ATTACHMENT_FRONT_LEFT:
- buf = GL_FRONT_LEFT;
- idx = BUFFER_FRONT_LEFT;
- break;
- case ST_ATTACHMENT_BACK_LEFT:
- buf = GL_BACK_LEFT;
- idx = BUFFER_BACK_LEFT;
- break;
- case ST_ATTACHMENT_FRONT_RIGHT:
- buf = GL_FRONT_RIGHT;
- idx = BUFFER_FRONT_RIGHT;
- break;
- case ST_ATTACHMENT_BACK_RIGHT:
- buf = GL_BACK_RIGHT;
- idx = BUFFER_BACK_RIGHT;
- break;
- default:
- buf = GL_NONE;
- idx = BUFFER_COUNT;
- break;
- }
-
- if (buf != GL_NONE) {
- if (buffer)
- *buffer = buf;
- if (index)
- *index = idx;
- }
-}
-
-/**
* Create a framebuffer from a manager interface.
*/
static struct st_framebuffer *
@@ -471,12 +423,6 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
st_visual_to_context_mode(stfbi->visual, &mode);
_mesa_initialize_window_framebuffer(&stfb->Base, &mode);
- /* modify the draw/read buffers of the fb */
- st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorDrawBuffer[0],
- &stfb->Base._ColorDrawBufferIndexes[0]);
- st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorReadBuffer,
- &stfb->Base._ColorReadBufferIndex);
-
stfb->iface = stfbi;
stfb->iface_stamp = p_atomic_read(&stfbi->stamp) - 1;
@@ -776,16 +722,6 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
if (stread != stdraw)
st_framebuffer_validate(stread, st);
- /* modify the draw/read buffers of the context */
- if (stdraw->iface) {
- st_visual_to_default_buffer(stdraw->iface->visual,
- &st->ctx->Color.DrawBuffer[0], NULL);
- }
- if (stread->iface) {
- st_visual_to_default_buffer(stread->iface->visual,
- &st->ctx->Pixel.ReadBuffer, NULL);
- }
-
ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
st->draw_stamp = stdraw->stamp - 1;
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 768da5114..04d3ef60f 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -649,6 +649,25 @@ st_translate_fragment_program(struct st_context *st,
if (write_all == GL_TRUE)
ureg_property_fs_color0_writes_all_cbufs(ureg, 1);
+ if (stfp->Base.FragDepthLayout != FRAG_DEPTH_LAYOUT_NONE) {
+ switch (stfp->Base.FragDepthLayout) {
+ case FRAG_DEPTH_LAYOUT_ANY:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_ANY);
+ break;
+ case FRAG_DEPTH_LAYOUT_GREATER:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_GREATER);
+ break;
+ case FRAG_DEPTH_LAYOUT_LESS:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_LESS);
+ break;
+ case FRAG_DEPTH_LAYOUT_UNCHANGED:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_UNCHANGED);
+ break;
+ default:
+ assert(0);
+ }
+ }
+
if (stfp->glsl_to_tgsi)
st_translate_program(st->ctx,
TGSI_PROCESSOR_FRAGMENT,
diff --git a/mesalib/src/mesa/swrast/s_accum.c b/mesalib/src/mesa/swrast/s_accum.c
deleted file mode 100644
index 0ec907d79..000000000
--- a/mesalib/src/mesa/swrast/s_accum.c
+++ /dev/null
@@ -1,598 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.2
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#include "main/glheader.h"
-#include "main/condrender.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/imports.h"
-
-#include "s_accum.h"
-#include "s_context.h"
-#include "s_masking.h"
-#include "s_span.h"
-
-
-/* XXX this would have to change for accum buffers with more or less
- * than 16 bits per color channel.
- */
-#define ACCUM_SCALE16 32767.0F
-
-
-/*
- * Accumulation buffer notes
- *
- * Normally, accumulation buffer values are GLshorts with values in
- * [-32767, 32767] which represent floating point colors in [-1, 1],
- * as defined by the OpenGL specification.
- *
- * We optimize for the common case used for full-scene antialiasing:
- * // start with accum buffer cleared to zero
- * glAccum(GL_LOAD, w); // or GL_ACCUM the first image
- * glAccum(GL_ACCUM, w);
- * ...
- * glAccum(GL_ACCUM, w);
- * glAccum(GL_RETURN, 1.0);
- * That is, we start with an empty accumulation buffer and accumulate
- * n images, each with weight w = 1/n.
- * In this scenario, we can simply store unscaled integer values in
- * the accum buffer instead of scaled integers. We'll also keep track
- * of the w value so when we do GL_RETURN we simply divide the accumulated
- * values by n (n=1/w).
- * This lets us avoid _many_ int->float->int conversions.
- */
-
-
-#if CHAN_BITS == 8
-/* enable the optimization */
-#define USE_OPTIMIZED_ACCUM 1
-#else
-#define USE_OPTIMIZED_ACCUM 0
-#endif
-
-
-/**
- * This is called when we fall out of optimized/unscaled accum buffer mode.
- * That is, we convert each unscaled accum buffer value into a scaled value
- * representing the range[-1, 1].
- */
-static void
-rescale_accum( struct gl_context *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- struct gl_renderbuffer *rb
- = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
- const GLfloat s = swrast->_IntegerAccumScaler * (32767.0F / CHAN_MAXF);
-
- assert(rb);
- assert(rb->_BaseFormat == GL_RGBA);
- /* add other types in future? */
- assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
- assert(swrast->_IntegerAccumMode);
-
- if (rb->GetPointer(ctx, rb, 0, 0)) {
- /* directly-addressable memory */
- GLuint y;
- for (y = 0; y < rb->Height; y++) {
- GLuint i;
- GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, 0, y);
- for (i = 0; i < 4 * rb->Width; i++) {
- acc[i] = (GLshort) (acc[i] * s);
- }
- }
- }
- else {
- /* use get/put row funcs */
- GLuint y;
- for (y = 0; y < rb->Height; y++) {
- GLshort accRow[MAX_WIDTH * 4];
- GLuint i;
- rb->GetRow(ctx, rb, rb->Width, 0, y, accRow);
- for (i = 0; i < 4 * rb->Width; i++) {
- accRow[i] = (GLshort) (accRow[i] * s);
- }
- rb->PutRow(ctx, rb, rb->Width, 0, y, accRow, NULL);
- }
- }
-
- swrast->_IntegerAccumMode = GL_FALSE;
-}
-
-
-
-/**
- * Clear the accumulation Buffer.
- */
-void
-_swrast_clear_accum_buffer( struct gl_context *ctx, struct gl_renderbuffer *rb )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint x, y, width, height;
-
- /* No accumulation buffer! Not an error. */
- if (!rb || !rb->Data)
- return;
-
- assert(rb->_BaseFormat == GL_RGBA);
- /* add other types in future? */
- assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
-
- /* bounds, with scissor */
- x = ctx->DrawBuffer->_Xmin;
- y = ctx->DrawBuffer->_Ymin;
- width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
-
- if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
- const GLfloat accScale = 32767.0;
- GLshort clearVal[4];
- GLuint i;
-
- clearVal[0] = (GLshort) (ctx->Accum.ClearColor[0] * accScale);
- clearVal[1] = (GLshort) (ctx->Accum.ClearColor[1] * accScale);
- clearVal[2] = (GLshort) (ctx->Accum.ClearColor[2] * accScale);
- clearVal[3] = (GLshort) (ctx->Accum.ClearColor[3] * accScale);
-
- for (i = 0; i < height; i++) {
- rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
- }
- }
- else {
- /* someday support other sizes */
- }
-
- /* update optimized accum state vars */
- if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
- ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
-#if USE_OPTIMIZED_ACCUM
- swrast->_IntegerAccumMode = GL_TRUE;
-#else
- swrast->_IntegerAccumMode = GL_FALSE;
-#endif
- swrast->_IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
- }
- else {
- swrast->_IntegerAccumMode = GL_FALSE;
- }
-}
-
-
-static void
-accum_add(struct gl_context *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- struct gl_renderbuffer *rb
- = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
-
- assert(rb);
-
- /* Leave optimized accum buffer mode */
- if (swrast->_IntegerAccumMode)
- rescale_accum(ctx);
-
- if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
- const GLshort incr = (GLshort) (value * ACCUM_SCALE16);
- if (rb->GetPointer(ctx, rb, 0, 0)) {
- GLint i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
- for (j = 0; j < 4 * width; j++) {
- acc[j] += incr;
- }
- }
- }
- else {
- GLint i, j;
- for (i = 0; i < height; i++) {
- GLshort accRow[4 * MAX_WIDTH];
- rb->GetRow(ctx, rb, width, xpos, ypos + i, accRow);
- for (j = 0; j < 4 * width; j++) {
- accRow[j] += incr;
- }
- rb->PutRow(ctx, rb, width, xpos, ypos + i, accRow, NULL);
- }
- }
- }
- else {
- /* other types someday */
- }
-}
-
-
-static void
-accum_mult(struct gl_context *ctx, GLfloat mult,
- GLint xpos, GLint ypos, GLint width, GLint height )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- struct gl_renderbuffer *rb
- = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
-
- assert(rb);
-
- /* Leave optimized accum buffer mode */
- if (swrast->_IntegerAccumMode)
- rescale_accum(ctx);
-
- if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
- if (rb->GetPointer(ctx, rb, 0, 0)) {
- GLint i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
- for (j = 0; j < 4 * width; j++) {
- acc[j] = (GLshort) (acc[j] * mult);
- }
- }
- }
- else {
- GLint i, j;
- for (i = 0; i < height; i++) {
- GLshort accRow[4 * MAX_WIDTH];
- rb->GetRow(ctx, rb, width, xpos, ypos + i, accRow);
- for (j = 0; j < 4 * width; j++) {
- accRow[j] = (GLshort) (accRow[j] * mult);
- }
- rb->PutRow(ctx, rb, width, xpos, ypos + i, accRow, NULL);
- }
- }
- }
- else {
- /* other types someday */
- }
-}
-
-
-
-static void
-accum_accum(struct gl_context *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- struct gl_renderbuffer *rb
- = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
- const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
-
- assert(rb);
-
- if (!ctx->ReadBuffer->_ColorReadBuffer) {
- /* no read buffer - OK */
- return;
- }
-
- /* May have to leave optimized accum buffer mode */
- if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
- swrast->_IntegerAccumScaler = value;
- if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
- rescale_accum(ctx);
-
- if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
- const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
- GLshort accumRow[4 * MAX_WIDTH];
- GLchan rgba[MAX_WIDTH][4];
- GLint i;
-
- for (i = 0; i < height; i++) {
- GLshort *acc;
- if (directAccess) {
- acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
- }
- else {
- rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
- acc = accumRow;
- }
-
- /* read colors from color buffer */
- _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
- xpos, ypos + i, CHAN_TYPE, rgba);
-
- /* do accumulation */
- if (swrast->_IntegerAccumMode) {
- /* simply add integer color values into accum buffer */
- GLint j;
- for (j = 0; j < width; j++) {
- acc[j * 4 + 0] += rgba[j][RCOMP];
- acc[j * 4 + 1] += rgba[j][GCOMP];
- acc[j * 4 + 2] += rgba[j][BCOMP];
- acc[j * 4 + 3] += rgba[j][ACOMP];
- }
- }
- else {
- /* scaled integer (or float) accum buffer */
- GLint j;
- for (j = 0; j < width; j++) {
- acc[j * 4 + 0] += (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
- acc[j * 4 + 1] += (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
- acc[j * 4 + 2] += (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
- acc[j * 4 + 3] += (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
- }
- }
-
- if (!directAccess) {
- rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
- }
- }
- }
- else {
- /* other types someday */
- }
-}
-
-
-
-static void
-accum_load(struct gl_context *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- struct gl_renderbuffer *rb
- = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
- const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
-
- assert(rb);
-
- if (!ctx->ReadBuffer->_ColorReadBuffer) {
- /* no read buffer - OK */
- return;
- }
-
- /* This is a change to go into optimized accum buffer mode */
- if (value > 0.0 && value <= 1.0) {
-#if USE_OPTIMIZED_ACCUM
- swrast->_IntegerAccumMode = GL_TRUE;
-#else
- swrast->_IntegerAccumMode = GL_FALSE;
-#endif
- swrast->_IntegerAccumScaler = value;
- }
- else {
- swrast->_IntegerAccumMode = GL_FALSE;
- swrast->_IntegerAccumScaler = 0.0;
- }
-
- if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
- const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
- GLshort accumRow[4 * MAX_WIDTH];
- GLchan rgba[MAX_WIDTH][4];
- GLint i;
-
- for (i = 0; i < height; i++) {
- GLshort *acc;
- if (directAccess) {
- acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
- }
- else {
- rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
- acc = accumRow;
- }
-
- /* read colors from color buffer */
- _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
- xpos, ypos + i, CHAN_TYPE, rgba);
-
- /* do load */
- if (swrast->_IntegerAccumMode) {
- /* just copy values in */
- GLint j;
- assert(swrast->_IntegerAccumScaler > 0.0);
- assert(swrast->_IntegerAccumScaler <= 1.0);
- for (j = 0; j < width; j++) {
- acc[j * 4 + 0] = rgba[j][RCOMP];
- acc[j * 4 + 1] = rgba[j][GCOMP];
- acc[j * 4 + 2] = rgba[j][BCOMP];
- acc[j * 4 + 3] = rgba[j][ACOMP];
- }
- }
- else {
- /* scaled integer (or float) accum buffer */
- GLint j;
- for (j = 0; j < width; j++) {
- acc[j * 4 + 0] = (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
- acc[j * 4 + 1] = (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
- acc[j * 4 + 2] = (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
- acc[j * 4 + 3] = (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
- }
- }
-
- if (!directAccess) {
- rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
- }
- }
- }
-}
-
-
-static void
-accum_return(struct gl_context *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- struct gl_framebuffer *fb = ctx->DrawBuffer;
- struct gl_renderbuffer *accumRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer;
- const GLboolean directAccess
- = (accumRb->GetPointer(ctx, accumRb, 0, 0) != NULL);
-
- static GLchan multTable[32768];
- static GLfloat prevMult = 0.0;
- const GLfloat mult = swrast->_IntegerAccumScaler;
- const GLint max = MIN2((GLint) (256 / mult), 32767);
-
- /* May have to leave optimized accum buffer mode */
- if (swrast->_IntegerAccumMode && value != 1.0)
- rescale_accum(ctx);
-
- if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
- /* build lookup table to avoid many floating point multiplies */
- GLint j;
- assert(swrast->_IntegerAccumScaler <= 1.0);
- if (mult != prevMult) {
- for (j = 0; j < max; j++)
- multTable[j] = IROUND((GLfloat) j * mult);
- prevMult = mult;
- }
- }
-
- if (accumRb->DataType == GL_SHORT ||
- accumRb->DataType == GL_UNSIGNED_SHORT) {
- const GLfloat scale = value * CHAN_MAXF / ACCUM_SCALE16;
- GLuint buffer;
- GLint i;
-
- /* XXX maybe transpose the 'i' and 'buffer' loops??? */
- for (i = 0; i < height; i++) {
- GLshort accumRow[4 * MAX_WIDTH];
- GLshort *acc;
- SWspan span;
-
- /* init color span */
- INIT_SPAN(span, GL_BITMAP);
- span.end = width;
- span.arrayMask = SPAN_RGBA;
- span.x = xpos;
- span.y = ypos + i;
-
- if (directAccess) {
- acc = (GLshort *) accumRb->GetPointer(ctx, accumRb, xpos, ypos +i);
- }
- else {
- accumRb->GetRow(ctx, accumRb, width, xpos, ypos + i, accumRow);
- acc = accumRow;
- }
-
- /* get the colors to return */
- if (swrast->_IntegerAccumMode) {
- GLint j;
- for (j = 0; j < width; j++) {
- ASSERT(acc[j * 4 + 0] < max);
- ASSERT(acc[j * 4 + 1] < max);
- ASSERT(acc[j * 4 + 2] < max);
- ASSERT(acc[j * 4 + 3] < max);
- span.array->rgba[j][RCOMP] = multTable[acc[j * 4 + 0]];
- span.array->rgba[j][GCOMP] = multTable[acc[j * 4 + 1]];
- span.array->rgba[j][BCOMP] = multTable[acc[j * 4 + 2]];
- span.array->rgba[j][ACOMP] = multTable[acc[j * 4 + 3]];
- }
- }
- else {
- /* scaled integer (or float) accum buffer */
- GLint j;
- for (j = 0; j < width; j++) {
-#if CHAN_BITS==32
- GLchan r = acc[j * 4 + 0] * scale;
- GLchan g = acc[j * 4 + 1] * scale;
- GLchan b = acc[j * 4 + 2] * scale;
- GLchan a = acc[j * 4 + 3] * scale;
-#else
- GLint r = IROUND( (GLfloat) (acc[j * 4 + 0]) * scale );
- GLint g = IROUND( (GLfloat) (acc[j * 4 + 1]) * scale );
- GLint b = IROUND( (GLfloat) (acc[j * 4 + 2]) * scale );
- GLint a = IROUND( (GLfloat) (acc[j * 4 + 3]) * scale );
-#endif
- span.array->rgba[j][RCOMP] = CLAMP( r, 0, CHAN_MAX );
- span.array->rgba[j][GCOMP] = CLAMP( g, 0, CHAN_MAX );
- span.array->rgba[j][BCOMP] = CLAMP( b, 0, CHAN_MAX );
- span.array->rgba[j][ACOMP] = CLAMP( a, 0, CHAN_MAX );
- }
- }
-
- /* store colors */
- for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) {
- struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer];
- const GLboolean masking = (!ctx->Color.ColorMask[buffer][RCOMP] ||
- !ctx->Color.ColorMask[buffer][GCOMP] ||
- !ctx->Color.ColorMask[buffer][BCOMP] ||
- !ctx->Color.ColorMask[buffer][ACOMP]);
- if (masking) {
- _swrast_mask_rgba_span(ctx, rb, &span, buffer);
- }
- rb->PutRow(ctx, rb, width, xpos, ypos + i, span.array->rgba, NULL);
- }
- }
- }
- else {
- /* other types someday */
- }
-}
-
-
-
-/**
- * Software fallback for glAccum.
- */
-void
-_swrast_Accum(struct gl_context *ctx, GLenum op, GLfloat value)
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLint xpos, ypos, width, height;
-
- if (swrast->NewState)
- _swrast_validate_derived( ctx );
-
- if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) {
- _mesa_warning(ctx, "Calling glAccum() without an accumulation buffer");
- return;
- }
-
- if (!_mesa_check_conditional_render(ctx))
- return;
-
- swrast_render_start(ctx);
-
- /* Compute region after calling swrast_render_start() so that we know the
- * drawbuffer's size/bounds are up to date.
- */
- xpos = ctx->DrawBuffer->_Xmin;
- ypos = ctx->DrawBuffer->_Ymin;
- width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
-
- switch (op) {
- case GL_ADD:
- if (value != 0.0F) {
- accum_add(ctx, value, xpos, ypos, width, height);
- }
- break;
- case GL_MULT:
- if (value != 1.0F) {
- accum_mult(ctx, value, xpos, ypos, width, height);
- }
- break;
- case GL_ACCUM:
- if (value != 0.0F) {
- accum_accum(ctx, value, xpos, ypos, width, height);
- }
- break;
- case GL_LOAD:
- accum_load(ctx, value, xpos, ypos, width, height);
- break;
- case GL_RETURN:
- accum_return(ctx, value, xpos, ypos, width, height);
- break;
- default:
- _mesa_problem(ctx, "invalid mode in _swrast_Accum()");
- break;
- }
-
- swrast_render_finish(ctx);
-}
diff --git a/mesalib/src/mesa/swrast/s_clear.c b/mesalib/src/mesa/swrast/s_clear.c
index 980d29bba..615747d69 100644
--- a/mesalib/src/mesa/swrast/s_clear.c
+++ b/mesalib/src/mesa/swrast/s_clear.c
@@ -23,13 +23,13 @@
*/
#include "main/glheader.h"
+#include "main/accum.h"
#include "main/colormac.h"
#include "main/condrender.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/mtypes.h"
-#include "s_accum.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_masking.h"
@@ -225,8 +225,7 @@ _swrast_Clear(struct gl_context *ctx, GLbitfield buffers)
_swrast_clear_depth_buffer(ctx, ctx->DrawBuffer->_DepthBuffer);
}
if (buffers & BUFFER_BIT_ACCUM) {
- _swrast_clear_accum_buffer(ctx,
- ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
+ _mesa_clear_accum_buffer(ctx);
}
if (buffers & BUFFER_BIT_STENCIL) {
_swrast_clear_stencil_buffer(ctx, ctx->DrawBuffer->_StencilBuffer);
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index 98702f068..924612578 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -597,7 +597,7 @@ _swrast_validate_derived( struct gl_context *ctx )
#define SWRAST_DEBUG 0
-/* Public entrypoints: See also s_accum.c, s_bitmap.c, etc.
+/* Public entrypoints: See also s_bitmap.c, etc.
*/
void
_swrast_Quad( struct gl_context *ctx,
@@ -755,10 +755,6 @@ _swrast_CreateContext( struct gl_context *ctx )
ctx->Driver.MapTexture = _swrast_map_texture;
ctx->Driver.UnmapTexture = _swrast_unmap_texture;
- /* Optimized Accum buffer */
- swrast->_IntegerAccumMode = GL_FALSE;
- swrast->_IntegerAccumScaler = 0.0;
-
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
swrast->TextureSample[i] = NULL;
diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h
index d3ba37819..446b990d9 100644
--- a/mesalib/src/mesa/swrast/s_context.h
+++ b/mesalib/src/mesa/swrast/s_context.h
@@ -203,11 +203,6 @@ typedef struct
/** Indicates how each attrib is to be interpolated (lines/tris) */
GLenum _InterpMode[FRAG_ATTRIB_MAX]; /* GL_FLAT or GL_SMOOTH (for now) */
- /* Accum buffer temporaries.
- */
- GLboolean _IntegerAccumMode; /**< Storing unscaled integers? */
- GLfloat _IntegerAccumScaler; /**< Implicit scale factor */
-
/* Working values:
*/
GLuint StippleCounter; /**< Line stipple counter */
diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c
index 3ba31f22c..3bdf48b25 100644
--- a/mesalib/src/mesa/swrast/s_copypix.c
+++ b/mesalib/src/mesa/swrast/s_copypix.c
@@ -610,6 +610,7 @@ fast_copy_pixels(struct gl_context *ctx,
struct gl_framebuffer *dstFb = ctx->DrawBuffer;
struct gl_renderbuffer *srcRb, *dstRb;
GLint row, yStep;
+ void *temp;
if (SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 ||
ctx->Pixel.ZoomX != 1.0F ||
@@ -667,14 +668,21 @@ fast_copy_pixels(struct gl_context *ctx,
yStep = 1;
}
+ temp = malloc(width * MAX_PIXEL_BYTES);
+ if (!temp) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
+ return GL_FALSE;
+ }
+
for (row = 0; row < height; row++) {
- GLuint temp[MAX_WIDTH][4];
srcRb->GetRow(ctx, srcRb, width, srcX, srcY, temp);
dstRb->PutRow(ctx, dstRb, width, dstX, dstY, temp, NULL);
srcY += yStep;
dstY += yStep;
}
+ free(temp);
+
return GL_TRUE;
}
diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c
new file mode 100644
index 000000000..7622e38fd
--- /dev/null
+++ b/mesalib/src/mesa/swrast/s_renderbuffer.c
@@ -0,0 +1,2034 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * Functions for allocating/managing software-based renderbuffers.
+ * Also, routines for reading/writing software-based renderbuffer data as
+ * ubytes, ushorts, uints, etc.
+ */
+
+
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/fbobject.h"
+#include "main/formats.h"
+#include "main/mtypes.h"
+#include "main/renderbuffer.h"
+#include "swrast/s_renderbuffer.h"
+
+
+/*
+ * Routines for get/put values in common buffer formats follow.
+ */
+
+/* Returns a bytes per pixel of the DataType in the get/put span
+ * functions for at least a subset of the available combinations a
+ * renderbuffer can have.
+ *
+ * It would be nice to see gl_renderbuffer start talking about a
+ * gl_format instead of a GLenum DataType.
+ */
+static int
+get_datatype_bytes(struct gl_renderbuffer *rb)
+{
+ int component_size;
+
+ switch (rb->DataType) {
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ component_size = 8;
+ break;
+ case GL_FLOAT:
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_INT_24_8_EXT:
+ component_size = 4;
+ break;
+ case GL_UNSIGNED_SHORT:
+ component_size = 2;
+ break;
+ case GL_UNSIGNED_BYTE:
+ component_size = 1;
+ break;
+ default:
+ component_size = 1;
+ assert(0);
+ }
+
+ switch (rb->_BaseFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL:
+ return component_size;
+ default:
+ return 4 * component_size;
+ }
+}
+
+/* This is commonly used by most of the accessors. */
+static void *
+get_pointer_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+
+ return ((char *) rb->Data +
+ (y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format));
+}
+
+/* GetRow() implementation for formats where DataType matches the rb->Format.
+ */
+static void
+get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
+{
+ void *src = rb->GetPointer(ctx, rb, x, y);
+ memcpy(values, src, count * _mesa_get_format_bytes(rb->Format));
+}
+
+/* Only used for float textures currently, but might also be used for
+ * RGBA8888, RGBA16, etc.
+ */
+static void
+get_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[], void *values)
+{
+ int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const void *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ char *dst = (char *) values + i * format_bytes;
+ memcpy(dst, src, format_bytes);
+ }
+}
+
+/* For the GL_RED/GL_RG/GL_RGB format/DataType combinations (and
+ * GL_LUMINANCE/GL_INTENSITY?), the Put functions are a matter of
+ * storing those initial components of the value per pixel into the
+ * destination.
+ */
+static void
+put_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *values, const GLubyte *mask)
+{
+ void *row = rb->GetPointer(ctx, rb, x, y);
+ int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
+ int datatype_bytes = get_datatype_bytes(rb);
+ unsigned int i;
+
+ if (mask) {
+ for (i = 0; i < count; i++) {
+ char *dst = (char *) row + i * format_bytes;
+ const char *src = (const char *) values + i * datatype_bytes;
+
+ if (mask[i]) {
+ memcpy(dst, src, format_bytes);
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ char *dst = (char *) row + i * format_bytes;
+ const char *src = (const char *) values + i * datatype_bytes;
+ memcpy(dst, src, format_bytes);
+ }
+ }
+}
+
+static void
+put_mono_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *value, const GLubyte *mask)
+{
+ void *row = rb->GetPointer(ctx, rb, x, y);
+ int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
+ unsigned int i;
+
+ if (mask) {
+ for (i = 0; i < count; i++) {
+ char *dst = (char *) row + i * format_bytes;
+ if (mask[i]) {
+ memcpy(dst, value, format_bytes);
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ char *dst = (char *) row + i * format_bytes;
+ memcpy(dst, value, format_bytes);
+ }
+ }
+}
+
+
+static void
+put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
+ int datatype_bytes = get_datatype_bytes(rb);
+ unsigned int i;
+
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ void *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
+ const char *src = (const char *) values + i * datatype_bytes;
+ memcpy(dst, src, format_bytes);
+ }
+ }
+}
+
+
+static void
+put_mono_values_generic(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
+ unsigned int i;
+
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ void *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
+ memcpy(dst, value, format_bytes);
+ }
+ }
+}
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLubyte values.
+ * Typically stencil.
+ */
+
+static void
+get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ memcpy(dst, values, count * sizeof(GLubyte));
+ }
+}
+
+
+static void
+put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLubyte val = *((const GLubyte *) value);
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLubyte val = *((const GLubyte *) value);
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLushort values.
+ * Typically depth/Z.
+ */
+
+static void
+get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = (GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ const GLushort *src = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ memcpy(dst, src, count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLushort val = *((const GLushort *) value);
+ GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLushort val = *((const GLushort *) value);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLuint values.
+ * Typically depth/Z or color index.
+ */
+
+static void
+get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT ||
+ rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ for (i = 0; i < count; i++) {
+ const GLuint *src = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLuint *src = (const GLuint *) values;
+ GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT ||
+ rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ memcpy(dst, src, count * sizeof(GLuint));
+ }
+}
+
+
+static void
+put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLuint val = *((const GLuint *) value);
+ GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT ||
+ rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLuint *src = (const GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT ||
+ rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *value,
+ const GLubyte *mask)
+{
+ const GLuint val = *((const GLuint *) value);
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT ||
+ rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 3 X GLubyte (or GLbyte) values.
+ * Typically color buffers.
+ * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming
+ * alpha values and return 255 for outgoing alpha values.
+ */
+
+static void *
+get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ /* No direct access since this buffer is RGB but caller will be
+ * treating it as if it were RGBA.
+ */
+ return NULL;
+}
+
+
+static void
+get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLubyte *src = ((const GLubyte *) rb->Data) +
+ 3 * (y * rb->RowStride + x);
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 255;
+ }
+}
+
+
+static void
+get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLubyte *src
+ = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]);
+ dst[i * 4 + 0] = src[0];
+ dst[i * 4 + 1] = src[1];
+ dst[i * 4 + 2] = src[2];
+ dst[i * 4 + 3] = 255;
+ }
+}
+
+
+static void
+put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
+ GLuint i;
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = src[i * 4 + 0];
+ dst[i * 3 + 1] = src[i * 4 + 1];
+ dst[i * 3 + 2] = src[i * 4 + 2];
+ }
+ }
+}
+
+
+static void
+put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
+ GLuint i;
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = src[i * 3 + 0];
+ dst[i * 3 + 1] = src[i * 3 + 1];
+ dst[i * 3 + 2] = src[i * 3 + 2];
+ }
+ }
+}
+
+
+static void
+put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ /* note: incoming value is RGB+A! */
+ const GLubyte val0 = ((const GLubyte *) value)[0];
+ const GLubyte val1 = ((const GLubyte *) value)[1];
+ const GLubyte val2 = ((const GLubyte *) value)[2];
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ if (!mask && val0 == val1 && val1 == val2) {
+ /* optimized case */
+ memset(dst, val0, 3 * count);
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = val0;
+ dst[i * 3 + 1] = val1;
+ dst[i * 3 + 2] = val2;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]);
+ dst[0] = src[i * 4 + 0];
+ dst[1] = src[i * 4 + 1];
+ dst[2] = src[i * 4 + 2];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ /* note: incoming value is RGB+A! */
+ const GLubyte val0 = ((const GLubyte *) value)[0];
+ const GLubyte val1 = ((const GLubyte *) value)[1];
+ const GLubyte val2 = ((const GLubyte *) value)[2];
+ GLuint i;
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = ((GLubyte *) rb->Data) +
+ 3 * (y[i] * rb->RowStride + x[i]);
+ dst[0] = val0;
+ dst[1] = val1;
+ dst[2] = val2;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 4 X GLubyte (or GLbyte) values.
+ * Typically color buffers.
+ */
+
+static void
+get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
+ rb->Format == MESA_FORMAT_RGBA8888_REV);
+ for (i = 0; i < count; i++) {
+ const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint *src = (const GLuint *) values;
+ GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
+ rb->Format == MESA_FORMAT_RGBA8888_REV);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ memcpy(dst, src, 4 * count * sizeof(GLubyte));
+ }
+}
+
+
+static void
+put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* Store RGB values in RGBA buffer */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->RowStride + x);
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
+ rb->Format == MESA_FORMAT_RGBA8888_REV);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 0xff;
+ }
+ }
+}
+
+
+static void
+put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint val = *((const GLuint *) value);
+ GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
+ rb->Format == MESA_FORMAT_RGBA8888_REV);
+ if (!mask && val == 0) {
+ /* common case */
+ memset(dst, 0, count * 4 * sizeof(GLubyte));
+ }
+ else {
+ /* general case */
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint *src = (const GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
+ rb->Format == MESA_FORMAT_RGBA8888_REV);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint val = *((const GLuint *) value);
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
+ rb->Format == MESA_FORMAT_RGBA8888_REV);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 4 X GLushort (or GLshort) values.
+ * Typically accum buffer.
+ */
+
+static void
+get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = (GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ const GLushort *src
+ = (GLushort *) rb->Data + 4 * (y[i] * rb->RowStride + x[i]);
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i * 4 + 0] = src[i * 4 + 0];
+ dst[i * 4 + 1] = src[i * 4 + 1];
+ dst[i * 4 + 2] = src[i * 4 + 2];
+ dst[i * 4 + 3] = src[i * 4 + 3];
+ }
+ }
+ }
+ else {
+ memcpy(dst, src, 4 * count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* Put RGB values in RGBA buffer */
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 0xffff;
+ }
+ }
+ }
+ else {
+ memcpy(dst, src, 4 * count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLushort val0 = ((const GLushort *) value)[0];
+ const GLushort val1 = ((const GLushort *) value)[1];
+ const GLushort val2 = ((const GLushort *) value)[2];
+ const GLushort val3 = ((const GLushort *) value)[3];
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) {
+ /* common case for clearing accum buffer */
+ memset(dst, 0, count * 4 * sizeof(GLushort));
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 4 + 0] = val0;
+ dst[i * 4 + 1] = val1;
+ dst[i * 4 + 2] = val2;
+ dst[i * 4 + 3] = val3;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst =
+ ((GLushort *) rb->Data) + 4 * (y[i] * rb->RowStride + x[i]);
+ dst[0] = src[i * 4 + 0];
+ dst[1] = src[i * 4 + 1];
+ dst[2] = src[i * 4 + 2];
+ dst[3] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLushort val0 = ((const GLushort *) value)[0];
+ const GLushort val1 = ((const GLushort *) value)[1];
+ const GLushort val2 = ((const GLushort *) value)[2];
+ const GLushort val3 = ((const GLushort *) value)[3];
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = ((GLushort *) rb->Data) +
+ 4 * (y[i] * rb->RowStride + x[i]);
+ dst[0] = val0;
+ dst[1] = val1;
+ dst[2] = val2;
+ dst[3] = val3;
+ }
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_R8.
+ */
+static void
+get_row_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLubyte *src = rb->GetPointer(ctx, rb, x, y);
+ GLuint *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i] = 0xff000000 | src[i];
+ }
+}
+
+static void
+get_values_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLubyte *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i] = 0xff000000 | *src;
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_GR88.
+ */
+static void
+get_row_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLushort *src = rb->GetPointer(ctx, rb, x, y);
+ GLuint *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i] = 0xff000000 | src[i];
+ }
+}
+
+static void
+get_values_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[], void *values)
+{
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i] = 0xff000000 | *src;
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_R16.
+ */
+static void
+get_row_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLushort *src = rb->GetPointer(ctx, rb, x, y);
+ GLushort *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] = src[i];
+ dst[i * 4 + GCOMP] = 0;
+ dst[i * 4 + BCOMP] = 0;
+ dst[i * 4 + ACOMP] = 0xffff;
+ }
+}
+
+static void
+get_values_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLushort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] = *src;
+ dst[i * 4 + GCOMP] = 0;
+ dst[i * 4 + BCOMP] = 0;
+ dst[i * 4 + ACOMP] = 0xffff;
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_RG1616.
+ */
+static void
+get_row_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLushort *src = rb->GetPointer(ctx, rb, x, y);
+ GLushort *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] = src[i * 2];
+ dst[i * 4 + GCOMP] = src[i * 2 + 1];
+ dst[i * 4 + BCOMP] = 0;
+ dst[i * 4 + ACOMP] = 0xffff;
+ }
+}
+
+static void
+get_values_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] = src[0];
+ dst[i * 4 + GCOMP] = src[1];
+ dst[i * 4 + BCOMP] = 0;
+ dst[i * 4 + ACOMP] = 0xffff;
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_INTENSITY_FLOAT32.
+ */
+static void
+get_row_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
+{
+ const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] =
+ dst[i * 4 + GCOMP] =
+ dst[i * 4 + BCOMP] =
+ dst[i * 4 + ACOMP] = src[i];
+ }
+}
+
+static void
+get_values_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values)
+{
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] =
+ dst[i * 4 + GCOMP] =
+ dst[i * 4 + BCOMP] =
+ dst[i * 4 + ACOMP] = src[0];
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_LUMINANCE_FLOAT32.
+ */
+static void
+get_row_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
+{
+ const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] =
+ dst[i * 4 + GCOMP] =
+ dst[i * 4 + BCOMP] = src[i];
+ dst[i * 4 + ACOMP] = 1.0;
+ }
+}
+
+static void
+get_values_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values)
+{
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] =
+ dst[i * 4 + GCOMP] =
+ dst[i * 4 + BCOMP] = src[0];
+ dst[i * 4 + ACOMP] = 1.0;
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_ALPHA_FLOAT32.
+ */
+static void
+get_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
+{
+ const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] = 0.0;
+ dst[i * 4 + GCOMP] = 0.0;
+ dst[i * 4 + BCOMP] = 0.0;
+ dst[i * 4 + ACOMP] = src[i];
+ }
+}
+
+static void
+get_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values)
+{
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] = 0.0;
+ dst[i * 4 + GCOMP] = 0.0;
+ dst[i * 4 + BCOMP] = 0.0;
+ dst[i * 4 + ACOMP] = src[0];
+ }
+}
+
+static void
+put_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *values, const GLubyte *mask)
+{
+ float *dst = rb->GetPointer(ctx, rb, x, y);
+ const float *src = values;
+ unsigned int i;
+
+ if (mask) {
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i * 4 + ACOMP];
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i * 4 + ACOMP];
+ }
+ }
+}
+
+static void
+put_mono_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *value, const GLubyte *mask)
+{
+ float *dst = rb->GetPointer(ctx, rb, x, y);
+ const float *src = value;
+ unsigned int i;
+
+ if (mask) {
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[ACOMP];
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ dst[i] = src[ACOMP];
+ }
+ }
+}
+
+static void
+put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ const float *src = values;
+ unsigned int i;
+
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ float *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
+
+ *dst = src[i * 4 + ACOMP];
+ }
+ }
+}
+
+static void
+put_mono_values_a_float32(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const float *src = value;
+ unsigned int i;
+
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ float *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
+ *dst = src[ACOMP];
+ }
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_R_FLOAT32.
+ */
+static void
+get_row_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
+{
+ const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] = src[i];
+ dst[i * 4 + GCOMP] = 0.0;
+ dst[i * 4 + BCOMP] = 0.0;
+ dst[i * 4 + ACOMP] = 1.0;
+ }
+}
+
+static void
+get_values_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values)
+{
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] = src[0];
+ dst[i * 4 + GCOMP] = 0.0;
+ dst[i * 4 + BCOMP] = 0.0;
+ dst[i * 4 + ACOMP] = 1.0;
+ }
+}
+
+/**********************************************************************
+ * Functions for MESA_FORMAT_RG_FLOAT32.
+ */
+static void
+get_row_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
+{
+ const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + RCOMP] = src[i * 2 + 0];
+ dst[i * 4 + GCOMP] = src[i * 2 + 1];
+ dst[i * 4 + BCOMP] = 0.0;
+ dst[i * 4 + ACOMP] = 1.0;
+ }
+}
+
+static void
+get_values_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values)
+{
+ GLfloat *dst = values;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
+ dst[i * 4 + RCOMP] = src[0];
+ dst[i * 4 + GCOMP] = src[1];
+ dst[i * 4 + BCOMP] = 0.0;
+ dst[i * 4 + ACOMP] = 1.0;
+ }
+}
+
+/**
+ * This is the default software fallback for gl_renderbuffer's span
+ * access functions.
+ *
+ * The assumptions are that rb->Data will be a pointer to (0,0), that pixels
+ * are packed in the type of rb->Format, and that subsequent rows appear
+ * rb->RowStride pixels later.
+ */
+void
+_swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
+{
+ rb->GetPointer = get_pointer_generic;
+ rb->GetRow = get_row_generic;
+
+ switch (rb->Format) {
+ case MESA_FORMAT_RGB888:
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte3;
+ rb->GetRow = get_row_ubyte3;
+ rb->GetValues = get_values_ubyte3;
+ rb->PutRow = put_row_ubyte3;
+ rb->PutRowRGB = put_row_rgb_ubyte3;
+ rb->PutMonoRow = put_mono_row_ubyte3;
+ rb->PutValues = put_values_ubyte3;
+ rb->PutMonoValues = put_mono_values_ubyte3;
+ break;
+
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_RGBA8888_REV:
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetValues = get_values_ubyte4;
+ rb->PutRow = put_row_ubyte4;
+ rb->PutRowRGB = put_row_rgb_ubyte4;
+ rb->PutMonoRow = put_mono_row_ubyte4;
+ rb->PutValues = put_values_ubyte4;
+ rb->PutMonoValues = put_mono_values_ubyte4;
+ break;
+
+ case MESA_FORMAT_R8:
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetValues = get_values_r8;
+ rb->GetRow = get_row_r8;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = put_row_generic;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_GR88:
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetValues = get_values_rg88;
+ rb->GetRow = get_row_rg88;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = put_row_generic;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_R16:
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetValues = get_values_r16;
+ rb->GetRow = get_row_r16;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = put_row_generic;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_RG1616:
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetValues = get_values_rg1616;
+ rb->GetRow = get_row_rg1616;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = put_row_generic;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_SIGNED_RGBA_16:
+ rb->DataType = GL_SHORT;
+ rb->GetValues = get_values_ushort4;
+ rb->PutRow = put_row_ushort4;
+ rb->PutRowRGB = put_row_rgb_ushort4;
+ rb->PutMonoRow = put_mono_row_ushort4;
+ rb->PutValues = put_values_ushort4;
+ rb->PutMonoValues = put_mono_values_ushort4;
+ break;
+
+ case MESA_FORMAT_S8:
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetValues = get_values_ubyte;
+ rb->PutRow = put_row_ubyte;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ubyte;
+ rb->PutValues = put_values_ubyte;
+ rb->PutMonoValues = put_mono_values_ubyte;
+ break;
+
+ case MESA_FORMAT_Z16:
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ break;
+
+ case MESA_FORMAT_Z32:
+ case MESA_FORMAT_X8_Z24:
+ case MESA_FORMAT_Z24_X8:
+ rb->DataType = GL_UNSIGNED_INT;
+ rb->GetValues = get_values_uint;
+ rb->PutRow = put_row_uint;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_uint;
+ rb->PutValues = put_values_uint;
+ rb->PutMonoValues = put_mono_values_uint;
+ break;
+
+ case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_S8_Z24:
+ rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
+ rb->GetValues = get_values_uint;
+ rb->PutRow = put_row_uint;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_uint;
+ rb->PutValues = put_values_uint;
+ rb->PutMonoValues = put_mono_values_uint;
+ break;
+
+ case MESA_FORMAT_RGBA_FLOAT32:
+ rb->GetRow = get_row_generic;
+ rb->GetValues = get_values_generic;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_INTENSITY_FLOAT32:
+ rb->GetRow = get_row_i_float32;
+ rb->GetValues = get_values_i_float32;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ rb->GetRow = get_row_l_float32;
+ rb->GetValues = get_values_l_float32;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ rb->GetRow = get_row_a_float32;
+ rb->GetValues = get_values_a_float32;
+ rb->PutRow = put_row_a_float32;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_a_float32;
+ rb->PutValues = put_values_a_float32;
+ rb->PutMonoValues = put_mono_values_a_float32;
+ break;
+
+ case MESA_FORMAT_RG_FLOAT32:
+ rb->GetRow = get_row_rg_float32;
+ rb->GetValues = get_values_rg_float32;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ case MESA_FORMAT_R_FLOAT32:
+ rb->GetRow = get_row_r_float32;
+ rb->GetValues = get_values_r_float32;
+ rb->PutRow = put_row_generic;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_generic;
+ rb->PutValues = put_values_generic;
+ rb->PutMonoValues = put_mono_values_generic;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**
+ * This is a software fallback for the gl_renderbuffer->AllocStorage
+ * function.
+ * Device drivers will typically override this function for the buffers
+ * which it manages (typically color buffers, Z and stencil).
+ * Other buffers (like software accumulation and aux buffers) which the driver
+ * doesn't manage can be handled with this function.
+ *
+ * This one multi-purpose function can allocate stencil, depth, accum, color
+ * or color-index buffers!
+ *
+ * This function also plugs in the appropriate GetPointer, Get/PutRow and
+ * Get/PutValues functions.
+ */
+static GLboolean
+soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width, GLuint height)
+{
+ switch (internalFormat) {
+ case GL_RGB:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ rb->Format = MESA_FORMAT_RGB888;
+ break;
+ case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+#if 1
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+#endif
+ if (_mesa_little_endian())
+ rb->Format = MESA_FORMAT_RGBA8888_REV;
+ else
+ rb->Format = MESA_FORMAT_RGBA8888;
+ break;
+ case GL_RGBA16:
+ case GL_RGBA16_SNORM:
+ /* for accum buffer */
+ rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
+ break;
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ rb->Format = MESA_FORMAT_S8;
+ break;
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ rb->Format = MESA_FORMAT_Z16;
+ break;
+ case GL_DEPTH_COMPONENT24:
+ rb->Format = MESA_FORMAT_X8_Z24;
+ break;
+ case GL_DEPTH_COMPONENT32:
+ rb->Format = MESA_FORMAT_Z32;
+ break;
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ rb->Format = MESA_FORMAT_Z24_S8;
+ break;
+ default:
+ /* unsupported format */
+ return GL_FALSE;
+ }
+
+ _swrast_set_renderbuffer_accessors(rb);
+
+ ASSERT(rb->DataType);
+ ASSERT(rb->GetPointer);
+ ASSERT(rb->GetRow);
+ ASSERT(rb->GetValues);
+ ASSERT(rb->PutRow);
+ ASSERT(rb->PutMonoRow);
+ ASSERT(rb->PutValues);
+ ASSERT(rb->PutMonoValues);
+
+ /* free old buffer storage */
+ if (rb->Data) {
+ free(rb->Data);
+ rb->Data = NULL;
+ }
+
+ rb->RowStride = width;
+
+ if (width > 0 && height > 0) {
+ /* allocate new buffer storage */
+ rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format));
+
+ if (rb->Data == NULL) {
+ rb->Width = 0;
+ rb->Height = 0;
+ rb->RowStride = 0;
+ _mesa_error(ctx, GL_OUT_OF_MEMORY,
+ "software renderbuffer allocation (%d x %d x %d)",
+ width, height, _mesa_get_format_bytes(rb->Format));
+ return GL_FALSE;
+ }
+ }
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
+ if (rb->Name == 0 &&
+ internalFormat == GL_RGBA16_SNORM &&
+ rb->_BaseFormat == 0) {
+ /* NOTE: This is a special case just for accumulation buffers.
+ * This is a very limited use case- there's no snorm texturing or
+ * rendering going on.
+ */
+ rb->_BaseFormat = GL_RGBA;
+ }
+ else {
+ /* the internalFormat should have been error checked long ago */
+ ASSERT(rb->_BaseFormat);
+ }
+
+ return GL_TRUE;
+}
+
+
+void
+_swrast_map_soft_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ GLubyte *map = rb->Data;
+ int cpp = _mesa_get_format_bytes(rb->Format);
+ int stride = rb->RowStride * cpp;
+
+ ASSERT(rb->Data);
+
+ map += y * stride;
+ map += x * cpp;
+
+ *out_map = map;
+ *out_stride = stride;
+}
+
+
+void
+_swrast_unmap_soft_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+}
+
+
+
+/**
+ * Allocate a software-based renderbuffer. This is called via the
+ * ctx->Driver.NewRenderbuffer() function when the user creates a new
+ * renderbuffer.
+ * This would not be used for hardware-based renderbuffers.
+ */
+struct gl_renderbuffer *
+_swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name)
+{
+ struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
+ if (rb) {
+ rb->AllocStorage = soft_renderbuffer_storage;
+ /* Normally, one would setup the PutRow, GetRow, etc functions here.
+ * But we're doing that in the soft_renderbuffer_storage() function
+ * instead.
+ */
+ }
+ return rb;
+}
+
+
+/**
+ * Add software-based color renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+static GLboolean
+add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint rgbBits, GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ gl_buffer_index b;
+
+ if (rgbBits > 16 || alphaBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in add_color_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct gl_renderbuffer *rb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ assert(fb->Attachment[b].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
+ return GL_FALSE;
+ }
+
+ rb->InternalFormat = GL_RGBA;
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, b, rb);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based depth renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+static GLboolean
+add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint depthBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (depthBits > 32) {
+ _mesa_problem(ctx,
+ "Unsupported depthBits in add_depth_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer");
+ return GL_FALSE;
+ }
+
+ if (depthBits <= 16) {
+ rb->InternalFormat = GL_DEPTH_COMPONENT16;
+ }
+ else if (depthBits <= 24) {
+ rb->InternalFormat = GL_DEPTH_COMPONENT24;
+ }
+ else {
+ rb->InternalFormat = GL_DEPTH_COMPONENT32;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based stencil renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+static GLboolean
+add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint stencilBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (stencilBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported stencilBits in add_stencil_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
+ return GL_FALSE;
+ }
+
+ assert(stencilBits <= 8);
+ rb->InternalFormat = GL_STENCIL_INDEX8;
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based accumulation renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+static GLboolean
+add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint redBits, GLuint greenBits,
+ GLuint blueBits, GLuint alphaBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported accumBits in add_accum_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
+ return GL_FALSE;
+ }
+
+ rb->InternalFormat = GL_RGBA16_SNORM;
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Add a software-based aux renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ *
+ * NOTE: color-index aux buffers not supported.
+ */
+static GLboolean
+add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint colorBits, GLuint numBuffers)
+{
+ GLuint i;
+
+ if (colorBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported colorBits in add_aux_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(numBuffers <= MAX_AUX_BUFFERS);
+
+ for (i = 0; i < numBuffers; i++) {
+ struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
+
+ assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL);
+
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer");
+ return GL_FALSE;
+ }
+
+ assert (colorBits <= 8);
+ rb->InternalFormat = GL_RGBA;
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Create/attach software-based renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers. Drivers can just as well
+ * call the individual _mesa_add_*_renderbuffer() routines directly.
+ */
+void
+_swrast_add_soft_renderbuffers(struct gl_framebuffer *fb,
+ GLboolean color,
+ GLboolean depth,
+ GLboolean stencil,
+ GLboolean accum,
+ GLboolean alpha,
+ GLboolean aux)
+{
+ GLboolean frontLeft = GL_TRUE;
+ GLboolean backLeft = fb->Visual.doubleBufferMode;
+ GLboolean frontRight = fb->Visual.stereoMode;
+ GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
+
+ if (color) {
+ assert(fb->Visual.redBits == fb->Visual.greenBits);
+ assert(fb->Visual.redBits == fb->Visual.blueBits);
+ add_color_renderbuffers(NULL, fb,
+ fb->Visual.redBits,
+ fb->Visual.alphaBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+
+ if (depth) {
+ assert(fb->Visual.depthBits > 0);
+ add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
+ }
+
+ if (stencil) {
+ assert(fb->Visual.stencilBits > 0);
+ add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
+ }
+
+ if (accum) {
+ assert(fb->Visual.accumRedBits > 0);
+ assert(fb->Visual.accumGreenBits > 0);
+ assert(fb->Visual.accumBlueBits > 0);
+ add_accum_renderbuffer(NULL, fb,
+ fb->Visual.accumRedBits,
+ fb->Visual.accumGreenBits,
+ fb->Visual.accumBlueBits,
+ fb->Visual.accumAlphaBits);
+ }
+
+ if (aux) {
+ assert(fb->Visual.numAuxBuffers > 0);
+ add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
+ fb->Visual.numAuxBuffers);
+ }
+
+#if 0
+ if (multisample) {
+ /* maybe someday */
+ }
+#endif
+}
diff --git a/mesalib/src/mesa/swrast/s_accum.h b/mesalib/src/mesa/swrast/s_renderbuffer.h
index bdd6ac326..266ebd934 100644
--- a/mesalib/src/mesa/swrast/s_accum.h
+++ b/mesalib/src/mesa/swrast/s_renderbuffer.h
@@ -1,38 +1,66 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef S_ACCUM_H
-#define S_ACCUM_H
-
-
-struct gl_context;
-struct gl_renderbuffer;
-
-
-extern void
-_swrast_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
-
-
-#endif
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_RENDERBUFFER_H
+#define S_RENDERBUFFER_H
+
+#include "main/glheader.h"
+
+
+struct gl_context;
+struct gl_framebuffer;
+struct gl_renderbuffer;
+
+
+extern struct gl_renderbuffer *
+_swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name);
+
+extern void
+_swrast_map_soft_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride);
+
+extern void
+_swrast_unmap_soft_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb);
+
+extern void
+_swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb);
+
+
+extern void
+_swrast_add_soft_renderbuffers(struct gl_framebuffer *fb,
+ GLboolean color,
+ GLboolean depth,
+ GLboolean stencil,
+ GLboolean accum,
+ GLboolean alpha,
+ GLboolean aux);
+
+
+#endif /* S_RENDERBUFFER_H */
diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
index e9512b561..877c29c9b 100644
--- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h
+++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
@@ -2270,7 +2270,7 @@ static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage,
{
/* only return Z, not stencil data */
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
texel[0] = ((*src) >> 8) * scale;
ASSERT(texImage->Base.TexFormat == MESA_FORMAT_Z24_S8 ||
texImage->Base.TexFormat == MESA_FORMAT_Z24_X8);
@@ -2298,7 +2298,7 @@ static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage,
{
/* only return Z, not stencil data */
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
texel[0] = ((*src) & 0x00ffffff) * scale;
ASSERT(texImage->Base.TexFormat == MESA_FORMAT_S8_Z24 ||
texImage->Base.TexFormat == MESA_FORMAT_X8_Z24);
diff --git a/mesalib/src/mesa/swrast/s_zoom.c b/mesalib/src/mesa/swrast/s_zoom.c
index 16bb997f3..f407fdcf4 100644
--- a/mesalib/src/mesa/swrast/s_zoom.c
+++ b/mesalib/src/mesa/swrast/s_zoom.c
@@ -299,11 +299,17 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span,
* Also, clipping may change the span end value, so store it as well.
*/
const GLint end = zoomed.end; /* save */
- GLuint rgbaSave[MAX_WIDTH][4];
+ void *rgbaSave;
const GLint pixelSize =
(zoomed.array->ChanType == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) :
((zoomed.array->ChanType == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort)
: 4 * sizeof(GLfloat));
+
+ rgbaSave = malloc(zoomed.end * pixelSize);
+ if (!rgbaSave) {
+ return;
+ }
+
if (y1 - y0 > 1) {
memcpy(rgbaSave, zoomed.array->rgba, zoomed.end * pixelSize);
}
@@ -315,6 +321,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span,
memcpy(zoomed.array->rgba, rgbaSave, zoomed.end * pixelSize);
}
}
+
+ free(rgbaSave);
}
}
diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h
index 17b66c664..dd4055159 100644
--- a/mesalib/src/mesa/swrast/swrast.h
+++ b/mesalib/src/mesa/swrast/swrast.h
@@ -127,9 +127,6 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
extern void
_swrast_Clear(struct gl_context *ctx, GLbitfield buffers);
-extern void
-_swrast_Accum(struct gl_context *ctx, GLenum op, GLfloat value);
-
/* Reset the stipple counter
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index 35f929731..1fa030a92 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -887,7 +887,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
int key = 0, rootX, rootY;
ButtonClassPtr b;
int ret = 0;
- int state, i;
+ int corestate, i;
DeviceIntPtr mouse = NULL, kbd = NULL;
DeviceEvent *event = &ev->device_event;
@@ -917,9 +917,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
mouse = NULL;
}
- /* State needs to be assembled BEFORE the device is updated. */
- state = (kbd && kbd->key) ? XkbStateFieldFromRec(&kbd->key->xkbInfo->state) : 0;
- state |= (mouse && mouse->button) ? (mouse->button->state) : 0;
+ /* core state needs to be assembled BEFORE the device is updated. */
+ corestate = (kbd && kbd->key) ? XkbStateFieldFromRec(&kbd->key->xkbInfo->state) : 0;
+ corestate |= (mouse && mouse->button) ? (mouse->button->state) : 0;
for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
if (BitIsOn(mouse->button->down, i))
@@ -969,7 +969,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
event->root_x = rootX;
event->root_y = rootY;
NoticeEventTime((InternalEvent*)event);
- event->corestate = state;
+ event->corestate = corestate;
key = event->detail.key;
break;
default:
@@ -1006,11 +1006,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
deactivateDeviceGrab = TRUE;
break;
case ET_ButtonPress:
- event->detail.button = b->map[key];
- if (!event->detail.button) { /* there's no button 0 */
- event->detail.button = key;
+ if (b->map[key] == 0) /* there's no button 0 */
return;
- }
+ event->detail.button = b->map[key];
if (!grab && CheckDeviceGrabs(device, event, 0))
{
/* if a passive grab was activated, the event has been sent
@@ -1019,11 +1017,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
}
break;
case ET_ButtonRelease:
- event->detail.button = b->map[key];
- if (!event->detail.button) { /* there's no button 0 */
- event->detail.button = key;
+ if (b->map[key] == 0) /* there's no button 0 */
return;
- }
+ event->detail.button = b->map[key];
if (grab && !b->buttonsDown &&
device->deviceGrab.fromPassiveGrab &&
(device->deviceGrab.grab->type == ButtonPress ||
@@ -1037,7 +1033,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
if (grab)
DeliverGrabbedEvent((InternalEvent*)event, device, deactivateDeviceGrab);
- else if (device->focus && !IsPointerEvent((InternalEvent*)ev))
+ else if (device->focus && !IsPointerEvent(ev))
DeliverFocusedEvent(device, (InternalEvent*)event,
GetSpriteWindow(device));
else
@@ -1635,6 +1631,7 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
static void
FreeInputClient(InputClientsPtr *other)
{
+ xi2mask_free(&(*other)->xi2mask);
free(*other);
*other = NULL;
}
@@ -1657,6 +1654,9 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
return BadAlloc;
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
goto bail;
+ others->xi2mask = xi2mask_new();
+ if (!others->xi2mask)
+ goto bail;
others->mask[mskidx] = mask;
others->resource = FakeClientID(client->index);
others->next = pWin->optional->inputMasks->inputClients;
@@ -1678,6 +1678,12 @@ MakeInputMasks(WindowPtr pWin)
imasks = calloc(1, sizeof(struct _OtherInputMasks));
if (!imasks)
return FALSE;
+ imasks->xi2mask = xi2mask_new();
+ if (!imasks->xi2mask)
+ {
+ free(imasks);
+ return FALSE;
+ }
pWin->optional->inputMasks = imasks;
return TRUE;
}
@@ -1685,6 +1691,7 @@ MakeInputMasks(WindowPtr pWin)
static void
FreeInputMask(OtherInputMasks **imask)
{
+ xi2mask_free(&(*imask)->xi2mask);
free(*imask);
*imask = NULL;
}
@@ -1695,20 +1702,17 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin)
InputClientsPtr others;
struct _OtherInputMasks *inputMasks; /* default: NULL */
WindowPtr pChild, tmp;
- int i, j;
+ int i;
pChild = pWin;
while (1) {
if ((inputMasks = wOtherInputMasks(pChild)) != 0) {
- for (i = 0; i < EMASKSIZE; i++)
- memset(inputMasks->xi2mask[i], 0, sizeof(inputMasks->xi2mask[i]));
+ xi2mask_zero(inputMasks->xi2mask, -1);
for (others = inputMasks->inputClients; others;
others = others->next) {
for (i = 0; i < EMASKSIZE; i++)
inputMasks->inputEvents[i] |= others->mask[i];
- for (i = 0; i < EMASKSIZE; i++)
- for (j = 0; j < XI2MASKSIZE; j++)
- inputMasks->xi2mask[i][j] |= others->xi2mask[i][j];
+ xi2mask_merge(inputMasks->xi2mask, others->xi2mask);
}
for (i = 0; i < EMASKSIZE; i++)
inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i];
@@ -2032,20 +2036,25 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
dev->valuator->motionHintWindow = pWin;
else if ((type == DeviceButtonPress) && (!grab) &&
(deliveryMask & DeviceButtonGrabMask)) {
- GrabRec tempGrab;
+ GrabPtr tempGrab;
- tempGrab.device = dev;
- tempGrab.resource = client->clientAsMask;
- tempGrab.window = pWin;
- tempGrab.ownerEvents =
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return;
+
+ tempGrab->device = dev;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->window = pWin;
+ tempGrab->ownerEvents =
(deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
- tempGrab.eventMask = deliveryMask;
- tempGrab.keyboardMode = GrabModeAsync;
- tempGrab.pointerMode = GrabModeAsync;
- tempGrab.confineTo = NullWindow;
- tempGrab.cursor = NullCursor;
- tempGrab.next = NULL;
- (*dev->deviceGrab.ActivateGrab) (dev, &tempGrab, currentTime, TRUE);
+ tempGrab->eventMask = deliveryMask;
+ tempGrab->keyboardMode = GrabModeAsync;
+ tempGrab->pointerMode = GrabModeAsync;
+ tempGrab->confineTo = NullWindow;
+ tempGrab->cursor = NullCursor;
+ tempGrab->next = NULL;
+ (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, currentTime, TRUE);
+ FreeGrab(tempGrab);
}
}
@@ -2191,14 +2200,12 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
for (others = wOtherInputMasks(win)->inputClients; others;
others = others->next) {
if (SameClient(others, client)) {
- memset(others->xi2mask[dev->id], 0,
- sizeof(others->xi2mask[dev->id]));
+ xi2mask_zero(others->xi2mask, dev->id);
break;
}
}
}
- len = min(len, sizeof(others->xi2mask[dev->id]));
if (len && !others)
{
@@ -2207,11 +2214,14 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
others= wOtherInputMasks(win)->inputClients;
}
- if (others)
- memset(others->xi2mask[dev->id], 0, sizeof(others->xi2mask[dev->id]));
+ if (others) {
+ xi2mask_zero(others->xi2mask, dev->id);
+ len = min(len, xi2mask_mask_size(others->xi2mask));
+ }
- if (len)
- memcpy(others->xi2mask[dev->id], mask, len);
+ if (len) {
+ xi2mask_set_one_mask(others->xi2mask, dev->id, mask, len);
+ }
RecalculateDeviceDeliverableEvents(win);
diff --git a/xorg-server/Xi/ungrdevb.c b/xorg-server/Xi/ungrdevb.c
index 9e9ece47a..628024870 100644
--- a/xorg-server/Xi/ungrdevb.c
+++ b/xorg-server/Xi/ungrdevb.c
@@ -96,7 +96,7 @@ ProcXUngrabDeviceButton(ClientPtr client)
DeviceIntPtr dev;
DeviceIntPtr mdev;
WindowPtr pWin;
- GrabRec temporaryGrab;
+ GrabPtr temporaryGrab;
int rc;
REQUEST(xUngrabDeviceButtonReq);
@@ -126,17 +126,23 @@ ProcXUngrabDeviceButton(ClientPtr client)
(stuff->modifiers & ~AllModifiersMask))
return BadValue;
- temporaryGrab.resource = client->clientAsMask;
- temporaryGrab.device = dev;
- temporaryGrab.window = pWin;
- temporaryGrab.type = DeviceButtonPress;
- temporaryGrab.grabtype = GRABTYPE_XI;
- temporaryGrab.modifierDevice = mdev;
- temporaryGrab.modifiersDetail.exact = stuff->modifiers;
- temporaryGrab.modifiersDetail.pMask = NULL;
- temporaryGrab.detail.exact = stuff->button;
- temporaryGrab.detail.pMask = NULL;
-
- DeletePassiveGrabFromList(&temporaryGrab);
+ temporaryGrab = AllocGrab();
+ if (!temporaryGrab)
+ return BadAlloc;
+
+ temporaryGrab->resource = client->clientAsMask;
+ temporaryGrab->device = dev;
+ temporaryGrab->window = pWin;
+ temporaryGrab->type = DeviceButtonPress;
+ temporaryGrab->grabtype = GRABTYPE_XI;
+ temporaryGrab->modifierDevice = mdev;
+ temporaryGrab->modifiersDetail.exact = stuff->modifiers;
+ temporaryGrab->modifiersDetail.pMask = NULL;
+ temporaryGrab->detail.exact = stuff->button;
+ temporaryGrab->detail.pMask = NULL;
+
+ DeletePassiveGrabFromList(temporaryGrab);
+
+ FreeGrab(temporaryGrab);
return Success;
}
diff --git a/xorg-server/Xi/ungrdevk.c b/xorg-server/Xi/ungrdevk.c
index 526347db4..b0d83cbbc 100644
--- a/xorg-server/Xi/ungrdevk.c
+++ b/xorg-server/Xi/ungrdevk.c
@@ -98,7 +98,7 @@ ProcXUngrabDeviceKey(ClientPtr client)
DeviceIntPtr dev;
DeviceIntPtr mdev;
WindowPtr pWin;
- GrabRec temporaryGrab;
+ GrabPtr temporaryGrab;
int rc;
REQUEST(xUngrabDeviceKeyReq);
@@ -133,17 +133,22 @@ ProcXUngrabDeviceKey(ClientPtr client)
(stuff->modifiers & ~AllModifiersMask))
return BadValue;
- temporaryGrab.resource = client->clientAsMask;
- temporaryGrab.device = dev;
- temporaryGrab.window = pWin;
- temporaryGrab.type = DeviceKeyPress;
- temporaryGrab.grabtype = GRABTYPE_XI;
- temporaryGrab.modifierDevice = mdev;
- temporaryGrab.modifiersDetail.exact = stuff->modifiers;
- temporaryGrab.modifiersDetail.pMask = NULL;
- temporaryGrab.detail.exact = stuff->key;
- temporaryGrab.detail.pMask = NULL;
-
- DeletePassiveGrabFromList(&temporaryGrab);
+ temporaryGrab = AllocGrab();
+ if (!temporaryGrab)
+ return BadAlloc;
+
+ temporaryGrab->resource = client->clientAsMask;
+ temporaryGrab->device = dev;
+ temporaryGrab->window = pWin;
+ temporaryGrab->type = DeviceKeyPress;
+ temporaryGrab->grabtype = GRABTYPE_XI;
+ temporaryGrab->modifierDevice = mdev;
+ temporaryGrab->modifiersDetail.exact = stuff->modifiers;
+ temporaryGrab->modifiersDetail.pMask = NULL;
+ temporaryGrab->detail.exact = stuff->key;
+ temporaryGrab->detail.pMask = NULL;
+
+ DeletePassiveGrabFromList(temporaryGrab);
+ FreeGrab(temporaryGrab);
return Success;
}
diff --git a/xorg-server/Xi/xichangehierarchy.c b/xorg-server/Xi/xichangehierarchy.c
index 614d23116..503404e64 100644
--- a/xorg-server/Xi/xichangehierarchy.c
+++ b/xorg-server/Xi/xichangehierarchy.c
@@ -200,6 +200,19 @@ unwind:
return rc;
}
+static void
+disable_clientpointer(DeviceIntPtr dev)
+{
+ int i;
+
+ for (i = 0; i < currentMaxClients; i++)
+ {
+ ClientPtr client = clients[i];
+ if (client && client->clientPtr == dev)
+ client->clientPtr = NULL;
+ }
+}
+
static int
remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
int flags[MAXDEVICES])
@@ -250,6 +263,8 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
if (rc != Success)
goto unwind;
+ disable_clientpointer(ptr);
+
/* Disabling sends the devices floating, reattach them if
* desired. */
if (r->return_mode == XIAttachToMaster)
diff --git a/xorg-server/Xi/xigrabdev.c b/xorg-server/Xi/xigrabdev.c
index a9b655c0e..1cfbf243b 100644
--- a/xorg-server/Xi/xigrabdev.c
+++ b/xorg-server/Xi/xigrabdev.c
@@ -41,6 +41,7 @@
#include "exglobals.h" /* BadDevice */
#include "exevents.h"
#include "xigrabdev.h"
+#include "inpututils.h"
int
SProcXIGrabDevice(ClientPtr client)
@@ -64,7 +65,7 @@ ProcXIGrabDevice(ClientPtr client)
xXIGrabDeviceReply rep;
int ret = Success;
uint8_t status;
- GrabMask mask;
+ GrabMask mask = { 0 };
int mask_len;
REQUEST(xXIGrabDeviceReq);
@@ -81,9 +82,13 @@ ProcXIGrabDevice(ClientPtr client)
stuff->mask_len * 4) != Success)
return BadValue;
- mask_len = min(sizeof(mask.xi2mask[stuff->deviceid]), stuff->mask_len * 4);
- memset(mask.xi2mask, 0, sizeof(mask.xi2mask));
- memcpy(mask.xi2mask, (char*)&stuff[1], mask_len);
+ mask.xi2mask = xi2mask_new();
+ if (!mask.xi2mask)
+ return BadAlloc;
+
+ mask_len = min(xi2mask_mask_size(mask.xi2mask), stuff->mask_len * 4);
+ /* FIXME: I think the old code was broken here */
+ xi2mask_set_one_mask(mask.xi2mask, dev->id, (unsigned char*)&stuff[1], mask_len);
ret = GrabDevice(client, dev, stuff->grab_mode,
stuff->paired_device_mode,
@@ -96,6 +101,8 @@ ProcXIGrabDevice(ClientPtr client)
None /* confineTo */,
&status);
+ xi2mask_free(&mask.xi2mask);
+
if (ret != Success)
return ret;
diff --git a/xorg-server/Xi/xipassivegrab.c b/xorg-server/Xi/xipassivegrab.c
index 2f13a95e8..4860757fc 100644
--- a/xorg-server/Xi/xipassivegrab.c
+++ b/xorg-server/Xi/xipassivegrab.c
@@ -44,6 +44,7 @@
#include "xipassivegrab.h"
#include "dixgrabs.h"
#include "misc.h"
+#include "inpututils.h"
int
SProcXIPassiveGrabDevice(ClientPtr client)
@@ -82,7 +83,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
int i, ret = Success;
uint32_t *modifiers;
xXIGrabModifierInfo *modifiers_failed;
- GrabMask mask;
+ GrabMask mask = { 0 };
GrabParameters param;
void *tmp;
int mask_len;
@@ -124,9 +125,12 @@ ProcXIPassiveGrabDevice(ClientPtr client)
stuff->mask_len * 4) != Success)
return BadValue;
- mask_len = min(sizeof(mask.xi2mask[stuff->deviceid]), stuff->mask_len * 4);
- memset(mask.xi2mask, 0, sizeof(mask.xi2mask));
- memcpy(mask.xi2mask[stuff->deviceid], &stuff[1], mask_len * 4);
+ mask.xi2mask = xi2mask_new();
+ if (!mask.xi2mask)
+ return BadAlloc;
+
+ mask_len = min(xi2mask_mask_size(mask.xi2mask), stuff->mask_len * 4);
+ xi2mask_set_one_mask(mask.xi2mask, stuff->deviceid, (unsigned char*)&stuff[1], mask_len * 4);
rep.repType = X_Reply;
rep.RepType = X_XIPassiveGrabDevice;
@@ -212,6 +216,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
free(modifiers_failed);
out:
+ xi2mask_free(&mask.xi2mask);
return ret;
}
@@ -253,7 +258,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
{
DeviceIntPtr dev, mod_dev;
WindowPtr win;
- GrabRec tempGrab;
+ GrabPtr tempGrab;
uint32_t* modifiers;
int i, rc;
@@ -293,29 +298,36 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);
- tempGrab.resource = client->clientAsMask;
- tempGrab.device = dev;
- tempGrab.window = win;
+
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return BadAlloc;
+
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->device = dev;
+ tempGrab->window = win;
switch(stuff->grab_type)
{
- case XIGrabtypeButton: tempGrab.type = XI_ButtonPress; break;
- case XIGrabtypeKeycode: tempGrab.type = XI_KeyPress; break;
- case XIGrabtypeEnter: tempGrab.type = XI_Enter; break;
- case XIGrabtypeFocusIn: tempGrab.type = XI_FocusIn; break;
+ case XIGrabtypeButton: tempGrab->type = XI_ButtonPress; break;
+ case XIGrabtypeKeycode: tempGrab->type = XI_KeyPress; break;
+ case XIGrabtypeEnter: tempGrab->type = XI_Enter; break;
+ case XIGrabtypeFocusIn: tempGrab->type = XI_FocusIn; break;
}
- tempGrab.grabtype = GRABTYPE_XI2;
- tempGrab.modifierDevice = mod_dev;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.detail.exact = stuff->detail;
- tempGrab.detail.pMask = NULL;
+ tempGrab->grabtype = GRABTYPE_XI2;
+ tempGrab->modifierDevice = mod_dev;
+ tempGrab->modifiersDetail.pMask = NULL;
+ tempGrab->detail.exact = stuff->detail;
+ tempGrab->detail.pMask = NULL;
modifiers = (uint32_t*)&stuff[1];
for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
{
- tempGrab.modifiersDetail.exact = *modifiers;
- DeletePassiveGrabFromList(&tempGrab);
+ tempGrab->modifiersDetail.exact = *modifiers;
+ DeletePassiveGrabFromList(tempGrab);
}
+ FreeGrab(tempGrab);
+
return Success;
}
diff --git a/xorg-server/Xi/xiselectev.c b/xorg-server/Xi/xiselectev.c
index 3af4f1fb9..ee14edb6d 100644
--- a/xorg-server/Xi/xiselectev.c
+++ b/xorg-server/Xi/xiselectev.c
@@ -33,6 +33,7 @@
#include "exglobals.h"
#include "exevents.h"
#include <X11/extensions/XI2proto.h>
+#include "inpututils.h"
#include "xiselectev.h"
@@ -249,7 +250,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
for (i = 0; i < MAXDEVICES; i++)
{
int j;
- unsigned char *devmask = others->xi2mask[i];
+ const unsigned char *devmask = xi2mask_get_one_mask(others->xi2mask, i);
if (i > 2)
{
@@ -259,7 +260,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
- for (j = XI2MASKSIZE - 1; j >= 0; j--)
+ for (j = xi2mask_mask_size(others->xi2mask) - 1; j >= 0; j--)
{
if (devmask[j] != 0)
{
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index e584b76fd..8a96bcc49 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -73,6 +73,7 @@ SOFTWARE.
#include "dixevents.h"
#include "mipointer.h"
#include "eventstr.h"
+#include "dixgrabs.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
@@ -277,6 +278,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
dev->deviceGrab.grabTime = currentTime;
dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+ dev->deviceGrab.activeGrab = AllocGrab();
XkbSetExtension(dev, ProcessKeyboardEvent);
@@ -945,6 +947,7 @@ CloseDevice(DeviceIntPtr dev)
}
}
+ FreeGrab(dev->deviceGrab.activeGrab);
free(dev->deviceGrab.sync.event);
free(dev->config_info); /* Allocated in xf86ActivateDevice. */
free(dev->last.scroll);
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index 12b601449..3d75104b3 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -420,12 +420,6 @@ GetXI2EventFilterMask(int evtype)
return (1 << (evtype % 8));
}
-static inline int
-GetXI2EventFilterOffset(int evtype)
-{
- return (evtype / 8);
-}
-
/**
* For the given event, return the matching event filter. This filter may then
* be AND'ed with the selected event mask.
@@ -459,12 +453,15 @@ GetEventFilter(DeviceIntPtr dev, xEvent *event)
* for the event_type.
*/
static int
-GetXI2MaskByte(unsigned char xi2mask[][XI2MASKSIZE], DeviceIntPtr dev, int event_type)
+GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type)
{
- int byte = GetXI2EventFilterOffset(event_type);
- return xi2mask[dev->id][byte] |
- xi2mask[XIAllDevices][byte] |
- (IsMaster(dev) ? xi2mask[XIAllMasterDevices][byte] : 0);
+ /* we just return the matching filter because that's the only use
+ * for this mask anyway.
+ */
+ if (xi2mask_isset(mask, dev, event_type))
+ return GetXI2EventFilterMask(event_type);
+ else
+ return 0;
}
@@ -476,16 +473,14 @@ Bool
WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
{
OtherInputMasks *inputMasks = wOtherInputMasks(win);
- int filter;
int evtype;
if (!inputMasks || xi2_get_type(ev) == 0)
return 0;
evtype = ((xGenericEvent*)ev)->evtype;
- filter = GetEventFilter(dev, ev);
- return !!(GetXI2MaskByte(inputMasks->xi2mask, dev, evtype) & filter);
+ return xi2mask_isset(inputMasks->xi2mask, dev, evtype);
}
Mask
@@ -1135,12 +1130,14 @@ NoticeEventTime(InternalEvent *ev)
void
EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
{
- QdEventPtr tail = *syncEvents.pendtail;
+ QdEventPtr tail;
QdEventPtr qe;
SpritePtr pSprite = device->spriteInfo->sprite;
int eventlen;
DeviceEvent *event = &ev->device_event;
+ tail = list_last_entry(&syncEvents.pending, QdEventRec, next);
+
NoticeTime((InternalEvent*)event);
/* Fix for key repeating bug. */
@@ -1199,15 +1196,13 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
qe = malloc(sizeof(QdEventRec) + eventlen);
if (!qe)
return;
- qe->next = (QdEventPtr)NULL;
+ list_init(&qe->next);
qe->device = device;
qe->pScreen = pSprite->hotPhys.pScreen;
qe->months = currentTime.months;
qe->event = (InternalEvent *)(qe + 1);
memcpy(qe->event, event, eventlen);
- if (tail)
- syncEvents.pendtail = &tail->next;
- *syncEvents.pendtail = qe;
+ list_append(&qe->next, &syncEvents.pending);
}
/**
@@ -1219,22 +1214,20 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
* If there is none, we're done. If there is at least one device that is not
* frozen, then re-run from the beginning of the event queue.
*/
-static void
+void
PlayReleasedEvents(void)
{
- QdEventPtr *prev, qe;
+ QdEventPtr tmp;
+ QdEventPtr qe;
DeviceIntPtr dev;
DeviceIntPtr pDev;
- prev = &syncEvents.pending;
- while ( (qe = *prev) )
- {
+restart:
+ list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) {
if (!qe->device->deviceGrab.sync.frozen)
{
- *prev = qe->next;
- pDev = qe->device;
- if (*syncEvents.pendtail == *prev)
- syncEvents.pendtail = prev;
+ list_del(&qe->next);
+ pDev = qe->device;
if (qe->event->any.type == ET_Motion)
CheckVirtualMotion(pDev, qe, NullWindow);
syncEvents.time.months = qe->months;
@@ -1271,12 +1264,11 @@ PlayReleasedEvents(void)
;
if (!dev)
break;
+
/* Playing the event may have unfrozen another device. */
/* So to play it safe, restart at the head of the queue */
- prev = &syncEvents.pending;
+ goto restart;
}
- else
- prev = &qe->next;
}
}
@@ -1317,7 +1309,8 @@ ComputeFreezes(void)
for (dev = inputInfo.devices; dev; dev = dev->next)
FreezeThaw(dev, dev->deviceGrab.sync.other ||
(dev->deviceGrab.sync.state >= FROZEN));
- if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending))
+ if (syncEvents.playingEvents ||
+ (!replayDev && list_is_empty(&syncEvents.pending)))
return;
syncEvents.playingEvents = TRUE;
if (replayDev)
@@ -1514,8 +1507,8 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
grabinfo->grabTime = time;
if (grab->cursor)
grab->cursor->refcnt++;
- grabinfo->activeGrab = *grab;
- grabinfo->grab = &grabinfo->activeGrab;
+ CopyGrab(grabinfo->activeGrab, grab);
+ grabinfo->grab = grabinfo->activeGrab;
grabinfo->fromPassiveGrab = isPassive;
grabinfo->implicitGrab = autoGrab & ImplicitGrabMask;
PostNewCursor(mouse);
@@ -1591,8 +1584,8 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool pass
grabinfo->grabTime = syncEvents.time;
else
grabinfo->grabTime = time;
- grabinfo->activeGrab = *grab;
- grabinfo->grab = &grabinfo->activeGrab;
+ CopyGrab(grabinfo->activeGrab, grab);
+ grabinfo->grab = grabinfo->activeGrab;
grabinfo->fromPassiveGrab = passive;
grabinfo->implicitGrab = passive & ImplicitGrabMask;
CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
@@ -1981,7 +1974,7 @@ static BOOL
ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
xEvent *event, Mask deliveryMask)
{
- GrabRec tempGrab;
+ GrabPtr tempGrab;
OtherInputMasks *inputMasks;
CARD8 type = event->u.u.type;
GrabType grabtype;
@@ -1995,30 +1988,32 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
else
return FALSE;
- memset(&tempGrab, 0, sizeof(GrabRec));
- tempGrab.next = NULL;
- tempGrab.device = dev;
- tempGrab.resource = client->clientAsMask;
- tempGrab.window = win;
- tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
- tempGrab.eventMask = deliveryMask;
- tempGrab.keyboardMode = GrabModeAsync;
- tempGrab.pointerMode = GrabModeAsync;
- tempGrab.confineTo = NullWindow;
- tempGrab.cursor = NullCursor;
- tempGrab.type = type;
- tempGrab.grabtype = grabtype;
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return FALSE;
+ tempGrab->next = NULL;
+ tempGrab->device = dev;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->window = win;
+ tempGrab->ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
+ tempGrab->eventMask = deliveryMask;
+ tempGrab->keyboardMode = GrabModeAsync;
+ tempGrab->pointerMode = GrabModeAsync;
+ tempGrab->confineTo = NullWindow;
+ tempGrab->cursor = NullCursor;
+ tempGrab->type = type;
+ tempGrab->grabtype = grabtype;
/* get the XI and XI2 device mask */
inputMasks = wOtherInputMasks(win);
- tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
+ tempGrab->deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
if (inputMasks)
- memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
- sizeof(tempGrab.xi2mask));
+ xi2mask_merge(tempGrab->xi2mask, inputMasks->xi2mask);
- (*dev->deviceGrab.ActivateGrab)(dev, &tempGrab,
+ (*dev->deviceGrab.ActivateGrab)(dev, tempGrab,
currentTime, TRUE | ImplicitGrabMask);
+ FreeGrab(tempGrab);
return TRUE;
}
@@ -2563,10 +2558,7 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
if ((type = GetXI2Type(event)) != 0)
{
- filter = GetXI2EventFilterMask(type);
-
- if (inputMasks &&
- (GetXI2MaskByte(inputMasks->xi2mask, dev, type) & filter))
+ if (inputMasks && xi2mask_isset(inputMasks->xi2mask, dev, type))
rc |= EVENT_XI2_MASK;
}
@@ -3665,7 +3657,7 @@ CheckPassiveGrabsOnWindow(
{
SpritePtr pSprite = device->spriteInfo->sprite;
GrabPtr grab = wPassiveGrabs(pWin);
- GrabRec tempGrab;
+ GrabPtr tempGrab;
GrabInfoPtr grabinfo;
#define CORE_MATCH 0x1
#define XI_MATCH 0x2
@@ -3674,27 +3666,30 @@ CheckPassiveGrabsOnWindow(
if (!grab)
return NULL;
+
+ tempGrab = AllocGrab();
+
/* Fill out the grab details, but leave the type for later before
* comparing */
switch (event->any.type)
{
case ET_KeyPress:
case ET_KeyRelease:
- tempGrab.detail.exact = event->device_event.detail.key;
+ tempGrab->detail.exact = event->device_event.detail.key;
break;
case ET_ButtonPress:
case ET_ButtonRelease:
- tempGrab.detail.exact = event->device_event.detail.button;
+ tempGrab->detail.exact = event->device_event.detail.button;
break;
default:
- tempGrab.detail.exact = 0;
+ tempGrab->detail.exact = 0;
break;
}
- tempGrab.window = pWin;
- tempGrab.device = device;
- tempGrab.detail.pMask = NULL;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.next = NULL;
+ tempGrab->window = pWin;
+ tempGrab->device = device;
+ tempGrab->detail.pMask = NULL;
+ tempGrab->modifiersDetail.pMask = NULL;
+ tempGrab->next = NULL;
for (; grab; grab = grab->next)
{
DeviceIntPtr gdev;
@@ -3719,29 +3714,29 @@ CheckPassiveGrabsOnWindow(
if (gdev && gdev->key)
xkbi= gdev->key->xkbInfo;
- tempGrab.modifierDevice = grab->modifierDevice;
- tempGrab.modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
+ tempGrab->modifierDevice = grab->modifierDevice;
+ tempGrab->modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
/* Check for XI2 and XI grabs first */
- tempGrab.type = GetXI2Type(event);
- tempGrab.grabtype = GRABTYPE_XI2;
- if (GrabMatchesSecond(&tempGrab, grab, FALSE))
+ tempGrab->type = GetXI2Type(event);
+ tempGrab->grabtype = GRABTYPE_XI2;
+ if (GrabMatchesSecond(tempGrab, grab, FALSE))
match = XI2_MATCH;
if (!match)
{
- tempGrab.grabtype = GRABTYPE_XI;
- if ((tempGrab.type = GetXIType(event)) &&
- (GrabMatchesSecond(&tempGrab, grab, FALSE)))
+ tempGrab->grabtype = GRABTYPE_XI;
+ if ((tempGrab->type = GetXIType(event)) &&
+ (GrabMatchesSecond(tempGrab, grab, FALSE)))
match = XI_MATCH;
}
/* Check for a core grab (ignore the device when comparing) */
if (!match && checkCore)
{
- tempGrab.grabtype = GRABTYPE_CORE;
- if ((tempGrab.type = GetCoreType(event)) &&
- (GrabMatchesSecond(&tempGrab, grab, TRUE)))
+ tempGrab->grabtype = GRABTYPE_CORE;
+ if ((tempGrab->type = GetCoreType(event)) &&
+ (GrabMatchesSecond(tempGrab, grab, TRUE)))
match = CORE_MATCH;
}
@@ -3769,7 +3764,7 @@ CheckPassiveGrabsOnWindow(
Since XGrabDeviceButton requires to specify the
modifierDevice explicitly, we don't override this choice.
*/
- if (tempGrab.type < GenericEvent)
+ if (tempGrab->type < GenericEvent)
{
grab->device = device;
grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD);
@@ -3808,7 +3803,7 @@ CheckPassiveGrabsOnWindow(
if (match & (XI_MATCH | CORE_MATCH))
{
event->device_event.corestate &= 0x1f00;
- event->device_event.corestate |= tempGrab.modifiersDetail.exact &
+ event->device_event.corestate |= tempGrab->modifiersDetail.exact &
(~0x1f00);
}
@@ -3869,6 +3864,7 @@ CheckPassiveGrabsOnWindow(
break;
}
+ FreeGrab(tempGrab);
return grab;
#undef CORE_MATCH
#undef XI_MATCH
@@ -4156,12 +4152,11 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
if (rc == Success)
{
int evtype = xi2_get_type(xi2);
- mask = GetXI2MaskByte(grab->xi2mask, thisDev, evtype);
+ mask = xi2mask_isset(grab->xi2mask, thisDev, evtype);
/* try XI2 event */
FixUpEventFromWindow(pSprite, xi2, grab->window, None, TRUE);
/* XXX: XACE */
- deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask,
- GetEventFilter(thisDev, xi2), grab);
+ deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask, 1, grab);
} else if (rc != BadMatch)
ErrorF("[dix] %s: XI2 conversion failed in DGE (%d, %d). Skipping delivery.\n",
thisDev->name, event->any.type, rc);
@@ -4635,9 +4630,8 @@ DeviceEnterLeaveEvent(
if (grab)
{
Mask mask;
- mask = GetXI2MaskByte(grab->xi2mask, mouse, type);
- TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask,
- filter, grab);
+ mask = xi2mask_isset(grab->xi2mask, mouse, type);
+ TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask, 1, grab);
} else {
if (!WindowXI2MaskIsset(mouse, pWin, (xEvent*)event))
goto out;
@@ -5086,29 +5080,30 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
*status = GrabFrozen;
else
{
- GrabRec tempGrab;
+ GrabPtr tempGrab;
- /* Otherwise segfaults happen on grabbed MPX devices */
- memset(&tempGrab, 0, sizeof(GrabRec));
+ tempGrab = AllocGrab();
- tempGrab.next = NULL;
- tempGrab.window = pWin;
- tempGrab.resource = client->clientAsMask;
- tempGrab.ownerEvents = ownerEvents;
- tempGrab.keyboardMode = keyboard_mode;
- tempGrab.pointerMode = pointer_mode;
+ tempGrab->next = NULL;
+ tempGrab->window = pWin;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->ownerEvents = ownerEvents;
+ tempGrab->keyboardMode = keyboard_mode;
+ tempGrab->pointerMode = pointer_mode;
if (grabtype == GRABTYPE_CORE)
- tempGrab.eventMask = mask->core;
+ tempGrab->eventMask = mask->core;
else if (grabtype == GRABTYPE_XI)
- tempGrab.eventMask = mask->xi;
+ tempGrab->eventMask = mask->xi;
else
- memcpy(tempGrab.xi2mask, mask->xi2mask, sizeof(tempGrab.xi2mask));
- tempGrab.device = dev;
- tempGrab.cursor = cursor;
- tempGrab.confineTo = confineTo;
- tempGrab.grabtype = grabtype;
- (*grabInfo->ActivateGrab)(dev, &tempGrab, time, FALSE);
+ xi2mask_merge(tempGrab->xi2mask, mask->xi2mask);
+ tempGrab->device = dev;
+ tempGrab->cursor = cursor;
+ tempGrab->confineTo = confineTo;
+ tempGrab->grabtype = grabtype;
+ (*grabInfo->ActivateGrab)(dev, tempGrab, time, FALSE);
*status = GrabSuccess;
+
+ FreeGrab(tempGrab);
}
return Success;
}
@@ -5264,6 +5259,7 @@ void
InitEvents(void)
{
int i;
+ QdEventPtr qe, tmp;
inputInfo.numDevices = 0;
inputInfo.devices = (DeviceIntPtr)NULL;
@@ -5277,13 +5273,10 @@ InitEvents(void)
syncEvents.replayDev = (DeviceIntPtr)NULL;
syncEvents.replayWin = NullWindow;
- while (syncEvents.pending)
- {
- QdEventPtr next = syncEvents.pending->next;
- free(syncEvents.pending);
- syncEvents.pending = next;
- }
- syncEvents.pendtail = &syncEvents.pending;
+ if (syncEvents.pending.next)
+ list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next)
+ free(qe);
+ list_init(&syncEvents.pending);
syncEvents.playingEvents = FALSE;
syncEvents.time.months = 0;
syncEvents.time.milliseconds = 0; /* hardly matters */
@@ -5429,7 +5422,7 @@ ProcUngrabKey(ClientPtr client)
{
REQUEST(xUngrabKeyReq);
WindowPtr pWin;
- GrabRec tempGrab;
+ GrabPtr tempGrab;
DeviceIntPtr keybd = PickKeyboard(client);
int rc;
@@ -5451,21 +5444,27 @@ ProcUngrabKey(ClientPtr client)
client->errorValue = stuff->modifiers;
return BadValue;
}
- tempGrab.resource = client->clientAsMask;
- tempGrab.device = keybd;
- tempGrab.window = pWin;
- tempGrab.modifiersDetail.exact = stuff->modifiers;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.modifierDevice = keybd;
- tempGrab.type = KeyPress;
- tempGrab.grabtype = GRABTYPE_CORE;
- tempGrab.detail.exact = stuff->key;
- tempGrab.detail.pMask = NULL;
- tempGrab.next = NULL;
-
- if (!DeletePassiveGrabFromList(&tempGrab))
- return BadAlloc;
- return Success;
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return BadAlloc;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->device = keybd;
+ tempGrab->window = pWin;
+ tempGrab->modifiersDetail.exact = stuff->modifiers;
+ tempGrab->modifiersDetail.pMask = NULL;
+ tempGrab->modifierDevice = keybd;
+ tempGrab->type = KeyPress;
+ tempGrab->grabtype = GRABTYPE_CORE;
+ tempGrab->detail.exact = stuff->key;
+ tempGrab->detail.pMask = NULL;
+ tempGrab->next = NULL;
+
+ if (!DeletePassiveGrabFromList(tempGrab))
+ rc = BadAlloc;
+
+ FreeGrab(tempGrab);
+
+ return rc;
}
/**
@@ -5629,7 +5628,7 @@ ProcUngrabButton(ClientPtr client)
{
REQUEST(xUngrabButtonReq);
WindowPtr pWin;
- GrabRec tempGrab;
+ GrabPtr tempGrab;
int rc;
DeviceIntPtr ptr;
@@ -5646,21 +5645,26 @@ ProcUngrabButton(ClientPtr client)
ptr = PickPointer(client);
- tempGrab.resource = client->clientAsMask;
- tempGrab.device = ptr;
- tempGrab.window = pWin;
- tempGrab.modifiersDetail.exact = stuff->modifiers;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
- tempGrab.type = ButtonPress;
- tempGrab.detail.exact = stuff->button;
- tempGrab.grabtype = GRABTYPE_CORE;
- tempGrab.detail.pMask = NULL;
- tempGrab.next = NULL;
-
- if (!DeletePassiveGrabFromList(&tempGrab))
- return BadAlloc;
- return Success;
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return BadAlloc;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->device = ptr;
+ tempGrab->window = pWin;
+ tempGrab->modifiersDetail.exact = stuff->modifiers;
+ tempGrab->modifiersDetail.pMask = NULL;
+ tempGrab->modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
+ tempGrab->type = ButtonPress;
+ tempGrab->detail.exact = stuff->button;
+ tempGrab->grabtype = GRABTYPE_CORE;
+ tempGrab->detail.pMask = NULL;
+ tempGrab->next = NULL;
+
+ if (!DeletePassiveGrabFromList(tempGrab))
+ rc = BadAlloc;
+
+ FreeGrab(tempGrab);
+ return rc;
}
/**
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c
index c28356d9b..aced130a7 100644
--- a/xorg-server/dix/grabs.c
+++ b/xorg-server/dix/grabs.c
@@ -60,6 +60,7 @@ SOFTWARE.
#include "dixgrabs.h"
#include "xace.h"
#include "exevents.h"
+#include "inpututils.h"
#define BITMASK(i) (((Mask)1) << ((i) & 31))
#define MASKIDX(i) ((i) >> 5)
@@ -122,13 +123,15 @@ PrintDeviceGrabInfo(DeviceIntPtr dev)
}
else if (grab->grabtype == GRABTYPE_XI2)
{
- for (i = 0; i < EMASKSIZE; i++)
+ for (i = 0; i < xi2mask_num_masks(grab->xi2mask); i++)
{
+ const unsigned char *mask;
int print;
print = 0;
for (j = 0; j < XI2MASKSIZE; j++)
{
- if (grab->xi2mask[i][j])
+ mask = xi2mask_get_one_mask(grab->xi2mask, i);
+ if (mask[j])
{
print = 1;
break;
@@ -137,8 +140,8 @@ PrintDeviceGrabInfo(DeviceIntPtr dev)
if (!print)
continue;
ErrorF(" xi2 event mask for device %d: 0x", dev->id);
- for (j = 0; j < XI2MASKSIZE; j++)
- ErrorF("%x", grab->xi2mask[i][j]);
+ for (j = 0; j < xi2mask_mask_size(grab->xi2mask); j++)
+ ErrorF("%x", mask[j]);
ErrorF("\n");
}
}
@@ -181,6 +184,22 @@ UngrabAllDevices(Bool kill_client)
}
GrabPtr
+AllocGrab(void)
+{
+ GrabPtr grab = calloc(1, sizeof(GrabRec));
+
+ if (grab) {
+ grab->xi2mask = xi2mask_new();
+ if (!grab->xi2mask) {
+ free(grab);
+ grab = NULL;
+ }
+ }
+
+ return grab;
+}
+
+GrabPtr
CreateGrab(
int client,
DeviceIntPtr device,
@@ -196,7 +215,7 @@ CreateGrab(
{
GrabPtr grab;
- grab = calloc(1, sizeof(GrabRec));
+ grab = AllocGrab();
if (!grab)
return (GrabPtr)NULL;
grab->resource = FakeClientID(client);
@@ -219,14 +238,14 @@ CreateGrab(
grab->next = NULL;
if (grabtype == GRABTYPE_XI2)
- memcpy(grab->xi2mask, mask->xi2mask, sizeof(mask->xi2mask));
+ xi2mask_merge(grab->xi2mask, mask->xi2mask);
if (cursor)
cursor->refcnt++;
return grab;
}
-static void
+void
FreeGrab(GrabPtr pGrab)
{
free(pGrab->modifiersDetail.pMask);
@@ -235,9 +254,60 @@ FreeGrab(GrabPtr pGrab)
if (pGrab->cursor)
FreeCursor(pGrab->cursor, (Cursor)0);
+ xi2mask_free(&pGrab->xi2mask);
free(pGrab);
}
+Bool
+CopyGrab(GrabPtr dst, const GrabPtr src)
+{
+ Mask *mdetails_mask = NULL;
+ Mask *details_mask = NULL;
+ XI2Mask *xi2mask;
+
+ if (src->cursor)
+ src->cursor->refcnt++;
+
+ if (src->modifiersDetail.pMask) {
+ int len = MasksPerDetailMask * sizeof(Mask);
+ mdetails_mask = malloc(len);
+ if (!mdetails_mask)
+ return FALSE;
+ memcpy(mdetails_mask, src->modifiersDetail.pMask, len);
+ }
+
+ if (src->detail.pMask) {
+ int len = MasksPerDetailMask * sizeof(Mask);
+ details_mask = malloc(len);
+ if (!details_mask) {
+ free(mdetails_mask);
+ return FALSE;
+ }
+ memcpy(details_mask, src->detail.pMask, len);
+ }
+
+ if (!dst->xi2mask) {
+ xi2mask = xi2mask_new();
+ if (!xi2mask) {
+ free(mdetails_mask);
+ free(details_mask);
+ return FALSE;
+ }
+ } else {
+ xi2mask = dst->xi2mask;
+ xi2mask_zero(xi2mask, -1);
+ }
+
+ *dst = *src;
+ dst->modifiersDetail.pMask = mdetails_mask;
+ dst->detail.pMask = details_mask;
+ dst->xi2mask = xi2mask;
+
+ xi2mask_merge(dst->xi2mask, src->xi2mask);
+
+ return TRUE;
+}
+
int
DeletePassiveGrab(pointer value, XID id)
{
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c
index c152b2d8b..60f9fa0a8 100644
--- a/xorg-server/dix/inpututils.c
+++ b/xorg-server/dix/inpututils.c
@@ -892,3 +892,184 @@ double_to_fp3232(double in)
ret.frac = frac_d;
return ret;
}
+
+/**
+ * DO NOT USE THIS FUNCTION. It only exists for the test cases. Use
+ * xi2mask_new() instead to get the standard sized masks.
+ *
+ * @param nmasks The number of masks (== number of devices)
+ * @param size The size of the masks in bytes
+ * @return The new mask or NULL on allocation error.
+ */
+XI2Mask*
+xi2mask_new_with_size(size_t nmasks, size_t size)
+{
+ int i;
+
+ XI2Mask *mask = calloc(1, sizeof(*mask));
+ if (!mask)
+ return NULL;
+
+
+ mask->nmasks = nmasks;
+ mask->mask_size = size;
+
+ mask->masks = calloc(mask->nmasks, sizeof(*mask->masks));
+ if (!mask->masks)
+ goto unwind;
+
+ for (i = 0; i < mask->nmasks; i++) {
+ mask->masks[i] = calloc(1, mask->mask_size);
+ if (!mask->masks[i])
+ goto unwind;
+ }
+ return mask;
+
+unwind:
+ xi2mask_free(&mask);
+ return NULL;
+}
+
+
+/**
+ * Create a new XI2 mask of the standard size, i.e. for all devices + fake
+ * devices and for the highest supported XI2 event type.
+ *
+ * @return The new mask or NULL on allocation error.
+ */
+XI2Mask*
+xi2mask_new(void)
+{
+ return xi2mask_new_with_size(EMASKSIZE, XI2MASKSIZE);
+}
+
+/**
+ * Frees memory associated with mask and resets mask to NULL.
+ */
+void
+xi2mask_free(XI2Mask** mask)
+{
+ int i;
+
+ if (!(*mask))
+ return;
+
+ for (i = 0; (*mask)->masks && i < (*mask)->nmasks; i++)
+ free((*mask)->masks[i]);
+ free((*mask)->masks);
+ free((*mask));
+ *mask = NULL;
+}
+
+/**
+ * Test if the bit for event type is set for this device, or the
+ * XIAllDevices/XIAllMasterDevices (if applicable) is set.
+ *
+ * @return TRUE if the bit is set, FALSE otherwise
+ */
+Bool
+xi2mask_isset(XI2Mask* mask, const DeviceIntPtr dev, int event_type)
+{
+ int set = 0;
+
+ BUG_WARN(dev->id < 0);
+ BUG_WARN(dev->id >= mask->nmasks);
+ BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
+
+ set = !!BitIsOn(mask->masks[XIAllDevices], event_type);
+ if (!set)
+ set = !!BitIsOn(mask->masks[dev->id], event_type);
+ if (!set && IsMaster(dev))
+ set = !!BitIsOn(mask->masks[XIAllMasterDevices], event_type);
+
+ return set;
+}
+
+/**
+ * Set the mask bit for this event type for this device.
+ */
+void
+xi2mask_set(XI2Mask *mask, int deviceid, int event_type)
+{
+ BUG_WARN(deviceid < 0);
+ BUG_WARN(deviceid >= mask->nmasks);
+ BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
+
+ SetBit(mask->masks[deviceid], event_type);
+}
+
+/**
+ * Zero out the xi2mask, for the deviceid given. If the deviceid is < 0, all
+ * masks are zeroed.
+ */
+void
+xi2mask_zero(XI2Mask *mask, int deviceid)
+{
+ int i;
+
+ BUG_WARN(deviceid > 0 && deviceid >= mask->nmasks);
+
+ if (deviceid >= 0)
+ memset(mask->masks[deviceid], 0, mask->mask_size);
+ else
+ for (i = 0; i < mask->nmasks; i++)
+ memset(mask->masks[i], 0, mask->mask_size);
+}
+
+/**
+ * Merge source into dest, i.e. dest |= source.
+ * If the masks are of different size, only the overlapping section is merged.
+ */
+void
+xi2mask_merge(XI2Mask *dest, const XI2Mask *source)
+{
+ int i, j;
+
+ for (i = 0; i < min(dest->nmasks, source->nmasks); i++)
+ for (j = 0; j < min(dest->mask_size, source->mask_size); j++)
+ dest->masks[i][j] |= source->masks[i][j];
+}
+
+/**
+ * @return The number of masks in mask
+ */
+size_t
+xi2mask_num_masks(const XI2Mask *mask)
+{
+ return mask->nmasks;
+}
+
+/**
+ * @return The size of each mask in bytes
+ */
+size_t
+xi2mask_mask_size(const XI2Mask *mask)
+{
+ return mask->mask_size;
+}
+
+/**
+ * Set the mask for the given deviceid to the source mask.
+ * If the mask given is larger than the target memory, only the overlapping
+ * parts are copied.
+ */
+void
+xi2mask_set_one_mask(XI2Mask *xi2mask, int deviceid, const unsigned char *mask, size_t mask_size)
+{
+ BUG_WARN(deviceid < 0);
+ BUG_WARN(deviceid >= xi2mask->nmasks);
+
+ memcpy(xi2mask->masks[deviceid], mask, min(xi2mask->mask_size, mask_size));
+}
+
+/**
+ * Get a reference to the XI2mask for this particular device.
+ */
+const unsigned char*
+xi2mask_get_one_mask(const XI2Mask *mask, int deviceid)
+{
+ BUG_WARN(deviceid < 0);
+ BUG_WARN(deviceid >= mask->nmasks);
+
+ return mask->masks[deviceid];
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index a9645e77b..d35464351 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(12, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(14, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(15, 0)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
diff --git a/xorg-server/hw/xfree86/xaa/xaalocal.h b/xorg-server/hw/xfree86/xaa/xaalocal.h
index 6c492c013..0780fb133 100644
--- a/xorg-server/hw/xfree86/xaa/xaalocal.h
+++ b/xorg-server/hw/xfree86/xaa/xaalocal.h
@@ -1,1755 +1,1759 @@
-
-#ifndef _XAALOCAL_H
-#define _XAALOCAL_H
-
-/* This file is very unorganized ! */
-
-
-#include "gcstruct.h"
-#include "regionstr.h"
-#include "xf86fbman.h"
-#include "xaa.h"
-#include "mi.h"
-#include "picturestr.h"
-
-#define GCWhenForced (GCArcMode << 1)
-
-#define DO_COLOR_8x8 0x00000001
-#define DO_MONO_8x8 0x00000002
-#define DO_CACHE_BLT 0x00000003
-#define DO_COLOR_EXPAND 0x00000004
-#define DO_CACHE_EXPAND 0x00000005
-#define DO_IMAGE_WRITE 0x00000006
-#define DO_PIXMAP_COPY 0x00000007
-#define DO_SOLID 0x00000008
-
-
-typedef CARD32 * (*GlyphScanlineFuncPtr)(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
-
-typedef CARD32 *(*StippleScanlineProcPtr)(CARD32*, CARD32*, int, int, int);
-
-typedef void (*RectFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int,
- XAACacheInfoPtr);
-typedef void (*TrapFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int,
- int, int, int, int, int, int,
- XAACacheInfoPtr);
-
-
-
-typedef struct _XAAScreen {
- CreateGCProcPtr CreateGC;
- CloseScreenProcPtr CloseScreen;
- GetImageProcPtr GetImage;
- GetSpansProcPtr GetSpans;
- CopyWindowProcPtr CopyWindow;
- WindowExposuresProcPtr WindowExposures;
- CreatePixmapProcPtr CreatePixmap;
- DestroyPixmapProcPtr DestroyPixmap;
- ChangeWindowAttributesProcPtr ChangeWindowAttributes;
- XAAInfoRecPtr AccelInfoRec;
- Bool (*EnterVT)(int, int);
- void (*LeaveVT)(int, int);
- int (*SetDGAMode)(int, int, DGADevicePtr);
- void (*EnableDisableFBAccess)(int, Bool);
- CompositeProcPtr Composite;
- GlyphsProcPtr Glyphs;
-} XAAScreenRec, *XAAScreenPtr;
-
-#define OPS_ARE_PIXMAP 0x00000001
-#define OPS_ARE_ACCEL 0x00000002
-
-typedef struct _XAAGC {
- GCOps *wrapOps;
- GCFuncs *wrapFuncs;
- GCOps *XAAOps;
- int DashLength;
- unsigned char* DashPattern;
- unsigned long changes;
- unsigned long flags;
-} XAAGCRec, *XAAGCPtr;
-
-#define REDUCIBILITY_CHECKED 0x00000001
-#define REDUCIBLE_TO_8x8 0x00000002
-#define REDUCIBLE_TO_2_COLOR 0x00000004
-#define DIRTY 0x00010000
-#define OFFSCREEN 0x00020000
-#define DGA_PIXMAP 0x00040000
-#define SHARED_PIXMAP 0x00080000
-#define LOCKED_PIXMAP 0x00100000
-
-#define REDUCIBILITY_MASK \
- (REDUCIBILITY_CHECKED | REDUCIBLE_TO_8x8 | REDUCIBLE_TO_2_COLOR)
-
-typedef struct _XAAPixmap {
- unsigned long flags;
- CARD32 pattern0;
- CARD32 pattern1;
- int fg;
- int bg;
- FBAreaPtr offscreenArea;
- Bool freeData;
-} XAAPixmapRec, *XAAPixmapPtr;
-
-
-extern _X_EXPORT Bool
-XAACreateGC(
- GCPtr pGC
-);
-
-extern _X_EXPORT Bool
-XAAInitAccel(
- ScreenPtr pScreen,
- XAAInfoRecPtr infoRec
-);
-
-extern _X_EXPORT RegionPtr
-XAABitBlt(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx,
- int srcy,
- int width,
- int height,
- int dstx,
- int dsty,
- void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr),
- unsigned long bitPlane
-);
-
-extern _X_EXPORT void
-XAAScreenToScreenBitBlt(
- ScrnInfoPtr pScrn,
- int nbox,
- DDXPointPtr pptSrc,
- BoxPtr pbox,
- int xdir,
- int ydir,
- int alu,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAADoBitBlt(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc
-);
-
-extern _X_EXPORT void
-XAADoImageWrite(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc
-);
-
-extern _X_EXPORT void
-XAADoImageRead(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc
-);
-
-extern _X_EXPORT void
-XAACopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc
-);
-
-
-extern _X_EXPORT RegionPtr
-XAACopyArea(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx,
- int srcy,
- int width,
- int height,
- int dstx,
- int dsty
-);
-
-extern _X_EXPORT void
-XAAValidateCopyArea(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidatePutImage(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidateCopyPlane(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidatePushPixels(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidateFillSpans(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidatePolyGlyphBlt(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidateImageGlyphBlt(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-extern _X_EXPORT void
-XAAValidatePolylines(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-
-extern _X_EXPORT RegionPtr
-XAACopyPlaneColorExpansion(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx,
- int srcy,
- int width,
- int height,
- int dstx,
- int dsty,
- unsigned long bitPlane
-);
-
-
-extern _X_EXPORT void
-XAAPushPixelsSolidColorExpansion(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDrawable,
- int dx,
- int dy,
- int xOrg,
- int yOrg
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandMSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3MSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandLSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3LSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandMSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3MSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandLSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3LSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWritePixmap (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
-);
-
-extern _X_EXPORT void
-XAAWritePixmapScanline (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
-);
-
-typedef void (*ClipAndRenderRectsFunc)(GCPtr, int, BoxPtr, int, int);
-
-
-extern _X_EXPORT void
-XAAClipAndRenderRects(
- GCPtr pGC,
- ClipAndRenderRectsFunc func,
- int nrectFill,
- xRectangle *prectInit,
- int xorg, int yorg
-);
-
-
-typedef void (*ClipAndRenderSpansFunc)(GCPtr, int, DDXPointPtr, int*,
- int, int, int);
-
-extern _X_EXPORT void
-XAAClipAndRenderSpans(
- GCPtr pGC,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted,
- ClipAndRenderSpansFunc func,
- int xorg,
- int yorg
-);
-
-
-extern _X_EXPORT void
-XAAFillSolidRects(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pat0, int pat1,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pat0, int pat1,
- int xorg, int yorg
-);
-
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAFillCacheBltRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAFillCacheExpandRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillImageWriteRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-);
-
-
-extern _X_EXPORT void
-XAATEGlyphRendererMSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRenderer3MSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRenderer3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererLSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-
-extern _X_EXPORT void
-XAATEGlyphRenderer3LSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRenderer3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-
-extern _X_EXPORT void
-XAATEGlyphRendererScanlineMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererScanline3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererScanlineLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererScanline3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirstFixedBase[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
-
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirst[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
-
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirstFixedBase[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
-
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
-
-extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void);
-extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirst(void);
-extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void);
-extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirst(void);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3LSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsLSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3LSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3MSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsMSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3MSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRectsLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRects3LSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRectsMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRects3MSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpans3LSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansLSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpans3LSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpans3MSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansMSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpans3MSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandSpansLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandSpans3LSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandSpansMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandSpans3MSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirstFixedBase[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirst[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirstFixedBase[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirst[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirst(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirst(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3MSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3MSBFirst(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3LSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3LSBFirst(void);
-
-extern _X_EXPORT int
-XAAPolyText8TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
-
-extern _X_EXPORT int
-XAAPolyText16TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageText8TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
-
-extern _X_EXPORT void
-XAAImageText16TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageGlyphBltTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-extern _X_EXPORT void
-XAAPolyGlyphBltTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-
-extern _X_EXPORT int
-XAAPolyText8NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
-
-extern _X_EXPORT int
-XAAPolyText16NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageText8NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
-
-extern _X_EXPORT void
-XAAImageText16NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageGlyphBltNonTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-extern _X_EXPORT void
-XAAPolyGlyphBltNonTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-
-extern _X_EXPORT void XAANonTEGlyphRenderer(
- ScrnInfoPtr pScrn,
- int x, int y, int n,
- NonTEGlyphPtr glyphs,
- BoxPtr pbox,
- int fg, int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAFillSolidSpans(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int patx, int paty,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int patx, int paty,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr,
- int xorigin, int yorigin
-);
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr,
- int xorigin, int yorigin
-);
-
-extern _X_EXPORT void
-XAAFillCacheBltSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted,
- XAACacheInfoPtr pCache,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillCacheExpandSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillSpans(
- DrawablePtr pDrawable,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidth,
- int fSorted
-);
-
-
-extern _X_EXPORT void
-XAAInitPixmapCache(
- ScreenPtr pScreen,
- RegionPtr areas,
- pointer data
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapToCache(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapToCacheLinear(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
-);
-
-extern _X_EXPORT void
-XAAWritePixmapToCache(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
-);
-
-extern _X_EXPORT void
-XAAWritePixmapToCacheLinear(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
-);
-
-extern _X_EXPORT void
-XAASolidHorVertLineAsRects(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-);
-
-extern _X_EXPORT void
-XAASolidHorVertLineAsTwoPoint(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-);
-
-extern _X_EXPORT void
-XAASolidHorVertLineAsBresenham(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-);
-
-
-extern _X_EXPORT void
-XAAPolyRectangleThinSolid(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-);
-
-
-extern _X_EXPORT void
-XAAPolylinesWideSolid (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
-);
-
-extern _X_EXPORT void
-XAAFillPolygonSolid(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-);
-
-extern _X_EXPORT void
-XAAFillPolygonStippled(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-);
-
-
-extern _X_EXPORT void
-XAAFillPolygonTiled(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-);
-
-
-extern _X_EXPORT int
-XAAIsEasyPolygon(
- DDXPointPtr ptsIn,
- int count,
- BoxPtr extents,
- int origin,
- DDXPointPtr *topPoint,
- int *topY, int *bottomY,
- int shape
-);
-
-extern _X_EXPORT void
-XAAFillPolygonHelper(
- ScrnInfoPtr pScrn,
- DDXPointPtr ptsIn,
- int count,
- DDXPointPtr topPoint,
- int y,
- int maxy,
- int origin,
- RectFuncPtr RectFunc,
- TrapFuncPtr TrapFunc,
- int xorg,
- int yorg,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAPolySegment(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-);
-
-extern _X_EXPORT void
-XAAPolyLines(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit
-);
-
-extern _X_EXPORT void
-XAAPolySegmentDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-);
-
-extern _X_EXPORT void
-XAAPolyLinesDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit
-);
-
-
-extern _X_EXPORT void
-XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache);
-
-extern _X_EXPORT void
-XAAWriteColor8x8PatternToCache(
- ScrnInfoPtr pScrn,
- PixmapPtr pPix,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAARotateMonoPattern(
- int *pat0, int *pat1,
- int xoffset, int yoffset,
- Bool msbfirst
-);
-
-extern _X_EXPORT void XAAComputeDash(GCPtr pGC);
-
-extern _X_EXPORT void XAAMoveDWORDS_FixedBase(
- register CARD32* dest,
- register CARD32* src,
- register int dwords
-);
-
-extern _X_EXPORT void XAAMoveDWORDS_FixedSrc(
- register CARD32* dest,
- register CARD32* src,
- register int dwords
-);
-
-extern _X_EXPORT void XAAMoveDWORDS(
- register CARD32* dest,
- register CARD32* src,
- register int dwords
-);
-
-extern _X_EXPORT int
-XAAGetRectClipBoxes(
- GCPtr pGC,
- BoxPtr pboxClippedBase,
- int nrectFill,
- xRectangle *prectInit
-);
-
-extern _X_EXPORT void
-XAASetupOverlay8_32Planar(ScreenPtr);
-
-extern _X_EXPORT void
-XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACacheTile(ScrnInfoPtr Scrn, PixmapPtr pPix);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACachePlanarMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
-
-typedef XAACacheInfoPtr (*XAACachePlanarMonoStippleProc)(ScrnInfoPtr, PixmapPtr);
-extern _X_EXPORT XAACachePlanarMonoStippleProc XAAGetCachePlanarMonoStipple(void);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACacheStipple(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACacheMono8x8Pattern(ScrnInfoPtr Scrn, int pat0, int pat1);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACacheColor8x8Pattern(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg);
-
-extern _X_EXPORT void
-XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h);
-
-extern _X_EXPORT void XAAClosePixmapCache(ScreenPtr pScreen);
-void XAAInvalidatePixmapCache(ScreenPtr pScreen);
-
-extern _X_EXPORT Bool XAACheckStippleReducibility(PixmapPtr pPixmap);
-extern _X_EXPORT Bool XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono);
-
-extern _X_EXPORT int XAAStippledFillChooser(GCPtr pGC);
-extern _X_EXPORT int XAAOpaqueStippledFillChooser(GCPtr pGC);
-extern _X_EXPORT int XAATiledFillChooser(GCPtr pGC);
-
-extern _X_EXPORT void XAAMoveInOffscreenPixmaps(ScreenPtr pScreen);
-extern _X_EXPORT void XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen);
-extern _X_EXPORT void XAARemoveAreaCallback(FBAreaPtr area);
-extern _X_EXPORT void XAAMoveOutOffscreenPixmap(PixmapPtr pPix);
-extern _X_EXPORT Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
-
-extern _X_EXPORT void
-XAAComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
-
-
-extern _X_EXPORT Bool
-XAADoComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
-
-
-extern _X_EXPORT void
-XAAGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs);
-
-extern _X_EXPORT Bool
-XAADoGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs);
-
-
-
-/* helpers */
-extern _X_EXPORT void
-XAA_888_plus_PICT_a8_to_8888 (
- CARD32 color,
- CARD8 *alphaPtr, /* in bytes */
- int alphaPitch,
- CARD32 *dstPtr,
- int dstPitch, /* in dwords */
- int width,
- int height
-);
-
-extern _X_EXPORT Bool
-XAAGetRGBAFromPixel(
- CARD32 pixel,
- CARD16 *red,
- CARD16 *green,
- CARD16 *blue,
- CARD16 *alpha,
- CARD32 format
-);
-
-
-extern _X_EXPORT Bool
-XAAGetPixelFromRGBA (
- CARD32 *pixel,
- CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- CARD32 format
-);
-
-/* XXX should be static */
-extern _X_EXPORT GCOps XAAFallbackOps;
-extern _X_EXPORT GCOps *XAAGetFallbackOps(void);
-extern _X_EXPORT GCFuncs XAAGCFuncs;
-extern _X_EXPORT DevPrivateKey XAAGetScreenKey(void);
-extern _X_EXPORT DevPrivateKey XAAGetGCKey(void);
-extern _X_EXPORT DevPrivateKey XAAGetPixmapKey(void);
-
-extern _X_EXPORT unsigned int XAAShiftMasks[32];
-
-extern _X_EXPORT unsigned int byte_expand3[256], byte_reversed_expand3[256];
-
-extern _X_EXPORT CARD32 XAAReverseBitOrder(CARD32 data);
-
-#define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\
- dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey())
-
-#define GET_XAASCREENPTR_FROM_GC(pGC)\
- dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey())
-
-#define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\
- dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey())
-
-#define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\
-((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec
-
-#define GET_XAAINFORECPTR_FROM_GC(pGC)\
-((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
-
-#define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\
-((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
-
-#define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\
-((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
-
-#define XAA_GET_PIXMAP_PRIVATE(pix)\
- (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey())
-
-#define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))
-
-#define CHECK_FG(pGC, flags) \
- (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->fgPixel))
-
-#define CHECK_BG(pGC, flags) \
- (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->bgPixel))
-
-#define CHECK_ROP(pGC, flags) \
- (!(flags & GXCOPY_ONLY) || (pGC->alu == GXcopy))
-
-#define CHECK_ROPSRC(pGC, flags) \
- (!(flags & ROP_NEEDS_SOURCE) || ((pGC->alu != GXclear) && \
- (pGC->alu != GXnoop) && (pGC->alu != GXinvert) && \
- (pGC->alu != GXset)))
-
-#define CHECK_PLANEMASK(pGC, flags) \
- (!(flags & NO_PLANEMASK) || \
- ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == \
- infoRec->FullPlanemasks[pGC->depth - 1]))
-
-#define CHECK_COLORS(pGC, flags) \
- (!(flags & RGB_EQUAL) || \
- (CHECK_RGB_EQUAL(pGC->fgPixel) && CHECK_RGB_EQUAL(pGC->bgPixel)))
-
-#define CHECK_NO_GXCOPY(pGC, flags) \
- ((pGC->alu != GXcopy) || !(flags & NO_GXCOPY) || \
- ((pGC->planemask & infoRec->FullPlanemask) != infoRec->FullPlanemask))
-
-#define IS_OFFSCREEN_PIXMAP(pPix)\
- ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->offscreenArea)
-
-#define PIXMAP_IS_SHARED(pPix)\
- ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & SHARED_PIXMAP)
-
-#define OFFSCREEN_PIXMAP_LOCKED(pPix)\
- ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & LOCKED_PIXMAP)
-
-#define XAA_DEPTH_BUG(pGC) \
- ((pGC->depth == 32) && (pGC->bgPixel == 0xffffffff))
-
-#define DELIST_OFFSCREEN_PIXMAP(pPix) { \
- PixmapLinkPtr _pLink, _prev; \
- _pLink = infoRec->OffscreenPixmaps; \
- _prev = NULL; \
- while(_pLink) { \
- if(_pLink->pPix == pPix) { \
- if(_prev) _prev->next = _pLink->next; \
- else infoRec->OffscreenPixmaps = _pLink->next; \
- free(_pLink); \
- break; \
- } \
- _prev = _pLink; \
- _pLink = _pLink->next; \
- }}
-
-
-#define SWAP_BITS_IN_BYTES(v) \
- (((0x01010101 & (v)) << 7) | ((0x02020202 & (v)) << 5) | \
- ((0x04040404 & (v)) << 3) | ((0x08080808 & (v)) << 1) | \
- ((0x10101010 & (v)) >> 1) | ((0x20202020 & (v)) >> 3) | \
- ((0x40404040 & (v)) >> 5) | ((0x80808080 & (v)) >> 7))
-
-/*
- * Moved XAAPixmapCachePrivate here from xaaPCache.c, since driver
- * replacements for CacheMonoStipple need access to it
- */
-
-typedef struct {
- int Num512x512;
- int Current512;
- XAACacheInfoPtr Info512;
- int Num256x256;
- int Current256;
- XAACacheInfoPtr Info256;
- int Num128x128;
- int Current128;
- XAACacheInfoPtr Info128;
- int NumMono;
- int CurrentMono;
- XAACacheInfoPtr InfoMono;
- int NumColor;
- int CurrentColor;
- XAACacheInfoPtr InfoColor;
- int NumPartial;
- int CurrentPartial;
- XAACacheInfoPtr InfoPartial;
- DDXPointRec MonoOffsets[64];
- DDXPointRec ColorOffsets[64];
-} XAAPixmapCachePrivate, *XAAPixmapCachePrivatePtr;
-
-
-#endif /* _XAALOCAL_H */
+
+#ifndef _XAALOCAL_H
+#define _XAALOCAL_H
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+/* This file is very unorganized ! */
+
+
+#include "gcstruct.h"
+#include "regionstr.h"
+#include "xf86fbman.h"
+#include "xaa.h"
+#include "mi.h"
+#include "picturestr.h"
+
+#define GCWhenForced (GCArcMode << 1)
+
+#define DO_COLOR_8x8 0x00000001
+#define DO_MONO_8x8 0x00000002
+#define DO_CACHE_BLT 0x00000003
+#define DO_COLOR_EXPAND 0x00000004
+#define DO_CACHE_EXPAND 0x00000005
+#define DO_IMAGE_WRITE 0x00000006
+#define DO_PIXMAP_COPY 0x00000007
+#define DO_SOLID 0x00000008
+
+
+typedef CARD32 * (*GlyphScanlineFuncPtr)(
+ CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
+);
+
+typedef CARD32 *(*StippleScanlineProcPtr)(CARD32*, CARD32*, int, int, int);
+
+typedef void (*RectFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int,
+ XAACacheInfoPtr);
+typedef void (*TrapFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int,
+ int, int, int, int, int, int,
+ XAACacheInfoPtr);
+
+
+
+typedef struct _XAAScreen {
+ CreateGCProcPtr CreateGC;
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CopyWindowProcPtr CopyWindow;
+ WindowExposuresProcPtr WindowExposures;
+ CreatePixmapProcPtr CreatePixmap;
+ DestroyPixmapProcPtr DestroyPixmap;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ XAAInfoRecPtr AccelInfoRec;
+ Bool (*EnterVT)(int, int);
+ void (*LeaveVT)(int, int);
+ int (*SetDGAMode)(int, int, DGADevicePtr);
+ void (*EnableDisableFBAccess)(int, Bool);
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+} XAAScreenRec, *XAAScreenPtr;
+
+#define OPS_ARE_PIXMAP 0x00000001
+#define OPS_ARE_ACCEL 0x00000002
+
+typedef struct _XAAGC {
+ GCOps *wrapOps;
+ GCFuncs *wrapFuncs;
+ GCOps *XAAOps;
+ int DashLength;
+ unsigned char* DashPattern;
+ unsigned long changes;
+ unsigned long flags;
+} XAAGCRec, *XAAGCPtr;
+
+#define REDUCIBILITY_CHECKED 0x00000001
+#define REDUCIBLE_TO_8x8 0x00000002
+#define REDUCIBLE_TO_2_COLOR 0x00000004
+#define DIRTY 0x00010000
+#define OFFSCREEN 0x00020000
+#define DGA_PIXMAP 0x00040000
+#define SHARED_PIXMAP 0x00080000
+#define LOCKED_PIXMAP 0x00100000
+
+#define REDUCIBILITY_MASK \
+ (REDUCIBILITY_CHECKED | REDUCIBLE_TO_8x8 | REDUCIBLE_TO_2_COLOR)
+
+typedef struct _XAAPixmap {
+ unsigned long flags;
+ CARD32 pattern0;
+ CARD32 pattern1;
+ int fg;
+ int bg;
+ FBAreaPtr offscreenArea;
+ Bool freeData;
+} XAAPixmapRec, *XAAPixmapPtr;
+
+
+extern _X_EXPORT Bool
+XAACreateGC(
+ GCPtr pGC
+);
+
+extern _X_EXPORT Bool
+XAAInitAccel(
+ ScreenPtr pScreen,
+ XAAInfoRecPtr infoRec
+);
+
+extern _X_EXPORT RegionPtr
+XAABitBlt(
+ DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC *pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr),
+ unsigned long bitPlane
+);
+
+extern _X_EXPORT void
+XAAScreenToScreenBitBlt(
+ ScrnInfoPtr pScrn,
+ int nbox,
+ DDXPointPtr pptSrc,
+ BoxPtr pbox,
+ int xdir,
+ int ydir,
+ int alu,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAADoBitBlt(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc
+);
+
+extern _X_EXPORT void
+XAADoImageWrite(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc
+);
+
+extern _X_EXPORT void
+XAADoImageRead(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc
+);
+
+extern _X_EXPORT void
+XAACopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc
+);
+
+
+extern _X_EXPORT RegionPtr
+XAACopyArea(
+ DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC *pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty
+);
+
+extern _X_EXPORT void
+XAAValidateCopyArea(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidatePutImage(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidateCopyPlane(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidatePushPixels(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidateFillSpans(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidatePolyGlyphBlt(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidateImageGlyphBlt(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+extern _X_EXPORT void
+XAAValidatePolylines(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+);
+
+
+extern _X_EXPORT RegionPtr
+XAACopyPlaneColorExpansion(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long bitPlane
+);
+
+
+extern _X_EXPORT void
+XAAPushPixelsSolidColorExpansion(
+ GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpandMSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpand3MSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpandMSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpand3MSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpandLSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpand3LSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpandLSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapColorExpand3LSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpandMSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpand3MSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpandMSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpand3MSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpandLSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpand3LSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpandLSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapScanlineColorExpand3LSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAWritePixmap (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int rop,
+ unsigned int planemask,
+ int transparency_color,
+ int bpp, int depth
+);
+
+extern _X_EXPORT void
+XAAWritePixmapScanline (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int rop,
+ unsigned int planemask,
+ int transparency_color,
+ int bpp, int depth
+);
+
+typedef void (*ClipAndRenderRectsFunc)(GCPtr, int, BoxPtr, int, int);
+
+
+extern _X_EXPORT void
+XAAClipAndRenderRects(
+ GCPtr pGC,
+ ClipAndRenderRectsFunc func,
+ int nrectFill,
+ xRectangle *prectInit,
+ int xorg, int yorg
+);
+
+
+typedef void (*ClipAndRenderSpansFunc)(GCPtr, int, DDXPointPtr, int*,
+ int, int, int);
+
+extern _X_EXPORT void
+XAAClipAndRenderSpans(
+ GCPtr pGC,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted,
+ ClipAndRenderSpansFunc func,
+ int xorg,
+ int yorg
+);
+
+
+extern _X_EXPORT void
+XAAFillSolidRects(
+ ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox
+);
+
+extern _X_EXPORT void
+XAAFillMono8x8PatternRects(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pat0, int pat1,
+ int xorg, int yorg
+);
+
+extern _X_EXPORT void
+XAAFillMono8x8PatternRectsScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pat0, int pat1,
+ int xorg, int yorg
+);
+
+
+extern _X_EXPORT void
+XAAFillColor8x8PatternRectsScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache
+);
+
+extern _X_EXPORT void
+XAAFillColor8x8PatternRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache
+);
+
+extern _X_EXPORT void
+XAAFillCacheBltRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+);
+
+extern _X_EXPORT void
+XAAFillCacheExpandRects(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillImageWriteRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill,
+ xRectangle *prectInit
+);
+
+
+extern _X_EXPORT void
+XAATEGlyphRendererMSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRenderer3MSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRendererMSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRenderer3MSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRendererLSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+
+extern _X_EXPORT void
+XAATEGlyphRenderer3LSBFirstFixedBase (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRendererLSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRenderer3LSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+
+extern _X_EXPORT void
+XAATEGlyphRendererScanlineMSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRendererScanline3MSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRendererScanlineLSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+extern _X_EXPORT void
+XAATEGlyphRendererScanline3LSBFirst (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft, int startline,
+ unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask
+);
+
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirstFixedBase[32])(
+ CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
+);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirst[32])(
+ CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
+);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirstFixedBase[32])(
+ CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
+);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32])(
+ CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
+);
+
+extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void);
+extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirst(void);
+extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void);
+extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirst(void);
+
+extern _X_EXPORT void
+XAAFillColorExpandRectsLSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRects3LSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRectsLSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRects3LSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRectsMSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRects3MSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRectsMSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandRects3MSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandRectsLSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandRects3LSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandRectsMSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandRects3MSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpansLSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpans3LSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpansLSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpans3LSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpansMSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpans3MSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpansMSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillColorExpandSpans3MSBFirstFixedBase(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandSpansLSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandSpans3LSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAPutImage(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandSpansMSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillScanlineColorExpandSpans3MSBFirst(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirstFixedBase[6])(
+ CARD32* base, CARD32* src, int offset, int width, int dwords
+);
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirst[6])(
+ CARD32* base, CARD32* src, int offset, int width, int dwords
+);
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirstFixedBase[6])(
+ CARD32* base, CARD32* src, int offset, int width, int dwords
+);
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirst[6])(
+ CARD32* base, CARD32* src, int offset, int width, int dwords
+);
+
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirst(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirst(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3MSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3MSBFirst(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3LSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3LSBFirst(void);
+
+extern _X_EXPORT int
+XAAPolyText8TEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ char *chars
+);
+
+extern _X_EXPORT int
+XAAPolyText16TEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ unsigned short *chars
+);
+
+extern _X_EXPORT void
+XAAImageText8TEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ char *chars
+);
+
+extern _X_EXPORT void
+XAAImageText16TEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ unsigned short *chars
+);
+
+extern _X_EXPORT void
+XAAImageGlyphBltTEColorExpansion(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+);
+
+extern _X_EXPORT void
+XAAPolyGlyphBltTEColorExpansion(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+);
+
+
+extern _X_EXPORT int
+XAAPolyText8NonTEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ char *chars
+);
+
+extern _X_EXPORT int
+XAAPolyText16NonTEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ unsigned short *chars
+);
+
+extern _X_EXPORT void
+XAAImageText8NonTEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ char *chars
+);
+
+extern _X_EXPORT void
+XAAImageText16NonTEColorExpansion(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ unsigned short *chars
+);
+
+extern _X_EXPORT void
+XAAImageGlyphBltNonTEColorExpansion(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+);
+
+extern _X_EXPORT void
+XAAPolyGlyphBltNonTEColorExpansion(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+);
+
+
+extern _X_EXPORT void XAANonTEGlyphRenderer(
+ ScrnInfoPtr pScrn,
+ int x, int y, int n,
+ NonTEGlyphPtr glyphs,
+ BoxPtr pbox,
+ int fg, int rop,
+ unsigned int planemask
+);
+
+extern _X_EXPORT void
+XAAFillSolidSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted
+);
+
+extern _X_EXPORT void
+XAAFillMono8x8PatternSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int patx, int paty,
+ int xorg, int yorg
+);
+
+extern _X_EXPORT void
+XAAFillMono8x8PatternSpansScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int patx, int paty,
+ int xorg, int yorg
+);
+
+extern _X_EXPORT void
+XAAFillColor8x8PatternSpansScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr,
+ int xorigin, int yorigin
+);
+
+extern _X_EXPORT void
+XAAFillColor8x8PatternSpans(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr,
+ int xorigin, int yorigin
+);
+
+extern _X_EXPORT void
+XAAFillCacheBltSpans(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points,
+ int *widths,
+ int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorg, int yorg
+);
+
+extern _X_EXPORT void
+XAAFillCacheExpandSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+);
+
+extern _X_EXPORT void
+XAAFillSpans(
+ DrawablePtr pDrawable,
+ GC *pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidth,
+ int fSorted
+);
+
+
+extern _X_EXPORT void
+XAAInitPixmapCache(
+ ScreenPtr pScreen,
+ RegionPtr areas,
+ pointer data
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapToCache(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int fg, int bg
+);
+
+extern _X_EXPORT void
+XAAWriteBitmapToCacheLinear(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int fg, int bg
+);
+
+extern _X_EXPORT void
+XAAWritePixmapToCache(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int bpp, int depth
+);
+
+extern _X_EXPORT void
+XAAWritePixmapToCacheLinear(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int bpp, int depth
+);
+
+extern _X_EXPORT void
+XAASolidHorVertLineAsRects(
+ ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir
+);
+
+extern _X_EXPORT void
+XAASolidHorVertLineAsTwoPoint(
+ ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir
+);
+
+extern _X_EXPORT void
+XAASolidHorVertLineAsBresenham(
+ ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir
+);
+
+
+extern _X_EXPORT void
+XAAPolyRectangleThinSolid(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit
+);
+
+
+extern _X_EXPORT void
+XAAPolylinesWideSolid (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pPts
+);
+
+extern _X_EXPORT void
+XAAFillPolygonSolid(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+);
+
+extern _X_EXPORT void
+XAAFillPolygonStippled(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+);
+
+
+extern _X_EXPORT void
+XAAFillPolygonTiled(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+);
+
+
+extern _X_EXPORT int
+XAAIsEasyPolygon(
+ DDXPointPtr ptsIn,
+ int count,
+ BoxPtr extents,
+ int origin,
+ DDXPointPtr *topPoint,
+ int *topY, int *bottomY,
+ int shape
+);
+
+extern _X_EXPORT void
+XAAFillPolygonHelper(
+ ScrnInfoPtr pScrn,
+ DDXPointPtr ptsIn,
+ int count,
+ DDXPointPtr topPoint,
+ int y,
+ int maxy,
+ int origin,
+ RectFuncPtr RectFunc,
+ TrapFuncPtr TrapFunc,
+ int xorg,
+ int yorg,
+ XAACacheInfoPtr pCache
+);
+
+extern _X_EXPORT void
+XAAPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+);
+
+extern _X_EXPORT void
+XAAPolyLines(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pptInit
+);
+
+extern _X_EXPORT void
+XAAPolySegmentDashed(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+);
+
+extern _X_EXPORT void
+XAAPolyLinesDashed(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pptInit
+);
+
+
+extern _X_EXPORT void
+XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+XAAWriteColor8x8PatternToCache(
+ ScrnInfoPtr pScrn,
+ PixmapPtr pPix,
+ XAACacheInfoPtr pCache
+);
+
+extern _X_EXPORT void
+XAARotateMonoPattern(
+ int *pat0, int *pat1,
+ int xoffset, int yoffset,
+ Bool msbfirst
+);
+
+extern _X_EXPORT void XAAComputeDash(GCPtr pGC);
+
+extern _X_EXPORT void XAAMoveDWORDS_FixedBase(
+ register CARD32* dest,
+ register CARD32* src,
+ register int dwords
+);
+
+extern _X_EXPORT void XAAMoveDWORDS_FixedSrc(
+ register CARD32* dest,
+ register CARD32* src,
+ register int dwords
+);
+
+extern _X_EXPORT void XAAMoveDWORDS(
+ register CARD32* dest,
+ register CARD32* src,
+ register int dwords
+);
+
+extern _X_EXPORT int
+XAAGetRectClipBoxes(
+ GCPtr pGC,
+ BoxPtr pboxClippedBase,
+ int nrectFill,
+ xRectangle *prectInit
+);
+
+extern _X_EXPORT void
+XAASetupOverlay8_32Planar(ScreenPtr);
+
+extern _X_EXPORT void
+XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
+
+extern _X_EXPORT XAACacheInfoPtr
+XAACacheTile(ScrnInfoPtr Scrn, PixmapPtr pPix);
+
+extern _X_EXPORT XAACacheInfoPtr
+XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
+
+extern _X_EXPORT XAACacheInfoPtr
+XAACachePlanarMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
+
+typedef XAACacheInfoPtr (*XAACachePlanarMonoStippleProc)(ScrnInfoPtr, PixmapPtr);
+extern _X_EXPORT XAACachePlanarMonoStippleProc XAAGetCachePlanarMonoStipple(void);
+
+extern _X_EXPORT XAACacheInfoPtr
+XAACacheStipple(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg);
+
+extern _X_EXPORT XAACacheInfoPtr
+XAACacheMono8x8Pattern(ScrnInfoPtr Scrn, int pat0, int pat1);
+
+extern _X_EXPORT XAACacheInfoPtr
+XAACacheColor8x8Pattern(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg);
+
+extern _X_EXPORT void
+XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h);
+
+extern _X_EXPORT void XAAClosePixmapCache(ScreenPtr pScreen);
+void XAAInvalidatePixmapCache(ScreenPtr pScreen);
+
+extern _X_EXPORT Bool XAACheckStippleReducibility(PixmapPtr pPixmap);
+extern _X_EXPORT Bool XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono);
+
+extern _X_EXPORT int XAAStippledFillChooser(GCPtr pGC);
+extern _X_EXPORT int XAAOpaqueStippledFillChooser(GCPtr pGC);
+extern _X_EXPORT int XAATiledFillChooser(GCPtr pGC);
+
+extern _X_EXPORT void XAAMoveInOffscreenPixmaps(ScreenPtr pScreen);
+extern _X_EXPORT void XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen);
+extern _X_EXPORT void XAARemoveAreaCallback(FBAreaPtr area);
+extern _X_EXPORT void XAAMoveOutOffscreenPixmap(PixmapPtr pPix);
+extern _X_EXPORT Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
+
+extern _X_EXPORT void
+XAAComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+
+extern _X_EXPORT Bool
+XAADoComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+
+extern _X_EXPORT void
+XAAGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs);
+
+extern _X_EXPORT Bool
+XAADoGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs);
+
+
+
+/* helpers */
+extern _X_EXPORT void
+XAA_888_plus_PICT_a8_to_8888 (
+ CARD32 color,
+ CARD8 *alphaPtr, /* in bytes */
+ int alphaPitch,
+ CARD32 *dstPtr,
+ int dstPitch, /* in dwords */
+ int width,
+ int height
+);
+
+extern _X_EXPORT Bool
+XAAGetRGBAFromPixel(
+ CARD32 pixel,
+ CARD16 *red,
+ CARD16 *green,
+ CARD16 *blue,
+ CARD16 *alpha,
+ CARD32 format
+);
+
+
+extern _X_EXPORT Bool
+XAAGetPixelFromRGBA (
+ CARD32 *pixel,
+ CARD16 red,
+ CARD16 green,
+ CARD16 blue,
+ CARD16 alpha,
+ CARD32 format
+);
+
+/* XXX should be static */
+extern _X_EXPORT GCOps XAAFallbackOps;
+extern _X_EXPORT GCOps *XAAGetFallbackOps(void);
+extern _X_EXPORT GCFuncs XAAGCFuncs;
+extern _X_EXPORT DevPrivateKey XAAGetScreenKey(void);
+extern _X_EXPORT DevPrivateKey XAAGetGCKey(void);
+extern _X_EXPORT DevPrivateKey XAAGetPixmapKey(void);
+
+extern _X_EXPORT unsigned int XAAShiftMasks[32];
+
+extern _X_EXPORT unsigned int byte_expand3[256], byte_reversed_expand3[256];
+
+extern _X_EXPORT CARD32 XAAReverseBitOrder(CARD32 data);
+
+#define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\
+ dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey())
+
+#define GET_XAASCREENPTR_FROM_GC(pGC)\
+ dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey())
+
+#define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\
+ dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey())
+
+#define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\
+((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec
+
+#define GET_XAAINFORECPTR_FROM_GC(pGC)\
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
+
+#define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\
+((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
+
+#define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\
+((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
+
+#define XAA_GET_PIXMAP_PRIVATE(pix)\
+ (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey())
+
+#define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))
+
+#define CHECK_FG(pGC, flags) \
+ (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->fgPixel))
+
+#define CHECK_BG(pGC, flags) \
+ (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->bgPixel))
+
+#define CHECK_ROP(pGC, flags) \
+ (!(flags & GXCOPY_ONLY) || (pGC->alu == GXcopy))
+
+#define CHECK_ROPSRC(pGC, flags) \
+ (!(flags & ROP_NEEDS_SOURCE) || ((pGC->alu != GXclear) && \
+ (pGC->alu != GXnoop) && (pGC->alu != GXinvert) && \
+ (pGC->alu != GXset)))
+
+#define CHECK_PLANEMASK(pGC, flags) \
+ (!(flags & NO_PLANEMASK) || \
+ ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == \
+ infoRec->FullPlanemasks[pGC->depth - 1]))
+
+#define CHECK_COLORS(pGC, flags) \
+ (!(flags & RGB_EQUAL) || \
+ (CHECK_RGB_EQUAL(pGC->fgPixel) && CHECK_RGB_EQUAL(pGC->bgPixel)))
+
+#define CHECK_NO_GXCOPY(pGC, flags) \
+ ((pGC->alu != GXcopy) || !(flags & NO_GXCOPY) || \
+ ((pGC->planemask & infoRec->FullPlanemask) != infoRec->FullPlanemask))
+
+#define IS_OFFSCREEN_PIXMAP(pPix)\
+ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->offscreenArea)
+
+#define PIXMAP_IS_SHARED(pPix)\
+ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & SHARED_PIXMAP)
+
+#define OFFSCREEN_PIXMAP_LOCKED(pPix)\
+ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & LOCKED_PIXMAP)
+
+#define XAA_DEPTH_BUG(pGC) \
+ ((pGC->depth == 32) && (pGC->bgPixel == 0xffffffff))
+
+#define DELIST_OFFSCREEN_PIXMAP(pPix) { \
+ PixmapLinkPtr _pLink, _prev; \
+ _pLink = infoRec->OffscreenPixmaps; \
+ _prev = NULL; \
+ while(_pLink) { \
+ if(_pLink->pPix == pPix) { \
+ if(_prev) _prev->next = _pLink->next; \
+ else infoRec->OffscreenPixmaps = _pLink->next; \
+ free(_pLink); \
+ break; \
+ } \
+ _prev = _pLink; \
+ _pLink = _pLink->next; \
+ }}
+
+
+#define SWAP_BITS_IN_BYTES(v) \
+ (((0x01010101 & (v)) << 7) | ((0x02020202 & (v)) << 5) | \
+ ((0x04040404 & (v)) << 3) | ((0x08080808 & (v)) << 1) | \
+ ((0x10101010 & (v)) >> 1) | ((0x20202020 & (v)) >> 3) | \
+ ((0x40404040 & (v)) >> 5) | ((0x80808080 & (v)) >> 7))
+
+/*
+ * Moved XAAPixmapCachePrivate here from xaaPCache.c, since driver
+ * replacements for CacheMonoStipple need access to it
+ */
+
+typedef struct {
+ int Num512x512;
+ int Current512;
+ XAACacheInfoPtr Info512;
+ int Num256x256;
+ int Current256;
+ XAACacheInfoPtr Info256;
+ int Num128x128;
+ int Current128;
+ XAACacheInfoPtr Info128;
+ int NumMono;
+ int CurrentMono;
+ XAACacheInfoPtr InfoMono;
+ int NumColor;
+ int CurrentColor;
+ XAACacheInfoPtr InfoColor;
+ int NumPartial;
+ int CurrentPartial;
+ XAACacheInfoPtr InfoPartial;
+ DDXPointRec MonoOffsets[64];
+ DDXPointRec ColorOffsets[64];
+} XAAPixmapCachePrivate, *XAAPixmapCachePrivatePtr;
+
+
+#endif /* _XAALOCAL_H */
diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h
index f98c87b04..cfbfa1f41 100644
--- a/xorg-server/include/dix.h
+++ b/xorg-server/include/dix.h
@@ -339,6 +339,7 @@ extern _X_EXPORT void NoticeEventTime(InternalEvent *ev);
extern void EnqueueEvent(
InternalEvent * /* ev */,
DeviceIntPtr /* device */);
+extern void PlayReleasedEvents(void);
extern void ActivatePointerGrab(
DeviceIntPtr /* mouse */,
diff --git a/xorg-server/include/dixgrabs.h b/xorg-server/include/dixgrabs.h
index 229c8bb53..65ff45d1d 100644
--- a/xorg-server/include/dixgrabs.h
+++ b/xorg-server/include/dixgrabs.h
@@ -31,6 +31,10 @@ struct _GrabParameters;
extern void PrintDeviceGrabInfo(DeviceIntPtr dev);
extern void UngrabAllDevices(Bool kill_client);
+extern GrabPtr AllocGrab(void);
+extern void FreeGrab(GrabPtr grab);
+extern Bool CopyGrab(GrabPtr dst, const GrabPtr src);
+
extern GrabPtr CreateGrab(
int /* client */,
DeviceIntPtr /* device */,
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h
index 8e7b47a4c..8b0c18e70 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/include/input.h
@@ -205,6 +205,7 @@ extern _X_EXPORT KeybdCtrl defaultKeyboardControl;
extern _X_EXPORT PtrCtrl defaultPointerControl;
typedef struct _InputOption InputOption;
+typedef struct _XI2Mask XI2Mask;
typedef struct _InputAttributes {
char *product;
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h
index f482a2294..5634f3cfc 100644
--- a/xorg-server/include/inputstr.h
+++ b/xorg-server/include/inputstr.h
@@ -118,7 +118,7 @@ typedef struct _InputClients {
XID resource; /**< id for putting into resource manager */
Mask mask[EMASKSIZE]; /**< Actual XI event mask, deviceid is index */
/** XI2 event masks. One per device, each bit is a mask of (1 << type) */
- unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
+ struct _XI2Mask *xi2mask;
} InputClients;
/**
@@ -148,7 +148,7 @@ typedef struct _OtherInputMasks {
/** The clients that selected for events */
InputClientsPtr inputClients;
/* XI2 event masks. One per device, each bit is a mask of (1 << type) */
- unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
+ struct _XI2Mask *xi2mask;
} OtherInputMasks;
/*
@@ -176,7 +176,7 @@ typedef enum {
union _GrabMask {
Mask core;
Mask xi;
- char xi2mask[EMASKSIZE][XI2MASKSIZE];
+ struct _XI2Mask *xi2mask;
};
/**
@@ -210,7 +210,7 @@ typedef struct _GrabRec {
Mask eventMask;
Mask deviceMask;
/* XI2 event masks. One per device, each bit is a mask of (1 << type) */
- unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
+ struct _XI2Mask *xi2mask;
} GrabRec;
/**
@@ -451,7 +451,7 @@ typedef struct _GrabInfoRec {
TimeStamp grabTime;
Bool fromPassiveGrab; /* true if from passive grab */
Bool implicitGrab; /* implicit from ButtonPress */
- GrabRec activeGrab;
+ GrabPtr activeGrab;
GrabPtr grab;
CARD8 activatingKey;
void (*ActivateGrab) (
@@ -575,7 +575,7 @@ extern _X_EXPORT InputInfo inputInfo;
/* for keeping the events for devices grabbed synchronously */
typedef struct _QdEvent *QdEventPtr;
typedef struct _QdEvent {
- QdEventPtr next;
+ struct list next;
DeviceIntPtr device;
ScreenPtr pScreen; /* what screen the pointer was on */
unsigned long months; /* milliseconds is in the event */
@@ -591,8 +591,8 @@ typedef struct _QdEvent {
* replayed and processed as if they would come from the device directly.
*/
typedef struct _EventSyncInfo {
- QdEventPtr pending, /**< list of queued events */
- *pendtail; /**< last event in list */
+ struct list pending;
+
/** The device to replay events for. Only set in AllowEvents(), in which
* case it is set to the device specified in the request. */
DeviceIntPtr replayDev; /* kludgy rock to put flag for */
@@ -622,4 +622,10 @@ static inline WindowPtr DeepestSpriteWin(SpritePtr sprite)
return sprite->spriteTrace[sprite->spriteTraceGood - 1];
}
+struct _XI2Mask {
+ unsigned char **masks; /* event mask in masks[deviceid][event type byte] */
+ size_t nmasks; /* number of masks */
+ size_t mask_size; /* size of each mask in bytes */
+};
+
#endif /* INPUTSTRUCT_H */
diff --git a/xorg-server/include/inpututils.h b/xorg-server/include/inpututils.h
index 2832ed5b1..5f9dfecc3 100644
--- a/xorg-server/include/inpututils.h
+++ b/xorg-server/include/inpututils.h
@@ -46,4 +46,16 @@ FP1616 double_to_fp1616(double in);
double fp1616_to_double(FP1616 in);
double fp3232_to_double(FP3232 in);
+
+XI2Mask* xi2mask_new(void);
+XI2Mask* xi2mask_new_with_size(size_t, size_t); /* don't use it */
+void xi2mask_free(XI2Mask** mask);
+Bool xi2mask_isset(XI2Mask* mask, const DeviceIntPtr dev, int event_type);
+void xi2mask_set(XI2Mask *mask, int deviceid, int event_type);
+void xi2mask_zero(XI2Mask *mask, int deviceid);
+void xi2mask_merge(XI2Mask *dest, const XI2Mask *source);
+size_t xi2mask_num_masks(const XI2Mask *mask);
+size_t xi2mask_mask_size(const XI2Mask *mask);
+void xi2mask_set_one_mask(XI2Mask *xi2mask, int deviceid, const unsigned char *mask, size_t mask_size);
+const unsigned char* xi2mask_get_one_mask(const XI2Mask *xi2mask, int deviceid);
#endif
diff --git a/xorg-server/include/list.h b/xorg-server/include/list.h
index 4706e178b..6ec2bac53 100644
--- a/xorg-server/include/list.h
+++ b/xorg-server/include/list.h
@@ -28,6 +28,7 @@
/**
* @file Classic doubly-link circular list implementation.
+ * For real usage examples of the linked list, see the file test/list.c
*
* Example:
* We need to keep a list of struct foo in the parent struct bar, i.e. what
@@ -35,16 +36,16 @@
*
* struct bar {
* ...
- * struct foo *foos; -----> struct foo {}, struct foo {}, struct foo{}
+ * struct foo *list_of_foos; -----> struct foo {}, struct foo {}, struct foo{}
* ...
* }
*
- * We need one list head in bar and a list element in all foos (both are of
+ * We need one list head in bar and a list element in all list_of_foos (both are of
* data type 'struct list').
*
* struct bar {
* ...
- * struct list foos;
+ * struct list list_of_foos;
* ...
* }
*
@@ -58,27 +59,27 @@
*
* struct bar bar;
* ...
- * list_init(&bar.foos);
+ * list_init(&bar.list_of_foos);
*
* Then we create the first element and add it to this list:
*
* struct foo *foo = malloc(...);
* ....
- * list_add(&foo->entry, &bar.foos);
+ * list_add(&foo->entry, &bar.list_of_foos);
*
* Repeat the above for each element you want to add to the list. Deleting
* works with the element itself.
* list_del(&foo->entry);
* free(foo);
*
- * Note: calling list_del(&bar.foos) will set bar.foos to an empty
+ * Note: calling list_del(&bar.list_of_foos) will set bar.list_of_foos to an empty
* list again.
*
* Looping through the list requires a 'struct foo' as iterator and the
* name of the field the subnodes use.
*
* struct foo *iterator;
- * list_for_each_entry(iterator, &bar.foos, entry) {
+ * list_for_each_entry(iterator, &bar.list_of_foos, entry) {
* if (iterator->something == ...)
* ...
* }
@@ -87,7 +88,7 @@
* loop. You need to run the safe for-each loop instead:
*
* struct foo *iterator, *next;
- * list_for_each_entry_safe(iterator, next, &bar.foos, entry) {
+ * list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) {
* if (...)
* list_del(&iterator->entry);
* }
@@ -96,14 +97,8 @@
/**
* The linkage struct for list nodes. This struct must be part of your
- * to-be-linked struct.
- *
- * Example:
- * struct foo {
- * int a;
- * void *b;
- * struct list *mylist;
- * }
+ * to-be-linked struct. struct list is required for both the head of the
+ * list and for each list node.
*
* Position and name of the struct list field is irrelevant.
* There are no requirements that elements of a list are of the same type.
@@ -118,7 +113,7 @@ struct list {
* Initialize the list as an empty list.
*
* Example:
- * list_init(&foo->mylist);
+ * list_init(&bar->list_of_foos);
*
* @param The list to initialized.
*/
@@ -140,7 +135,8 @@ __list_add(struct list *entry,
}
/**
- * Insert a new element after the given list head.
+ * Insert a new element after the given list head. The new element does not
+ * need to be initialised as empty list.
* The list changes from:
* head → some element → ...
* to
@@ -148,7 +144,7 @@ __list_add(struct list *entry,
*
* Example:
* struct foo *newfoo = malloc(...);
- * list_add(&newfoo->mylist, &foo->mylist);
+ * list_add(&newfoo->entry, &bar->list_of_foos);
*
* @param entry The new element to prepend to the list.
* @param head The existing list.
@@ -159,6 +155,28 @@ list_add(struct list *entry, struct list *head)
__list_add(entry, head, head->next);
}
+/**
+ * Append a new element to the end of the list given with this list head.
+ *
+ * The list changes from:
+ * head → some element → ... → lastelement
+ * to
+ * head → some element → ... → lastelement → new element
+ *
+ * Example:
+ * struct foo *newfoo = malloc(...);
+ * list_append(&newfoo->entry, &bar->list_of_foos);
+ *
+ * @param entry The new element to prepend to the list.
+ * @param head The existing list.
+ */
+static inline void
+list_append(struct list *entry, struct list *head)
+{
+ __list_add(entry, head->prev, head);
+}
+
+
static inline void
__list_del(struct list *prev, struct list *next)
{
@@ -176,7 +194,7 @@ __list_del(struct list *prev, struct list *next)
* the list but rather reset the list as empty list.
*
* Example:
- * list_del(&newfoo->mylist);
+ * list_del(&foo->entry);
*
* @param entry The element to remove.
*/
@@ -191,7 +209,7 @@ list_del(struct list *entry)
* Check if the list is empty.
*
* Example:
- * list_is_empty(&foo->mylist);
+ * list_is_empty(&bar->list_of_foos);
*
* @return True if the list contains one or more elements or False otherwise.
*/
@@ -206,7 +224,7 @@ list_is_empty(struct list *head)
*
* Example:
* struct foo* f;
- * f = container_of(&foo->mylist, struct foo, mylist);
+ * f = container_of(&foo->entry, struct foo, entry);
* assert(f == foo);
*
* @param ptr Pointer to the struct list.
@@ -230,7 +248,7 @@ list_is_empty(struct list *head)
*
* Example:
* struct foo *first;
- * first = list_first_entry(&foo->mylist, struct foo, mylist);
+ * first = list_first_entry(&bar->list_of_foos, struct foo, list_of_foos);
*
* @param ptr The list head
* @param type Data type of the list element to retrieve
@@ -240,6 +258,21 @@ list_is_empty(struct list *head)
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
+/**
+ * Retrieve the last list entry for the given listpointer.
+ *
+ * Example:
+ * struct foo *first;
+ * first = list_last_entry(&bar->list_of_foos, struct foo, list_of_foos);
+ *
+ * @param ptr The list head
+ * @param type Data type of the list element to retrieve
+ * @param member Member name of the struct list field in the list element.
+ * @return A pointer to the last list element.
+ */
+#define list_last_entry(ptr, type, member) \
+ list_entry((ptr)->prev, type, member)
+
#define __container_of(ptr, sample, member) \
(void *)((char *)(ptr) \
- ((char *)&(sample)->member - (char *)(sample)))
@@ -248,7 +281,7 @@ list_is_empty(struct list *head)
*
* Example:
* struct foo *iterator;
- * list_for_each_entry(iterator, &foo->mylist, mylist) {
+ * list_for_each_entry(iterator, &bar->list_of_foos, entry) {
* [modify iterator]
* }
*
diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h
index 871c6b04f..61f690927 100644
--- a/xorg-server/include/misc.h
+++ b/xorg-server/include/misc.h
@@ -369,11 +369,18 @@ typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
extern _X_EXPORT unsigned long globalSerialNumber;
extern _X_EXPORT unsigned long serverGeneration;
-#define BUG_WARN(cond) \
+/* Don't use this directly, use BUG_WARN or BUG_WARN_MSG instead */
+#define __BUG_WARN_MSG(cond, with_msg, ...) \
do { if (cond) { \
ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \
__FILE__, __LINE__, __func__); \
+ if (with_msg) ErrorF(__VA_ARGS__); \
xorg_backtrace(); \
} } while(0)
+#define BUG_WARN_MSG(cond, msg, ...) \
+ __BUG_WARN_MSG(cond, 1, msg, __VA_ARGS__)
+
+#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL)
+
#endif /* MISC_H */
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c
index 5b4c8c193..c44e5f613 100644
--- a/xorg-server/test/input.c
+++ b/xorg-server/test/input.c
@@ -1674,8 +1674,75 @@ mieq_test(void) {
mieqFini();
}
+/* Simple check that we're replaying events in-order */
+static void
+process_input_proc(InternalEvent *ev, DeviceIntPtr device)
+{
+ static int last_evtype = -1;
+
+ if (ev->any.header == 0xac)
+ last_evtype = -1;
+
+ assert(ev->any.type == ++last_evtype);
+}
+
+static void
+dix_enqueue_events(void) {
+#define NEVENTS 5
+ DeviceIntRec dev;
+ InternalEvent ev[NEVENTS];
+ SpriteInfoRec spriteInfo;
+ SpriteRec sprite;
+ QdEventPtr qe;
+ int i;
+
+ memset(&dev, 0, sizeof(dev));
+ dev.public.processInputProc = process_input_proc;
+
+ memset(&spriteInfo, 0, sizeof(spriteInfo));
+ memset(&sprite, 0, sizeof(sprite));
+ dev.spriteInfo = &spriteInfo;
+ spriteInfo.sprite = &sprite;
+
+ InitEvents();
+ assert(list_is_empty(&syncEvents.pending));
+
+ /* this way PlayReleasedEvents really runs through all events in the
+ * queue */
+ inputInfo.devices = &dev;
+
+ /* to reset process_input_proc */
+ ev[0].any.header = 0xac;
+
+ for (i = 0; i < NEVENTS; i++)
+ {
+ ev[i].any.length = sizeof(*ev);
+ ev[i].any.type = i;
+ EnqueueEvent(&ev[i], &dev);
+ assert(!list_is_empty(&syncEvents.pending));
+ qe = list_last_entry(&syncEvents.pending, QdEventRec, next);
+ assert(memcmp(qe->event, &ev[i], ev[i].any.length) == 0);
+ qe = list_first_entry(&syncEvents.pending, QdEventRec, next);
+ assert(memcmp(qe->event, &ev[0], ev[i].any.length) == 0);
+ }
+
+ /* calls process_input_proc */
+ dev.deviceGrab.sync.frozen = 1;
+ PlayReleasedEvents();
+ assert(!list_is_empty(&syncEvents.pending));
+
+
+ dev.deviceGrab.sync.frozen = 0;
+ PlayReleasedEvents();
+ assert(list_is_empty(&syncEvents.pending));
+
+ inputInfo.devices = NULL;
+}
+
+
int main(int argc, char** argv)
{
+ dix_enqueue_events();
dix_double_fp_conversion();
dix_input_valuator_masks();
dix_input_attributes();
diff --git a/xorg-server/test/list.c b/xorg-server/test/list.c
index f7d7bffce..ffb85efd0 100644
--- a/xorg-server/test/list.c
+++ b/xorg-server/test/list.c
@@ -89,6 +89,42 @@ test_list_add(void)
};
static void
+test_list_append(void)
+{
+ struct parent parent = {0};
+ struct child child[3];
+ struct child *c;
+ int i;
+
+ list_init(&parent.children);
+
+ list_append(&child[0].node, &parent.children);
+ assert(!list_is_empty(&parent.children));
+
+ c = list_first_entry(&parent.children, struct child, node);
+ assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
+ c = list_last_entry(&parent.children, struct child, node);
+ assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
+
+ list_append(&child[1].node, &parent.children);
+ c = list_first_entry(&parent.children, struct child, node);
+ assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
+ c = list_last_entry(&parent.children, struct child, node);
+ assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
+
+ list_append(&child[2].node, &parent.children);
+ c = list_first_entry(&parent.children, struct child, node);
+ assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
+ c = list_last_entry(&parent.children, struct child, node);
+ assert(memcmp(c, &child[2], sizeof(struct child)) == 0);
+
+ i = 0;
+ list_for_each_entry(c, &parent.children, node) {
+ assert(memcmp(c, &child[i++], sizeof(struct child)) == 0);
+ }
+};
+
+static void
test_list_del(void)
{
struct parent parent = {0};
@@ -325,6 +361,7 @@ int main(int argc, char** argv)
{
test_list_init();
test_list_add();
+ test_list_append();
test_list_del();
test_list_for_each();
diff --git a/xorg-server/test/xi2/Makefile.am b/xorg-server/test/xi2/Makefile.am
index c6e93e78f..913ba0f8b 100644
--- a/xorg-server/test/xi2/Makefile.am
+++ b/xorg-server/test/xi2/Makefile.am
@@ -10,7 +10,8 @@ noinst_PROGRAMS = \
protocol-xipassivegrabdevice \
protocol-xiquerypointer \
protocol-xiwarppointer \
- protocol-eventconvert
+ protocol-eventconvert \
+ xi2
TESTS=$(noinst_PROGRAMS)
TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
@@ -34,6 +35,7 @@ protocol_xiquerypointer_LDADD=$(TEST_LDADD)
protocol_xipassivegrabdevice_LDADD=$(TEST_LDADD)
protocol_xiwarppointer_LDADD=$(TEST_LDADD)
protocol_eventconvert_LDADD=$(TEST_LDADD)
+xi2_LDADD=$(TEST_LDADD)
protocol_xiqueryversion_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient
protocol_xiquerydevice_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient
@@ -44,6 +46,7 @@ protocol_xigetclientpointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-w
protocol_xipassivegrabdevice_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,GrabButton -Wl,-wrap,dixLookupWindow -Wl,-wrap,WriteToClient
protocol_xiquerypointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow
protocol_xiwarppointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow
+xi2_LDFLAGS=$(AM_LDFLAGS)
protocol_xiqueryversion_SOURCES=$(COMMON_SOURCES) protocol-xiqueryversion.c
protocol_xiquerydevice_SOURCES=$(COMMON_SOURCES) protocol-xiquerydevice.c
diff --git a/xorg-server/test/xi2/xi2.c b/xorg-server/test/xi2/xi2.c
new file mode 100644
index 000000000..5143caff8
--- /dev/null
+++ b/xorg-server/test/xi2/xi2.c
@@ -0,0 +1,129 @@
+/**
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdint.h>
+#include "inpututils.h"
+#include "inputstr.h"
+#include "assert.h"
+
+static void xi2mask_test(void)
+{
+ XI2Mask *xi2mask = NULL,
+ *mergemask = NULL;
+ unsigned char *mask;
+ DeviceIntRec dev;
+ int i;
+
+ /* size >= nmasks * 2 for the test cases below */
+ xi2mask = xi2mask_new_with_size(MAXDEVICES + 2, (MAXDEVICES + 2) * 2);
+ assert(xi2mask);
+ assert(xi2mask->nmasks > 0);
+ assert(xi2mask->mask_size > 0);
+
+ assert(xi2mask_mask_size(xi2mask) == xi2mask->mask_size);
+ assert(xi2mask_num_masks(xi2mask) == xi2mask->nmasks);
+
+ mask = calloc(1, xi2mask_mask_size(xi2mask));
+ /* ensure zeros */
+ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
+ const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
+ }
+
+ /* set various bits */
+ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
+ const unsigned char *m;
+ xi2mask_set(xi2mask, i, i);
+
+ dev.id = i;
+ assert(xi2mask_isset(xi2mask, &dev, i));
+
+ m = xi2mask_get_one_mask(xi2mask, i);
+ SetBit(mask, i);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
+ ClearBit(mask, i);
+ }
+
+ /* ensure zeros one-by-one */
+ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
+ const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) != 0);
+ xi2mask_zero(xi2mask, i);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
+ }
+
+ /* re-set, zero all */
+ for (i = 0; i < xi2mask_num_masks(xi2mask); i++)
+ xi2mask_set(xi2mask, i, i);
+ xi2mask_zero(xi2mask, -1);
+
+ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
+ const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
+ }
+
+ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
+ const unsigned char *m;
+ SetBit(mask, i);
+ xi2mask_set_one_mask(xi2mask, i, mask, xi2mask_mask_size(xi2mask));
+ m = xi2mask_get_one_mask(xi2mask, i);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
+ ClearBit(mask, i);
+ }
+
+ mergemask = xi2mask_new_with_size(MAXDEVICES + 2, (MAXDEVICES + 2) * 2);
+ for (i = 0; i < xi2mask_num_masks(mergemask); i++) {
+ dev.id = i;
+ xi2mask_set(mergemask, i, i * 2);
+ }
+
+ /* xi2mask still has all i bits set, should now also have all i * 2 bits */
+ xi2mask_merge(xi2mask, mergemask);
+ for (i = 0; i < xi2mask_num_masks(mergemask); i++) {
+ const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+ SetBit(mask, i);
+ SetBit(mask, i * 2);
+ assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
+ ClearBit(mask, i);
+ ClearBit(mask, i * 2);
+ }
+
+ xi2mask_free(&xi2mask);
+ assert(xi2mask == NULL);
+
+ xi2mask_free(&mergemask);
+ assert(mergemask == NULL);
+ free(mask);
+}
+
+
+int main(int argc, char** argv)
+{
+ xi2mask_test();
+
+ return 0;
+}
diff --git a/xorg-server/xfixes/cursor.c b/xorg-server/xfixes/cursor.c
index ed3babcb4..e61135e89 100644
--- a/xorg-server/xfixes/cursor.c
+++ b/xorg-server/xfixes/cursor.c
@@ -181,9 +181,9 @@ CursorDisplayCursor (DeviceIntPtr pDev,
ev.type = XFixesEventBase + XFixesCursorNotify;
ev.subtype = XFixesDisplayCursorNotify;
ev.window = e->pWindow->drawable.id;
- ev.cursorSerial = pCursor->serialNumber;
+ ev.cursorSerial = pCursor ? pCursor->serialNumber : 0;
ev.timestamp = currentTime.milliseconds;
- ev.name = pCursor->name;
+ ev.name = pCursor ? pCursor->name : None;
WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
}
}