Unverified Commit 975511c8 authored by Mihai Moldovan's avatar Mihai Moldovan

Merge branch…

Merge branch 'sunweaver-pr/hw-nxagent-drop-duplicate-Xserver-code_disable-Xserver-code-and-include-in-nxagent' into arctica-3.6.x Attributes GH PR #120: https://github.com/ArcticaProject/nx-libs/pull/120
parents 9df15366 a5befd4e
XCOMM $XFree86: xc/programs/Xserver/GL/glx/Imakefile,v 1.11 2004/01/28 18:11:50 alanh Exp $
NULL =
#if DoLoadableServer
# if !BuildModuleInSubdir
# define IHaveModules
......@@ -22,29 +24,95 @@ LinkSourceFile(glcontextmodes.h, $(MESASRCDIR)/src/mesa/drivers/dri/common)
LinkSourceFile(indirect_size.c, $(MESASRCDIR)/src/glx/x11)
LinkSourceFile(indirect_size.h, $(MESASRCDIR)/src/glx/x11)
SRCS = global.c glxbuf.c glxcmds.c glxcmdsswap.c glxext.c \
glxfb.c glximports.c glxmem.c glxpix.c glxscreens.c \
glxutil.c render2.c render2swap.c renderpix.c \
renderpixswap.c rensize.c rensizetab.c single2.c \
single2swap.c singlepix.c singlepixswap.c \
singlesize.c xfont.c g_disptab.c g_disptab_EXT.c \
g_render.c g_renderswap.c g_single.c g_singleswap.c \
glcontextmodes.c indirect_size.c $(MSRCS)
OBJS = global.o glxbuf.o glxcmds.o glxcmdsswap.o glxext.o \
glxfb.o glximports.o glxmem.o glxpix.o glxscreens.o \
glxutil.o render2.o render2swap.o renderpix.o \
renderpixswap.o rensize.o rensizetab.o single2.o \
single2swap.o singlepix.o singlepixswap.o \
singlesize.o xfont.o g_disptab.o g_disptab_EXT.o \
g_render.o g_renderswap.o g_single.o g_singleswap.o \
glcontextmodes.o indirect_size.o $(MOBJS)
INCLUDES = -I$(SERVERSRC)/GL/glx -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(MESASRCDIR)/include \
-I$(XINCLUDESRC) -I$(SERVERSRC)/mi \
-I$(EXTINCSRC) -I$(LIBSRC)/GL/include \
#if (!(defined(NXAgentServer) && NXAgentServer))
NXAGENT_SKIP_SRCS = \
glxext.c \
$(NULL)
NXAGENT_SKIP_OBJS = \
glxext.o \
$(NULL)
#endif
SRCS = global.c \
glxbuf.c \
glxcmds.c \
glxcmdsswap.c \
glxfb.c \
glximports.c \
glxmem.c \
glxpix.c \
glxscreens.c \
glxutil.c \
render2.c \
render2swap.c \
renderpix.c \
renderpixswap.c \
rensize.c \
rensizetab.c \
single2.c \
single2swap.c \
singlepix.c \
singlepixswap.c \
singlesize.c \
xfont.c \
g_disptab.c \
g_disptab_EXT.c \
g_render.c \
g_renderswap.c \
g_single.c \
g_singleswap.c \
glcontextmodes. c \
indirect_size.c \
$(MSRCS) \
$(NXAGENT_SKIP_SRCS) \
$(NULL)
OBJS = global.o \
glxbuf.o \
glxcmds.o \
glxcmdsswap.o \
glxfb.o \
glximports.o \
glxmem.o \
glxpix.o \
glxscreens.o \
glxutil.o \
render2.o \
render2swap.o \
renderpix.o \
renderpixswap.o \
rensize.o \
rensizetab.o \
single2.o \
single2swap.o \
singlepix.o \
singlepixswap.o \
singlesize.o \
xfont.o \
g_disptab.o \
g_disptab_EXT.o \
g_render.o \
g_renderswap.o \
g_single.o \
g_singleswap.o \
glcontextmodes.o \
indirect_size.o \
$(MOBJS) \
$(NXAGENT_SKIP_OBJS) \
$(NULL)
INCLUDES = -I$(SERVERSRC)/GL/glx \
-I$(SERVERSRC)/GL/include \
-I$(SERVERSRC)/include \
-I$(INCLUDESRC) \
-I$(MESASRCDIR)/include \
-I$(XINCLUDESRC) \
-I$(SERVERSRC)/mi \
-I$(EXTINCSRC) \
-I$(LIBSRC)/GL/include \
-I$(XF86SRC) \
`pkg-config --cflags-only-I pixman-1`
`pkg-config --cflags-only-I pixman-1` \
$(NULL)
#if defined(DarwinArchitecture) && ((OSMajorVersion == 6 && OSMinorVersion < 3) || OSMajorVersion < 6)
NO_EXT_DEFS = -DMISSING_GL_EXTS
......
......@@ -390,6 +390,8 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
/************************************************************************/
#ifndef NXAGENT_SERVER
/*
** Top level dispatcher; all commands are executed from here down.
*/
......@@ -493,6 +495,9 @@ static int __glXSwapDispatch(ClientPtr client)
return (*proc)(cl, (GLbyte *) stuff);
}
#endif /* NXAGENT_SERVER */
int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc)
{
return BadRequest;
......
......@@ -187,7 +187,9 @@ INSTPGMFLAGS =
cfb24/ModuleLibraryTargetName(cfb24)
CFB32 = cfb/ModuleLibraryTargetName(cfb) \
cfb32/ModuleLibraryTargetName(cfb32)
#if (!(defined(NXAgentServer) && NXAgentServer))
DAMAGE = miext/damage/ModuleLibraryTargetName(damage)
#endif
SHADOW = miext/shadow/ModuleLibraryTargetName(shadow)
LAYER = miext/layer/ModuleLibraryTargetName(layer)
#else
......@@ -212,7 +214,9 @@ INSTPGMFLAGS =
cfb/LibraryTargetName(cfb)
CFB32 = cfb32/LibraryTargetName(cfb32) \
cfb/LibraryTargetName(cfb)
#if (!(defined(NXAgentServer) && NXAgentServer))
DAMAGE = miext/damage/LibraryTargetName(damage)
#endif
SHADOW = miext/shadow/LibraryTargetName(shadow)
LAYER = miext/layer/LibraryTargetName(layer)
#endif
......@@ -356,7 +360,6 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \
hw/nxagent/NXmiglyph.o \
hw/nxagent/NXmiexpose.o \
hw/nxagent/NXresource.o \
hw/nxagent/NXmiwindow.o \
hw/nxagent/NXdamage.o
#elif !defined(LynxOSArchitecture) && \
!defined(Win32Architecture) && \
......@@ -377,7 +380,6 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \
hw/nxagent/NXmiglyph.o \
hw/nxagent/NXmiexpose.o \
hw/nxagent/NXresource.o \
hw/nxagent/NXmiwindow.o \
hw/nxagent/NXdamage.o
#else
NXAGENTOBJS = hw/nxagent/miinitext.o \
......@@ -396,7 +398,6 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \
hw/nxagent/NXmiglyph.o \
hw/nxagent/NXmiexpose.o \
hw/nxagent/NXresource.o \
hw/nxagent/NXmiwindow.o \
hw/nxagent/NXdamage.o \
dix/main.o
#endif
......
......@@ -30,7 +30,7 @@ XCOMM $XFree86: xc/programs/Xserver/Xext/Imakefile,v 3.43 2003/04/21 18:56:48 sv
SUBDIRS = extmod
#endif
#if HasShm
#if HasShm && (!(defined(NXAgentServer) && NXAgentServer))
SHMSRCS = shm.c
SHMOBJS = shm.o
#endif
......@@ -48,7 +48,10 @@ XF86BIGFOBJS = xf86bigfont.o
#endif
#endif
#if BuildXvExt
#if BuildXvExt && ( (defined(NXAgentServer) && NXAgentServer) && !defined(SunArchitecture) && !defined(cygwinArchitecture) )
XVSRCS = xvmain.c xvmc.c
XVOBJS = xvmain.o xvmc.o
#elif BuildXvExt
XVSRCS = xvmain.c xvdisp.c xvmc.c
XVOBJS = xvmain.o xvdisp.o xvmc.o
#endif
......
......@@ -202,6 +202,7 @@ static Bool CheckForShmSyscall()
#endif
#ifndef NXAGENT_SERVER
void
ShmExtensionInit(INITARGS)
{
......@@ -265,6 +266,7 @@ ShmExtensionInit(INITARGS)
EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent;
}
}
#endif /* NXAGENT_SERVER */
/*ARGSUSED*/
static void
......@@ -502,6 +504,7 @@ ProcShmDetach(client)
return(client->noClientException);
}
#ifndef NXAGENT_SERVER
static void
miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
DrawablePtr dst;
......@@ -563,6 +566,7 @@ fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy,
data);
}
#endif /* NXAGENT_SERVER */
#ifdef PANORAMIX
......@@ -824,6 +828,7 @@ CreatePmap:
#endif
#ifndef NXAGENT_SERVER
static int
ProcShmPutImage(client)
register ClientPtr client;
......@@ -934,7 +939,7 @@ ProcShmPutImage(client)
return (client->noClientException);
}
#endif /* NXAGENT_SERVER */
static int
......@@ -1047,6 +1052,7 @@ ProcShmGetImage(client)
return(client->noClientException);
}
#ifndef NXAGENT_SERVER
static PixmapPtr
fbShmCreatePixmap (pScreen, width, height, depth, addr)
ScreenPtr pScreen;
......@@ -1068,6 +1074,7 @@ fbShmCreatePixmap (pScreen, width, height, depth, addr)
}
return pPixmap;
}
#endif /* NXAGENT_SERVER */
static int
ProcShmCreatePixmap(client)
......@@ -1142,6 +1149,7 @@ CreatePmap:
return (BadAlloc);
}
#ifndef NXAGENT_SERVER
static int
ProcShmDispatch (client)
register ClientPtr client;
......@@ -1177,6 +1185,7 @@ ProcShmDispatch (client)
return BadRequest;
}
}
#endif /* NXAGENT_SERVER */
static void
SShmCompletionEvent(from, to)
......@@ -1286,6 +1295,7 @@ SProcShmCreatePixmap(client)
return ProcShmCreatePixmap(client);
}
#ifndef NXAGENT_SERVER
static int
SProcShmDispatch (client)
register ClientPtr client;
......@@ -1309,3 +1319,4 @@ SProcShmDispatch (client)
return BadRequest;
}
}
#endif /* NXAGENT_SERVER */
\ No newline at end of file
......@@ -224,6 +224,8 @@ static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*);
**
*/
#if !defined(NXAGENT_SERVER) || defined(__sun) || defined(__CYGWIN__)
int
ProcXvDispatch(ClientPtr client)
{
......@@ -351,6 +353,8 @@ SProcXvDispatch(ClientPtr client)
}
}
}
#endif /* !defined(NXAGENT_SERVER) || defined(__sun) || defined(__CYGWIN__) */
static int
ProcXvQueryExtension(ClientPtr client)
......
XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
XCOMM $XFree86: xc/programs/Xserver/dix/Imakefile,v 3.17 2003/04/15 18:30:43 alanh Exp $
NULL =
#include <Server.tmpl>
XPSRC = xpstubs.c
......@@ -15,18 +13,80 @@ FFS_SRC = ffs.c
FFS_OBJ = ffs.o
#endif
SRCS = atom.c colormap.c cursor.c devices.c dispatch.c dixutils.c events.c \
extension.c gc.c globals.c glyphcurs.c grabs.c \
main.c property.c region.c resource.c swaprep.c swapreq.c \
tables.c window.c initatoms.c dixfonts.c privates.c pixmap.c $(FFS_SRC)
OBJS = atom.o colormap.o cursor.o devices.o dispatch.o dixutils.o events.o \
extension.o gc.o globals.o glyphcurs.o grabs.o \
main.o property.o region.o resource.o swaprep.o swapreq.o \
tables.o window.o initatoms.o dixfonts.o privates.o pixmap.o $(FFS_OBJ)
INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
-I$(SERVERSRC)/Xext -I$(SERVERSRC)/lbx \
`pkg-config --cflags-only-I pixman-1`
#if (!(defined(NXAgentServer) && NXAgentServer))
NXAGENT_SKIP_SRCS = \
dispatch.c \
dixfonts.c \
events.c \
extension.c \
glyphcurs.c \
property.c \
resource.c \
window.c \
$(NULL)
NXAGENT_SKIP_OBJS = \
dispatch.o \
dixfonts.o \
events.o \
extension.o \
glyphcurs.o \
property.o \
resource.o \
window.o \
$(NULL)
#endif
SRCS = \
atom.c \
colormap.c \
cursor.c \
devices.c \
dixutils.c \
gc.c \
globals.c \
grabs.c \
main.c \
region.c \
swaprep.c \
swapreq.c \
tables.c \
initatoms.c \
privates.c \
pixmap.c \
$(NXAGENT_SKIP_SRCS) \
$(FFS_SRC) \
$(NULL)
OBJS = \
atom.o \
colormap.o \
cursor.o \
devices.o \
dixutils.o \
gc.o \
globals.o \
grabs.o \
main.o \
region.o \
swaprep.o \
swapreq.o \
tables.o \
initatoms.o \
privates.o \
pixmap.o \
$(NXAGENT_SKIP_OBJS) \
$(FFS_OBJ) \
$(NULL)
INCLUDES = -I../include \
-I$(XINCLUDESRC) \
-I$(EXTINCSRC) \
-I$(SERVERSRC)/Xext \
-I$(SERVERSRC)/lbx \
`pkg-config --cflags-only-I pixman-1` \
$(NULL)
LINTLIBS = ../os/llib-los.ln
/*
......
......@@ -209,6 +209,7 @@ UpdateCurrentTimeIf()
currentTime = systime;
}
#ifndef NXAGENT_SERVER
void
InitSelections()
{
......@@ -217,6 +218,7 @@ InitSelections()
CurrentSelections = (Selection *)NULL;
NumCurrentSelections = 0;
}
#endif /* NXAGENT_SERVER */
void
FlushClientCaches(XID id)
......@@ -349,6 +351,7 @@ SmartScheduleClient (int *clientReady, int nready)
}
#endif
#ifndef NXAGENT_SERVER
#define MAJOROP ((xReq *)client->requestBuffer)->reqType
void
......@@ -485,6 +488,7 @@ Dispatch(void)
}
#undef MAJOROP
#endif /* NXAGENT_SERVER */
int
ProcBadRequest(ClientPtr client)
......@@ -639,6 +643,7 @@ ProcChangeSaveSet(register ClientPtr client)
}
}
#ifndef NXAGENT_SERVER
int
ProcReparentWindow(register ClientPtr client)
{
......@@ -673,6 +678,7 @@ ProcReparentWindow(register ClientPtr client)
else
return (BadMatch);
}
#endif /* NXAGENT_SERVER */
int
ProcMapWindow(register ClientPtr client)
......@@ -790,6 +796,7 @@ GetGeometry(register ClientPtr client, xGetGeometryReply *rep)
REQUEST_SIZE_MATCH(xResourceReq);
SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess);
memset(rep, 0, sizeof(xGetGeometryReply));
rep->type = X_Reply;
rep->length = 0;
rep->sequenceNumber = client->sequence;
......@@ -829,7 +836,6 @@ ProcGetGeometry(register ClientPtr client)
xGetGeometryReply rep;
int status;
memset(&rep, 0, sizeof(xGetGeometryReply));
if ((status = GetGeometry(client, &rep)) != Success)
return status;
......@@ -838,6 +844,7 @@ ProcGetGeometry(register ClientPtr client)
}
#ifndef NXAGENT_SERVER
int
ProcQueryTree(register ClientPtr client)
{
......@@ -887,6 +894,8 @@ ProcQueryTree(register ClientPtr client)
return(client->noClientException);
}
#endif /* NXAGENT_SERVER */
int
ProcInternAtom(register ClientPtr client)
......@@ -950,6 +959,7 @@ ProcGetAtomName(register ClientPtr client)
extern int k5_bad();
#endif
#ifndef NXAGENT_SERVER
int
ProcSetSelectionOwner(register ClientPtr client)
{
......@@ -1045,6 +1055,7 @@ ProcSetSelectionOwner(register ClientPtr client)
return (BadAtom);
}
}
#endif /* NXAGENT_SERVER */
int
ProcGetSelectionOwner(register ClientPtr client)
......@@ -1078,6 +1089,7 @@ ProcGetSelectionOwner(register ClientPtr client)
}
}
#ifndef NXAGENT_SERVER
int
ProcConvertSelection(register ClientPtr client)
{
......@@ -1143,6 +1155,7 @@ ProcConvertSelection(register ClientPtr client)
return (BadAtom);
}
}
#endif /* NXAGENT_SERVER */
int
ProcGrabServer(register ClientPtr client)
......@@ -1285,6 +1298,7 @@ ProcTranslateCoords(register ClientPtr client)
return(client->noClientException);
}
#ifndef NXAGENT_SERVER
int
ProcOpenFont(register ClientPtr client)
{
......@@ -1324,6 +1338,7 @@ ProcCloseFont(register ClientPtr client)
return (BadFont);
}
}
#endif /* NXAGENT_SERVER */
int
ProcQueryFont(register ClientPtr client)
......@@ -1335,6 +1350,7 @@ ProcQueryFont(register ClientPtr client)
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id; /* EITHER font or gc */
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
SecurityReadAccess);
if (!pFont)
......@@ -1367,6 +1383,7 @@ ProcQueryFont(register ClientPtr client)
rlength = sizeof(xQueryFontReply) +
FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) +
nprotoxcistructs * sizeof(xCharInfo);
reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength);
if(!reply)
{
......@@ -1435,6 +1452,7 @@ ProcQueryTextExtents(register ClientPtr client)
return(client->noClientException);
}
#ifndef NXAGENT_SERVER
int
ProcListFonts(register ClientPtr client)
{
......@@ -1456,6 +1474,7 @@ ProcListFontsWithInfo(register ClientPtr client)
return StartListFontsWithInfo(client, stuff->nbytes,
(unsigned char *) &stuff[1], stuff->maxNames);
}
#endif /* NXAGENT_SERVER */
/**
*
......@@ -1527,6 +1546,7 @@ CreatePmap:
return (BadAlloc);
}
#ifndef NXAGENT_SERVER
int
ProcFreePixmap(register ClientPtr client)
{
......@@ -1548,6 +1568,7 @@ ProcFreePixmap(register ClientPtr client)
return (BadPixmap);
}
}
#endif /* NXAGENT_SERVER */
int
ProcCreateGC(register ClientPtr client)
......@@ -3186,6 +3207,7 @@ ProcQueryBestSize (register ClientPtr client)
}
#ifndef NXAGENT_SERVER
int
ProcSetScreenSaver (register ClientPtr client)
{
......@@ -3241,6 +3263,7 @@ ProcSetScreenSaver (register ClientPtr client)
SetScreenSaverTimer();
return (client->noClientException);
}
#endif /* NXAGENT_SERVER */
int
ProcGetScreenSaver(register ClientPtr client)
......@@ -3446,6 +3469,7 @@ ProcChangeCloseDownMode(register ClientPtr client)
}
}
#ifndef NXAGENT_SERVER
int ProcForceScreenSaver(register ClientPtr client)
{
REQUEST(xForceScreenSaverReq);
......@@ -3461,6 +3485,7 @@ int ProcForceScreenSaver(register ClientPtr client)
SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode);
return client->noClientException;
}
#endif /* NXAGENT_SERVER */
int ProcNoOperation(register ClientPtr client)
{
......@@ -3495,6 +3520,7 @@ InitProcVectors(void)
}
/**********************
* CloseDownClient
*
......@@ -3502,6 +3528,7 @@ InitProcVectors(void)
* then killed again, the client is really destroyed.
*********************/
#ifndef NXAGENT_SERVER
char dispatchExceptionAtReset = DE_RESET;
void
......@@ -3589,6 +3616,7 @@ CloseDownClient(register ClientPtr client)
currentMaxClients--;
}
}
#endif /* NXAGENT_SERVER */
static void
KillAllClients()
......@@ -3682,6 +3710,7 @@ extern int clientPrivateLen;
extern unsigned *clientPrivateSizes;
extern unsigned totalClientSize;
#ifndef NXAGENT_SERVER
int
InitClientPrivates(ClientPtr client)
{
......@@ -3716,6 +3745,7 @@ InitClientPrivates(ClientPtr client)
}
return 1;
}
#endif /* NXAGENT_SERVER */
/************************
* int NextAvailableClient(ospriv)
......
......@@ -72,63 +72,6 @@ Equipment Corporation.
#include <stdio.h>
#endif
#ifdef NX_TRANS_SOCKET
char _NXFontPath[1024];
/*
* Override the default font path and make
* it configurable at run time, based on
* the NX_FONT environment.
*/
static const char *_NXGetFontPath(const char *path)
{
const char *fontEnv;
/*
* Check the environment only once.
*/
if (*_NXFontPath != '\0')
{
return _NXFontPath;
}
fontEnv = getenv("NX_FONT");
if (fontEnv != NULL && *fontEnv != '\0')
{
if (strlen(fontEnv) + 1 > 1024)
{
#ifdef NX_TRANS_TEST
fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n");
#endif
goto _NXGetFontPathError;
}
strcpy(_NXFontPath, fontEnv);
#ifdef NX_TRANS_TEST
fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath);
#endif
return _NXFontPath;
}
_NXGetFontPathError:
strcpy(_NXFontPath, path);
#ifdef NX_TRANS_TEST
fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath);
#endif
return _NXFontPath;
}
#endif
#ifdef PANORAMIX
#include "panoramiX.h"
#endif
......@@ -288,6 +231,7 @@ FreeFPE (FontPathElementPtr fpe)
}
}
#ifndef NXAGENT_SERVER
static Bool
doOpenFont(ClientPtr client, OFclosurePtr c)
{
......@@ -438,6 +382,7 @@ bail:
xfree(c);
return TRUE;
}
#endif /* NXAGENT_SERVER */
int
OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
......@@ -634,6 +579,7 @@ QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
return;
}
#ifndef NXAGENT_SERVER
static Bool
doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
{
......@@ -1163,6 +1109,7 @@ bail:
xfree(c);
return TRUE;
}
#endif /* NXAGENT_SERVER */
int
StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
......@@ -1401,6 +1348,13 @@ doPolyText(ClientPtr client, register PTclosurePtr c)
err = BadAlloc;
goto bail;
}
#ifdef NXAGENT_SERVER
pGC->tileIsPixel = TRUE;
pGC->tile.pixel = 0;
pGC->stipple = NullPixmap;
#endif
if ((err = CopyGC(c->pGC, pGC, GCFunction |
GCPlaneMask | GCForeground |
GCBackground | GCFillStyle |
......@@ -1593,6 +1547,13 @@ doImageText(ClientPtr client, register ITclosurePtr c)
err = BadAlloc;
goto bail;
}
#ifdef NXAGENT_SERVER
pGC->tileIsPixel = TRUE;
pGC->tile.pixel = 0;
pGC->stipple = NullPixmap;
#endif
if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
GCForeground | GCBackground | GCFillStyle |
GCTile | GCStipple | GCTileStipXOrigin |
......@@ -1733,7 +1694,6 @@ find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int le
return (FontPathElementPtr) 0;
}
static int
SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
{
......@@ -1810,11 +1770,13 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
err = (*fpe_functions[fpe->type].init_fpe) (fpe);
if (err != Successful)
{
#ifndef NXAGENT_SERVER
if (persist)
{
ErrorF("Could not init font path element %s, removing from list!\n",
fpe->name);
}
#endif /* NXAGENT_SERVER */
xfree (fpe->name);
xfree (fpe);
}
......@@ -1862,6 +1824,7 @@ SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
return err;
}
#ifndef NXAGENT_SERVER
int
SetDefaultFontPath(char *path)
{
......@@ -1876,19 +1839,11 @@ SetDefaultFontPath(char *path)
bad;
/* get enough for string, plus values -- use up commas */
#ifdef NX_TRANS_SOCKET
len = strlen(_NXGetFontPath(path)) + 1;
#else
len = strlen(path) + 1;
#endif
nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
if (!newpath)
return BadAlloc;
#ifdef NX_TRANS_SOCKET
pp = (unsigned char *) _NXGetFontPath(path);
#else
pp = (unsigned char *) path;
#endif
cp++;
while (*pp) {
if (*pp == ',') {
......@@ -1910,6 +1865,7 @@ SetDefaultFontPath(char *path)
return err;
}
#endif /* NXAGENT_SERVER */
unsigned char *
GetFontPath(int *count, int *length)
......@@ -1928,7 +1884,7 @@ GetFontPath(int *count, int *length)
if (c == NULL) {
free(font_path_string);
font_path_string = NULL;
return BadAlloc;
return NULL;
}
font_path_string = c;
......
......@@ -1218,6 +1218,7 @@ CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
ComputeFreezes();
}
#ifndef NXAGENT_SERVER
void
ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
TimeStamp time, Bool autoGrab)
......@@ -1269,6 +1270,7 @@ DeactivatePointerGrab(register DeviceIntPtr mouse)
FreeCursor(grab->cursor, (Cursor)0);
ComputeFreezes();
}
#endif /* NXAGENT_SERVER */
void
ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
......@@ -1914,6 +1916,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
return FALSE;
}
#ifndef NXAGENT_SERVER
static WindowPtr
XYToWindow(int x, int y)
{
......@@ -1961,6 +1964,7 @@ XYToWindow(int x, int y)
}
return spriteTrace[spriteTraceGood-1];
}
#endif /* NXAGENT_SERVER */
static Bool
CheckMotion(xEvent *xE)
......@@ -2072,6 +2076,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
}
#endif
#ifndef NXAGENT_SERVER
void
DefineInitialRootWindow(register WindowPtr win)
{
......@@ -2113,6 +2118,7 @@ DefineInitialRootWindow(register WindowPtr win)
}
#endif
}
#endif /* NXAGENT_SERVER */
/*
* This does not take any shortcuts, and even ignores its argument, since
......@@ -3140,6 +3146,7 @@ EnterLeaveEvent(
}
if (mask & filters[type])
{
memset(&event, 0, sizeof(xEvent));
event.u.u.type = type;
event.u.u.detail = detail;
event.u.enterLeave.time = currentTime.milliseconds;
......@@ -3966,6 +3973,7 @@ CloseDownEvents(void)
spriteTraceSize = 0;
}
#ifndef NXAGENT_SERVER
int
ProcSendEvent(ClientPtr client)
{
......@@ -4053,6 +4061,7 @@ ProcSendEvent(ClientPtr client)
NullGrab, 0);
return Success;
}
#endif /* NXAGENT_SERVER */
int
ProcUngrabKey(ClientPtr client)
......
......@@ -287,7 +287,7 @@ CloseDownExtensions()
}
}
#ifndef NXAGENT_SERVER
int
ProcQueryExtension(ClientPtr client)
{
......@@ -392,7 +392,7 @@ ProcListExtensions(ClientPtr client)
}
return(client->noClientException);
}
#endif
ExtensionLookupProc
LookupProc(char *name, GCPtr pGC)
......
......@@ -74,6 +74,7 @@ the first one we find.
cursor metrics.
*/
#ifndef NXAGENT_SERVER
int
ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, unsigned char **ppbits)
{
......@@ -138,7 +139,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns
(*pScreen->DestroyPixmap)(ppix);
return Success;
}
#endif /* NXAGENT_SERVER */
Bool
CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm)
......
......@@ -188,6 +188,7 @@ found:
return Success;
}
#ifndef NXAGENT_SERVER
int
ProcChangeProperty(ClientPtr client)
{
......@@ -368,6 +369,7 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
}
return(Success);
}
#endif /* NXAGENT_SERVER */
int
DeleteProperty(WindowPtr pWin, Atom propName)
......@@ -446,6 +448,8 @@ NullPropertyReply(
return(client->noClientException);
}
#ifndef NXAGENT_SERVER
/*****************
* GetProperty
* If type Any is specified, returns the property from the specified
......@@ -600,6 +604,7 @@ ProcGetProperty(ClientPtr client)
}
return(client->noClientException);
}
#endif /* NXAGENT_SERVER */
int
ProcListProperties(ClientPtr client)
......
......@@ -422,6 +422,7 @@ FakeClientID(register int client)
return id;
}
#ifndef NXAGENT_SERVER
Bool
AddResource(XID id, RESTYPE type, void * value)
{
......@@ -457,6 +458,7 @@ AddResource(XID id, RESTYPE type, void * value)
rrec->expectID = id + 1;
return TRUE;
}
#endif /* NXAGENT_SERVER */
static void
RebuildTable(int client)
......@@ -507,6 +509,7 @@ RebuildTable(int client)
clientTable[client].resources = resources;
}
#ifndef NXAGENT_SERVER
void
FreeResource(XID id, RESTYPE skipDeleteFuncType)
{
......@@ -573,6 +576,7 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
}
}
}
#endif /* NXAGENT_SERVER */
/*
* Change the value associated with a resource id. Caller
......@@ -606,6 +610,7 @@ ChangeResourceValue (XID id, RESTYPE rtype, void * value)
* add and delete an equal number of resources!
*/
#ifndef NXAGENT_SERVER
void
FindClientResourcesByType(
ClientPtr client,
......@@ -693,6 +698,7 @@ LookupClientResourceComplex(
}
return NULL;
}
#endif /* NXAGENT_SERVER */
void
......
......@@ -160,7 +160,7 @@ static Bool TileScreenSaver(int i, int kind);
int numSaveUndersViewable = 0;
int deltaSaveUndersViewable = 0;
#ifdef DEBUG
#if defined(DEBUG) || (defined(NXAGENT_SERVER) && defined(WINDOW_TREE_DEBUG))
/******
* PrintWindowTree
* For debugging only
......@@ -286,6 +286,7 @@ SetWindowToDefaults(register WindowPtr pWin)
#endif
}
#ifndef NXAGENT_SERVER
static void
MakeRootTile(WindowPtr pWin)
{
......@@ -331,6 +332,7 @@ MakeRootTile(WindowPtr pWin)
FreeScratchGC(pGC);
}
#endif /* NXAGENT_SERVER */
WindowPtr
AllocateWindow(ScreenPtr pScreen)
......@@ -477,6 +479,7 @@ CreateRootWindow(ScreenPtr pScreen)
return TRUE;
}
#ifndef NXAGENT_SERVER
void
InitRootWindow(WindowPtr pWin)
{
......@@ -498,6 +501,7 @@ InitRootWindow(WindowPtr pWin)
MapWindow(pWin, serverClient);
}
#endif /* NXAGENT_SERVER */
/* Set the region to the intersection of the rectangle and the
* window's winSize. The window is typically the parent of the
......@@ -509,7 +513,6 @@ ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn,
register int x, register int y,
register int w, register int h)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
BoxRec box;
box = *(RegionExtents(&pWin->winSize));
......@@ -873,12 +876,14 @@ CrushTree(WindowPtr pWin)
}
}
/*****
* DeleteWindow
* Deletes child of window then window itself
* If wid is None, don't send any events
*****/
#ifndef NXAGENT_SERVER
int
DeleteWindow(void * value, XID wid)
{
......@@ -914,6 +919,7 @@ DeleteWindow(void * value, XID wid)
xfree(pWin);
return Success;
}
#endif /* NXAGENT_SERVER */
void
DestroySubwindows(register WindowPtr pWin, ClientPtr client)
......@@ -1231,6 +1237,25 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt
#endif /* DO_SAVE_UNDERS */
break;
case CWEventMask:
/*
* TODO: Some applications like java bean shell
* don' t work if they cannot monitor the root
* window for Structure Redirect events. However
* this doesn't seem to be the best solution, since
* also an X server with a window manager running,
* doesn't allow to monitor for those events, but
* the java bean shell works flawlessy on this
* server.
*
* #ifdef NXAGENT_SERVER
* if (nxagentCheckIllegalRootMonitoring(pWin, (Mask)*pVlist))
* {
* return BadAccess;
* }
* #endif
*/
result = EventSelectForWindow(pWin, client, (Mask )*pVlist);
if (result)
{
......@@ -1599,8 +1624,6 @@ CreateUnclippedWinSize (register WindowPtr pWin)
pRgn = RegionCreate(&box, 1);
#ifdef SHAPE
if (wBoundingShape (pWin) || wClipShape (pWin)) {
ScreenPtr pScreen = pWin->drawable.pScreen;
RegionTranslate(pRgn, - pWin->drawable.x,
- pWin->drawable.y);
if (wBoundingShape (pWin))
......@@ -1635,8 +1658,6 @@ SetWinSize (register WindowPtr pWin)
(int)pWin->drawable.height);
#ifdef SHAPE
if (wBoundingShape (pWin) || wClipShape (pWin)) {
ScreenPtr pScreen = pWin->drawable.pScreen;
RegionTranslate(&pWin->winSize, - pWin->drawable.x,
- pWin->drawable.y);
if (wBoundingShape (pWin))
......@@ -1677,8 +1698,6 @@ SetBorderSize (register WindowPtr pWin)
(int)(pWin->drawable.height + (bw<<1)));
#ifdef SHAPE
if (wBoundingShape (pWin)) {
ScreenPtr pScreen = pWin->drawable.pScreen;
RegionTranslate(&pWin->borderSize, - pWin->drawable.x,
- pWin->drawable.y);
RegionIntersect(&pWin->borderSize, &pWin->borderSize,
......@@ -1752,6 +1771,7 @@ GravityTranslate (register int x, register int y, int oldx, int oldy,
}
/* XXX need to retile border on each window with ParentRelative origin */
#ifndef NXAGENT_SERVER
void
ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh)
{
......@@ -1816,6 +1836,7 @@ ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh)
}
}
}
#endif /* NXAGENT_SERVER */
#define GET_INT16(m, f) \
if (m & mask) \
......@@ -1888,7 +1909,6 @@ MakeBoundingRegion (
BoxPtr pBox)
{
RegionPtr pRgn;
ScreenPtr pScreen = pWin->drawable.pScreen;
pRgn = RegionCreate(pBox, 1);
if (wBoundingShape (pWin)) {
......@@ -1909,12 +1929,10 @@ ShapeOverlap (
BoxPtr pSibBox)
{
RegionPtr pWinRgn, pSibRgn;
register ScreenPtr pScreen;
Bool ret;
if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib))
return TRUE;
pScreen = pWin->drawable.pScreen;
pWinRgn = MakeBoundingRegion (pWin, pWinBox);
pSibRgn = MakeBoundingRegion (pSib, pSibBox);
RegionIntersect(pWinRgn, pWinRgn, pSibRgn);
......@@ -2015,7 +2033,6 @@ WhereDoIGoInTheStack(
int smode)
{
BoxRec box;
register ScreenPtr pScreen;
WindowPtr pHead, pFirst;
if ((pWin == pWin->parent->firstChild) &&
......@@ -2023,7 +2040,6 @@ WhereDoIGoInTheStack(
return((WindowPtr ) NULL);
pHead = RealChildHead(pWin->parent);
pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
pScreen = pWin->drawable.pScreen;
box.x1 = x;
box.y1 = y;
box.x2 = x + (int)w;
......@@ -2164,6 +2180,7 @@ ReflectStackChange(
* ConfigureWindow
*****/
#ifndef NXAGENT_SERVER
int
ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client)
{
......@@ -2417,6 +2434,7 @@ ActuallyDoSomething:
#undef RESIZE_WIN
#undef REBORDER_WIN
}
#endif /* NXAGENT_SERVER */
/******
......@@ -2436,6 +2454,17 @@ CirculateWindow(WindowPtr pParent, int direction, ClientPtr client)
xEvent event;
BoxRec box;
/*
* #ifdef NXAGENT_SERVER
* if (nxagentOption(Rootless) && nxagentWMIsRunning &&
* nxagentWindowTopLevel(pWin) && pWin -> overrideRedirect == 0)
* {
* nxagentCirculateRootlessWindows(direction);
* return Success;
* }
* #endif
*/
pHead = RealChildHead(pParent);
pFirst = pHead ? pHead->nextSib : pParent->firstChild;
if (direction == RaiseLowest)
......@@ -2501,6 +2530,7 @@ CompareWIDs(
* ReparentWindow
*****/
#ifndef NXAGENT_SERVER
int
ReparentWindow(register WindowPtr pWin, register WindowPtr pParent,
int x, int y, ClientPtr client)
......@@ -2593,6 +2623,7 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent,
RecalculateDeliverableEvents(pWin);
return(Success);
}
#endif /* NXAGENT_SERVER */
static void
RealizeTree(WindowPtr pWin)
......@@ -2635,6 +2666,7 @@ RealizeTree(WindowPtr pWin)
* MapNotify event is generated.
*****/
#ifndef NXAGENT_SERVER
int
MapWindow(register WindowPtr pWin, ClientPtr client)
{
......@@ -2737,7 +2769,7 @@ MapWindow(register WindowPtr pWin, ClientPtr client)
return(Success);
}
#endif /* NXAGENT_SERVER */
/*****
* MapSubwindows
......@@ -2926,6 +2958,7 @@ UnrealizeTree(
* generated. Cannot unmap a root window.
*****/
#ifndef NXAGENT_SERVER
int
UnmapWindow(register WindowPtr pWin, Bool fromConfigure)
{
......@@ -2979,6 +3012,7 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure)
WindowsRestructured ();
return(Success);
}
#endif /* NXAGENT_SERVER */
/*****
* UnmapSubwindows
......@@ -3159,10 +3193,8 @@ PointInWindowIsVisible(register WindowPtr pWin, int x, int y)
RegionPtr
NotClippedByChildren(register WindowPtr pWin)
{
register ScreenPtr pScreen;
RegionPtr pReg;
pScreen = pWin->drawable.pScreen;
pReg = RegionCreate(NullBox, 1);
if (pWin->parent ||
screenIsSaved != SCREEN_SAVER_ON ||
......@@ -3251,6 +3283,7 @@ static void DrawLogo(
);
#endif
#ifndef NXAGENT_SERVER
void
SaveScreens(int on, int mode)
{
......@@ -3363,6 +3396,7 @@ SaveScreens(int on, int mode)
if (mode == ScreenSaverReset)
SetScreenSaverTimer();
}
#endif /* NXAGENT_SERVER */
static Bool
TileScreenSaver(int i, int kind)
......
......@@ -34,7 +34,7 @@ SUBDIRS = module
#include <Server.tmpl>
#ifdef FbNoPixelAddrCode
DEFINES=-DFBNOPIXADDR -DFBNO24BIT
FB_DEFINES=-DFBNOPIXADDR -DFBNO24BIT
#endif
#if defined(IHaveModules)
......@@ -47,6 +47,16 @@ RENDERSRC = fbcompose.c
RENDEROBJ = fbcompose.o
#endif
#if defined(NXAgentServer) && NXAgentServer
NX_DEFINES = -DNXAGENT_SERVER
#endif
#if defined(NXAgentServer) && NXAgentServer
DEFINES = $(FB_DEFINES) $(NX_DEFINES)
#else
DEFINES = $(FB_DEFINES)
#endif
SRCS = $(XFMODSRC) \
fballpriv.c \
fbbits.c \
......
......@@ -24,7 +24,7 @@
#include "Options.h"
#include "Windows.h"
#include "NXcomposite.h"
#include "X11/include/Xcomposite_nxagent.h"
/*
* Set here the required log level.
......
......@@ -23,7 +23,6 @@ SRCS = NXwindow.c \
NXmiglyph.c \
NXmiexpose.c \
NXresource.c \
NXmiwindow.c \
NXdamage.c \
NXmitrap.c \
Args.c \
......@@ -85,7 +84,6 @@ OBJS = NXwindow.o \
NXmiglyph.o \
NXmiexpose.o \
NXresource.o \
NXmiwindow.o \
NXdamage.o \
NXmitrap.o \
Args.o \
......
/*
* $Id: composite.h,v 1.4 2004/07/08 07:20:55 keithp Exp $
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _COMPOSITE_H_
#define _COMPOSITE_H_
#ifndef NXAGENT_SERVER
#include <nx-X11/extensions/xfixeswire.h>
#endif
#define COMPOSITE_NAME "Composite"
#define COMPOSITE_MAJOR 0
#define COMPOSITE_MINOR 4
#define CompositeRedirectAutomatic 0
#define CompositeRedirectManual 1
#define X_CompositeQueryVersion 0
#define X_CompositeRedirectWindow 1
#define X_CompositeRedirectSubwindows 2
#define X_CompositeUnredirectWindow 3
#define X_CompositeUnredirectSubwindows 4
#define X_CompositeCreateRegionFromBorderClip 5
#define X_CompositeNameWindowPixmap 6
#define X_CompositeGetOverlayWindow 7
#define X_CompositeReleaseOverlayWindow 8
#define CompositeNumberRequests (X_CompositeReleaseOverlayWindow + 1)
#define CompositeNumberEvents 0
#endif /* _COMPOSITE_H_ */
......@@ -39,1307 +39,51 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
#include <X11/fonts/font.h>
#include "dixfontstr.h"
#include <X11/fonts/fontstruct.h>
#include "mi.h"
#include "regionstr.h"
#include "globals.h"
#include "gcstruct.h"
#include "damage.h"
#include "damagestr.h"
#ifdef COMPOSITE
#include "cw.h"
#endif
#define wrap(priv, real, mem, func) {\
priv->mem = real->mem; \
real->mem = func; \
}
#define unwrap(priv, real, mem) {\
real->mem = priv->mem; \
}
#define BOX_SAME(a,b) \
((a)->x1 == (b)->x1 && \
(a)->y1 == (b)->y1 && \
(a)->x2 == (b)->x2 && \
(a)->y2 == (b)->y2)
#define DAMAGE_VALIDATE_ENABLE 0
#define DAMAGE_DEBUG_ENABLE 0
#if DAMAGE_DEBUG_ENABLE
#define DAMAGE_DEBUG(x) ErrorF x
#else
#define DAMAGE_DEBUG(x)
#endif
#define getPixmapDamageRef(pPixmap) \
((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr))
#define pixmapDamage(pPixmap) damagePixPriv(pPixmap)
static DamagePtr *
getDrawableDamageRef (DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
{
ScreenPtr pScreen = pDrawable->pScreen;
pPixmap = 0;
if (pScreen->GetWindowPixmap
#ifdef ROOTLESS_WORKAROUND
&& ((WindowPtr)pDrawable)->viewable
#endif
)
pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr)pDrawable);
if (!pPixmap)
{
damageScrPriv(pScreen);
return &pScrPriv->pScreenDamage;
}
}
else
pPixmap = (PixmapPtr) pDrawable;
return getPixmapDamageRef (pPixmap);
}
#define getDrawableDamage(pDrawable) (*getDrawableDamageRef (pDrawable))
#define getWindowDamage(pWin) getDrawableDamage(&(pWin)->drawable)
#define drawableDamage(pDrawable) \
DamagePtr pDamage = getDrawableDamage(pDrawable)
#define windowDamage(pWin) drawableDamage(&(pWin)->drawable)
#define winDamageRef(pWindow) \
DamagePtr *pPrev = (DamagePtr *) \
&(pWindow->devPrivates[damageWinPrivateIndex].ptr)
#if DAMAGE_DEBUG_ENABLE
static void
_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where)
#define damageDamageRegion(d,r,c,m) _damageDamageRegion(d,r,c,m,__FUNCTION__)
#else
static void
damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
int subWindowMode)
#endif
{
ScreenPtr pScreen = pDrawable->pScreen;
damageScrPriv(pScreen);
drawableDamage(pDrawable);
DamagePtr pNext;
RegionRec clippedRec;
RegionPtr pDamageRegion;
RegionRec pixClip;
Bool was_empty;
RegionRec tmpRegion;
BoxRec tmpBox;
int draw_x, draw_y;
#ifdef COMPOSITE
int screen_x = 0, screen_y = 0;
#endif
/* short circuit for empty regions */
if (!RegionNotEmpty(pRegion))
return;
#ifdef COMPOSITE
/*
* When drawing to a pixmap which is storing window contents,
* the region presented is in pixmap relative coordinates which
* need to be converted to screen relative coordinates
*/
if (pDrawable->type != DRAWABLE_WINDOW)
{
screen_x = ((PixmapPtr) pDrawable)->screen_x - pDrawable->x;
screen_y = ((PixmapPtr) pDrawable)->screen_y - pDrawable->y;
}
if (screen_x || screen_y)
RegionTranslate(pRegion, screen_x, screen_y);
#endif
if (pDrawable->type == DRAWABLE_WINDOW &&
((WindowPtr)(pDrawable))->backingStore == NotUseful)
{
if (subWindowMode == ClipByChildren)
{
RegionIntersect(pRegion, pRegion,
&((WindowPtr)(pDrawable))->clipList);
}
else if (subWindowMode == IncludeInferiors)
{
RegionPtr pTempRegion =
NotClippedByChildren((WindowPtr)(pDrawable));
RegionIntersect(pRegion, pRegion, pTempRegion);
RegionDestroy(pTempRegion);
}
/* If subWindowMode is set to an invalid value, don't perform
* any drawable-based clipping. */
}
RegionNull(&clippedRec);
for (; pDamage; pDamage = pNext)
{
pNext = pDamage->pNext;
/*
* Check for internal damage and don't send events
*/
if (pScrPriv->internalLevel > 0 && !pDamage->isInternal)
{
DAMAGE_DEBUG (("non internal damage, skipping at %d\n",
pScrPriv->internalLevel));
continue;
}
/*
* Check for unrealized windows
*/
if (pDamage->pDrawable->type == DRAWABLE_WINDOW &&
!((WindowPtr) (pDamage->pDrawable))->realized)
{
#if 0
DAMAGE_DEBUG (("damage while window unrealized\n"));
#endif
continue;
}
draw_x = pDamage->pDrawable->x;
draw_y = pDamage->pDrawable->y;
#ifdef COMPOSITE
/*
* Need to move everyone to screen coordinates
* XXX what about off-screen pixmaps with non-zero x/y?
*/
if (pDamage->pDrawable->type != DRAWABLE_WINDOW)
{
draw_x += ((PixmapPtr) pDamage->pDrawable)->screen_x;
draw_y += ((PixmapPtr) pDamage->pDrawable)->screen_y;
}
#endif
/*
* Clip against border or pixmap bounds
*/
pDamageRegion = pRegion;
if (clip || pDamage->pDrawable != pDrawable)
{
pDamageRegion = &clippedRec;
if (pDamage->pDrawable->type == DRAWABLE_WINDOW) {
RegionIntersect(pDamageRegion, pRegion,
&((WindowPtr)(pDamage->pDrawable))->borderClip);
} else {
BoxRec box;
box.x1 = draw_x;
box.y1 = draw_y;
box.x2 = draw_x + pDamage->pDrawable->width;
box.y2 = draw_y + pDamage->pDrawable->height;
RegionInit(&pixClip, &box, 1);
RegionIntersect(pDamageRegion, pRegion, &pixClip);
RegionUninit(&pixClip);
}
/*
* Short circuit empty results
*/
if (!RegionNotEmpty(pDamageRegion))
continue;
}
DAMAGE_DEBUG (("%s %d x %d +%d +%d (target 0x%lx monitor 0x%lx)\n",
where,
pDamageRegion->extents.x2 - pDamageRegion->extents.x1,
pDamageRegion->extents.y2 - pDamageRegion->extents.y1,
pDamageRegion->extents.x1, pDamageRegion->extents.y1,
pDrawable->id, pDamage->pDrawable->id));
/*
* Move region to target coordinate space
*/
if (draw_x || draw_y)
RegionTranslate(pDamageRegion, -draw_x, -draw_y);
switch (pDamage->damageLevel) {
case DamageReportRawRegion:
(*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure);
break;
case DamageReportDeltaRegion:
RegionNull(&tmpRegion);
RegionSubtract(&tmpRegion, pDamageRegion, &pDamage->damage);
if (RegionNotEmpty(&tmpRegion))
{
RegionUnion(&pDamage->damage,
&pDamage->damage, pDamageRegion);
(*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure);
}
RegionUninit(&tmpRegion);
break;
case DamageReportBoundingBox:
tmpBox = *RegionExtents(&pDamage->damage);
RegionUnion(&pDamage->damage,
&pDamage->damage, pDamageRegion);
if (!BOX_SAME (&tmpBox, RegionExtents(&pDamage->damage)))
(*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure);
break;
case DamageReportNonEmpty:
was_empty = !RegionNotEmpty(&pDamage->damage);
RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
if (was_empty && RegionNotEmpty(&pDamage->damage))
(*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure);
break;
case DamageReportNone:
RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
break;
}
/*
* translate original region back
*/
if (pDamageRegion == pRegion && (draw_x || draw_y))
RegionTranslate(pDamageRegion, draw_x, draw_y);
}
#ifdef COMPOSITE
if (screen_x || screen_y)
RegionTranslate(pRegion, -screen_x, -screen_y);
#endif
RegionUninit(&clippedRec);
}
#if DAMAGE_DEBUG_ENABLE
#define damageDamageBox(d,b,m) _damageDamageBox(d,b,m,__FUNCTION__)
static void
_damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode, const char *where)
#else
static void
damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode)
#endif
{
RegionRec region;
RegionInit(&region, pBox, 1);
#if DAMAGE_DEBUG_ENABLE
_damageDamageRegion (pDrawable, &region, TRUE, subWindowMode, where);
#else
damageDamageRegion (pDrawable, &region, TRUE, subWindowMode);
#endif
RegionUninit(&region);
}
static void damageValidateGC(GCPtr, unsigned long, DrawablePtr);
static void damageChangeGC(GCPtr, unsigned long);
static void damageCopyGC(GCPtr, unsigned long, GCPtr);
static void damageDestroyGC(GCPtr);
static void damageChangeClip(GCPtr, int, void *, int);
static void damageDestroyClip(GCPtr);
static void damageCopyClip(GCPtr, GCPtr);
GCFuncs damageGCFuncs = {
damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC,
damageChangeClip, damageDestroyClip, damageCopyClip
};
extern GCOps damageGCOps;
static Bool
damageCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
damageScrPriv(pScreen);
damageGCPriv(pGC);
Bool ret;
pGC->pCompositeClip = 0;
unwrap (pScrPriv, pScreen, CreateGC);
if((ret = (*pScreen->CreateGC) (pGC))) {
pGCPriv->ops = NULL;
pGCPriv->funcs = pGC->funcs;
pGC->funcs = &damageGCFuncs;
}
wrap (pScrPriv, pScreen, CreateGC, damageCreateGC);
return ret;
}
#ifdef NOTUSED
static void
damageWrapGC (GCPtr pGC)
{
damageGCPriv(pGC);
pGCPriv->ops = NULL;
pGCPriv->funcs = pGC->funcs;
pGC->funcs = &damageGCFuncs;
}
static void
damageUnwrapGC (GCPtr pGC)
{
damageGCPriv(pGC);
pGC->funcs = pGCPriv->funcs;
if (pGCPriv->ops)
pGC->ops = pGCPriv->ops;
}
#endif
#define DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable) \
damageGCPriv(pGC); \
GCFuncs *oldFuncs = pGC->funcs; \
unwrap(pGCPriv, pGC, funcs); \
unwrap(pGCPriv, pGC, ops); \
#define DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable) \
wrap(pGCPriv, pGC, funcs, oldFuncs); \
wrap(pGCPriv, pGC, ops, &damageGCOps)
#define DAMAGE_GC_FUNC_PROLOGUE(pGC) \
damageGCPriv(pGC); \
unwrap(pGCPriv, pGC, funcs); \
if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops)
#define DAMAGE_GC_FUNC_EPILOGUE(pGC) \
wrap(pGCPriv, pGC, funcs, &damageGCFuncs); \
if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &damageGCOps)
static void
damageValidateGC(GCPtr pGC,
unsigned long changes,
DrawablePtr pDrawable)
{
DAMAGE_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ValidateGC)(pGC, changes, pDrawable);
pGCPriv->ops = pGC->ops; /* just so it's not NULL */
DAMAGE_GC_FUNC_EPILOGUE (pGC);
}
static void
damageDestroyGC(GCPtr pGC)
{
DAMAGE_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->DestroyGC)(pGC);
DAMAGE_GC_FUNC_EPILOGUE (pGC);
}
static void
damageChangeGC (GCPtr pGC,
unsigned long mask)
{
DAMAGE_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ChangeGC) (pGC, mask);
DAMAGE_GC_FUNC_EPILOGUE (pGC);
}
static void
damageCopyGC (GCPtr pGCSrc,
unsigned long mask,
GCPtr pGCDst)
{
DAMAGE_GC_FUNC_PROLOGUE (pGCDst);
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
DAMAGE_GC_FUNC_EPILOGUE (pGCDst);
}
static void
damageChangeClip (GCPtr pGC,
int type,
void *pvalue,
int nrects)
{
DAMAGE_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
DAMAGE_GC_FUNC_EPILOGUE (pGC);
}
static void
damageCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
DAMAGE_GC_FUNC_PROLOGUE (pgcDst);
(* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
DAMAGE_GC_FUNC_EPILOGUE (pgcDst);
}
static void
damageDestroyClip(GCPtr pGC)
{
DAMAGE_GC_FUNC_PROLOGUE (pGC);
(* pGC->funcs->DestroyClip)(pGC);
DAMAGE_GC_FUNC_EPILOGUE (pGC);
}
#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \
BoxPtr extents = &pGC->pCompositeClip->extents;\
if(box.x1 < extents->x1) box.x1 = extents->x1; \
if(box.x2 > extents->x2) box.x2 = extents->x2; \
if(box.y1 < extents->y1) box.y1 = extents->y1; \
if(box.y2 > extents->y2) box.y2 = extents->y2; \
}
#define TRANSLATE_BOX(box, pDrawable) { \
box.x1 += pDrawable->x; \
box.x2 += pDrawable->x; \
box.y1 += pDrawable->y; \
box.y2 += pDrawable->y; \
}
#define TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC) { \
TRANSLATE_BOX(box, pDrawable); \
TRIM_BOX(box, pGC); \
}
#define BOX_NOT_EMPTY(box) \
(((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
#define checkGCDamage(d,g) (getDrawableDamage(d) && \
(!g->pCompositeClip ||\
RegionNotEmpty(\
g->pCompositeClip)))
#ifdef RENDER
#define TRIM_PICTURE_BOX(box, pDst) { \
BoxPtr extents = &pDst->pCompositeClip->extents;\
if(box.x1 < extents->x1) box.x1 = extents->x1; \
if(box.x2 > extents->x2) box.x2 = extents->x2; \
if(box.y1 < extents->y1) box.y1 = extents->y1; \
if(box.y2 > extents->y2) box.y2 = extents->y2; \
}
#define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \
RegionNotEmpty(p->pCompositeClip))
static void
damageComposite (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height)
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
damageScrPriv(pScreen);
if (checkPictureDamage (pDst))
{
BoxRec box;
box.x1 = xDst + pDst->pDrawable->x;
box.y1 = yDst + pDst->pDrawable->y;
box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
TRIM_PICTURE_BOX(box, pDst);
if (BOX_NOT_EMPTY(box))
damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode);
}
unwrap (pScrPriv, ps, Composite);
(*ps->Composite) (op,
pSrc,
pMask,
pDst,
xSrc,
ySrc,
xMask,
yMask,
xDst,
yDst,
width,
height);
wrap (pScrPriv, ps, Composite, damageComposite);
}
static void
damageGlyphs (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlist,
GlyphListPtr list,
GlyphPtr *glyphs)
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
damageScrPriv(pScreen);
if (checkPictureDamage (pDst))
{
int nlistTmp = nlist;
GlyphListPtr listTmp = list;
GlyphPtr *glyphsTmp = glyphs;
int x, y;
int n;
GlyphPtr glyph;
BoxRec box;
int x1, y1, x2, y2;
box.x1 = 32767;
box.y1 = 32767;
box.x2 = -32767;
box.y2 = -32767;
x = pDst->pDrawable->x;
y = pDst->pDrawable->y;
while (nlistTmp--)
{
x += listTmp->xOff;
y += listTmp->yOff;
n = listTmp->len;
while (n--)
{
glyph = *glyphsTmp++;
x1 = x - glyph->info.x;
y1 = y - glyph->info.y;
x2 = x1 + glyph->info.width;
y2 = y1 + glyph->info.height;
if (x1 < box.x1)
box.x1 = x1;
if (y1 < box.y1)
box.y1 = y1;
if (x2 > box.x2)
box.x2 = x2;
if (y2 > box.y2)
box.y2 = y2;
x += glyph->info.xOff;
y += glyph->info.yOff;
}
listTmp++;
}
TRIM_PICTURE_BOX (box, pDst);
if (BOX_NOT_EMPTY(box))
damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode);
}
unwrap (pScrPriv, ps, Glyphs);
(*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
wrap (pScrPriv, ps, Glyphs, damageGlyphs);
}
#endif
/**********************************************************/
static void
damageFillSpans(DrawablePtr pDrawable,
GC *pGC,
int npt,
DDXPointPtr ppt,
int *pwidth,
int fSorted)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (npt && checkGCDamage (pDrawable, pGC))
{
int nptTmp = npt;
DDXPointPtr pptTmp = ppt;
int *pwidthTmp = pwidth;
BoxRec box;
box.x1 = pptTmp->x;
box.x2 = box.x1 + *pwidthTmp;
box.y2 = box.y1 = pptTmp->y;
while(--nptTmp)
{
pptTmp++;
pwidthTmp++;
if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
if(box.x2 < (pptTmp->x + *pwidthTmp))
box.x2 = pptTmp->x + *pwidthTmp;
if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
}
box.y2++;
if(!pGC->miTranslate) {
TRANSLATE_BOX(box, pDrawable);
}
TRIM_BOX(box, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damageSetSpans(DrawablePtr pDrawable,
GCPtr pGC,
char *pcharsrc,
DDXPointPtr ppt,
int *pwidth,
int npt,
int fSorted)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (npt && checkGCDamage (pDrawable, pGC))
{
DDXPointPtr pptTmp = ppt;
int *pwidthTmp = pwidth;
int nptTmp = npt;
BoxRec box;
box.x1 = pptTmp->x;
box.x2 = box.x1 + *pwidthTmp;
box.y2 = box.y1 = pptTmp->y;
while(--nptTmp)
{
pptTmp++;
pwidthTmp++;
if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
if(box.x2 < (pptTmp->x + *pwidthTmp))
box.x2 = pptTmp->x + *pwidthTmp;
if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
}
box.y2++;
if(!pGC->miTranslate) {
TRANSLATE_BOX(box, pDrawable);
}
TRIM_BOX(box, pGC);
#include "../../miext/damage/damage.h"
#include <X11/fonts/font.h>
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
/* prototypes */
static void
damagePutImage(DrawablePtr pDrawable,
static int
damageText (DrawablePtr pDrawable,
GCPtr pGC,
int depth,
int x,
int y,
int w,
int h,
int leftPad,
int format,
char *pImage)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (checkGCDamage (pDrawable, pGC))
{
BoxRec box;
box.x1 = x + pDrawable->x;
box.x2 = box.x1 + w;
box.y1 = y + pDrawable->y;
box.y2 = box.y1 + h;
TRIM_BOX(box, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h,
leftPad, format, pImage);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static RegionPtr
damageCopyArea(DrawablePtr pSrc,
DrawablePtr pDst,
GC *pGC,
int srcx,
int srcy,
int width,
int height,
int dstx,
int dsty)
{
RegionPtr ret;
DAMAGE_GC_OP_PROLOGUE(pGC, pDst);
/* The driver will only call SourceValidate() when pSrc != pDst,
* but the software sprite (misprite.c) always need to know when a
* drawable is copied so it can remove the sprite. See #1030. */
if ((pSrc == pDst) && pSrc->pScreen->SourceValidate &&
pSrc->type == DRAWABLE_WINDOW &&
((WindowPtr)pSrc)->viewable)
{
(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height);
}
if (checkGCDamage (pDst, pGC))
{
BoxRec box;
box.x1 = dstx + pDst->x;
box.x2 = box.x1 + width;
box.y1 = dsty + pDst->y;
box.y2 = box.y1 + height;
TRIM_BOX(box, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDst, &box, pGC->subWindowMode);
}
ret = (*pGC->ops->CopyArea)(pSrc, pDst,
pGC, srcx, srcy, width, height, dstx, dsty);
DAMAGE_GC_OP_EPILOGUE(pGC, pDst);
return ret;
}
static RegionPtr
damageCopyPlane(DrawablePtr pSrc,
DrawablePtr pDst,
GCPtr pGC,
int srcx,
int srcy,
int width,
int height,
int dstx,
int dsty,
unsigned long bitPlane)
{
RegionPtr ret;
DAMAGE_GC_OP_PROLOGUE(pGC, pDst);
/* The driver will only call SourceValidate() when pSrc != pDst,
* but the software sprite (misprite.c) always need to know when a
* drawable is copied so it can remove the sprite. See #1030. */
if ((pSrc == pDst) && pSrc->pScreen->SourceValidate &&
pSrc->type == DRAWABLE_WINDOW &&
((WindowPtr)pSrc)->viewable)
{
(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height);
}
if (checkGCDamage (pDst, pGC))
{
BoxRec box;
box.x1 = dstx + pDst->x;
box.x2 = box.x1 + width;
box.y1 = dsty + pDst->y;
box.y2 = box.y1 + height;
TRIM_BOX(box, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDst, &box, pGC->subWindowMode);
}
ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
DAMAGE_GC_OP_EPILOGUE(pGC, pDst);
return ret;
}
static void
damagePolyPoint(DrawablePtr pDrawable,
GCPtr pGC,
int mode,
int npt,
xPoint *ppt)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (npt && checkGCDamage (pDrawable, pGC))
{
BoxRec box;
int nptTmp = npt;
xPoint *pptTmp = ppt;
box.x2 = box.x1 = pptTmp->x;
box.y2 = box.y1 = pptTmp->y;
/* this could be slow if the points were spread out */
while(--nptTmp)
{
pptTmp++;
if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;
if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
}
box.x2++;
box.y2++;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolylines(DrawablePtr pDrawable,
GCPtr pGC,
int mode,
int npt,
DDXPointPtr ppt)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (npt && checkGCDamage (pDrawable, pGC))
{
int nptTmp = npt;
DDXPointPtr pptTmp = ppt;
BoxRec box;
int extra = pGC->lineWidth >> 1;
box.x2 = box.x1 = pptTmp->x;
box.y2 = box.y1 = pptTmp->y;
if(nptTmp > 1)
{
if(pGC->joinStyle == JoinMiter)
extra = 6 * pGC->lineWidth;
else if(pGC->capStyle == CapProjecting)
extra = pGC->lineWidth;
}
if(mode == CoordModePrevious)
{
int x = box.x1;
int y = box.y1;
while(--nptTmp)
{
pptTmp++;
x += pptTmp->x;
y += pptTmp->y;
if(box.x1 > x) box.x1 = x;
else if(box.x2 < x) box.x2 = x;
if(box.y1 > y) box.y1 = y;
else if(box.y2 < y) box.y2 = y;
}
}
else
{
while(--nptTmp)
{
pptTmp++;
if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;
if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
}
}
box.x2++;
box.y2++;
if(extra)
{
box.x1 -= extra;
box.x2 += extra;
box.y1 -= extra;
box.y2 += extra;
}
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolySegment(DrawablePtr pDrawable,
GCPtr pGC,
int nSeg,
xSegment *pSeg)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (nSeg && checkGCDamage (pDrawable, pGC))
{
BoxRec box;
int extra = pGC->lineWidth;
int nsegTmp = nSeg;
xSegment *pSegTmp = pSeg;
if(pGC->capStyle != CapProjecting)
extra >>= 1;
if(pSegTmp->x2 > pSegTmp->x1) {
box.x1 = pSegTmp->x1;
box.x2 = pSegTmp->x2;
} else {
box.x2 = pSegTmp->x1;
box.x1 = pSegTmp->x2;
}
if(pSegTmp->y2 > pSegTmp->y1) {
box.y1 = pSegTmp->y1;
box.y2 = pSegTmp->y2;
} else {
box.y2 = pSegTmp->y1;
box.y1 = pSegTmp->y2;
}
while(--nsegTmp)
{
pSegTmp++;
if(pSegTmp->x2 > pSegTmp->x1)
{
if(pSegTmp->x1 < box.x1) box.x1 = pSegTmp->x1;
if(pSegTmp->x2 > box.x2) box.x2 = pSegTmp->x2;
}
else
{
if(pSegTmp->x2 < box.x1) box.x1 = pSegTmp->x2;
if(pSegTmp->x1 > box.x2) box.x2 = pSegTmp->x1;
}
if(pSegTmp->y2 > pSegTmp->y1)
{
if(pSegTmp->y1 < box.y1) box.y1 = pSegTmp->y1;
if(pSegTmp->y2 > box.y2) box.y2 = pSegTmp->y2;
}
else
{
if(pSegTmp->y2 < box.y1) box.y1 = pSegTmp->y2;
if(pSegTmp->y1 > box.y2) box.y2 = pSegTmp->y1;
}
}
box.x2++;
box.y2++;
if(extra)
{
box.x1 -= extra;
box.x2 += extra;
box.y1 -= extra;
box.y2 += extra;
}
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolyRectangle(DrawablePtr pDrawable,
GCPtr pGC,
int nRects,
xRectangle *pRects)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (nRects && checkGCDamage (pDrawable, pGC))
{
BoxRec box;
int offset1, offset2, offset3;
int nRectsTmp = nRects;
xRectangle *pRectsTmp = pRects;
offset2 = pGC->lineWidth;
if(!offset2) offset2 = 1;
offset1 = offset2 >> 1;
offset3 = offset2 - offset1;
while(nRectsTmp--)
{
box.x1 = pRectsTmp->x - offset1;
box.y1 = pRectsTmp->y - offset1;
box.x2 = box.x1 + pRectsTmp->width + offset2;
box.y2 = box.y1 + offset2;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
box.x1 = pRectsTmp->x - offset1;
box.y1 = pRectsTmp->y + offset3;
box.x2 = box.x1 + offset2;
box.y2 = box.y1 + pRectsTmp->height - offset2;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
box.x1 = pRectsTmp->x + pRectsTmp->width - offset1;
box.y1 = pRectsTmp->y + offset3;
box.x2 = box.x1 + offset2;
box.y2 = box.y1 + pRectsTmp->height - offset2;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
box.x1 = pRectsTmp->x - offset1;
box.y1 = pRectsTmp->y + pRectsTmp->height - offset1;
box.x2 = box.x1 + pRectsTmp->width + offset2;
box.y2 = box.y1 + offset2;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
pRectsTmp++;
}
}
(*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolyArc(DrawablePtr pDrawable,
GCPtr pGC,
int nArcs,
xArc *pArcs)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (nArcs && checkGCDamage (pDrawable, pGC))
{
int extra = pGC->lineWidth >> 1;
BoxRec box;
int nArcsTmp = nArcs;
xArc *pArcsTmp = pArcs;
box.x1 = pArcsTmp->x;
box.x2 = box.x1 + pArcsTmp->width;
box.y1 = pArcsTmp->y;
box.y2 = box.y1 + pArcsTmp->height;
while(--nArcsTmp)
{
pArcsTmp++;
if(box.x1 > pArcsTmp->x)
box.x1 = pArcsTmp->x;
if(box.x2 < (pArcsTmp->x + pArcsTmp->width))
box.x2 = pArcsTmp->x + pArcsTmp->width;
if(box.y1 > pArcsTmp->y)
box.y1 = pArcsTmp->y;
if(box.y2 < (pArcsTmp->y + pArcsTmp->height))
box.y2 = pArcsTmp->y + pArcsTmp->height;
}
if(extra)
{
box.x1 -= extra;
box.x2 += extra;
box.y1 -= extra;
box.y2 += extra;
}
box.x2++;
box.y2++;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damageFillPolygon(DrawablePtr pDrawable,
GCPtr pGC,
int shape,
int mode,
int npt,
DDXPointPtr ppt)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (npt > 2 && checkGCDamage (pDrawable, pGC))
{
DDXPointPtr pptTmp = ppt;
int nptTmp = npt;
BoxRec box;
box.x2 = box.x1 = pptTmp->x;
box.y2 = box.y1 = pptTmp->y;
if(mode != CoordModeOrigin)
{
int x = box.x1;
int y = box.y1;
while(--nptTmp)
{
pptTmp++;
x += pptTmp->x;
y += pptTmp->y;
if(box.x1 > x) box.x1 = x;
else if(box.x2 < x) box.x2 = x;
if(box.y1 > y) box.y1 = y;
else if(box.y2 < y) box.y2 = y;
}
}
else
{
while(--nptTmp)
{
pptTmp++;
if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;
if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
}
}
box.x2++;
box.y2++;
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolyFillRect(DrawablePtr pDrawable,
unsigned long count,
char *chars,
FontEncoding fontEncoding,
Bool textType);
static int
damagePolyText8(DrawablePtr pDrawable,
GCPtr pGC,
int nRects,
xRectangle *pRects)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (nRects && checkGCDamage (pDrawable, pGC))
{
BoxRec box;
xRectangle *pRectsTmp = pRects;
int nRectsTmp = nRects;
box.x1 = pRectsTmp->x;
box.x2 = box.x1 + pRectsTmp->width;
box.y1 = pRectsTmp->y;
box.y2 = box.y1 + pRectsTmp->height;
while(--nRectsTmp)
{
pRectsTmp++;
if(box.x1 > pRectsTmp->x) box.x1 = pRectsTmp->x;
if(box.x2 < (pRectsTmp->x + pRectsTmp->width))
box.x2 = pRectsTmp->x + pRectsTmp->width;
if(box.y1 > pRectsTmp->y) box.y1 = pRectsTmp->y;
if(box.y2 < (pRectsTmp->y + pRectsTmp->height))
box.y2 = pRectsTmp->y + pRectsTmp->height;
}
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolyFillArc(DrawablePtr pDrawable,
int x,
int y,
int count,
char *chars);
static int
damagePolyText16(DrawablePtr pDrawable,
GCPtr pGC,
int nArcs,
xArc *pArcs)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (nArcs && checkGCDamage (pDrawable, pGC))
{
BoxRec box;
int nArcsTmp = nArcs;
xArc *pArcsTmp = pArcs;
box.x1 = pArcsTmp->x;
box.x2 = box.x1 + pArcsTmp->width;
box.y1 = pArcsTmp->y;
box.y2 = box.y1 + pArcsTmp->height;
while(--nArcsTmp)
{
pArcsTmp++;
if(box.x1 > pArcsTmp->x)
box.x1 = pArcsTmp->x;
if(box.x2 < (pArcsTmp->x + pArcsTmp->width))
box.x2 = pArcsTmp->x + pArcsTmp->width;
if(box.y1 > pArcsTmp->y)
box.y1 = pArcsTmp->y;
if(box.y2 < (pArcsTmp->y + pArcsTmp->height))
box.y2 = pArcsTmp->y + pArcsTmp->height;
}
TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
/*
* general Poly/Image text function. Extract glyph information,
* compute bounding box and remove cursor if it is overlapped.
*/
int x,
int y,
int count,
unsigned short *chars);
static void
damageDamageChars (DrawablePtr pDrawable,
FontPtr font,
damageImageText8(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
unsigned int n,
CharInfoPtr *charinfo,
Bool imageblt,
int subWindowMode)
{
ExtentInfoRec extents;
BoxRec box;
QueryGlyphExtents(font, charinfo, n, &extents);
if (imageblt)
{
if (extents.overallWidth > extents.overallRight)
extents.overallRight = extents.overallWidth;
if (extents.overallWidth < extents.overallLeft)
extents.overallLeft = extents.overallWidth;
if (extents.overallLeft > 0)
extents.overallLeft = 0;
if (extents.fontAscent > extents.overallAscent)
extents.overallAscent = extents.fontAscent;
if (extents.fontDescent > extents.overallDescent)
extents.overallDescent = extents.fontDescent;
}
box.x1 = x + extents.overallLeft;
box.y1 = y - extents.overallAscent;
box.x2 = x + extents.overallRight;
box.y2 = y + extents.overallDescent;
damageDamageBox (pDrawable, &box, subWindowMode);
}
int count,
char *chars);
static void
damageImageText16(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
int count,
unsigned short *chars);
/*
* values for textType:
*/
#define TT_POLY8 0
#define TT_IMAGE8 1
#define TT_POLY16 2
#define TT_IMAGE16 3
#include "../../miext/damage/damage.c"
static int
damageText (DrawablePtr pDrawable,
......@@ -1391,86 +135,6 @@ damageText (DrawablePtr pDrawable,
return x + w;
}
#ifndef NXAGENT_SERVER
static int
damagePolyText8(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
int count,
char *chars)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (checkGCDamage (pDrawable, pGC))
x = damageText (pDrawable, pGC, x, y, (unsigned long) count, chars,
Linear8Bit, TT_POLY8);
else
x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
return x;
}
static int
damagePolyText16(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
int count,
unsigned short *chars)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (checkGCDamage (pDrawable, pGC))
x = damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars,
FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit,
TT_POLY16);
else
x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
return x;
}
static void
damageImageText8(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
int count,
char *chars)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (checkGCDamage (pDrawable, pGC))
damageText (pDrawable, pGC, x, y, (unsigned long) count, chars,
Linear8Bit, TT_IMAGE8);
else
(*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damageImageText16(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
int count,
unsigned short *chars)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if (checkGCDamage (pDrawable, pGC))
damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars,
FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit,
TT_IMAGE16);
else
(*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
#else /* #ifndef NXAGENT_SERVER */
static int
damagePolyText8(DrawablePtr pDrawable,
GCPtr pGC,
......@@ -1551,523 +215,3 @@ damageImageText16(DrawablePtr pDrawable,
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
#endif /* #ifndef NXAGENT_SERVER */
static void
damageImageGlyphBlt(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
unsigned int nglyph,
CharInfoPtr *ppci,
void *pglyphBase)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y,
nglyph, ppci, TRUE, pGC->subWindowMode);
(*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph,
ppci, pglyphBase);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePolyGlyphBlt(DrawablePtr pDrawable,
GCPtr pGC,
int x,
int y,
unsigned int nglyph,
CharInfoPtr *ppci,
void *pglyphBase)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y,
nglyph, ppci, FALSE, pGC->subWindowMode);
(*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph,
ppci, pglyphBase);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damagePushPixels(GCPtr pGC,
PixmapPtr pBitMap,
DrawablePtr pDrawable,
int dx,
int dy,
int xOrg,
int yOrg)
{
DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
if(checkGCDamage (pDrawable, pGC))
{
BoxRec box;
box.x1 = xOrg;
box.y1 = yOrg;
if(!pGC->miTranslate) {
box.x1 += pDrawable->x;
box.y1 += pDrawable->y;
}
box.x2 = box.x1 + dx;
box.y2 = box.y1 + dy;
TRIM_BOX(box, pGC);
if(BOX_NOT_EMPTY(box))
damageDamageBox (pDrawable, &box, pGC->subWindowMode);
}
(*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
static void
damageRemoveDamage (DamagePtr *pPrev, DamagePtr pDamage)
{
while (*pPrev)
{
if (*pPrev == pDamage)
{
*pPrev = pDamage->pNext;
return;
}
pPrev = &(*pPrev)->pNext;
}
#if DAMAGE_VALIDATE_ENABLE
ErrorF ("Damage not on list\n");
abort ();
#endif
}
static void
damageInsertDamage (DamagePtr *pPrev, DamagePtr pDamage)
{
#if DAMAGE_VALIDATE_ENABLE
DamagePtr pOld;
for (pOld = *pPrev; pOld; pOld = pOld->pNext)
if (pOld == pDamage) {
ErrorF ("Damage already on list\n");
abort ();
}
#endif
pDamage->pNext = *pPrev;
*pPrev = pDamage;
}
static Bool
damageDestroyPixmap (PixmapPtr pPixmap)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
damageScrPriv(pScreen);
if (pPixmap->refcnt == 1)
{
DamagePtr *pPrev = getPixmapDamageRef (pPixmap);
DamagePtr pDamage;
while ((pDamage = *pPrev))
{
damageRemoveDamage (pPrev, pDamage);
if (!pDamage->isWindow)
DamageDestroy (pDamage);
}
}
unwrap (pScrPriv, pScreen, DestroyPixmap);
(*pScreen->DestroyPixmap) (pPixmap);
wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
return TRUE;
}
static void
damagePaintWindow(WindowPtr pWindow,
RegionPtr prgn,
int what)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
damageScrPriv(pScreen);
/*
* Painting background none doesn't actually *do* anything, so
* no damage is recorded
*/
if ((what != PW_BACKGROUND || pWindow->backgroundState != None) &&
getWindowDamage (pWindow))
damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
if(what == PW_BACKGROUND) {
unwrap (pScrPriv, pScreen, PaintWindowBackground);
(*pScreen->PaintWindowBackground) (pWindow, prgn, what);
wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
} else {
unwrap (pScrPriv, pScreen, PaintWindowBorder);
(*pScreen->PaintWindowBorder) (pWindow, prgn, what);
wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
}
}
static void
damageCopyWindow(WindowPtr pWindow,
DDXPointRec ptOldOrg,
RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
damageScrPriv(pScreen);
if (getWindowDamage (pWindow))
{
int dx = pWindow->drawable.x - ptOldOrg.x;
int dy = pWindow->drawable.y - ptOldOrg.y;
/*
* The region comes in source relative, but the damage occurs
* at the destination location. Translate back and forth.
*/
RegionTranslate(prgnSrc, dx, dy);
damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE, -1);
RegionTranslate(prgnSrc, -dx, -dy);
}
unwrap (pScrPriv, pScreen, CopyWindow);
(*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
}
GCOps damageGCOps = {
damageFillSpans, damageSetSpans,
damagePutImage, damageCopyArea,
damageCopyPlane, damagePolyPoint,
damagePolylines, damagePolySegment,
damagePolyRectangle, damagePolyArc,
damageFillPolygon, damagePolyFillRect,
damagePolyFillArc, damagePolyText8,
damagePolyText16, damageImageText8,
damageImageText16, damageImageGlyphBlt,
damagePolyGlyphBlt, damagePushPixels,
#ifdef NEED_LINEHELPER
NULL,
#endif
{NULL} /* devPrivate */
};
static void
damageRestoreAreas (PixmapPtr pPixmap,
RegionPtr prgn,
int xorg,
int yorg,
WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
damageScrPriv(pScreen);
damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
(*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn,
xorg, yorg, pWindow);
wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
damageRestoreAreas);
}
static void
damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
{
DamagePtr pDamage;
ScreenPtr pScreen = pWindow->drawable.pScreen;
damageScrPriv(pScreen);
if ((pDamage = damageGetWinPriv(pWindow)))
{
PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow);
DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap);
while (pDamage)
{
damageRemoveDamage (pPrev, pDamage);
pDamage = pDamage->pNextWin;
}
}
unwrap (pScrPriv, pScreen, SetWindowPixmap);
(*pScreen->SetWindowPixmap) (pWindow, pPixmap);
wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
if ((pDamage = damageGetWinPriv(pWindow)))
{
DamagePtr *pPrev = getPixmapDamageRef(pPixmap);
while (pDamage)
{
damageInsertDamage (pPrev, pDamage);
pDamage = pDamage->pNextWin;
}
}
}
static Bool
damageDestroyWindow (WindowPtr pWindow)
{
DamagePtr pDamage;
ScreenPtr pScreen = pWindow->drawable.pScreen;
Bool ret;
damageScrPriv(pScreen);
while ((pDamage = damageGetWinPriv(pWindow)))
{
DamageUnregister (&pWindow->drawable, pDamage);
DamageDestroy (pDamage);
}
unwrap (pScrPriv, pScreen, DestroyWindow);
ret = (*pScreen->DestroyWindow) (pWindow);
wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
return ret;
}
static Bool
damageCloseScreen (int i, ScreenPtr pScreen)
{
damageScrPriv(pScreen);
unwrap (pScrPriv, pScreen, DestroyPixmap);
unwrap (pScrPriv, pScreen, CreateGC);
unwrap (pScrPriv, pScreen, PaintWindowBackground);
unwrap (pScrPriv, pScreen, PaintWindowBorder);
unwrap (pScrPriv, pScreen, CopyWindow);
unwrap (pScrPriv, pScreen, CloseScreen);
unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
xfree (pScrPriv);
return (*pScreen->CloseScreen) (i, pScreen);
}
int damageScrPrivateIndex;
int damagePixPrivateIndex;
int damageGCPrivateIndex;
int damageWinPrivateIndex;
int damageGeneration;
Bool
DamageSetup (ScreenPtr pScreen)
{
DamageScrPrivPtr pScrPriv;
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
if (damageGeneration != serverGeneration)
{
damageScrPrivateIndex = AllocateScreenPrivateIndex ();
if (damageScrPrivateIndex == -1)
return FALSE;
damageGCPrivateIndex = AllocateGCPrivateIndex ();
if (damageGCPrivateIndex == -1)
return FALSE;
damagePixPrivateIndex = AllocatePixmapPrivateIndex ();
if (damagePixPrivateIndex == -1)
return FALSE;
damageWinPrivateIndex = AllocateWindowPrivateIndex ();
if (damageWinPrivateIndex == -1)
return FALSE;
damageGeneration = serverGeneration;
}
if (pScreen->devPrivates[damageScrPrivateIndex].ptr)
return TRUE;
if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec)))
return FALSE;
if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0))
return FALSE;
if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0))
return FALSE;
pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec));
if (!pScrPriv)
return FALSE;
#ifdef COMPOSITE
/* This is a kludge to ensure wrapping order with the composite wrapper.
* If it's done from compinit.c, then DamageSetup may be called before the
* extension init phase, so that cw will be higher in the wrapping chain and
* rewrite drawables before damage gets to it, causing confusion.
*/
if (!noCompositeExtension)
miInitializeCompositeWrapper (pScreen);
#endif
pScrPriv->internalLevel = 0;
pScrPriv->pScreenDamage = 0;
wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
wrap (pScrPriv, pScreen, CreateGC, damageCreateGC);
wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen);
wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
damageRestoreAreas);
#ifdef RENDER
if (ps) {
wrap (pScrPriv, ps, Glyphs, damageGlyphs);
wrap (pScrPriv, ps, Composite, damageComposite);
}
#endif
pScreen->devPrivates[damageScrPrivateIndex].ptr = (void *) pScrPriv;
return TRUE;
}
DamagePtr
DamageCreate (DamageReportFunc damageReport,
DamageDestroyFunc damageDestroy,
DamageReportLevel damageLevel,
Bool isInternal,
ScreenPtr pScreen,
void *closure)
{
DamagePtr pDamage;
pDamage = xalloc (sizeof (DamageRec));
if (!pDamage)
return 0;
pDamage->pNext = 0;
pDamage->pNextWin = 0;
RegionNull(&pDamage->damage);
pDamage->damageLevel = damageLevel;
pDamage->isInternal = isInternal;
pDamage->closure = closure;
pDamage->isWindow = FALSE;
pDamage->pDrawable = 0;
pDamage->damageReport = damageReport;
pDamage->damageDestroy = damageDestroy;
return pDamage;
}
void
DamageRegister (DrawablePtr pDrawable,
DamagePtr pDamage)
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
WindowPtr pWindow = (WindowPtr) pDrawable;
winDamageRef(pWindow);
#if DAMAGE_VALIDATE_ENABLE
DamagePtr pOld;
for (pOld = *pPrev; pOld; pOld = pOld->pNextWin)
if (pOld == pDamage) {
ErrorF ("Damage already on window list\n");
abort ();
}
#endif
pDamage->pNextWin = *pPrev;
*pPrev = pDamage;
pDamage->isWindow = TRUE;
}
else
pDamage->isWindow = FALSE;
pDamage->pDrawable = pDrawable;
damageInsertDamage (getDrawableDamageRef (pDrawable), pDamage);
}
void
DamageDrawInternal (ScreenPtr pScreen, Bool enable)
{
damageScrPriv (pScreen);
pScrPriv->internalLevel += enable ? 1 : -1;
}
void
DamageUnregister (DrawablePtr pDrawable,
DamagePtr pDamage)
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
WindowPtr pWindow = (WindowPtr) pDrawable;
winDamageRef (pWindow);
#if DAMAGE_VALIDATE_ENABLE
int found = 0;
#endif
while (*pPrev)
{
if (*pPrev == pDamage)
{
*pPrev = pDamage->pNextWin;
#if DAMAGE_VALIDATE_ENABLE
found = 1;
#endif
break;
}
pPrev = &(*pPrev)->pNextWin;
}
#if DAMAGE_VALIDATE_ENABLE
if (!found) {
ErrorF ("Damage not on window list\n");
abort ();
}
#endif
}
pDamage->pDrawable = 0;
damageRemoveDamage (getDrawableDamageRef (pDrawable), pDamage);
}
void
DamageDestroy (DamagePtr pDamage)
{
if (pDamage->damageDestroy)
(*pDamage->damageDestroy) (pDamage, pDamage->closure);
RegionUninit(&pDamage->damage);
xfree (pDamage);
}
Bool
DamageSubtract (DamagePtr pDamage,
const RegionPtr pRegion)
{
RegionPtr pClip;
RegionRec pixmapClip;
DrawablePtr pDrawable = pDamage->pDrawable;
RegionSubtract(&pDamage->damage, &pDamage->damage, pRegion);
if (pDrawable)
{
if (pDrawable->type == DRAWABLE_WINDOW)
pClip = &((WindowPtr) pDrawable)->borderClip;
else
{
BoxRec box;
box.x1 = pDrawable->x;
box.y1 = pDrawable->y;
box.x2 = pDrawable->x + pDrawable->width;
box.y2 = pDrawable->y + pDrawable->height;
RegionInit(&pixmapClip, &box, 1);
pClip = &pixmapClip;
}
RegionTranslate(&pDamage->damage, pDrawable->x, pDrawable->y);
RegionIntersect(&pDamage->damage, &pDamage->damage, pClip);
RegionTranslate(&pDamage->damage, -pDrawable->x, -pDrawable->y);
if (pDrawable->type != DRAWABLE_WINDOW)
RegionUninit(&pixmapClip);
}
return RegionNotEmpty(&pDamage->damage);
}
void
DamageEmpty (DamagePtr pDamage)
{
RegionEmpty(&pDamage->damage);
}
RegionPtr
DamageRegion (DamagePtr pDamage)
{
return &pDamage->damage;
}
void
DamageDamageRegion (DrawablePtr pDrawable,
RegionPtr pRegion)
{
damageDamageRegion (pDrawable, pRegion, FALSE, -1);
}
......@@ -95,15 +95,6 @@ Equipment Corporation.
/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.32 2003/11/10 18:21:45 tsi Exp $ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifdef PANORAMIX_DEBUG
#include <stdio.h>
int ProcInitialConnection();
#endif
#ifdef __sun
#define False 0
#define True 1
......@@ -115,37 +106,9 @@ int ProcInitialConnection();
#include <nx-X11/Xlib.h>
#undef GC
#include "../../dix/dispatch.c"
#include "windowstr.h"
#include "dixfontstr.h"
#include "gcstruct.h"
#include "selection.h"
#include "colormapst.h"
#include "cursorstr.h"
#include "scrnintstr.h"
#include "opaque.h"
#include "input.h"
#include "servermd.h"
#include "extnsionst.h"
#include "dixfont.h"
#include "../../dix/dispatch.h"
#include "swaprep.h"
#include "swapreq.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#ifdef XCSECURITY
#define _SECURITY_SERVER
#include <nx-X11/extensions/security.h>
#endif
#ifdef XAPPGROUP
#include <nx-X11/extensions/Xagsrv.h>
#endif
#ifdef XKB
#define XKB_IN_SERVER
#include "inputstr.h"
#include <nx-X11/extensions/XKBsrv.h>
#endif
#include "Atoms.h"
#include "Splash.h"
......@@ -182,10 +145,6 @@ Bool nxagentWMPassed = 0;
int nxagentAutoDisconnectTimeout = 0;
#ifdef LBX
#include "../../lbx/lbxserve.h"
#endif
#include "Xatom.h"
/*
......@@ -211,21 +170,6 @@ int nxagentAutoDisconnectTimeout = 0;
#include "Literals.h"
#endif
#define mskcnt ((MAXCLIENTS + 31) / 32)
#define BITMASK(i) (1U << ((i) & 31))
#define MASKIDX(i) ((i) >> 5)
#define MASKWORD(buf, i) buf[MASKIDX(i)]
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
extern xConnSetupPrefix connSetupPrefix;
extern char *ConnectionInfo;
Selection *CurrentSelections;
int NumCurrentSelections;
CallbackListPtr SelectionCallback = NULL;
#ifdef VIEWPORT_FRAME
extern WindowPtr nxagentViewportFrameLeft;
......@@ -248,82 +192,6 @@ extern int nxagentMaxAllowedResets;
extern int nxagentFindClientResource(int, RESTYPE, void *);
static ClientPtr grabClient;
#define GrabNone 0
#define GrabActive 1
#define GrabKickout 2
static int grabState = GrabNone;
static long grabWaiters[mskcnt];
CallbackListPtr ServerGrabCallback = NULL;
HWEventQueuePtr checkForInput[2];
extern int connBlockScreenStart;
static void KillAllClients(void);
static void DeleteClientFromAnySelections(ClientPtr client);
static int nextFreeClientID; /* always MIN free client ID */
static int nClients; /* number of authorized clients */
CallbackListPtr ClientStateCallback;
/* dispatchException & isItTimeToYield must be declared volatile since they
* are modified by signal handlers - otherwise optimizer may assume it doesn't
* need to actually check value in memory when used and may miss changes from
* signal handlers.
*/
volatile char dispatchException = 0;
volatile char isItTimeToYield;
/* Various of the DIX function interfaces were not designed to allow
* the client->errorValue to be set on BadValue and other errors.
* Rather than changing interfaces and breaking untold code we introduce
* a new global that dispatch can use.
*/
XID clientErrorValue; /* XXX this is a kludge */
#define SAME_SCREENS(a, b) (\
(a.pScreen == b.pScreen))
void
SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1)
{
checkForInput[0] = c0;
checkForInput[1] = c1;
}
void
UpdateCurrentTime()
{
TimeStamp systime;
/* To avoid time running backwards, we must call GetTimeInMillis before
* calling ProcessInputEvents.
*/
systime.months = currentTime.months;
systime.milliseconds = GetTimeInMillis();
if (systime.milliseconds < currentTime.milliseconds)
systime.months++;
if (*checkForInput[0] != *checkForInput[1])
ProcessInputEvents();
if (CompareTimeStamps(systime, currentTime) == LATER)
currentTime = systime;
}
/* Like UpdateCurrentTime, but can't call ProcessInputEvents */
void
UpdateCurrentTimeIf()
{
TimeStamp systime;
systime.months = currentTime.months;
systime.milliseconds = GetTimeInMillis();
if (systime.milliseconds < currentTime.milliseconds)
systime.months++;
if (*checkForInput[0] == *checkForInput[1])
currentTime = systime;
}
void
InitSelections()
......@@ -358,137 +226,6 @@ InitSelections()
}
void
FlushClientCaches(XID id)
{
int i;
register ClientPtr client;
client = clients[CLIENT_ID(id)];
if (client == NullClient)
return ;
for (i=0; i<currentMaxClients; i++)
{
client = clients[i];
if (client != NullClient)
{
if (client->lastDrawableID == id)
{
client->lastDrawableID = screenInfo.screens[0]->root->drawable.id;
client->lastDrawable = (DrawablePtr)screenInfo.screens[0]->root;
}
else if (client->lastGCID == id)
{
client->lastGCID = INVALID;
client->lastGC = (GCPtr)NULL;
}
}
}
}
#ifdef SMART_SCHEDULE
#undef SMART_DEBUG
#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */
#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */
Bool SmartScheduleDisable = FALSE;
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
long SmartScheduleTime;
ClientPtr SmartLastClient;
int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
int SmartScheduleClient(int *clientReady, int nready);
#ifdef SMART_DEBUG
long SmartLastPrint;
#endif
void Dispatch(void);
void InitProcVectors(void);
int
SmartScheduleClient (int *clientReady, int nready)
{
ClientPtr pClient;
int i;
int client;
int bestPrio, best = 0;
int bestRobin, robin;
long now = SmartScheduleTime;
long idle;
bestPrio = -0x7fffffff;
bestRobin = 0;
idle = 2 * SmartScheduleSlice;
for (i = 0; i < nready; i++)
{
client = clientReady[i];
pClient = clients[client];
/* Praise clients which are idle */
if ((now - pClient->smart_check_tick) >= idle)
{
if (pClient->smart_priority < 0)
pClient->smart_priority++;
}
pClient->smart_check_tick = now;
/* check priority to select best client */
robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff;
if (pClient->smart_priority > bestPrio ||
(pClient->smart_priority == bestPrio && robin > bestRobin))
{
bestPrio = pClient->smart_priority;
bestRobin = robin;
best = client;
}
#ifdef SMART_DEBUG
if ((now - SmartLastPrint) >= 5000)
fprintf (stderr, " %2d: %3d", client, pClient->smart_priority);
#endif
}
#ifdef SMART_DEBUG
if ((now - SmartLastPrint) >= 5000)
{
fprintf (stderr, " use %2d\n", best);
SmartLastPrint = now;
}
#endif
pClient = clients[best];
SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index;
/*
* Set current client pointer
*/
if (SmartLastClient != pClient)
{
pClient->smart_start_tick = now;
SmartLastClient = pClient;
}
/*
* Adjust slice
*/
if (nready == 1)
{
/*
* If it's been a long time since another client
* has run, bump the slice up to get maximal
* performance from a single client
*/
if ((now - pClient->smart_start_tick) > 1000 &&
SmartScheduleSlice < SmartScheduleMaxSlice)
{
SmartScheduleSlice += SmartScheduleInterval;
}
}
else
{
SmartScheduleSlice = SmartScheduleInterval;
}
return best;
}
#endif
#define MAJOROP ((xReq *)client->requestBuffer)->reqType
void
......@@ -846,159 +583,6 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
#undef MAJOROP
int
ProcBadRequest(ClientPtr client)
{
return (BadRequest);
}
int
ProcCreateWindow(ClientPtr client)
{
register WindowPtr pParent, pWin;
REQUEST(xCreateWindowReq);
int result;
int len;
REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
LEGAL_NEW_RESOURCE(stuff->wid, client);
if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
SecurityWriteAccess)))
return BadWindow;
len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
if (Ones(stuff->mask) != len)
return BadLength;
if (!stuff->width || !stuff->height)
{
client->errorValue = 0;
return BadValue;
}
pWin = CreateWindow(stuff->wid, pParent, stuff->x,
stuff->y, stuff->width, stuff->height,
stuff->borderWidth, stuff->class,
stuff->mask, (XID *) &stuff[1],
(int)stuff->depth,
client, stuff->visual, &result);
if (pWin)
{
Mask mask = pWin->eventMask;
pWin->eventMask = 0; /* subterfuge in case AddResource fails */
if (!AddResource(stuff->wid, RT_WINDOW, (void *)pWin))
return BadAlloc;
pWin->eventMask = mask;
}
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
int
ProcChangeWindowAttributes(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xChangeWindowAttributesReq);
register int result;
int len;
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityWriteAccess);
if (!pWin)
return(BadWindow);
len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
if (len != Ones(stuff->valueMask))
return BadLength;
result = ChangeWindowAttributes(pWin,
stuff->valueMask,
(XID *) &stuff[1],
client);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
int
ProcGetWindowAttributes(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xResourceReq);
xGetWindowAttributesReply wa;
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
memset(&wa, 0, sizeof(xGetWindowAttributesReply));
GetWindowAttributes(pWin, client, &wa);
WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
return(client->noClientException);
}
int
ProcDestroyWindow(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
SecurityDestroyAccess);
if (!pWin)
return(BadWindow);
if (pWin->parent)
FreeResource(stuff->id, RT_NONE);
return(client->noClientException);
}
int
ProcDestroySubwindows(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
SecurityDestroyAccess);
if (!pWin)
return(BadWindow);
DestroySubwindows(pWin, client);
return(client->noClientException);
}
int
ProcChangeSaveSet(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xChangeSaveSetReq);
register int result;
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
return BadMatch;
if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
{
result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
else
{
client->errorValue = stuff->mode;
return( BadValue );
}
}
int
ProcReparentWindow(register ClientPtr client)
{
register WindowPtr pWin, pParent;
......@@ -1039,10 +623,14 @@ ProcReparentWindow(register ClientPtr client)
return (BadMatch);
}
int
ProcMapWindow(register ClientPtr client)
ProcQueryTree(register ClientPtr client)
{
register WindowPtr pWin;
xQueryTreeReply reply;
int numChildren = 0;
register WindowPtr pChild, pWin, pHead;
Window *childIDs = (Window *)NULL;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
......@@ -1050,289 +638,59 @@ ProcMapWindow(register ClientPtr client)
SecurityReadAccess);
if (!pWin)
return(BadWindow);
MapWindow(pWin, client);
/* update cache to say it is mapped */
return(client->noClientException);
}
int
ProcMapSubwindows(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xResourceReq);
memset(&reply, 0, sizeof(xQueryTreeReply));
reply.type = X_Reply;
reply.root = pWin->drawable.pScreen->root->drawable.id;
reply.sequenceNumber = client->sequence;
if (pWin->parent)
reply.parent = pWin->parent->drawable.id;
else
reply.parent = (Window)None;
pHead = RealChildHead(pWin);
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
{
if (!IsViewportFrame(pChild))
{
numChildren++;
}
}
if (numChildren)
{
int curChild = 0;
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
MapSubwindows(pWin, client);
/* update cache to say it is mapped */
return(client->noClientException);
}
childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
if (!childIDs)
return BadAlloc;
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
{
if (!IsViewportFrame(pChild))
{
childIDs[curChild++] = pChild->drawable.id;
}
}
}
int
ProcUnmapWindow(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xResourceReq);
reply.nChildren = numChildren;
reply.length = (numChildren * sizeof(Window)) >> 2;
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
UnmapWindow(pWin, FALSE);
/* update cache to say it is mapped */
WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
if (numChildren)
{
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
DEALLOCATE_LOCAL(childIDs);
}
return(client->noClientException);
}
int
ProcUnmapSubwindows(register ClientPtr client)
ProcSetSelectionOwner(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
UnmapSubwindows(pWin);
return(client->noClientException);
}
int
ProcConfigureWindow(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xConfigureWindowReq);
register int result;
int len;
REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client,
SecurityWriteAccess);
if (!pWin)
return(BadWindow);
len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
if (Ones((Mask)stuff->mask) != len)
return BadLength;
result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1],
client);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
int
ProcCirculateWindow(register ClientPtr client)
{
register WindowPtr pWin;
REQUEST(xCirculateWindowReq);
REQUEST_SIZE_MATCH(xCirculateWindowReq);
if ((stuff->direction != RaiseLowest) &&
(stuff->direction != LowerHighest))
{
client->errorValue = stuff->direction;
return BadValue;
}
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityWriteAccess);
if (!pWin)
return(BadWindow);
CirculateWindow(pWin, (int)stuff->direction, client);
return(client->noClientException);
}
int
GetGeometry(register ClientPtr client, xGetGeometryReply *rep)
{
register DrawablePtr pDraw;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess);
memset(rep, 0, sizeof(xGetGeometryReply));
rep->type = X_Reply;
rep->length = 0;
rep->sequenceNumber = client->sequence;
rep->root = pDraw->pScreen->root->drawable.id;
rep->depth = pDraw->depth;
rep->width = pDraw->width;
rep->height = pDraw->height;
/* XXX - Because the pixmap-implementation of the multibuffer extension
* may have the buffer-id's drawable resource value be a pointer
* to the buffer's window instead of the buffer itself
* (this happens if the buffer is the displayed buffer),
* we also have to check that the id matches before we can
* truly say that it is a DRAWABLE_WINDOW.
*/
if ((pDraw->type == UNDRAWABLE_WINDOW) ||
((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id)))
{
register WindowPtr pWin = (WindowPtr)pDraw;
rep->x = pWin->origin.x - wBorderWidth (pWin);
rep->y = pWin->origin.y - wBorderWidth (pWin);
rep->borderWidth = pWin->borderWidth;
}
else /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */
{
rep->x = rep->y = rep->borderWidth = 0;
}
return Success;
}
int
ProcGetGeometry(register ClientPtr client)
{
xGetGeometryReply rep;
int status;
if ((status = GetGeometry(client, &rep)) != Success)
return status;
WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
return(client->noClientException);
}
int
ProcQueryTree(register ClientPtr client)
{
xQueryTreeReply reply;
int numChildren = 0;
register WindowPtr pChild, pWin, pHead;
Window *childIDs = (Window *)NULL;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
memset(&reply, 0, sizeof(xQueryTreeReply));
reply.type = X_Reply;
reply.root = pWin->drawable.pScreen->root->drawable.id;
reply.sequenceNumber = client->sequence;
if (pWin->parent)
reply.parent = pWin->parent->drawable.id;
else
reply.parent = (Window)None;
pHead = RealChildHead(pWin);
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
{
if (!IsViewportFrame(pChild))
{
numChildren++;
}
}
if (numChildren)
{
int curChild = 0;
childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
if (!childIDs)
return BadAlloc;
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
{
if (!IsViewportFrame(pChild))
{
childIDs[curChild++] = pChild->drawable.id;
}
}
}
reply.nChildren = numChildren;
reply.length = (numChildren * sizeof(Window)) >> 2;
WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
if (numChildren)
{
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
DEALLOCATE_LOCAL(childIDs);
}
return(client->noClientException);
}
int
ProcInternAtom(register ClientPtr client)
{
Atom atom;
char *tchar;
REQUEST(xInternAtomReq);
REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
{
client->errorValue = stuff->onlyIfExists;
return(BadValue);
}
tchar = (char *) &stuff[1];
atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
if (atom != BAD_RESOURCE)
{
xInternAtomReply reply;
memset(&reply, 0, sizeof(xInternAtomReply));
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
reply.atom = atom;
WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
return(client->noClientException);
}
else
return (BadAlloc);
}
int
ProcGetAtomName(register ClientPtr client)
{
char *str;
xGetAtomNameReply reply;
int len;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if ( (str = NameForAtom(stuff->id)) )
{
len = strlen(str);
memset(&reply, 0, sizeof(xGetAtomNameReply));
reply.type = X_Reply;
reply.length = (len + 3) >> 2;
reply.sequenceNumber = client->sequence;
reply.nameLength = len;
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
(void)WriteToClient(client, len, str);
return(client->noClientException);
}
else
{
client->errorValue = stuff->id;
return (BadAtom);
}
}
#ifdef K5AUTH
extern int k5_bad();
#endif
int
ProcSetSelectionOwner(register ClientPtr client)
{
WindowPtr pWin;
TimeStamp time;
REQUEST(xSetSelectionOwnerReq);
WindowPtr pWin;
TimeStamp time;
REQUEST(xSetSelectionOwnerReq);
REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
UpdateCurrentTime();
......@@ -1433,37 +791,6 @@ ProcSetSelectionOwner(register ClientPtr client)
}
}
int
ProcGetSelectionOwner(register ClientPtr client)
{
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (ValidAtom(stuff->id))
{
int i;
xGetSelectionOwnerReply reply;
i = 0;
while ((i < NumCurrentSelections) &&
CurrentSelections[i].selection != stuff->id) i++;
memset(&reply, 0, sizeof(xGetSelectionOwnerReply));
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
if (i < NumCurrentSelections)
reply.owner = CurrentSelections[i].window;
else
reply.owner = None;
WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
return(client->noClientException);
}
else
{
client->errorValue = stuff->id;
return (BadAtom);
}
}
int
ProcConvertSelection(register ClientPtr client)
......@@ -1553,146 +880,6 @@ ProcConvertSelection(register ClientPtr client)
}
}
int
ProcGrabServer(register ClientPtr client)
{
REQUEST_SIZE_MATCH(xReq);
if (grabState != GrabNone && client != grabClient)
{
ResetCurrentRequest(client);
client->sequence--;
BITSET(grabWaiters, client->index);
IgnoreClient(client);
return(client->noClientException);
}
OnlyListenToOneClient(client);
grabState = GrabKickout;
grabClient = client;
if (ServerGrabCallback)
{
ServerGrabInfoRec grabinfo;
grabinfo.client = client;
grabinfo.grabstate = SERVER_GRABBED;
CallCallbacks(&ServerGrabCallback, (void *)&grabinfo);
}
return(client->noClientException);
}
static void
UngrabServer(ClientPtr client)
{
int i;
grabState = GrabNone;
ListenToAllClients();
for (i = mskcnt; --i >= 0 && !grabWaiters[i]; )
;
if (i >= 0)
{
i <<= 5;
while (!GETBIT(grabWaiters, i))
i++;
BITCLEAR(grabWaiters, i);
AttendClient(clients[i]);
}
if (ServerGrabCallback)
{
ServerGrabInfoRec grabinfo;
grabinfo.client = client;
grabinfo.grabstate = SERVER_UNGRABBED;
CallCallbacks(&ServerGrabCallback, (void *)&grabinfo);
}
}
int
ProcUngrabServer(register ClientPtr client)
{
REQUEST_SIZE_MATCH(xReq);
UngrabServer(client);
return(client->noClientException);
}
int
ProcTranslateCoords(register ClientPtr client)
{
REQUEST(xTranslateCoordsReq);
register WindowPtr pWin, pDst;
xTranslateCoordsReply rep;
REQUEST_SIZE_MATCH(xTranslateCoordsReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
SecurityReadAccess);
if (!pDst)
return(BadWindow);
memset(&rep, 0, sizeof(xTranslateCoordsReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (!SAME_SCREENS(pWin->drawable, pDst->drawable))
{
rep.sameScreen = xFalse;
rep.child = None;
rep.dstX = rep.dstY = 0;
}
else
{
INT16 x, y;
rep.sameScreen = xTrue;
rep.child = None;
/* computing absolute coordinates -- adjust to destination later */
x = pWin->drawable.x + stuff->srcX;
y = pWin->drawable.y + stuff->srcY;
pWin = pDst->firstChild;
while (pWin)
{
#ifdef SHAPE
BoxRec box;
#endif
if ((pWin->mapped) &&
(x >= pWin->drawable.x - wBorderWidth (pWin)) &&
(x < pWin->drawable.x + (int)pWin->drawable.width +
wBorderWidth (pWin)) &&
(y >= pWin->drawable.y - wBorderWidth (pWin)) &&
(y < pWin->drawable.y + (int)pWin->drawable.height +
wBorderWidth (pWin))
#ifdef SHAPE
/* When a window is shaped, a further check
* is made to see if the point is inside
* borderSize
*/
&& (!wBoundingShape(pWin) ||
RegionContainsPoint(
&pWin->borderSize, x, y, &box))
&& (!wInputShape(pWin) ||
RegionContainsPoint(
wInputShape(pWin),
x - pWin->drawable.x,
y - pWin->drawable.y, &box))
#endif
)
{
rep.child = pWin->drawable.id;
pWin = (WindowPtr) NULL;
}
else
pWin = pWin->nextSib;
}
/* adjust to destination coordinates */
rep.dstX = x - pDst->drawable.x;
rep.dstY = y - pDst->drawable.y;
}
WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
return(client->noClientException);
}
int
ProcOpenFont(register ClientPtr client)
......@@ -1784,156 +971,17 @@ ProcCloseFont(register ClientPtr client)
}
}
int
ProcQueryFont(register ClientPtr client)
{
xQueryFontReply *reply;
FontPtr pFont;
register GC *pGC;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id; /* EITHER font or gc */
pFont = NULL;
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
SecurityReadAccess);
if (!pFont)
{
/* can't use VERIFY_GC because it might return BadGC */
pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
SecurityReadAccess);
if (!pGC)
{
client->errorValue = stuff->id;
return(BadFont); /* procotol spec says only error is BadFont */
}
pFont = pGC->font;
}
/* test
int
ProcListFonts(register ClientPtr client)
{
Atom name_atom, value_atom;
int nprops;
FontPropPtr props;
int i;
char *name;
char tmp[256];
name_atom = MakeAtom("FONT", 4, True);
value_atom = 0L;
REQUEST(xListFontsReq);
nprops = pFont->info.nprops;
props = pFont->info.props;
for (i = 0; i < nprops; i++)
if (props[i].name == name_atom) {
value_atom = props[i].value;
break;
}
if (!value_atom) return (BadFont);
name = (char *)NameForAtom(value_atom);
fprintf(stderr, "QueryFont: font name [%s]\n",name);
}
end test */
{
xCharInfo *pmax = FONTINKMAX(pFont);
xCharInfo *pmin = FONTINKMIN(pFont);
int nprotoxcistructs;
int rlength;
nprotoxcistructs = (
pmax->rightSideBearing == pmin->rightSideBearing &&
pmax->leftSideBearing == pmin->leftSideBearing &&
pmax->descent == pmin->descent &&
pmax->ascent == pmin->ascent &&
pmax->characterWidth == pmin->characterWidth) ?
0 : N2dChars(pFont);
rlength = sizeof(xQueryFontReply) +
FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) +
nprotoxcistructs * sizeof(xCharInfo);
reply = NULL;
reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength);
if(!reply)
{
return(BadAlloc);
}
memset(reply, 0, rlength);
reply->type = X_Reply;
reply->length = (rlength - sizeof(xGenericReply)) >> 2;
reply->sequenceNumber = client->sequence;
QueryFont( pFont, reply, nprotoxcistructs);
WriteReplyToClient(client, rlength, reply);
DEALLOCATE_LOCAL(reply);
return(client->noClientException);
}
}
int
ProcQueryTextExtents(register ClientPtr client)
{
REQUEST(xQueryTextExtentsReq);
xQueryTextExtentsReply reply;
FontPtr pFont;
GC *pGC;
ExtentInfoRec info;
unsigned long length;
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT,
SecurityReadAccess);
if (!pFont)
{
pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC,
SecurityReadAccess);
if (!pGC)
{
client->errorValue = stuff->fid;
return(BadFont);
}
pFont = pGC->font;
}
length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
length = length << 1;
if (stuff->oddLength)
{
if (length == 0)
return(BadLength);
length--;
}
if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info))
return(BadAlloc);
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
reply.drawDirection = info.drawDirection;
reply.fontAscent = info.fontAscent;
reply.fontDescent = info.fontDescent;
reply.overallAscent = info.overallAscent;
reply.overallDescent = info.overallDescent;
reply.overallWidth = info.overallWidth;
reply.overallLeft = info.overallLeft;
reply.overallRight = info.overallRight;
WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
return(client->noClientException);
}
int
ProcListFonts(register ClientPtr client)
{
char tmp[256];
REQUEST(xListFontsReq);
REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255);
tmp[stuff->nbytes]=0;
REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255);
tmp[stuff->nbytes]=0;
#ifdef NXAGENT_FONTMATCH_DEBUG
fprintf(stderr, "Dispatch: ListFont request with pattern %s max_names=%d\n",tmp,stuff->maxNames);
......@@ -1962,75 +1010,6 @@ ProcListFontsWithInfo(register ClientPtr client)
(unsigned char *) &stuff[1], stuff->maxNames);
}
/**
*
* \param value must conform to DeleteType
*/
int
dixDestroyPixmap(void * value, XID pid)
{
PixmapPtr pPixmap = (PixmapPtr)value;
return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
}
int
ProcCreatePixmap(register ClientPtr client)
{
PixmapPtr pMap;
register DrawablePtr pDraw;
REQUEST(xCreatePixmapReq);
DepthPtr pDepth;
register int i;
REQUEST_SIZE_MATCH(xCreatePixmapReq);
client->errorValue = stuff->pid;
LEGAL_NEW_RESOURCE(stuff->pid, client);
SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
SecurityReadAccess);
if (!stuff->width || !stuff->height)
{
client->errorValue = 0;
return BadValue;
}
if (stuff->width > 32767 || stuff->height > 32767)
{
/* It is allowed to try and allocate a pixmap which is larger than
* 32767 in either dimension. However, all of the framebuffer code
* is buggy and does not reliably draw to such big pixmaps, basically
* because the Region data structure operates with signed shorts
* for the rectangles in it.
*
* Furthermore, several places in the X server computes the
* size in bytes of the pixmap and tries to store it in an
* integer. This integer can overflow and cause the allocated size
* to be much smaller.
*
* So, such big pixmaps are rejected here with a BadAlloc
*/
return BadAlloc;
}
if (stuff->depth != 1)
{
pDepth = pDraw->pScreen->allowedDepths;
for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
if (pDepth->depth == stuff->depth)
goto CreatePmap;
client->errorValue = stuff->depth;
return BadValue;
}
CreatePmap:
pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap)
(pDraw->pScreen, stuff->width,
stuff->height, stuff->depth);
if (pMap)
{
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
if (AddResource(stuff->pid, RT_PIXMAP, (void *)pMap))
return(client->noClientException);
}
return (BadAlloc);
}
int
ProcFreePixmap(register ClientPtr client)
......@@ -2088,2004 +1067,107 @@ ProcFreePixmap(register ClientPtr client)
}
}
int
ProcCreateGC(register ClientPtr client)
{
int error;
GC *pGC;
register DrawablePtr pDraw;
unsigned len;
REQUEST(xCreateGCReq);
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
client->errorValue = stuff->gc;
LEGAL_NEW_RESOURCE(stuff->gc, client);
SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client,
SecurityReadAccess);
len = client->req_len - (sizeof(xCreateGCReq) >> 2);
if (len != Ones(stuff->mask))
return BadLength;
pGC = (GC *)CreateGC(pDraw, stuff->mask,
(XID *) &stuff[1], &error);
if (error != Success)
return error;
if (!AddResource(stuff->gc, RT_GC, (void *)pGC))
return (BadAlloc);
return(client->noClientException);
}
int
ProcChangeGC(register ClientPtr client)
{
GC *pGC;
REQUEST(xChangeGCReq);
int result;
unsigned len;
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess);
len = client->req_len - (sizeof(xChangeGCReq) >> 2);
if (len != Ones(stuff->mask))
return BadLength;
result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
return(result);
}
}
int
ProcCopyGC(register ClientPtr client)
{
register GC *dstGC;
register GC *pGC;
int result;
REQUEST(xCopyGCReq);
REQUEST_SIZE_MATCH(xCopyGCReq);
SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess);
SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess);
if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
return (BadMatch);
result = CopyGC(pGC, dstGC, stuff->mask);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
return(result);
}
}
int
ProcSetDashes(register ClientPtr client)
{
register GC *pGC;
int result;
REQUEST(xSetDashesReq);
REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
if (stuff->nDashes == 0)
{
client->errorValue = 0;
return BadValue;
}
SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes,
(unsigned char *)&stuff[1]);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
return(result);
}
}
int
ProcSetClipRectangles(register ClientPtr client)
{
int nr;
int result;
register GC *pGC;
REQUEST(xSetClipRectanglesReq);
REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
(stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
{
client->errorValue = stuff->ordering;
return BadValue;
}
SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
if (nr & 4)
return(BadLength);
nr >>= 3;
result = SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
nr, (xRectangle *)&stuff[1], (int)stuff->ordering);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
int
ProcFreeGC(register ClientPtr client)
{
register GC *pGC;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess);
FreeResource(stuff->id, RT_NONE);
return(client->noClientException);
}
int
ProcClearToBackground(register ClientPtr client)
{
REQUEST(xClearAreaReq);
register WindowPtr pWin;
REQUEST_SIZE_MATCH(xClearAreaReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityWriteAccess);
if (!pWin)
return(BadWindow);
if (pWin->drawable.class == InputOnly)
{
client->errorValue = stuff->window;
return (BadMatch);
}
if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
{
client->errorValue = stuff->exposures;
return(BadValue);
}
(*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y,
stuff->width, stuff->height,
(Bool)stuff->exposures);
return(client->noClientException);
}
int
ProcCopyArea(register ClientPtr client)
{
register DrawablePtr pDst;
register DrawablePtr pSrc;
register GC *pGC;
REQUEST(xCopyAreaReq);
RegionPtr pRgn;
REQUEST_SIZE_MATCH(xCopyAreaReq);
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client);
if (stuff->dstDrawable != stuff->srcDrawable)
{
SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client,
SecurityReadAccess);
if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth))
{
client->errorValue = stuff->dstDrawable;
return (BadMatch);
}
}
else
pSrc = pDst;
SET_DBE_SRCBUF(pSrc, stuff->srcDrawable);
pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
stuff->width, stuff->height,
stuff->dstX, stuff->dstY);
if (pGC->graphicsExposures)
{
(*pDst->pScreen->SendGraphicsExpose)
(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
if (pRgn)
RegionDestroy(pRgn);
}
return(client->noClientException);
}
int
ProcCopyPlane(register ClientPtr client)
ProcSetScreenSaver (register ClientPtr client)
{
register DrawablePtr psrcDraw, pdstDraw;
register GC *pGC;
REQUEST(xCopyPlaneReq);
RegionPtr pRgn;
REQUEST_SIZE_MATCH(xCopyPlaneReq);
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
if (stuff->dstDrawable != stuff->srcDrawable)
{
SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client,
SecurityReadAccess);
if (pdstDraw->pScreen != psrcDraw->pScreen)
{
client->errorValue = stuff->dstDrawable;
return (BadMatch);
}
}
else
psrcDraw = pdstDraw;
SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable);
/* Check to see if stuff->bitPlane has exactly ONE good bit set */
if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
(stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
{
client->errorValue = stuff->bitPlane;
return(BadValue);
}
pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY,
stuff->width, stuff->height,
stuff->dstX, stuff->dstY, stuff->bitPlane);
if (pGC->graphicsExposures)
{
(*pdstDraw->pScreen->SendGraphicsExpose)
(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
if (pRgn)
RegionDestroy(pRgn);
}
return(client->noClientException);
}
int blankingOption, exposureOption;
REQUEST(xSetScreenSaverReq);
int
ProcPolyPoint(register ClientPtr client)
{
int npoint;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolyPointReq);
REQUEST_AT_LEAST_SIZE(xPolyPointReq);
if ((stuff->coordMode != CoordModeOrigin) &&
(stuff->coordMode != CoordModePrevious))
REQUEST_SIZE_MATCH(xSetScreenSaverReq);
blankingOption = stuff->preferBlank;
if ((blankingOption != DontPreferBlanking) &&
(blankingOption != PreferBlanking) &&
(blankingOption != DefaultBlanking))
{
client->errorValue = stuff->coordMode;
client->errorValue = blankingOption;
return BadValue;
}
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
if (npoint)
{
(*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
(xPoint *) &stuff[1]);
}
return (client->noClientException);
}
int
ProcPolyLine(register ClientPtr client)
{
int npoint;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolyLineReq);
REQUEST_AT_LEAST_SIZE(xPolyLineReq);
if ((stuff->coordMode != CoordModeOrigin) &&
(stuff->coordMode != CoordModePrevious))
exposureOption = stuff->allowExpose;
if ((exposureOption != DontAllowExposures) &&
(exposureOption != AllowExposures) &&
(exposureOption != DefaultExposures))
{
client->errorValue = stuff->coordMode;
client->errorValue = exposureOption;
return BadValue;
}
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
if (npoint > 1)
{
(*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
(DDXPointPtr) &stuff[1]);
}
return(client->noClientException);
}
int
ProcPolySegment(register ClientPtr client)
{
int nsegs;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolySegmentReq);
REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
if (nsegs & 4)
return(BadLength);
nsegs >>= 3;
if (nsegs)
{
(*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
}
return (client->noClientException);
}
int
ProcPolyRectangle (register ClientPtr client)
{
int nrects;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolyRectangleReq);
REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
if (nrects & 4)
return(BadLength);
nrects >>= 3;
if (nrects)
{
(*pGC->ops->PolyRectangle)(pDraw, pGC,
nrects, (xRectangle *) &stuff[1]);
}
return(client->noClientException);
}
int
ProcPolyArc(register ClientPtr client)
{
int narcs;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolyArcReq);
REQUEST_AT_LEAST_SIZE(xPolyArcReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
if (narcs % sizeof(xArc))
return(BadLength);
narcs /= sizeof(xArc);
if (narcs)
{
(*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]);
}
return (client->noClientException);
}
int
ProcFillPoly(register ClientPtr client)
{
int things;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xFillPolyReq);
REQUEST_AT_LEAST_SIZE(xFillPolyReq);
if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) &&
(stuff->shape != Convex))
if (stuff->timeout < -1)
{
client->errorValue = stuff->shape;
client->errorValue = stuff->timeout;
return BadValue;
}
if ((stuff->coordMode != CoordModeOrigin) &&
(stuff->coordMode != CoordModePrevious))
if (stuff->interval < -1)
{
client->errorValue = stuff->coordMode;
client->errorValue = stuff->interval;
return BadValue;
}
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
if (things)
{
(*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
stuff->coordMode, things,
(DDXPointPtr) &stuff[1]);
}
return(client->noClientException);
}
/*
* The NX agent uses the screen saver procedure
* to monitor the user activities and launch its
* handlers (like timeout feature), so we can't
* always allow the clients to change our values.
*/
int
ProcPolyFillRectangle(register ClientPtr client)
{
int things;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolyFillRectangleReq);
REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
if (things & 4)
return(BadLength);
things >>= 3;
if (things)
{
(*pGC->ops->PolyFillRect) (pDraw, pGC, things,
(xRectangle *) &stuff[1]);
}
return (client->noClientException);
}
int
ProcPolyFillArc(register ClientPtr client)
{
int narcs;
register GC *pGC;
register DrawablePtr pDraw;
REQUEST(xPolyFillArcReq);
REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
if (narcs % sizeof(xArc))
return(BadLength);
narcs /= sizeof(xArc);
if (narcs)
{
(*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
}
return (client->noClientException);
}
#ifdef MATCH_CLIENT_ENDIAN
int
ServerOrder (void)
{
int whichbyte = 1;
if (*((char *) &whichbyte))
return LSBFirst;
return MSBFirst;
}
#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder())
void
ReformatImage (char *base, int nbytes, int bpp, int order)
{
switch (bpp) {
case 1: /* yuck */
if (BITMAP_BIT_ORDER != order)
BitOrderInvert ((unsigned char *) base, nbytes);
#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8
ReformatImage (base, nbytes, BITMAP_SCANLINE_UNIT, order);
#endif
break;
case 4:
break; /* yuck */
case 8:
break;
case 16:
if (IMAGE_BYTE_ORDER != order)
TwoByteSwap ((unsigned char *) base, nbytes);
break;
case 32:
if (IMAGE_BYTE_ORDER != order)
FourByteSwap ((unsigned char *) base, nbytes);
break;
}
}
#else
#define ReformatImage(b,n,bpp,o)
#endif
/* 64-bit server notes: the protocol restricts padding of images to
* 8-, 16-, or 32-bits. We would like to have 64-bits for the server
* to use internally. Removes need for internal alignment checking.
* All of the PutImage functions could be changed individually, but
* as currently written, they call other routines which require things
* to be 64-bit padded on scanlines, so we changed things here.
* If an image would be padded differently for 64- versus 32-, then
* copy each scanline to a 64-bit padded scanline.
* Also, we need to make sure that the image is aligned on a 64-bit
* boundary, even if the scanlines are padded to our satisfaction.
*/
int
ProcPutImage(register ClientPtr client)
{
register GC *pGC;
register DrawablePtr pDraw;
long length; /* length of scanline server padded */
long lengthProto; /* length of scanline protocol padded */
char *tmpImage;
REQUEST(xPutImageReq);
REQUEST_AT_LEAST_SIZE(xPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if (stuff->format == XYBitmap)
{
if ((stuff->depth != 1) ||
(stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
return BadMatch;
length = BitmapBytePad(stuff->width + stuff->leftPad);
}
else if (stuff->format == XYPixmap)
{
if ((pDraw->depth != stuff->depth) ||
(stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
return BadMatch;
length = BitmapBytePad(stuff->width + stuff->leftPad);
length *= stuff->depth;
}
else if (stuff->format == ZPixmap)
{
if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0))
return BadMatch;
length = PixmapBytePad(stuff->width, stuff->depth);
}
else
{
client->errorValue = stuff->format;
return BadValue;
}
tmpImage = (char *)&stuff[1];
lengthProto = length;
if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) +
(sizeof(xPutImageReq) >> 2)) != client->req_len)
return BadLength;
ReformatImage (tmpImage, lengthProto * stuff->height,
stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1,
ClientOrder(client));
(*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
stuff->width, stuff->height,
stuff->leftPad, stuff->format, tmpImage);
return (client->noClientException);
}
int
DoGetImage(register ClientPtr client, int format, Drawable drawable,
int x, int y, int width, int height,
Mask planemask, xGetImageReply **im_return)
{
register DrawablePtr pDraw;
int nlines, linesPerBuf;
register int linesDone;
long widthBytesLine, length;
Mask plane = 0;
char *pBuf;
xGetImageReply xgi;
#ifdef XCSECURITY
RegionPtr pVisibleRegion = NULL;
#endif
if ((format != XYPixmap) && (format != ZPixmap))
{
client->errorValue = format;
return(BadValue);
}
SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess);
memset(&xgi, 0, sizeof(xGetImageReply));
if(pDraw->type == DRAWABLE_WINDOW)
{
if( /* check for being viewable */
!((WindowPtr) pDraw)->realized ||
/* check for being on screen */
pDraw->x + x < 0 ||
pDraw->x + x + width > pDraw->pScreen->width ||
pDraw->y + y < 0 ||
pDraw->y + y + height > pDraw->pScreen->height ||
/* check for being inside of border */
x < - wBorderWidth((WindowPtr)pDraw) ||
x + width > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
y < -wBorderWidth((WindowPtr)pDraw) ||
y + height > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height
)
return(BadMatch);
xgi.visual = wVisual (((WindowPtr) pDraw));
}
else
{
if(x < 0 ||
x+width > (int)pDraw->width ||
y < 0 ||
y+height > (int)pDraw->height
)
return(BadMatch);
xgi.visual = None;
}
SET_DBE_SRCBUF(pDraw, drawable);
xgi.type = X_Reply;
xgi.sequenceNumber = client->sequence;
xgi.depth = pDraw->depth;
if(format == ZPixmap)
{
widthBytesLine = PixmapBytePad(width, pDraw->depth);
length = widthBytesLine * height;
}
else
{
widthBytesLine = BitmapBytePad(width);
plane = ((Mask)1) << (pDraw->depth - 1);
/* only planes asked for */
length = widthBytesLine * height *
Ones(planemask & (plane | (plane - 1)));
}
xgi.length = length;
if (im_return) {
pBuf = (char *)xcalloc(1, sz_xGetImageReply + length);
if (!pBuf)
return (BadAlloc);
if (widthBytesLine == 0)
linesPerBuf = 0;
else
linesPerBuf = height;
*im_return = (xGetImageReply *)pBuf;
*(xGetImageReply *)pBuf = xgi;
pBuf += sz_xGetImageReply;
} else {
xgi.length = (xgi.length + 3) >> 2;
if (widthBytesLine == 0 || height == 0)
linesPerBuf = 0;
else if (widthBytesLine >= IMAGE_BUFSIZE)
linesPerBuf = 1;
else
{
linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
if (linesPerBuf > height)
linesPerBuf = height;
}
length = linesPerBuf * widthBytesLine;
if (linesPerBuf < height)
{
/* we have to make sure intermediate buffers don't need padding */
while ((linesPerBuf > 1) &&
(length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
{
linesPerBuf--;
length -= widthBytesLine;
}
while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1))
{
linesPerBuf++;
length += widthBytesLine;
}
}
if(!(pBuf = (char *) ALLOCATE_LOCAL(length)))
return (BadAlloc);
memset(pBuf, 0, length);
WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
}
#ifdef XCSECURITY
if (client->trustLevel != XSecurityClientTrusted &&
pDraw->type == DRAWABLE_WINDOW)
{
pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
if (pVisibleRegion)
{
RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y);
}
}
#endif
if (linesPerBuf == 0)
{
/* nothing to do */
}
else if (format == ZPixmap)
{
linesDone = 0;
while (height - linesDone > 0)
{
nlines = min(linesPerBuf, height - linesDone);
(*pDraw->pScreen->GetImage) (pDraw,
x,
y + linesDone,
width,
nlines,
format,
planemask,
(void *) pBuf);
#ifdef XCSECURITY
if (pVisibleRegion)
SecurityCensorImage(client, pVisibleRegion, widthBytesLine,
pDraw, x, y + linesDone, width,
nlines, format, pBuf);
#endif
/* Note that this is NOT a call to WriteSwappedDataToClient,
as we do NOT byte swap */
if (!im_return)
{
ReformatImage (pBuf, (int)(nlines * widthBytesLine),
BitsPerPixel (pDraw->depth),
ClientOrder(client));
/* Don't split me, gcc pukes when you do */
(void)WriteToClient(client,
(int)(nlines * widthBytesLine),
pBuf);
}
linesDone += nlines;
}
}
else /* XYPixmap */
{
for (; plane; plane >>= 1)
{
if (planemask & plane)
{
linesDone = 0;
while (height - linesDone > 0)
{
nlines = min(linesPerBuf, height - linesDone);
(*pDraw->pScreen->GetImage) (pDraw,
x,
y + linesDone,
width,
nlines,
format,
plane,
(void *)pBuf);
#ifdef XCSECURITY
if (pVisibleRegion)
SecurityCensorImage(client, pVisibleRegion,
widthBytesLine,
pDraw, x, y + linesDone, width,
nlines, format, pBuf);
#endif
/* Note: NOT a call to WriteSwappedDataToClient,
as we do NOT byte swap */
if (im_return) {
pBuf += nlines * widthBytesLine;
} else {
ReformatImage (pBuf,
(int)(nlines * widthBytesLine),
1,
ClientOrder (client));
/* Don't split me, gcc pukes when you do */
(void)WriteToClient(client,
(int)(nlines * widthBytesLine),
pBuf);
}
linesDone += nlines;
}
}
}
}
#ifdef XCSECURITY
if (pVisibleRegion)
RegionDestroy(pVisibleRegion);
#endif
if (!im_return)
DEALLOCATE_LOCAL(pBuf);
return (client->noClientException);
}
int
ProcGetImage(register ClientPtr client)
{
REQUEST(xGetImageReq);
REQUEST_SIZE_MATCH(xGetImageReq);
return DoGetImage(client, stuff->format, stuff->drawable,
stuff->x, stuff->y,
(int)stuff->width, (int)stuff->height,
stuff->planeMask, (xGetImageReply **)NULL);
}
int
ProcPolyText(register ClientPtr client)
{
int err;
REQUEST(xPolyTextReq);
DrawablePtr pDraw;
GC *pGC;
REQUEST_AT_LEAST_SIZE(xPolyTextReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
err = PolyText(client,
pDraw,
pGC,
(unsigned char *)&stuff[1],
((unsigned char *) stuff) + (client->req_len << 2),
stuff->x,
stuff->y,
stuff->reqType,
stuff->drawable);
if (err == Success)
{
return(client->noClientException);
}
else
return err;
}
int
ProcImageText8(register ClientPtr client)
{
int err;
register DrawablePtr pDraw;
register GC *pGC;
REQUEST(xImageTextReq);
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
err = ImageText(client,
pDraw,
pGC,
stuff->nChars,
(unsigned char *)&stuff[1],
stuff->x,
stuff->y,
stuff->reqType,
stuff->drawable);
if (err == Success)
{
return(client->noClientException);
}
else
return err;
}
int
ProcImageText16(register ClientPtr client)
{
int err;
register DrawablePtr pDraw;
register GC *pGC;
REQUEST(xImageTextReq);
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
err = ImageText(client,
pDraw,
pGC,
stuff->nChars,
(unsigned char *)&stuff[1],
stuff->x,
stuff->y,
stuff->reqType,
stuff->drawable);
if (err == Success)
{
return(client->noClientException);
}
else
return err;
}
int
ProcCreateColormap(register ClientPtr client)
{
VisualPtr pVisual;
ColormapPtr pmap;
Colormap mid;
register WindowPtr pWin;
ScreenPtr pScreen;
REQUEST(xCreateColormapReq);
int i, result;
REQUEST_SIZE_MATCH(xCreateColormapReq);
if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll))
{
client->errorValue = stuff->alloc;
return(BadValue);
}
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
pScreen = pWin->drawable.pScreen;
for (i = 0, pVisual = pScreen->visuals;
i < pScreen->numVisuals;
i++, pVisual++)
{
if (pVisual->vid != stuff->visual)
continue;
result = CreateColormap(mid, pScreen, pVisual, &pmap,
(int)stuff->alloc, client->index);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
client->errorValue = stuff->visual;
return(BadValue);
}
int
ProcFreeColormap(register ClientPtr client)
{
ColormapPtr pmap;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP,
SecurityDestroyAccess);
if (pmap)
{
/* Freeing a default colormap is a no-op */
if (!(pmap->flags & IsDefault))
FreeResource(stuff->id, RT_NONE);
return (client->noClientException);
}
else
{
client->errorValue = stuff->id;
return (BadColor);
}
}
int
ProcCopyColormapAndFree(register ClientPtr client)
{
Colormap mid;
ColormapPtr pSrcMap;
REQUEST(xCopyColormapAndFreeReq);
int result;
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap,
RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) )
{
result = CopyColormapAndFree(mid, pSrcMap, client->index);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
else
{
client->errorValue = stuff->srcCmap;
return(BadColor);
}
}
int
ProcInstallColormap(register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
RT_COLORMAP, SecurityReadAccess);
if (pcmp)
{
(*(pcmp->pScreen->InstallColormap)) (pcmp);
return (client->noClientException);
}
else
{
client->errorValue = stuff->id;
return (BadColor);
}
}
int
ProcUninstallColormap(register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
RT_COLORMAP, SecurityReadAccess);
if (pcmp)
{
if(pcmp->mid != pcmp->pScreen->defColormap)
(*(pcmp->pScreen->UninstallColormap)) (pcmp);
return (client->noClientException);
}
else
{
client->errorValue = stuff->id;
return (BadColor);
}
}
int
ProcListInstalledColormaps(register ClientPtr client)
{
xListInstalledColormapsReply *preply;
int nummaps;
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
preply = (xListInstalledColormapsReply *)
ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
pWin->drawable.pScreen->maxInstalledCmaps *
sizeof(Colormap));
if(!preply)
return(BadAlloc);
preply->type = X_Reply;
preply->sequenceNumber = client->sequence;
nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
(pWin->drawable.pScreen, (Colormap *)&preply[1]);
preply->nColormaps = nummaps;
preply->length = nummaps;
WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
DEALLOCATE_LOCAL(preply);
return(client->noClientException);
}
int
ProcAllocColor (register ClientPtr client)
{
ColormapPtr pmap;
int retval;
xAllocColorReply acr;
REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq);
pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pmap)
{
#ifdef LBX
/*
* If the colormap is grabbed by a proxy, the server will have
* to regain control over the colormap. This AllocColor request
* will be handled after the server gets back the colormap control.
*/
if (LbxCheckColorRequest (client, pmap, (xReq *) stuff))
return Success;
#endif
acr.type = X_Reply;
acr.length = 0;
acr.sequenceNumber = client->sequence;
acr.red = stuff->red;
acr.green = stuff->green;
acr.blue = stuff->blue;
acr.pixel = 0;
if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index)) )
{
if (client->noClientException != Success)
return(client->noClientException);
else
return (retval);
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pmap->pScreen->myNum)
#endif
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
return (client->noClientException);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcAllocNamedColor (register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pcmp)
{
int retval;
xAllocNamedColorReply ancr;
#ifdef LBX
/*
* If the colormap is grabbed by a proxy, the server will have
* to regain control over the colormap. This AllocNamedColor request
* will be handled after the server gets back the colormap control.
*/
if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
return Success;
#endif
ancr.type = X_Reply;
ancr.length = 0;
ancr.sequenceNumber = client->sequence;
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
&ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue))
{
ancr.screenRed = ancr.exactRed;
ancr.screenGreen = ancr.exactGreen;
ancr.screenBlue = ancr.exactBlue;
ancr.pixel = 0;
if( (retval = AllocColor(pcmp,
&ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
&ancr.pixel, client->index)) )
{
if (client->noClientException != Success)
return(client->noClientException);
else
return(retval);
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr);
return (client->noClientException);
}
else
return(BadName);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcAllocColorCells (register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pcmp)
{
xAllocColorCellsReply accr;
int npixels, nmasks, retval;
long length;
Pixel *ppixels, *pmasks;
#ifdef LBX
/*
* If the colormap is grabbed by a proxy, the server will have
* to regain control over the colormap. This AllocColorCells request
* will be handled after the server gets back the colormap control.
*/
if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
return Success;
#endif
npixels = stuff->colors;
if (!npixels)
{
client->errorValue = npixels;
return (BadValue);
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
{
client->errorValue = stuff->contiguous;
return (BadValue);
}
nmasks = stuff->planes;
length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
ppixels = (Pixel *)ALLOCATE_LOCAL(length);
if(!ppixels)
return(BadAlloc);
pmasks = ppixels + npixels;
if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks,
(Bool)stuff->contiguous, ppixels, pmasks)) )
{
DEALLOCATE_LOCAL(ppixels);
if (client->noClientException != Success)
return(client->noClientException);
else
return(retval);
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
accr.type = X_Reply;
accr.length = length >> 2;
accr.sequenceNumber = client->sequence;
accr.nPixels = npixels;
accr.nMasks = nmasks;
WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
}
DEALLOCATE_LOCAL(ppixels);
return (client->noClientException);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcAllocColorPlanes(register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pcmp)
{
xAllocColorPlanesReply acpr;
int npixels, retval;
long length;
Pixel *ppixels;
#ifdef LBX
/*
* If the colormap is grabbed by a proxy, the server will have
* to regain control over the colormap. This AllocColorPlanes request
* will be handled after the server gets back the colormap control.
*/
if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
return Success;
#endif
npixels = stuff->colors;
if (!npixels)
{
client->errorValue = npixels;
return (BadValue);
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
{
client->errorValue = stuff->contiguous;
return (BadValue);
}
acpr.type = X_Reply;
acpr.sequenceNumber = client->sequence;
acpr.nPixels = npixels;
length = (long)npixels * sizeof(Pixel);
ppixels = (Pixel *)ALLOCATE_LOCAL(length);
if(!ppixels)
return(BadAlloc);
if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
(int)stuff->red, (int)stuff->green, (int)stuff->blue,
(Bool)stuff->contiguous, ppixels,
&acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
{
DEALLOCATE_LOCAL(ppixels);
if (client->noClientException != Success)
return(client->noClientException);
else
return(retval);
}
acpr.length = length >> 2;
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
}
DEALLOCATE_LOCAL(ppixels);
return (client->noClientException);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcFreeColors(register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xFreeColorsReq);
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pcmp)
{
int count;
int retval;
if(pcmp->flags & AllAllocated)
return(BadAccess);
count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
retval = FreeColors(pcmp, client->index, count,
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
return(retval);
}
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcStoreColors (ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xStoreColorsReq);
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pcmp)
{
int count;
int retval;
count = (client->req_len << 2) - sizeof(xStoreColorsReq);
if (count % sizeof(xColorItem))
return(BadLength);
count /= sizeof(xColorItem);
retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
return(retval);
}
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcStoreNamedColor (register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xStoreNamedColorReq);
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityWriteAccess);
if (pcmp)
{
xColorItem def;
int retval;
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
stuff->nbytes, &def.red, &def.green, &def.blue))
{
def.flags = stuff->flags;
def.pixel = stuff->pixel;
retval = StoreColors(pcmp, 1, &def);
if (client->noClientException != Success)
return(client->noClientException);
else
return(retval);
}
return (BadName);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcQueryColors(register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xQueryColorsReq);
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityReadAccess);
if (pcmp)
{
int count, retval;
xrgb *prgbs;
xQueryColorsReply qcr;
count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
if(!prgbs && count)
return(BadAlloc);
memset(prgbs, 0, count * sizeof(xrgb));
if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
{
if (prgbs) DEALLOCATE_LOCAL(prgbs);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
return (retval);
}
}
memset(&qcr, 0, sizeof(xQueryColorsReply));
qcr.type = X_Reply;
qcr.length = (count * sizeof(xrgb)) >> 2;
qcr.sequenceNumber = client->sequence;
qcr.nColors = count;
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
if (count)
{
client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
}
if (prgbs) DEALLOCATE_LOCAL(prgbs);
return(client->noClientException);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcLookupColor(register ClientPtr client)
{
ColormapPtr pcmp;
REQUEST(xLookupColorReq);
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
RT_COLORMAP, SecurityReadAccess);
if (pcmp)
{
xLookupColorReply lcr;
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
&lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue))
{
lcr.type = X_Reply;
lcr.length = 0;
lcr.sequenceNumber = client->sequence;
lcr.screenRed = lcr.exactRed;
lcr.screenGreen = lcr.exactGreen;
lcr.screenBlue = lcr.exactBlue;
(*pcmp->pScreen->ResolveColor)(&lcr.screenRed,
&lcr.screenGreen,
&lcr.screenBlue,
pcmp->pVisual);
WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
return(client->noClientException);
}
return (BadName);
}
else
{
client->errorValue = stuff->cmap;
return (BadColor);
}
}
int
ProcCreateCursor (register ClientPtr client)
{
CursorPtr pCursor;
register PixmapPtr src;
register PixmapPtr msk;
unsigned char * srcbits;
unsigned char * mskbits;
unsigned short width, height;
long n;
CursorMetricRec cm;
REQUEST(xCreateCursorReq);
REQUEST_SIZE_MATCH(xCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source,
RT_PIXMAP, SecurityReadAccess);
msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask,
RT_PIXMAP, SecurityReadAccess);
if ( src == (PixmapPtr)NULL)
{
client->errorValue = stuff->source;
return (BadPixmap);
}
if ( msk == (PixmapPtr)NULL)
{
if (stuff->mask != None)
{
client->errorValue = stuff->mask;
return (BadPixmap);
}
}
else if ( src->drawable.width != msk->drawable.width
|| src->drawable.height != msk->drawable.height
|| src->drawable.depth != 1
|| msk->drawable.depth != 1)
return (BadMatch);
width = src->drawable.width;
height = src->drawable.height;
if ( stuff->x > width
|| stuff->y > height )
return (BadMatch);
n = BitmapBytePad(width)*height;
srcbits = (unsigned char *)xalloc(n);
if (!srcbits)
return (BadAlloc);
mskbits = (unsigned char *)xalloc(n);
if (!mskbits)
{
xfree(srcbits);
return (BadAlloc);
}
/* zeroing the (pad) bits helps some ddx cursor handling */
bzero((char *)srcbits, n);
(* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
XYPixmap, 1, (void *)srcbits);
if ( msk == (PixmapPtr)NULL)
{
register unsigned char *bits = mskbits;
while (--n >= 0)
*bits++ = ~0;
}
else
{
/* zeroing the (pad) bits helps some ddx cursor handling */
bzero((char *)mskbits, n);
(* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width,
height, XYPixmap, 1, (void *)mskbits);
}
cm.width = width;
cm.height = height;
cm.xhot = stuff->x;
cm.yhot = stuff->y;
pCursor = AllocCursor( srcbits, mskbits, &cm,
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
stuff->backRed, stuff->backGreen, stuff->backBlue);
if (pCursor && AddResource(stuff->cid, RT_CURSOR, (void *)pCursor))
{
#ifdef TEST
fprintf(stderr, "ProcCreateCursor: Created cursor at [%p].\n", (void *) pCursor);
#endif
return (client->noClientException);
}
return BadAlloc;
}
int
ProcCreateGlyphCursor (register ClientPtr client)
{
CursorPtr pCursor;
int res;
REQUEST(xCreateGlyphCursorReq);
REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
res = AllocGlyphCursor(stuff->source, stuff->sourceChar,
stuff->mask, stuff->maskChar,
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
stuff->backRed, stuff->backGreen, stuff->backBlue,
&pCursor, client);
if (res != Success)
return res;
if (AddResource(stuff->cid, RT_CURSOR, (void *)pCursor))
return client->noClientException;
return BadAlloc;
}
int
ProcFreeCursor (register ClientPtr client)
{
CursorPtr pCursor;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id,
RT_CURSOR, SecurityDestroyAccess);
if (pCursor)
{
FreeResource(stuff->id, RT_NONE);
return (client->noClientException);
}
else
{
client->errorValue = stuff->id;
return (BadCursor);
}
}
int
ProcQueryBestSize (register ClientPtr client)
{
xQueryBestSizeReply reply;
register DrawablePtr pDraw;
ScreenPtr pScreen;
REQUEST(xQueryBestSizeReq);
REQUEST_SIZE_MATCH(xQueryBestSizeReq);
if ((stuff->class != CursorShape) &&
(stuff->class != TileShape) &&
(stuff->class != StippleShape))
{
client->errorValue = stuff->class;
return(BadValue);
}
SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
SecurityReadAccess);
if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
return (BadMatch);
pScreen = pDraw->pScreen;
(* pScreen->QueryBestSize)(stuff->class, &stuff->width,
&stuff->height, pScreen);
memset(&reply, 0, sizeof(xQueryBestSizeReply));
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
reply.width = stuff->width;
reply.height = stuff->height;
WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
return (client->noClientException);
}
int
ProcSetScreenSaver (register ClientPtr client)
{
int blankingOption, exposureOption;
REQUEST(xSetScreenSaverReq);
REQUEST_SIZE_MATCH(xSetScreenSaverReq);
blankingOption = stuff->preferBlank;
if ((blankingOption != DontPreferBlanking) &&
(blankingOption != PreferBlanking) &&
(blankingOption != DefaultBlanking))
{
client->errorValue = blankingOption;
return BadValue;
}
exposureOption = stuff->allowExpose;
if ((exposureOption != DontAllowExposures) &&
(exposureOption != AllowExposures) &&
(exposureOption != DefaultExposures))
{
client->errorValue = exposureOption;
return BadValue;
}
if (stuff->timeout < -1)
{
client->errorValue = stuff->timeout;
return BadValue;
}
if (stuff->interval < -1)
{
client->errorValue = stuff->interval;
return BadValue;
}
/*
* The NX agent uses the screen saver procedure
* to monitor the user activities and launch its
* handlers (like timeout feature), so we can't
* always allow the clients to change our values.
*/
#ifdef TEST
fprintf(stderr, "ProcSetScreenSaver: Called with timeout [%d] interval [%d] Blanking [%d] Exposure [%d].\n",
stuff -> timeout, stuff -> interval, blankingOption, exposureOption);
#endif
if (nxagentOption(Timeout) == 0)
{
if (blankingOption == DefaultBlanking)
{
ScreenSaverBlanking = defaultScreenSaverBlanking;
}
else
{
ScreenSaverBlanking = blankingOption;
}
if (exposureOption == DefaultExposures)
{
ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
}
else
{
ScreenSaverAllowExposures = exposureOption;
}
if (stuff->timeout >= 0)
{
ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
}
else
{
ScreenSaverTime = defaultScreenSaverTime;
}
if (stuff->interval >= 0)
{
ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
}
else
{
ScreenSaverInterval = defaultScreenSaverInterval;
}
SetScreenSaverTimer();
}
#ifdef TEST
else
{
fprintf(stderr, "ProcSetScreenSaver: Keeping auto-disconnect timeout set to [%d] seconds.\n",
nxagentOption(Timeout));
}
#endif
return (client->noClientException);
}
int
ProcGetScreenSaver(register ClientPtr client)
{
xGetScreenSaverReply rep;
REQUEST_SIZE_MATCH(xReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
rep.preferBlanking = ScreenSaverBlanking;
rep.allowExposures = ScreenSaverAllowExposures;
WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
return (client->noClientException);
}
int
ProcChangeHosts(register ClientPtr client)
{
REQUEST(xChangeHostsReq);
int result;
REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
if(stuff->mode == HostInsert)
result = AddHost(client, (int)stuff->hostFamily,
stuff->hostLength, (void *)&stuff[1]);
else if (stuff->mode == HostDelete)
result = RemoveHost(client, (int)stuff->hostFamily,
stuff->hostLength, (void *)&stuff[1]);
else
{
client->errorValue = stuff->mode;
return BadValue;
}
if (!result)
result = client->noClientException;
return (result);
}
int
ProcListHosts(register ClientPtr client)
{
xListHostsReply reply;
int len, nHosts, result;
void * pdata;
/* REQUEST(xListHostsReq); */
#ifdef TEST
fprintf(stderr, "ProcSetScreenSaver: Called with timeout [%d] interval [%d] Blanking [%d] Exposure [%d].\n",
stuff -> timeout, stuff -> interval, blankingOption, exposureOption);
#endif
REQUEST_SIZE_MATCH(xListHostsReq);
#ifdef XCSECURITY
/* untrusted clients can't list hosts */
if (client->trustLevel != XSecurityClientTrusted)
if (nxagentOption(Timeout) == 0)
{
if (blankingOption == DefaultBlanking)
{
SecurityAudit("client %d attempted to list hosts\n", client->index);
return BadAccess;
ScreenSaverBlanking = defaultScreenSaverBlanking;
}
#endif
result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
if (result != Success)
return(result);
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.nHosts = nHosts;
reply.length = len >> 2;
WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
if (nHosts)
else
{
client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
WriteSwappedDataToClient(client, len, pdata);
ScreenSaverBlanking = blankingOption;
}
xfree(pdata);
return (client->noClientException);
}
int
ProcChangeAccessControl(register ClientPtr client)
{
int result;
REQUEST(xSetAccessControlReq);
REQUEST_SIZE_MATCH(xSetAccessControlReq);
if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess))
if (exposureOption == DefaultExposures)
{
client->errorValue = stuff->mode;
return BadValue;
ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
}
result = ChangeAccessControl(client, stuff->mode == EnableAccess);
if (!result)
result = client->noClientException;
return (result);
}
int
ProcKillClient(register ClientPtr client)
{
REQUEST(xResourceReq);
ClientPtr killclient;
REQUEST_SIZE_MATCH(xResourceReq);
if (stuff->id == AllTemporary)
else
{
CloseDownRetainedResources();
return (client->noClientException);
ScreenSaverAllowExposures = exposureOption;
}
if ((killclient = LookupClient(stuff->id, client)))
{
CloseDownClient(killclient);
/* if an LBX proxy gets killed, isItTimeToYield will be set */
if (isItTimeToYield || (client == killclient))
if (stuff->timeout >= 0)
{
/* force yield and return Success, so that Dispatch()
* doesn't try to touch client
*/
isItTimeToYield = TRUE;
return (Success);
}
return (client->noClientException);
ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
}
else
{
client->errorValue = stuff->id;
return (BadValue);
ScreenSaverTime = defaultScreenSaverTime;
}
}
int
ProcSetFontPath(register ClientPtr client)
{
unsigned char *ptr;
unsigned long nbytes, total;
long nfonts;
int n, result;
int error;
REQUEST(xSetFontPathReq);
REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
total = nbytes;
ptr = (unsigned char *)&stuff[1];
nfonts = stuff->nFonts;
while (--nfonts >= 0)
if (stuff->interval >= 0)
{
if ((total == 0) || (total < (n = (*ptr + 1))))
return(BadLength);
total -= n;
ptr += n;
ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
}
if (total >= 4)
return(BadLength);
result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
&error);
if (!result)
else
{
result = client->noClientException;
client->errorValue = error;
ScreenSaverInterval = defaultScreenSaverInterval;
}
return (result);
}
int
ProcGetFontPath(register ClientPtr client)
{
xGetFontPathReply reply;
int stringLens, numpaths;
unsigned char *bufferStart;
/* REQUEST (xReq); */
REQUEST_SIZE_MATCH(xReq);
bufferStart = GetFontPath(&numpaths, &stringLens);
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.length = (stringLens + numpaths + 3) >> 2;
reply.nPaths = numpaths;
WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
if (stringLens || numpaths)
(void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart);
return(client->noClientException);
}
int
ProcChangeCloseDownMode(register ClientPtr client)
{
REQUEST(xSetCloseDownModeReq);
REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
if ((stuff->mode == AllTemporary) ||
(stuff->mode == RetainPermanent) ||
(stuff->mode == RetainTemporary))
{
client->closeDownMode = stuff->mode;
return (client->noClientException);
SetScreenSaverTimer();
}
#ifdef TEST
else
{
client->errorValue = stuff->mode;
return (BadValue);
fprintf(stderr, "ProcSetScreenSaver: Keeping auto-disconnect timeout set to [%d] seconds.\n",
nxagentOption(Timeout));
}
#endif
return (client->noClientException);
}
int ProcForceScreenSaver(register ClientPtr client)
{
REQUEST(xForceScreenSaverReq);
......@@ -4125,38 +1207,6 @@ int ProcForceScreenSaver(register ClientPtr client)
return client->noClientException;
}
int ProcNoOperation(register ClientPtr client)
{
REQUEST_AT_LEAST_SIZE(xReq);
/* noop -- don't do anything */
return(client->noClientException);
}
void
InitProcVectors(void)
{
int i;
for (i = 0; i<256; i++)
{
if(!ProcVector[i])
{
ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
ReplySwapVector[i] = ReplyNotSwappd;
}
#ifdef K5AUTH
if (!k5_Vector[i])
{
k5_Vector[i] = k5_bad;
}
#endif
}
for(i = LASTEvent; i < 128; i++)
{
EventSwapVector[i] = NotImplemented;
}
}
/**********************
* CloseDownClient
......@@ -4230,9 +1280,6 @@ CloseDownClient(register ClientPtr client)
if (ClientIsAsleep(client))
ClientSignal (client);
ProcessWorkQueueZombies();
#ifdef LBX
ProcessQTagZombies();
#endif
CloseDownConnection(client);
/* If the client made it to the Running stage, nClients has
......@@ -4276,104 +1323,6 @@ CloseDownClient(register ClientPtr client)
}
}
static void
KillAllClients()
{
int i;
for (i=1; i<currentMaxClients; i++)
if (clients[i]) {
/* Make sure Retained clients are released. */
clients[i]->closeDownMode = DestroyAll;
CloseDownClient(clients[i]);
}
}
/*********************
* CloseDownRetainedResources
*
* Find all clients that are gone and have terminated in RetainTemporary
* and destroy their resources.
*********************/
void
CloseDownRetainedResources()
{
register int i;
register ClientPtr client;
for (i=1; i<currentMaxClients; i++)
{
client = clients[i];
if (client && (client->closeDownMode == RetainTemporary)
&& (client->clientGone))
CloseDownClient(client);
}
}
void InitClient(ClientPtr client, int i, void * ospriv)
{
client->index = i;
client->sequence = 0;
client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
client->clientGone = FALSE;
if (i)
{
client->closeDownMode = DestroyAll;
client->lastDrawable = (DrawablePtr)screenInfo.screens[0]->root;
client->lastDrawableID = screenInfo.screens[0]->root->drawable.id;
}
else
{
client->closeDownMode = RetainPermanent;
client->lastDrawable = (DrawablePtr)NULL;
client->lastDrawableID = INVALID;
}
client->lastGC = (GCPtr) NULL;
client->lastGCID = INVALID;
client->numSaved = 0;
client->saveSet = (SaveSetElt *)NULL;
client->noClientException = Success;
#ifdef LOG_DEBUG
client->requestLogIndex = 0;
#endif
client->requestVector = InitialVector;
client->osPrivate = ospriv;
client->swapped = FALSE;
client->big_requests = FALSE;
client->priority = 0;
client->clientState = ClientStateInitial;
#ifdef XKB
if (!noXkbExtension) {
client->xkbClientFlags = 0;
client->mapNotifyMask = 0;
QueryMinMaxKeyCodes(&client->minKC,&client->maxKC);
}
#endif
client->replyBytesRemaining = 0;
#ifdef LBX
client->readRequest = StandardReadRequestFromClient;
#endif
#ifdef XCSECURITY
client->trustLevel = XSecurityClientTrusted;
client->CheckAccess = NULL;
client->authId = 0;
#endif
#ifdef XAPPGROUP
client->appgroup = NULL;
#endif
client->fontResFunc = NULL;
#ifdef SMART_SCHEDULE
client->smart_priority = 0;
client->smart_start_tick = SmartScheduleTime;
client->smart_stop_tick = SmartScheduleTime;
client->smart_check_tick = SmartScheduleTime;
#endif
}
extern int clientPrivateLen;
extern unsigned *clientPrivateSizes;
extern unsigned totalClientSize;
int
InitClientPrivates(ClientPtr client)
{
......@@ -4415,289 +1364,3 @@ InitClientPrivates(ClientPtr client)
return 1;
}
/************************
* int NextAvailableClient(ospriv)
*
* OS dependent portion can't assign client id's because of CloseDownModes.
* Returns NULL if there are no free clients.
*************************/
ClientPtr NextAvailableClient(void * ospriv)
{
register int i;
register ClientPtr client;
xReq data;
i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr)NULL;
clients[i] = client = (ClientPtr)xalloc(totalClientSize);
if (!client)
return (ClientPtr)NULL;
InitClient(client, i, ospriv);
InitClientPrivates(client);
if (!InitClientResources(client))
{
xfree(client);
return (ClientPtr)NULL;
}
data.reqType = 1;
data.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
{
FreeClientResources(client);
xfree(client);
return (ClientPtr)NULL;
}
if (i == currentMaxClients)
currentMaxClients++;
while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
nextFreeClientID++;
if (ClientStateCallback)
{
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *)NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *)&clientinfo);
}
return(client);
}
int
ProcInitialConnection(register ClientPtr client)
{
REQUEST(xReq);
register xConnClientPrefix *prefix;
int whichbyte = 1;
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
return (client->noClientException = -1);
if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
(!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
{
client->swapped = TRUE;
SwapConnClientPrefix(prefix);
}
stuff->reqType = 2;
stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) +
((prefix->nbytesAuthString + (unsigned)3) >> 2);
if (client->swapped)
{
swaps(&stuff->length, whichbyte);
}
ResetCurrentRequest(client);
return (client->noClientException);
}
#ifdef LBX
void
IncrementClientCount()
{
nClients++;
}
#endif
int
SendConnSetup(register ClientPtr client, char *reason)
{
register xWindowRoot *root;
register int i;
int numScreens;
char* lConnectionInfo;
xConnSetupPrefix* lconnSetupPrefix;
if (reason)
{
xConnSetupPrefix csp;
csp.success = xFalse;
csp.lengthReason = strlen(reason);
csp.length = (csp.lengthReason + (unsigned)3) >> 2;
csp.majorVersion = X_PROTOCOL;
csp.minorVersion = X_PROTOCOL_REVISION;
if (client->swapped)
WriteSConnSetupPrefix(client, &csp);
else
(void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
(void)WriteToClient(client, (int)csp.lengthReason, reason);
return (client->noClientException = -1);
}
numScreens = screenInfo.numScreens;
lConnectionInfo = ConnectionInfo;
lconnSetupPrefix = &connSetupPrefix;
/* We're about to start speaking X protocol back to the client by
* sending the connection setup info. This means the authorization
* step is complete, and we can count the client as an
* authorized one.
*/
nClients++;
client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
client->sequence = 0;
#ifdef XAPPGROUP
XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens);
#endif
((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
#ifdef MATCH_CLIENT_ENDIAN
((xConnSetup *)lConnectionInfo)->imageByteOrder = ClientOrder (client);
((xConnSetup *)lConnectionInfo)->bitmapBitOrder = ClientOrder (client);
#endif
/* fill in the "currentInputMask" */
root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart);
#ifdef PANORAMIX
if (noPanoramiXExtension)
numScreens = screenInfo.numScreens;
else
numScreens = ((xConnSetup *)ConnectionInfo)->numRoots;
#endif
for (i=0; i<numScreens; i++)
{
register unsigned int j;
register xDepth *pDepth;
root->currentInputMask = screenInfo.screens[i]->root->eventMask |
wOtherEventMasks (screenInfo.screens[i]->root);
pDepth = (xDepth *)(root + 1);
for (j = 0; j < root->nDepths; j++)
{
pDepth = (xDepth *)(((char *)(pDepth + 1)) +
pDepth->nVisuals * sizeof(xVisualType));
}
root = (xWindowRoot *)pDepth;
}
if (client->swapped)
{
WriteSConnSetupPrefix(client, lconnSetupPrefix);
WriteSConnectionInfo(client,
(unsigned long)(lconnSetupPrefix->length << 2),
lConnectionInfo);
}
else
{
(void)WriteToClient(client, sizeof(xConnSetupPrefix),
(char *) lconnSetupPrefix);
(void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2),
lConnectionInfo);
}
client->clientState = ClientStateRunning;
if (ClientStateCallback)
{
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = lconnSetupPrefix;
clientinfo.setup = (xConnSetup *)lConnectionInfo;
CallCallbacks((&ClientStateCallback), (void *)&clientinfo);
}
return (client->noClientException);
}
int
ProcEstablishConnection(register ClientPtr client)
{
char *reason, *auth_proto, *auth_string;
register xConnClientPrefix *prefix;
REQUEST(xReq);
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
auth_proto = (char *)prefix + sz_xConnClientPrefix;
auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
if ((prefix->majorVersion != X_PROTOCOL) ||
(prefix->minorVersion != X_PROTOCOL_REVISION))
reason = "Protocol version mismatch";
else
reason = ClientAuthorized(client,
(unsigned short)prefix->nbytesAuthProto,
auth_proto,
(unsigned short)prefix->nbytesAuthString,
auth_string);
/*
* If Kerberos is being used for this client, the clientState
* will be set to ClientStateAuthenticating at this point.
* More messages need to be exchanged among the X server, Kerberos
* server, and client to figure out if everyone is authorized.
* So we don't want to send the connection setup info yet, since
* the auth step isn't really done.
*/
if (client->clientState == ClientStateCheckingSecurity)
client->clientState = ClientStateCheckedSecurity;
else if (client->clientState != ClientStateAuthenticating)
return(SendConnSetup(client, reason));
return(client->noClientException);
}
void
SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode,
XID resId, int errorCode)
{
xError rep;
memset(&rep, 0, sizeof(xError));
rep.type = X_Error;
rep.sequenceNumber = client->sequence;
rep.errorCode = errorCode;
rep.majorCode = majorCode;
rep.minorCode = minorCode;
rep.resourceID = resId;
WriteEventsToClient (client, 1, (xEvent *)&rep);
}
void
DeleteWindowFromAnySelections(WindowPtr pWin)
{
register int i;
for (i = 0; i< NumCurrentSelections; i++)
if (CurrentSelections[i].pWin == pWin)
{
if (SelectionCallback)
{
SelectionInfoRec info;
info.selection = &CurrentSelections[i];
info.kind = SelectionWindowDestroy;
CallCallbacks(&SelectionCallback, &info);
}
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
}
}
static void
DeleteClientFromAnySelections(ClientPtr client)
{
register int i;
for (i = 0; i< NumCurrentSelections; i++)
if (CurrentSelections[i].client == client)
{
if (SelectionCallback)
{
SelectionInfoRec info;
info.selection = &CurrentSelections[i];
info.kind = SelectionWindowDestroy;
CallCallbacks(&SelectionCallback, &info);
}
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
}
}
void
MarkClientException(ClientPtr client)
{
client->noClientException = -1;
}
......@@ -68,31 +68,18 @@ Equipment Corporation.
******************************************************************/
/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */
#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include <nx-X11/Xmd.h>
#include <nx-X11/Xproto.h>
#include "scrnintstr.h"
#include "resource.h"
#include "dixstruct.h"
#include "cursorstr.h"
#include "misc.h"
#include "opaque.h"
#include "dixfontstr.h"
#include "closestr.h"
static Bool doOpenFont(ClientPtr client, OFclosurePtr c);
static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c);
#include "../../dix/dixfonts.c"
/*
#define NXAGENT_DEBUG
*/
#ifdef DEBUG
#include <stdio.h>
#endif
#include "Agent.h"
#include "Font.h"
......@@ -160,170 +147,6 @@ _NXGetFontPathError:
#endif
#ifdef PANORAMIX
#include "../../Xext/panoramiX.h"
#include "../../Xext/panoramiXsrv.h"
#endif
#ifdef LBX
#include "lbxserve.h"
#endif
#ifdef XF86BIGFONT
#define _XF86BIGFONT_SERVER_
#include <nx-X11/extensions/xf86bigfont.h>
#endif
#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
extern void register_fpe_functions(void);
extern void * fosNaturalParams;
extern FontPtr defaultFont;
static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
static int num_fpes = 0;
FPEFunctions *fpe_functions = (FPEFunctions *) 0;
static int num_fpe_types = 0;
static unsigned char *font_path_string;
static int num_slept_fpes = 0;
static int size_slept_fpes = 0;
static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
static FontPatternCachePtr patternCache;
int
FontToXError(err)
int err;
{
switch (err) {
case Successful:
return Success;
case AllocError:
return BadAlloc;
case BadFontName:
return BadName;
case BadFontPath:
case BadFontFormat: /* is there something better? */
case BadCharRange:
return BadValue;
default:
return err;
}
}
/*
* adding RT_FONT prevents conflict with default cursor font
*/
Bool
SetDefaultFont(char *defaultfontname)
{
int err;
FontPtr pf;
XID fid;
fid = FakeClientID(0);
err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
(unsigned) strlen(defaultfontname), defaultfontname);
if (err != Success)
return FALSE;
pf = (FontPtr) LookupIDByType(fid, RT_FONT);
if (pf == (FontPtr) NULL)
return FALSE;
defaultFont = pf;
return TRUE;
}
/*
* note that the font wakeup queue is not refcounted. this is because
* an fpe needs to be added when it's inited, and removed when it's finally
* freed, in order to handle any data that isn't requested, like FS events.
*
* since the only thing that should call these routines is the renderer's
* init_fpe() and free_fpe(), there shouldn't be any problem in using
* freed data.
*/
void
QueueFontWakeup(FontPathElementPtr fpe)
{
int i;
FontPathElementPtr *new;
for (i = 0; i < num_slept_fpes; i++) {
if (slept_fpes[i] == fpe) {
#ifdef DEBUG
fprintf(stderr, "re-queueing fpe wakeup\n");
#endif
return;
}
}
if (num_slept_fpes == size_slept_fpes) {
new = (FontPathElementPtr *)
xrealloc(slept_fpes,
sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
if (!new)
return;
slept_fpes = new;
size_slept_fpes += 4;
}
slept_fpes[num_slept_fpes] = fpe;
num_slept_fpes++;
}
void
RemoveFontWakeup(FontPathElementPtr fpe)
{
int i,
j;
for (i = 0; i < num_slept_fpes; i++) {
if (slept_fpes[i] == fpe) {
for (j = i; j < num_slept_fpes; j++) {
slept_fpes[j] = slept_fpes[j + 1];
}
num_slept_fpes--;
return;
}
}
}
void
FontWakeup(void * data, int count, void * LastSelectMask)
{
int i;
FontPathElementPtr fpe;
if (count < 0)
return;
/* wake up any fpe's that may be waiting for information */
for (i = 0; i < num_slept_fpes; i++) {
fpe = slept_fpes[i];
(void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
}
}
/* XXX -- these two funcs may want to be broken into macros */
static void
UseFPE(FontPathElementPtr fpe)
{
fpe->refcount++;
}
static void
FreeFPE (FontPathElementPtr fpe)
{
fpe->refcount--;
if (fpe->refcount == 0) {
(*fpe_functions[fpe->type].free_fpe) (fpe);
xfree(fpe->name);
xfree(fpe);
}
}
static Bool
doOpenFont(ClientPtr client, OFclosurePtr c)
{
......@@ -509,206 +332,6 @@ bail:
return TRUE;
}
int
OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
{
OFclosurePtr c;
int i;
FontPtr cached = (FontPtr)0;
#ifdef FONTDEBUG
char *f;
f = (char *)xalloc(lenfname + 1);
memmove(f, pfontname, lenfname);
f[lenfname] = '\0';
ErrorF("OpenFont: fontname is \"%s\"\n", f);
xfree(f);
#endif
if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
return BadName;
if (patternCache)
{
/*
** Check name cache. If we find a cached version of this font that
** is cachable, immediately satisfy the request with it. If we find
** a cached version of this font that is non-cachable, we do not
** satisfy the request with it. Instead, we pass the FontPtr to the
** FPE's open_font code (the fontfile FPE in turn passes the
** information to the rasterizer; the fserve FPE ignores it).
**
** Presumably, the font is marked non-cachable because the FPE has
** put some licensing restrictions on it. If the FPE, using
** whatever logic it relies on, determines that it is willing to
** share this existing font with the client, then it has the option
** to return the FontPtr we passed it as the newly-opened font.
** This allows the FPE to exercise its licensing logic without
** having to create another instance of a font that already exists.
*/
cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
if (cached && cached->info.cachable)
{
if (!AddResource(fid, RT_FONT, (void *) cached))
return BadAlloc;
cached->refcnt++;
return Success;
}
}
c = (OFclosurePtr) xalloc(sizeof(OFclosureRec));
if (!c)
return BadAlloc;
c->fontname = (char *) xalloc(lenfname);
c->origFontName = pfontname;
c->origFontNameLen = lenfname;
if (!c->fontname) {
xfree(c);
return BadAlloc;
}
/*
* copy the current FPE list, so that if it gets changed by another client
* while we're blocking, the request still appears atomic
*/
c->fpe_list = (FontPathElementPtr *)
xalloc(sizeof(FontPathElementPtr) * num_fpes);
if (!c->fpe_list) {
xfree(c->fontname);
xfree(c);
return BadAlloc;
}
memmove(c->fontname, pfontname, lenfname);
for (i = 0; i < num_fpes; i++) {
c->fpe_list[i] = font_path_elements[i];
UseFPE(c->fpe_list[i]);
}
c->client = client;
c->fontid = fid;
c->current_fpe = 0;
c->num_fpes = num_fpes;
c->fnamelen = lenfname;
c->slept = FALSE;
c->flags = flags;
c->non_cachable_font = cached;
(void) doOpenFont(client, c);
return Success;
}
/**
* Decrement font's ref count, and free storage if ref count equals zero
*
* \param value must conform to DeleteType
*/
int
CloseFont(void * value, XID fid)
{
int nscr;
ScreenPtr pscr;
FontPathElementPtr fpe;
FontPtr pfont = (FontPtr)value;
if (pfont == NullFont)
return (Success);
if (--pfont->refcnt == 0) {
if (patternCache)
RemoveCachedFontPattern (patternCache, pfont);
/*
* since the last reference is gone, ask each screen to free any
* storage it may have allocated locally for it.
*/
for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
pscr = screenInfo.screens[nscr];
if (pscr->UnrealizeFont)
(*pscr->UnrealizeFont) (pscr, pfont);
}
if (pfont == defaultFont)
defaultFont = NULL;
#ifdef LBX
LbxFreeFontTag(pfont);
#endif
#ifdef XF86BIGFONT
{
extern void XF86BigfontFreeFontShm(FontPtr);
XF86BigfontFreeFontShm(pfont);
}
#endif
fpe = pfont->fpe;
(*fpe_functions[fpe->type].close_font) (fpe, pfont);
FreeFPE(fpe);
}
return (Success);
}
/***====================================================================***/
/**
* Sets up pReply as the correct QueryFontReply for pFont with the first
* nProtoCCIStructs char infos.
*
* \param pReply caller must allocate this storage
*/
void
QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
{
FontPropPtr pFP;
int r,
c,
i;
xFontProp *prFP;
xCharInfo *prCI;
xCharInfo *charInfos[256];
unsigned char chars[512];
int ninfos;
unsigned long ncols;
unsigned long count;
/* pr->length set in dispatch */
pReply->minCharOrByte2 = pFont->info.firstCol;
pReply->defaultChar = pFont->info.defaultCh;
pReply->maxCharOrByte2 = pFont->info.lastCol;
pReply->drawDirection = pFont->info.drawDirection;
pReply->allCharsExist = pFont->info.allExist;
pReply->minByte1 = pFont->info.firstRow;
pReply->maxByte1 = pFont->info.lastRow;
pReply->fontAscent = pFont->info.fontAscent;
pReply->fontDescent = pFont->info.fontDescent;
pReply->minBounds = pFont->info.ink_minbounds;
pReply->maxBounds = pFont->info.ink_maxbounds;
pReply->nFontProps = pFont->info.nprops;
pReply->nCharInfos = nProtoCCIStructs;
for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
i < pFont->info.nprops;
i++, pFP++, prFP++) {
prFP->name = pFP->name;
prFP->value = pFP->value;
}
ninfos = 0;
ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
prCI = (xCharInfo *) (prFP);
for (r = pFont->info.firstRow;
ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
r++) {
i = 0;
for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
chars[i++] = r;
chars[i++] = c;
}
(*pFont->get_metrics) (pFont, ncols, chars,
TwoD16Bit, &count, charInfos);
i = 0;
for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
*prCI = *charInfos[i];
prCI++;
ninfos++;
}
}
return;
}
static Bool
doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
......@@ -1294,1094 +917,82 @@ bail:
return TRUE;
}
int
StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
int max_names)
SetDefaultFontPath(char *path)
{
int i;
LFWIclosurePtr c;
unsigned char *cp,
*pp,
*nump,
*newpath;
int num = 1,
len,
err,
size = 0,
bad;
/*
* The right error to return here would be BadName, however the
* specification does not allow for a Name error on this request.
* Perhaps a better solution would be to return a nil list, i.e.
* a list containing zero fontnames.
*/
if (length > XLFDMAXFONTNAMELEN)
/* get enough for string, plus values -- use up commas */
#ifdef NX_TRANS_SOCKET
len = strlen(_NXGetFontPath(path)) + 1;
#else
len = strlen(path) + 1;
#endif
nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
if (!newpath)
return BadAlloc;
if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
goto badAlloc;
c->fpe_list = (FontPathElementPtr *)
xalloc(sizeof(FontPathElementPtr) * num_fpes);
if (!c->fpe_list)
{
xfree(c);
goto badAlloc;
#ifdef NX_TRANS_SOCKET
pp = (unsigned char *) _NXGetFontPath(path);
#else
pp = (unsigned char *) path;
#endif
cp++;
while (*pp) {
if (*pp == ',') {
*nump = (unsigned char) size;
nump = cp++;
pp++;
num++;
size = 0;
} else {
*cp++ = *pp++;
size++;
}
memmove(c->current.pattern, pattern, length);
for (i = 0; i < num_fpes; i++)
{
c->fpe_list[i] = font_path_elements[i];
UseFPE(c->fpe_list[i]);
}
c->client = client;
c->num_fpes = num_fpes;
c->reply = 0;
c->length = 0;
c->current.patlen = length;
c->current.current_fpe = 0;
c->current.max_names = max_names;
c->current.list_started = FALSE;
c->current.private = 0;
c->savedNumFonts = 0;
c->haveSaved = FALSE;
c->slept = FALSE;
c->savedName = 0;
doListFontsWithInfo(client, c);
return Success;
badAlloc:
return BadAlloc;
*nump = (unsigned char) size;
err = SetFontPathElements(num, newpath, &bad, TRUE);
DEALLOCATE_LOCAL(newpath);
return err;
}
#define TextEltHeader 2
#define FontShiftSize 5
static XID clearGC[] = { CT_NONE };
#define clearGCmask (GCClipMask)
int
doPolyText(ClientPtr client, register PTclosurePtr c)
typedef struct
{
register FontPtr pFont = c->pGC->font, oldpFont;
Font fid, oldfid;
int err = Success, lgerr; /* err is in X error, not font error, space */
enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
FontPathElementPtr fpe;
GC *origGC = NULL;
LFclosurePtr c;
OFclosurePtr oc;
} nxFs,*nxFsPtr;
if (client->clientGone)
{
fpe = c->pGC->font->fpe;
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
if (c->slept)
{
/* Client has died, but we cannot bail out right now. We
need to clean up after the work we did when going to
sleep. Setting the drawable pointer to 0 makes this
happen without any attempts to render or perform other
unnecessary activities. */
c->pDraw = (DrawablePtr)0;
}
else
{
err = Success;
goto bail;
}
}
/* Make sure our drawable hasn't disappeared while we slept. */
if (c->slept &&
c->pDraw &&
c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
RC_DRAWABLE, SecurityWriteAccess))
{
/* Our drawable has disappeared. Treat like client died... ask
the FPE code to clean up after client and avoid further
rendering while we clean up after ourself. */
fpe = c->pGC->font->fpe;
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
c->pDraw = (DrawablePtr)0;
}
client_state = c->slept ? SLEEPING : NEVER_SLEPT;
while (c->endReq - c->pElt > TextEltHeader)
{
if (*c->pElt == FontChange)
{
if (c->endReq - c->pElt < FontShiftSize)
{
err = BadLength;
goto bail;
}
oldpFont = pFont;
oldfid = fid;
fid = ((Font)*(c->pElt+4)) /* big-endian */
| ((Font)*(c->pElt+3)) << 8
| ((Font)*(c->pElt+2)) << 16
| ((Font)*(c->pElt+1)) << 24;
pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
SecurityReadAccess);
if (!pFont)
{
client->errorValue = fid;
err = BadFont;
/* restore pFont and fid for step 4 (described below) */
pFont = oldpFont;
fid = oldfid;
/* If we're in START_SLEEP mode, the following step
shortens the request... in the unlikely event that
the fid somehow becomes valid before we come through
again to actually execute the polytext, which would
then mess up our refcounting scheme badly. */
c->err = err;
c->endReq = c->pElt;
goto bail;
}
/* Step 3 (described below) on our new font */
if (client_state == START_SLEEP)
pFont->refcnt++;
else
{
if (pFont != c->pGC->font && c->pDraw)
{
ChangeGC( c->pGC, GCFont, &fid);
ValidateGC(c->pDraw, c->pGC);
if (c->reqType == X_PolyText8)
c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8;
else
c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16;
}
/* Undo the refcnt++ we performed when going to sleep */
if (client_state == SLEEPING)
(void)CloseFont(c->pGC->font, (Font)0);
}
c->pElt += FontShiftSize;
}
else /* print a string */
{
unsigned char *pNextElt;
pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
if ( pNextElt > c->endReq)
{
err = BadLength;
goto bail;
}
if (client_state == START_SLEEP)
{
c->pElt = pNextElt;
continue;
}
if (c->pDraw)
{
lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
c->pElt + TextEltHeader);
}
else lgerr = Successful;
if (lgerr == Suspended)
{
if (!c->slept) {
int len;
GC *pGC;
PTclosurePtr new_closure;
/* We're putting the client to sleep. We need to do a few things
to ensure successful and atomic-appearing execution of the
remainder of the request. First, copy the remainder of the
request into a safe malloc'd area. Second, create a scratch GC
to use for the remainder of the request. Third, mark all fonts
referenced in the remainder of the request to prevent their
deallocation. Fourth, make the original GC look like the
request has completed... set its font to the final font value
from this request. These GC manipulations are for the unlikely
(but possible) event that some other client is using the GC.
Steps 3 and 4 are performed by running this procedure through
the remainder of the request in a special no-render mode
indicated by client_state = START_SLEEP. */
/* Step 1 */
/* Allocate a malloc'd closure structure to replace
the local one we were passed */
new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
if (!new_closure)
{
err = BadAlloc;
goto bail;
}
*new_closure = *c;
c = new_closure;
len = c->endReq - c->pElt;
c->data = (unsigned char *)xalloc(len);
if (!c->data)
{
xfree(c);
err = BadAlloc;
goto bail;
}
memmove(c->data, c->pElt, len);
c->pElt = c->data;
c->endReq = c->pElt + len;
/* Step 2 */
pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
if (!pGC)
{
xfree(c->data);
xfree(c);
err = BadAlloc;
goto bail;
}
pGC->tileIsPixel = TRUE;
pGC->tile.pixel = 0;
pGC->stipple = NullPixmap;
if ((err = CopyGC(c->pGC, pGC, GCFunction |
GCPlaneMask | GCForeground |
GCBackground | GCFillStyle |
GCTile | GCStipple |
GCTileStipXOrigin |
GCTileStipYOrigin | GCFont |
GCSubwindowMode | GCClipXOrigin |
GCClipYOrigin | GCClipMask)) !=
Success)
{
FreeScratchGC(pGC);
xfree(c->data);
xfree(c);
err = BadAlloc;
goto bail;
}
origGC = c->pGC;
c->pGC = pGC;
ValidateGC(c->pDraw, c->pGC);
c->slept = TRUE;
ClientSleep(client,
(ClientSleepProcPtr)doPolyText,
(void *) c);
#ifdef NXAGENT_DEBUG
fprintf(stderr, " NXdixfonts: doPolyText (1): client [%lx] sleeping.\n", client);
#endif
/* Set up to perform steps 3 and 4 */
client_state = START_SLEEP;
continue; /* on to steps 3 and 4 */
}
return TRUE;
}
else if (lgerr != Successful)
{
err = FontToXError(lgerr);
goto bail;
}
if (c->pDraw)
{
c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg,
*c->pElt, c->pElt + TextEltHeader);
}
c->pElt = pNextElt;
}
}
bail:
if (client_state == START_SLEEP)
{
/* Step 4 */
if (pFont != origGC->font)
{
ChangeGC(origGC, GCFont, &fid);
ValidateGC(c->pDraw, origGC);
}
/* restore pElt pointer for execution of remainder of the request */
c->pElt = c->data;
return TRUE;
}
if (c->err != Success) err = c->err;
if (err != Success && c->client != serverClient) {
#ifdef PANORAMIX
if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
#endif
SendErrorToClient(c->client, c->reqType, 0, 0, err);
}
if (c->slept)
{
ClientWakeup(c->client);
#ifdef NXAGENT_DEBUG
fprintf(stderr, " NXdixfonts: doPolytext: client [%lx] wakeup.\n", client);
#endif
ChangeGC(c->pGC, clearGCmask, clearGC);
/* Unreference the font from the scratch GC */
CloseFont(c->pGC->font, (Font)0);
c->pGC->font = NullFont;
FreeScratchGC(c->pGC);
xfree(c->data);
xfree(c);
}
return TRUE;
}
int
PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
{
PTclosureRec local_closure;
local_closure.pElt = pElt;
local_closure.endReq = endReq;
local_closure.client = client;
local_closure.pDraw = pDraw;
local_closure.xorg = xorg;
local_closure.yorg = yorg;
if ((local_closure.reqType = reqType) == X_PolyText8)
{
local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8;
local_closure.itemSize = 1;
}
else
{
local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16;
local_closure.itemSize = 2;
}
local_closure.pGC = pGC;
local_closure.did = did;
local_closure.err = Success;
local_closure.slept = FALSE;
(void) doPolyText(client, &local_closure);
return Success;
}
#undef TextEltHeader
#undef FontShiftSize
int
doImageText(ClientPtr client, register ITclosurePtr c)
{
int err = Success, lgerr; /* err is in X error, not font error, space */
FontPathElementPtr fpe;
if (client->clientGone)
{
fpe = c->pGC->font->fpe;
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
err = Success;
goto bail;
}
/* Make sure our drawable hasn't disappeared while we slept. */
if (c->slept &&
c->pDraw &&
c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
RC_DRAWABLE, SecurityWriteAccess))
{
/* Our drawable has disappeared. Treat like client died... ask
the FPE code to clean up after client. */
fpe = c->pGC->font->fpe;
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
err = Success;
goto bail;
}
lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
if (lgerr == Suspended)
{
if (!c->slept) {
GC *pGC;
unsigned char *data;
ITclosurePtr new_closure;
ITclosurePtr old_closure;
/* We're putting the client to sleep. We need to
save some state. Similar problem to that handled
in doPolyText, but much simpler because the
request structure is much simpler. */
new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
if (!new_closure)
{
err = BadAlloc;
goto bail;
}
old_closure = c;
*new_closure = *c;
c = new_closure;
data = (unsigned char *)xalloc(c->nChars * c->itemSize);
if (!data)
{
xfree(c);
c = old_closure;
err = BadAlloc;
goto bail;
}
memmove(data, c->data, c->nChars * c->itemSize);
c->data = data;
pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
if (!pGC)
{
xfree(c->data);
xfree(c);
c = old_closure;
err = BadAlloc;
goto bail;
}
pGC->tileIsPixel = TRUE;
pGC->tile.pixel = 0;
pGC->stipple = NullPixmap;
if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
GCForeground | GCBackground | GCFillStyle |
GCTile | GCStipple | GCTileStipXOrigin |
GCTileStipYOrigin | GCFont |
GCSubwindowMode | GCClipXOrigin |
GCClipYOrigin | GCClipMask)) != Success)
{
FreeScratchGC(pGC);
xfree(c->data);
xfree(c);
c = old_closure;
err = BadAlloc;
goto bail;
}
c->pGC = pGC;
ValidateGC(c->pDraw, c->pGC);
c->slept = TRUE;
ClientSleep(client, (ClientSleepProcPtr)doImageText, (void *) c);
#ifdef NXAGENT_DEBUG
fprintf(stderr, " NXdixfonts: doImageText (1): client [%lx] sleeping.\n", client);
#endif
}
return TRUE;
}
else if (lgerr != Successful)
{
err = FontToXError(lgerr);
goto bail;
}
if (c->pDraw)
{
(* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
c->nChars, c->data);
}
bail:
if (err != Success && c->client != serverClient) {
SendErrorToClient(c->client, c->reqType, 0, 0, err);
}
if (c->slept)
{
ClientWakeup(c->client);
#ifdef NXAGENT_DEBUG
fprintf(stderr, " NXdixfonts: doImageText: client [%lx] wakeup.\n", client);
#endif
ChangeGC(c->pGC, clearGCmask, clearGC);
/* Unreference the font from the scratch GC */
CloseFont(c->pGC->font, (Font)0);
c->pGC->font = NullFont;
FreeScratchGC(c->pGC);
xfree(c->data);
xfree(c);
}
return TRUE;
}
int
ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
unsigned char *data, int xorg, int yorg, int reqType, XID did)
{
ITclosureRec local_closure;
local_closure.client = client;
local_closure.pDraw = pDraw;
local_closure.pGC = pGC;
local_closure.nChars = nChars;
local_closure.data = data;
local_closure.xorg = xorg;
local_closure.yorg = yorg;
if ((local_closure.reqType = reqType) == X_ImageText8)
{
local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8;
local_closure.itemSize = 1;
}
else
{
local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16;
local_closure.itemSize = 2;
}
local_closure.did = did;
local_closure.slept = FALSE;
(void) doImageText(client, &local_closure);
return Success;
}
/* does the necessary magic to figure out the fpe type */
static int
DetermineFPEType(char *pathname)
{
int i;
for (i = 0; i < num_fpe_types; i++) {
if ((*fpe_functions[i].name_check) (pathname))
return i;
}
return -1;
}
static void
FreeFontPath(FontPathElementPtr *list, int n, Bool force)
{
int i;
for (i = 0; i < n; i++) {
if (force) {
/* Sanity check that all refcounts will be 0 by the time
we get to the end of the list. */
int found = 1; /* the first reference is us */
int j;
for (j = i+1; j < n; j++) {
if (list[j] == list[i])
found++;
}
if (list[i]->refcount != found) {
ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
list[i]->name_length, list[i]->name,
list[i]->refcount, found);
list[i]->refcount = found; /* ensure it will get freed */
}
}
FreeFPE(list[i]);
}
xfree((char *) list);
}
static FontPathElementPtr
find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
{
FontPathElementPtr fpe;
int i;
for (i = 0; i < num; i++) {
fpe = list[i];
if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
return fpe;
}
return (FontPathElementPtr) 0;
}
static int
SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
{
int i, err = 0;
int valid_paths = 0;
unsigned int len;
unsigned char *cp = paths;
FontPathElementPtr fpe = NULL, *fplist;
fplist = (FontPathElementPtr *)
xalloc(sizeof(FontPathElementPtr) * npaths);
if (!fplist) {
*bad = 0;
return BadAlloc;
}
for (i = 0; i < num_fpe_types; i++) {
if (fpe_functions[i].set_path_hook)
(*fpe_functions[i].set_path_hook) ();
}
for (i = 0; i < npaths; i++)
{
len = (unsigned int) (*cp++);
if (len == 0)
{
if (persist)
ErrorF ("Removing empty element from the valid list of fontpaths\n");
err = BadValue;
}
else
{
/* if it's already in our active list, just reset it */
/*
* note that this can miss FPE's in limbo -- may be worth catching
* them, though it'd muck up refcounting
*/
fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
if (fpe)
{
err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
if (err == Successful)
{
UseFPE(fpe);/* since it'll be decref'd later when freed
* from the old list */
}
else
fpe = 0;
}
/* if error or can't do it, act like it's a new one */
if (!fpe)
{
fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
if (!fpe)
{
err = BadAlloc;
goto bail;
}
fpe->name = (char *) xalloc(len + 1);
if (!fpe->name)
{
xfree(fpe);
err = BadAlloc;
goto bail;
}
fpe->refcount = 1;
strncpy(fpe->name, (char *) cp, (int) len);
fpe->name[len] = '\0';
fpe->name_length = len;
fpe->type = DetermineFPEType(fpe->name);
if (fpe->type == -1)
err = BadValue;
else
err = (*fpe_functions[fpe->type].init_fpe) (fpe);
if (err != Successful)
{
#ifndef NXAGENT_SERVER
if (persist)
{
ErrorF("Could not init font path element %s, removing from list!\n",
fpe->name);
}
#endif
xfree (fpe->name);
xfree (fpe);
}
}
}
if (err != Successful)
{
if (!persist)
goto bail;
}
else
{
fplist[valid_paths++] = fpe;
}
cp += len;
}
FreeFontPath(font_path_elements, num_fpes, FALSE);
font_path_elements = fplist;
if (patternCache)
EmptyFontPatternCache(patternCache);
num_fpes = valid_paths;
return Success;
bail:
*bad = i;
while (--valid_paths >= 0)
FreeFPE(fplist[valid_paths]);
xfree(fplist);
return FontToXError(err);
}
/* XXX -- do we need to pass error down to each renderer? */
int
SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
{
int err = Success;
if (npaths == 0) {
if (SetDefaultFontPath(defaultFontPath) != Success)
return BadValue;
} else {
err = SetFontPathElements(npaths, paths, error, FALSE);
}
return err;
}
int
SetDefaultFontPath(char *path)
{
unsigned char *cp,
*pp,
*nump,
*newpath;
int num = 1,
len,
err,
size = 0,
bad;
/* get enough for string, plus values -- use up commas */
#ifdef NX_TRANS_SOCKET
len = strlen(_NXGetFontPath(path)) + 1;
#else
len = strlen(path) + 1;
#endif
nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
if (!newpath)
return BadAlloc;
#ifdef NX_TRANS_SOCKET
pp = (unsigned char *) _NXGetFontPath(path);
#else
pp = (unsigned char *) path;
#endif
cp++;
while (*pp) {
if (*pp == ',') {
*nump = (unsigned char) size;
nump = cp++;
pp++;
num++;
size = 0;
} else {
*cp++ = *pp++;
size++;
}
}
*nump = (unsigned char) size;
err = SetFontPathElements(num, newpath, &bad, TRUE);
DEALLOCATE_LOCAL(newpath);
return err;
}
unsigned char *
GetFontPath(int *count, int *length)
{
int i;
unsigned char *c;
int len;
FontPathElementPtr fpe;
len = 0;
for (i = 0; i < num_fpes; i++) {
fpe = font_path_elements[i];
len += fpe->name_length + 1;
}
font_path_string = (unsigned char *) xrealloc(font_path_string, len);
if (!font_path_string)
return NULL;
c = font_path_string;
*length = 0;
for (i = 0; i < num_fpes; i++) {
fpe = font_path_elements[i];
*c = fpe->name_length;
*length += *c++;
memmove(c, fpe->name, fpe->name_length);
c += fpe->name_length;
}
*count = num_fpes;
return font_path_string;
}
int
LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data)
{
if (fpe_functions[pfont->fpe->type].load_glyphs)
return (*fpe_functions[pfont->fpe->type].load_glyphs)
(client, pfont, 0, nchars, item_size, data);
else
return Successful;
}
void
DeleteClientFontStuff(ClientPtr client)
{
int i;
FontPathElementPtr fpe;
for (i = 0; i < num_fpes; i++)
{
fpe = font_path_elements[i];
if (fpe_functions[fpe->type].client_died)
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
}
}
void
InitFonts ()
{
patternCache = MakeFontPatternCache();
register_fpe_functions();
}
int
GetDefaultPointSize ()
{
return 120;
}
FontResolutionPtr
GetClientResolutions (int *num)
{
if (requestingClient && requestingClient->fontResFunc != NULL &&
!requestingClient->clientGone)
{
return (*requestingClient->fontResFunc)(requestingClient, num);
}
else {
static struct _FontResolution res;
ScreenPtr pScreen;
pScreen = screenInfo.screens[0];
res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
/*
* XXX - we'll want this as long as bitmap instances are prevalent
so that we can match them from scalable fonts
*/
if (res.x_resolution < 88)
res.x_resolution = 75;
else
res.x_resolution = 100;
res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
if (res.y_resolution < 88)
res.y_resolution = 75;
else
res.y_resolution = 100;
res.point_size = 120;
*num = 1;
return &res;
}
}
/*
* returns the type index of the new fpe
*
* should be called (only once!) by each type of fpe when initialized
*/
int
RegisterFPEFunctions(NameCheckFunc name_func,
InitFpeFunc init_func,
FreeFpeFunc free_func,
ResetFpeFunc reset_func,
OpenFontFunc open_func,
CloseFontFunc close_func,
ListFontsFunc list_func,
StartLfwiFunc start_lfwi_func,
NextLfwiFunc next_lfwi_func,
WakeupFpeFunc wakeup_func,
ClientDiedFunc client_died,
LoadGlyphsFunc load_glyphs,
StartLaFunc start_list_alias_func,
NextLaFunc next_list_alias_func,
SetPathFunc set_path_func)
{
FPEFunctions *new;
/* grow the list */
new = (FPEFunctions *) xrealloc(fpe_functions,
(num_fpe_types + 1) * sizeof(FPEFunctions));
if (!new)
return -1;
fpe_functions = new;
fpe_functions[num_fpe_types].name_check = name_func;
fpe_functions[num_fpe_types].open_font = open_func;
fpe_functions[num_fpe_types].close_font = close_func;
fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
fpe_functions[num_fpe_types].list_fonts = list_func;
fpe_functions[num_fpe_types].start_list_fonts_with_info =
start_lfwi_func;
fpe_functions[num_fpe_types].list_next_font_with_info =
next_lfwi_func;
fpe_functions[num_fpe_types].init_fpe = init_func;
fpe_functions[num_fpe_types].free_fpe = free_func;
fpe_functions[num_fpe_types].reset_fpe = reset_func;
fpe_functions[num_fpe_types].client_died = client_died;
fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
start_list_alias_func;
fpe_functions[num_fpe_types].list_next_font_or_alias =
next_list_alias_func;
fpe_functions[num_fpe_types].set_path_hook = set_path_func;
return num_fpe_types++;
}
void
FreeFonts()
{
if (patternCache) {
FreeFontPatternCache(patternCache);
patternCache = 0;
}
FreeFontPath(font_path_elements, num_fpes, TRUE);
font_path_elements = 0;
num_fpes = 0;
xfree(fpe_functions);
num_fpe_types = 0;
fpe_functions = (FPEFunctions *) 0;
}
/* convenience functions for FS interface */
FontPtr
find_old_font(XID id)
{
return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
SecurityUnknownAccess);
}
Font
GetNewFontClientID()
{
return FakeClientID(0);
}
int
StoreFontClientFont(FontPtr pfont, Font id)
{
return AddResource(id, RT_NONE, (void *) pfont);
}
void
DeleteFontClientID(Font id)
{
FreeResource(id, RT_NONE);
}
int
client_auth_generation(ClientPtr client)
{
return 0;
}
static int fs_handlers_installed = 0;
static unsigned int last_server_gen;
int
init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
{
/* if server has reset, make sure the b&w handlers are reinstalled */
if (last_server_gen < serverGeneration) {
last_server_gen = serverGeneration;
fs_handlers_installed = 0;
}
if (fs_handlers_installed == 0) {
#ifdef DEBUG
fprintf(stderr, "adding FS b & w handlers\n");
#endif
if (!RegisterBlockAndWakeupHandlers(block_handler,
FontWakeup, (void *) 0))
return AllocError;
fs_handlers_installed++;
}
QueueFontWakeup(fpe);
return Successful;
}
void
remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
{
if (all) {
/* remove the handlers if no one else is using them */
if (--fs_handlers_installed == 0) {
#ifdef DEBUG
fprintf(stderr, "removing FS b & w handlers\n");
#endif
RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
(void *) 0);
}
}
RemoveFontWakeup(fpe);
}
#ifdef DEBUG
#define GLWIDTHBYTESPADDED(bits,nbytes) \
((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
:(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
:(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
:(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
: 0)
#define GLYPH_SIZE(ch, nbytes) \
GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
(ch)->metrics.leftSideBearing, (nbytes))
void
dump_char_ascii(CharInfoPtr cip)
{
int r,
l;
int bpr;
int byte;
static unsigned maskTab[] = {
(1 << 7), (1 << 6), (1 << 5), (1 << 4),
(1 << 3), (1 << 2), (1 << 1), (1 << 0),
};
bpr = GLYPH_SIZE(cip, 4);
for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {
void * row = (void *) cip->bits + r * bpr;
byte = 0;
for (l = 0; l <= (cip->metrics.rightSideBearing -
cip->metrics.leftSideBearing); l++) {
if (maskTab[l & 7] & (((int *)row)[l >> 3]))
putchar('X');
else
putchar('.');
}
putchar('\n');
}
}
#endif
typedef struct
{
LFclosurePtr c;
OFclosurePtr oc;
} nxFs,*nxFsPtr;
static Bool
#if NeedFunctionPrototypes
nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss)
#else
nxdoListFontsAndAliases(client, fss)
ClientPtr client;
nxFsPtr fss;
#endif
{
LFclosurePtr c=fss->c;
OFclosurePtr oc=fss->oc;
FontPathElementPtr fpe;
int err = Successful;
char *name, *resolved=NULL;
int namelen, resolvedlen;
int i;
int aliascount = 0;
char tmp[256];
tmp[0]=0;
static Bool
#if NeedFunctionPrototypes
nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss)
#else
nxdoListFontsAndAliases(client, fss)
ClientPtr client;
nxFsPtr fss;
#endif
{
LFclosurePtr c=fss->c;
OFclosurePtr oc=fss->oc;
FontPathElementPtr fpe;
int err = Successful;
char *name, *resolved=NULL;
int namelen, resolvedlen;
int i;
int aliascount = 0;
char tmp[256];
tmp[0]=0;
if (client->clientGone)
{
if (c->current.current_fpe < c->num_fpes)
......@@ -2796,4 +1407,3 @@ nxOpenFont(client, fid, flags, lenfname, pfontname)
nxdoListFontsAndAliases(client, fss);
return Success;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -64,265 +64,9 @@ SOFTWARE.
******************************************************************/
/* $Xorg: extension.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#define NEED_EVENTS
#define NEED_REPLIES
#include <nx-X11/Xproto.h>
#include "misc.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "../../dix/dispatch.h"
#ifdef XCSECURITY
#define _SECURITY_SERVER
#include <nx-X11/extensions/security.h>
#endif
#ifdef LBX
#include "lbxserve.h"
#endif
#include "Trap.h"
#define EXTENSION_BASE 128
#define EXTENSION_EVENT_BASE 64
#define LAST_EVENT 128
#define LAST_ERROR 255
ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS];
static ExtensionEntry **extensions = (ExtensionEntry **)NULL;
int lastEvent = EXTENSION_EVENT_BASE;
static int lastError = FirstExtensionError;
static unsigned int NumExtensions = 0;
ExtensionEntry *
AddExtension(char *name, int NumEvents, int NumErrors,
int (*MainProc)(ClientPtr c1),
int (*SwappedMainProc)(ClientPtr c2),
void (*CloseDownProc)(ExtensionEntry *e),
unsigned short (*MinorOpcodeProc)(ClientPtr c3))
{
int i;
register ExtensionEntry *ext, **newexts;
if (!MainProc || !SwappedMainProc || !MinorOpcodeProc)
return((ExtensionEntry *) NULL);
if ((lastEvent + NumEvents > LAST_EVENT) ||
(unsigned)(lastError + NumErrors > LAST_ERROR))
return((ExtensionEntry *) NULL);
ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
if (!ext)
return((ExtensionEntry *) NULL);
ext->name = (char *)xalloc(strlen(name) + 1);
ext->num_aliases = 0;
ext->aliases = (char **)NULL;
if (!ext->name)
{
xfree(ext);
return((ExtensionEntry *) NULL);
}
strcpy(ext->name, name);
i = NumExtensions;
newexts = (ExtensionEntry **) xrealloc(extensions,
(i + 1) * sizeof(ExtensionEntry *));
if (!newexts)
{
xfree(ext->name);
xfree(ext);
return((ExtensionEntry *) NULL);
}
NumExtensions++;
extensions = newexts;
extensions[i] = ext;
ext->index = i;
ext->base = i + EXTENSION_BASE;
ext->CloseDown = CloseDownProc;
ext->MinorOpcode = MinorOpcodeProc;
ProcVector[i + EXTENSION_BASE] = MainProc;
SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc;
if (NumEvents)
{
ext->eventBase = lastEvent;
ext->eventLast = lastEvent + NumEvents;
lastEvent += NumEvents;
}
else
{
ext->eventBase = 0;
ext->eventLast = 0;
}
if (NumErrors)
{
ext->errorBase = lastError;
ext->errorLast = lastError + NumErrors;
lastError += NumErrors;
}
else
{
ext->errorBase = 0;
ext->errorLast = 0;
}
#ifdef XCSECURITY
ext->secure = FALSE;
#endif
#ifdef LBX
(void) LbxAddExtension(name, ext->base, ext->eventBase, ext->errorBase);
#endif
return(ext);
}
Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
{
char *name;
char **aliases;
aliases = (char **)xrealloc(ext->aliases,
(ext->num_aliases + 1) * sizeof(char *));
if (!aliases)
return FALSE;
ext->aliases = aliases;
name = (char *)xalloc(strlen(alias) + 1);
if (!name)
return FALSE;
strcpy(name, alias);
ext->aliases[ext->num_aliases] = name;
ext->num_aliases++;
#ifdef LBX
return LbxAddExtensionAlias(ext->index, alias);
#else
return TRUE;
#endif
}
static int
FindExtension(char *extname, int len)
{
int i, j;
for (i=0; i<NumExtensions; i++)
{
if ((strlen(extensions[i]->name) == len) &&
!strncmp(extname, extensions[i]->name, len))
break;
for (j = extensions[i]->num_aliases; --j >= 0;)
{
if ((strlen(extensions[i]->aliases[j]) == len) &&
!strncmp(extname, extensions[i]->aliases[j], len))
break;
}
if (j >= 0) break;
}
return ((i == NumExtensions) ? -1 : i);
}
/*
* CheckExtension returns the extensions[] entry for the requested
* extension name. Maybe this could just return a Bool instead?
*/
ExtensionEntry *
CheckExtension(const char *extname)
{
int n;
n = FindExtension((char*)extname, strlen(extname));
if (n != -1)
return extensions[n];
else
return NULL;
}
void
DeclareExtensionSecurity(char *extname, Bool secure)
{
#ifdef XCSECURITY
int i = FindExtension(extname, strlen(extname));
if (i >= 0)
{
int majorop = extensions[i]->base;
extensions[i]->secure = secure;
if (secure)
{
UntrustedProcVector[majorop] = ProcVector[majorop];
SwappedUntrustedProcVector[majorop] = SwappedProcVector[majorop];
}
else
{
UntrustedProcVector[majorop] = ProcBadRequest;
SwappedUntrustedProcVector[majorop] = ProcBadRequest;
}
}
#endif
#ifdef LBX
LbxDeclareExtensionSecurity(extname, secure);
#endif
}
unsigned short
StandardMinorOpcode(ClientPtr client)
{
return ((xReq *)client->requestBuffer)->data;
}
unsigned short
MinorOpcodeOfRequest(ClientPtr client)
{
unsigned char major;
major = ((xReq *)client->requestBuffer)->reqType;
if (major < EXTENSION_BASE)
return 0;
major -= EXTENSION_BASE;
if (major >= NumExtensions)
return 0;
return (*extensions[major]->MinorOpcode)(client);
}
void
CloseDownExtensions()
{
register int i,j;
#ifdef LBX
LbxCloseDownExtensions();
#endif
for (i = NumExtensions - 1; i >= 0; i--)
{
if (extensions[i]->CloseDown)
(* extensions[i]->CloseDown)(extensions[i]);
NumExtensions = i;
xfree(extensions[i]->name);
for (j = extensions[i]->num_aliases; --j >= 0;)
xfree(extensions[i]->aliases[j]);
xfree(extensions[i]->aliases);
xfree(extensions[i]);
}
xfree(extensions);
extensions = (ExtensionEntry **)NULL;
lastEvent = EXTENSION_EVENT_BASE;
lastError = FirstExtensionError;
for (i=0; i<MAXSCREENS; i++)
{
register ScreenProcEntry *spentry = &AuxillaryScreenProcs[i];
while (spentry->num)
{
spentry->num--;
xfree(spentry->procList[spentry->num].name);
}
xfree(spentry->procList);
spentry->procList = (ProcEntryPtr)NULL;
}
}
#include "../../dix/extension.c"
int
ProcQueryExtension(ClientPtr client)
......@@ -443,69 +187,3 @@ ProcListExtensions(ClientPtr client)
}
return(client->noClientException);
}
ExtensionLookupProc
LookupProc(char *name, GCPtr pGC)
{
register int i;
register ScreenProcEntry *spentry;
spentry = &AuxillaryScreenProcs[pGC->pScreen->myNum];
if (spentry->num)
{
for (i = 0; i < spentry->num; i++)
if (strcmp(name, spentry->procList[i].name) == 0)
return(spentry->procList[i].proc);
}
return (ExtensionLookupProc)NULL;
}
Bool
RegisterProc(char *name, GC *pGC, ExtensionLookupProc proc)
{
return RegisterScreenProc(name, pGC->pScreen, proc);
}
Bool
RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc)
{
register ScreenProcEntry *spentry;
register ProcEntryPtr procEntry = (ProcEntryPtr)NULL;
char *newname;
int i;
spentry = &AuxillaryScreenProcs[pScreen->myNum];
/* first replace duplicates */
if (spentry->num)
{
for (i = 0; i < spentry->num; i++)
if (strcmp(name, spentry->procList[i].name) == 0)
{
procEntry = &spentry->procList[i];
break;
}
}
if (procEntry)
procEntry->proc = proc;
else
{
newname = (char *)xalloc(strlen(name)+1);
if (!newname)
return FALSE;
procEntry = (ProcEntryPtr)
xrealloc(spentry->procList,
sizeof(ProcEntryRec) * (spentry->num+1));
if (!procEntry)
{
xfree(newname);
return FALSE;
}
spentry->procList = procEntry;
procEntry += spentry->num;
procEntry->name = newname;
strcpy(newname, name);
procEntry->proc = proc;
spentry->num++;
}
return TRUE;
}
......@@ -35,20 +35,7 @@
**
*/
#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glxserver.h"
#include <windowstr.h>
#include <propertyst.h>
#include <os.h>
#include "g_disptab.h"
#include "unpack.h"
#include "glxutil.h"
#include "glxext.h"
#include "micmap.h"
#include "../../GL/glx/glxext.c"
#include "Trap.h"
......@@ -57,362 +44,6 @@
#undef TEST
#undef DEBUG
void GlxWrapInitVisuals(miInitVisualsProcPtr *);
void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs, void **privates);
static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */;
/*
** Forward declarations.
*/
static int __glXSwapDispatch(ClientPtr);
static int __glXDispatch(ClientPtr);
/*
** Called when the extension is reset.
*/
static void ResetExtension(ExtensionEntry* extEntry)
{
__glXFlushContextCache();
(*__glXExt->resetExtension)();
__glXScreenReset();
}
/*
** Initialize the per-client context storage.
*/
static void ResetClientState(int clientIndex)
{
__GLXclientState *cl = __glXClients[clientIndex];
if (cl->returnBuf) __glXFree(cl->returnBuf);
if (cl->largeCmdBuf) __glXFree(cl->largeCmdBuf);
if (cl->currentContexts) __glXFree(cl->currentContexts);
__glXMemset(cl, 0, sizeof(__GLXclientState));
/*
** By default, assume that the client supports
** GLX major version 1 minor version 0 protocol.
*/
cl->GLClientmajorVersion = 1;
cl->GLClientminorVersion = 0;
if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
}
/*
** Reset state used to keep track of large (multi-request) commands.
*/
void __glXResetLargeCommandStatus(__GLXclientState *cl)
{
cl->largeCmdBytesSoFar = 0;
cl->largeCmdBytesTotal = 0;
cl->largeCmdRequestsSoFar = 0;
cl->largeCmdRequestsTotal = 0;
}
/*
** This procedure is called when the client who created the context goes
** away OR when glXDestroyContext is called. In either case, all we do is
** flag that the ID is no longer valid, and (maybe) free the context.
** use.
*/
static int ContextGone(__GLXcontext* cx, XID id)
{
cx->idExists = GL_FALSE;
if (!cx->isCurrent) {
__glXFreeContext(cx);
}
return True;
}
/*
** Free a client's state.
*/
static int ClientGone(int clientIndex, XID id)
{
__GLXcontext *cx;
__GLXclientState *cl = __glXClients[clientIndex];
int i;
if (cl) {
/*
** Free all the contexts that are current for this client.
*/
for (i=0; i < cl->numCurrentContexts; i++) {
cx = cl->currentContexts[i];
if (cx) {
__glXDeassociateContext(cx);
cx->isCurrent = GL_FALSE;
if (!cx->idExists) {
__glXFreeContext(cx);
}
}
}
/*
** Re-initialize the client state structure. Don't free it because
** we'll probably get another client with this index and use the struct
** again. There is a maximum of MAXCLIENTS of these structures.
*/
ResetClientState(clientIndex);
}
return True;
}
/*
** Free a GLX Pixmap.
*/
static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id)
{
PixmapPtr pPixmap = (PixmapPtr) pGlxPixmap->pDraw;
pGlxPixmap->idExists = False;
if (!pGlxPixmap->refcnt) {
/*
** The DestroyPixmap routine should decrement the refcount and free
** only if it's zero.
*/
(*pGlxPixmap->pScreen->DestroyPixmap)(pPixmap);
__glXFree(pGlxPixmap);
}
return True;
}
/*
** Free a context.
*/
GLboolean __glXFreeContext(__GLXcontext *cx)
{
if (cx->idExists || cx->isCurrent) return GL_FALSE;
if (!cx->isDirect) {
if ((*cx->gc->exports.destroyContext)((__GLcontext *)cx->gc) == GL_FALSE) {
return GL_FALSE;
}
}
if (cx->feedbackBuf) __glXFree(cx->feedbackBuf);
if (cx->selectBuf) __glXFree(cx->selectBuf);
__glXFree(cx);
if (cx == __glXLastContext) {
__glXFlushContextCache();
}
return GL_TRUE;
}
extern RESTYPE __glXSwapBarrierRes;
static int SwapBarrierGone(int screen, XID drawable)
{
if (__glXSwapBarrierFuncs &&
__glXSwapBarrierFuncs[screen].bindSwapBarrierFunc != NULL) {
__glXSwapBarrierFuncs[screen].bindSwapBarrierFunc(screen, drawable, 0);
}
FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
return True;
}
/************************************************************************/
/*
** These routines can be used to check whether a particular GL command
** has caused an error. Specifically, we use them to check whether a
** given query has caused an error, in which case a zero-length data
** reply is sent to the client.
*/
static GLboolean errorOccured = GL_FALSE;
/*
** The GL was will call this routine if an error occurs.
*/
void __glXErrorCallBack(__GLinterface *gc, GLenum code)
{
errorOccured = GL_TRUE;
}
/*
** Clear the error flag before calling the GL command.
*/
void __glXClearErrorOccured(void)
{
errorOccured = GL_FALSE;
}
/*
** Check if the GL command caused an error.
*/
GLboolean __glXErrorOccured(void)
{
return errorOccured;
}
/************************************************************************/
/*
** Initialize the GLX extension.
*/
void GlxExtensionInit(void)
{
ExtensionEntry *extEntry;
int i;
__glXContextRes = CreateNewResourceType((DeleteType)ContextGone);
__glXClientRes = CreateNewResourceType((DeleteType)ClientGone);
__glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone);
/*
** Add extension to server extensions.
*/
extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
__GLX_NUMBER_ERRORS, __glXDispatch,
__glXSwapDispatch, ResetExtension,
StandardMinorOpcode);
if (!extEntry) {
FatalError("__glXExtensionInit: AddExtensions failed\n");
return;
}
if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) {
ErrorF("__glXExtensionInit: AddExtensionAlias failed\n");
return;
}
__glXBadContext = extEntry->errorBase + GLXBadContext;
__glXBadContextState = extEntry->errorBase + GLXBadContextState;
__glXBadDrawable = extEntry->errorBase + GLXBadDrawable;
__glXBadPixmap = extEntry->errorBase + GLXBadPixmap;
__glXBadContextTag = extEntry->errorBase + GLXBadContextTag;
__glXBadCurrentWindow = extEntry->errorBase + GLXBadCurrentWindow;
__glXBadRenderRequest = extEntry->errorBase + GLXBadRenderRequest;
__glXBadLargeRequest = extEntry->errorBase + GLXBadLargeRequest;
__glXUnsupportedPrivateRequest = extEntry->errorBase +
GLXUnsupportedPrivateRequest;
__glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone);
/*
** Initialize table of client state. There is never a client 0.
*/
for (i=1; i <= MAXCLIENTS; i++) {
__glXClients[i] = 0;
}
/*
** Initialize screen specific data.
*/
__glXScreenInit(screenInfo.numScreens);
}
/************************************************************************/
Bool __glXCoreType(void)
{
return __glXExt->type;
}
/************************************************************************/
void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs, void **privates)
{
(*__glXExt->setVisualConfigs)(nconfigs, configs, privates);
}
static miInitVisualsProcPtr saveInitVisualsProc;
Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
int *nvisualp, int *ndepthp,
int *rootDepthp, VisualID *defaultVisp,
unsigned long sizes, int bitsPerRGB,
int preferredVis)
{
Bool ret;
if (saveInitVisualsProc) {
ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
rootDepthp, defaultVisp, sizes, bitsPerRGB,
preferredVis);
if (!ret)
return False;
}
(*__glXExt->initVisuals)(visualp, depthp, nvisualp, ndepthp, rootDepthp,
defaultVisp, sizes, bitsPerRGB);
return True;
}
void
GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
{
saveInitVisualsProc = *initVisProc;
*initVisProc = GlxInitVisuals;
/* HACK: this shouldn't be done here but it's the earliest time */
__glXExt = __glXglDDXExtensionInfo(); /* from GLcore */
}
/************************************************************************/
void __glXFlushContextCache(void)
{
__glXLastContext = 0;
}
/*
** Make a context the current one for the GL (in this implementation, there
** is only one instance of the GL, and we use it to serve all GL clients by
** switching it between different contexts). While we are at it, look up
** a context by its tag and return its (__GLXcontext *).
*/
__GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
int *error)
{
__GLXcontext *cx;
/*
** See if the context tag is legal; it is managed by the extension,
** so if it's invalid, we have an implementation error.
*/
cx = (__GLXcontext *) __glXLookupContextByTag(cl, tag);
if (!cx) {
cl->client->errorValue = tag;
*error = __glXBadContextTag;
return 0;
}
if (!cx->isDirect) {
if (cx->drawPriv == NULL) {
/*
** The drawable has vanished. It must be a window, because only
** windows can be destroyed from under us; GLX pixmaps are
** refcounted and don't go away until no one is using them.
*/
*error = __glXBadCurrentWindow;
return 0;
}
}
if (cx == __glXLastContext) {
/* No need to re-bind */
return cx;
}
/* Make this context the current one for the GL. */
if (!cx->isDirect) {
if (!(*cx->gc->exports.forceCurrent)((__GLcontext *)cx->gc)) {
/* Bind failed, and set the error code. Bummer */
cl->client->errorValue = cx->id;
*error = __glXBadContextState;
return 0;
}
}
__glXLastContext = cx;
return cx;
}
/************************************************************************/
/*
** Top level dispatcher; all commands are executed from here down.
*/
......@@ -563,13 +194,3 @@ static int __glXSwapDispatch(ClientPtr client)
return result;
}
int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc)
{
return BadRequest;
}
void __glXNoSuchRenderOpcode(GLbyte *pc)
{
return;
}
......@@ -40,28 +40,10 @@
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
#include "regionstr.h"
#include "validate.h"
#include "windowstr.h"
#include "input.h"
#include "resource.h"
#include "colormapst.h"
#include "cursorstr.h"
#include "dixstruct.h"
#include "gcstruct.h"
#include "servermd.h"
#include "../../render/glyph.c"
#ifdef NXAGENT_SERVER
#include "NXpicturestr.h"
#include "NXglyphstr.h"
#include "Render.h"
#define PANIC
......@@ -69,238 +51,8 @@
#undef DEBUG
#undef TEST
#else
#include "picturestr.h"
#include "glyphstr.h"
#endif
#include <stdint.h>
/*
* From Knuth -- a good choice for hash/rehash values is p, p-2 where
* p and p-2 are both prime. These tables are sized to have an extra 10%
* free to avoid exponential performance degradation as the hash table fills
*/
static GlyphHashSetRec glyphHashSets[] = {
{ 32, 43, 41 },
{ 64, 73, 71 },
{ 128, 151, 149 },
{ 256, 283, 281 },
{ 512, 571, 569 },
{ 1024, 1153, 1151 },
{ 2048, 2269, 2267 },
{ 4096, 4519, 4517 },
{ 8192, 9013, 9011 },
{ 16384, 18043, 18041 },
{ 32768, 36109, 36107 },
{ 65536, 72091, 72089 },
{ 131072, 144409, 144407 },
{ 262144, 288361, 288359 },
{ 524288, 576883, 576881 },
{ 1048576, 1153459, 1153457 },
{ 2097152, 2307163, 2307161 },
{ 4194304, 4613893, 4613891 },
{ 8388608, 9227641, 9227639 },
{ 16777216, 18455029, 18455027 },
{ 33554432, 36911011, 36911009 },
{ 67108864, 73819861, 73819859 },
{ 134217728, 147639589, 147639587 },
{ 268435456, 295279081, 295279079 },
{ 536870912, 590559793, 590559791 }
};
#define NGLYPHHASHSETS (sizeof(glyphHashSets)/sizeof(glyphHashSets[0]))
const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
GlyphHashRec globalGlyphs[GlyphFormatNum];
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled)
{
int i;
for (i = 0; i < NGLYPHHASHSETS; i++)
if (glyphHashSets[i].entries >= filled)
return &glyphHashSets[i];
return 0;
}
static int _GlyphSetPrivateAllocateIndex = 0;
int
AllocateGlyphSetPrivateIndex (void)
{
return _GlyphSetPrivateAllocateIndex++;
}
void
ResetGlyphSetPrivateIndex (void)
{
_GlyphSetPrivateAllocateIndex = 0;
}
Bool
_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr)
{
void **new;
if (n > glyphSet->maxPrivate) {
if (glyphSet->devPrivates &&
glyphSet->devPrivates != (void *)(&glyphSet[1])) {
new = (void **) xrealloc (glyphSet->devPrivates,
(n + 1) * sizeof (void *));
if (!new)
return FALSE;
} else {
new = (void **) xalloc ((n + 1) * sizeof (void *));
if (!new)
return FALSE;
if (glyphSet->devPrivates)
memcpy (new,
glyphSet->devPrivates,
(glyphSet->maxPrivate + 1) * sizeof (void *));
}
glyphSet->devPrivates = new;
/* Zero out new, uninitialize privates */
while (++glyphSet->maxPrivate < n)
glyphSet->devPrivates[glyphSet->maxPrivate] = (void *)0;
}
glyphSet->devPrivates[n] = ptr;
return TRUE;
}
Bool
GlyphInit (ScreenPtr pScreen)
{
return TRUE;
}
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
{
CARD32 elt, step, s;
GlyphPtr glyph;
GlyphRefPtr table, gr, del;
CARD32 tableSize = hash->hashSet->size;
table = hash->table;
elt = signature % tableSize;
step = 0;
del = 0;
for (;;)
{
gr = &table[elt];
s = gr->signature;
glyph = gr->glyph;
if (!glyph)
{
if (del)
gr = del;
break;
}
if (glyph == DeletedGlyph)
{
if (!del)
del = gr;
else if (gr == del)
break;
}
else if (s == signature &&
(!match ||
memcmp (&compare->info, &glyph->info, compare->size) == 0))
{
break;
}
if (!step)
{
step = signature % hash->hashSet->rehash;
if (!step)
step = 1;
}
elt += step;
if (elt >= tableSize)
elt -= tableSize;
}
return gr;
}
CARD32
HashGlyph (GlyphPtr glyph)
{
CARD32 *bits = (CARD32 *) &(glyph->info);
CARD32 hash;
int n = glyph->size / sizeof (CARD32);
hash = 0;
while (n--)
hash ^= *bits++;
return hash;
}
#ifdef CHECK_DUPLICATES
void
DuplicateRef (GlyphPtr glyph, char *where)
{
ErrorF ("Duplicate Glyph 0x%x from %s\n", glyph, where);
}
void
CheckDuplicates (GlyphHashPtr hash, char *where)
{
GlyphPtr g;
int i, j;
for (i = 0; i < hash->hashSet->size; i++)
{
g = hash->table[i].glyph;
if (!g || g == DeletedGlyph)
continue;
for (j = i + 1; j < hash->hashSet->size; j++)
if (hash->table[j].glyph == g)
DuplicateRef (g, where);
}
}
#else
#define CheckDuplicates(a,b)
#define DuplicateRef(a,b)
#endif
void
FreeGlyph (GlyphPtr glyph, int format)
{
CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
if (--glyph->refcnt == 0)
{
GlyphRefPtr gr;
int i;
int first;
first = -1;
for (i = 0; i < globalGlyphs[format].hashSet->size; i++)
if (globalGlyphs[format].table[i].glyph == glyph)
{
if (first != -1)
DuplicateRef (glyph, "FreeGlyph check");
first = i;
}
gr = FindGlyphRef (&globalGlyphs[format],
HashGlyph (glyph), TRUE, glyph);
if (gr - globalGlyphs[format].table != first)
DuplicateRef (glyph, "Found wrong one");
if (gr->glyph && gr->glyph != DeletedGlyph)
{
gr->glyph = DeletedGlyph;
gr->signature = 0;
globalGlyphs[format].tableEntries--;
}
xfree (glyph);
}
}
void
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
{
......@@ -342,26 +94,6 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom");
}
Bool
DeleteGlyph (GlyphSetPtr glyphSet, Glyph id)
{
GlyphRefPtr gr;
GlyphPtr glyph;
gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
glyph = gr->glyph;
if (glyph && glyph != DeletedGlyph)
{
gr->glyph = DeletedGlyph;
glyphSet->hash.tableEntries--;
FreeGlyph (glyph, glyphSet->fdepth);
return TRUE;
}
return FALSE;
}
#ifdef NXAGENT_SERVER
GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id)
{
GlyphRefPtr gr;
......@@ -388,53 +120,6 @@ GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id)
return glyph;
}
#else
GlyphPtr
FindGlyph (GlyphSetPtr glyphSet, Glyph id)
{
GlyphPtr glyph;
glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph;
if (glyph == DeletedGlyph)
glyph = 0;
return glyph;
}
#endif
GlyphPtr
AllocateGlyph (xGlyphInfo *gi, int fdepth)
{
int size;
GlyphPtr glyph;
size_t padded_width;
padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]);
if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height)
return 0;
size = gi->height * padded_width;
glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
if (!glyph)
return 0;
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
return glyph;
}
Bool
AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
{
hash->table = (GlyphRefPtr) xalloc (hashSet->size * sizeof (GlyphRefRec));
if (!hash->table)
return FALSE;
memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec));
hash->hashSet = hashSet;
hash->tableEntries = 0;
return TRUE;
}
Bool
ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
{
......@@ -497,81 +182,3 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
CheckDuplicates (hash, "ResizeGlyphHash bottom");
return TRUE;
}
Bool
ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change)
{
return (ResizeGlyphHash (&glyphSet->hash, change, FALSE) &&
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], change, TRUE));
}
GlyphSetPtr
AllocateGlyphSet (int fdepth, PictFormatPtr format)
{
GlyphSetPtr glyphSet;
int size;
if (!globalGlyphs[fdepth].hashSet)
{
if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0]))
return FALSE;
}
size = (sizeof (GlyphSetRec) +
(sizeof (void *) * _GlyphSetPrivateAllocateIndex));
glyphSet = xalloc (size);
if (!glyphSet)
return FALSE;
bzero((char *)glyphSet, size);
glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1;
if (_GlyphSetPrivateAllocateIndex)
glyphSet->devPrivates = (void *)(&glyphSet[1]);
if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
{
xfree (glyphSet);
return FALSE;
}
glyphSet->refcnt = 1;
glyphSet->fdepth = fdepth;
glyphSet->format = format;
return glyphSet;
}
int
FreeGlyphSet (void * value,
XID gid)
{
GlyphSetPtr glyphSet = (GlyphSetPtr) value;
if (--glyphSet->refcnt == 0)
{
CARD32 i, tableSize = glyphSet->hash.hashSet->size;
GlyphRefPtr table = glyphSet->hash.table;
GlyphPtr glyph;
for (i = 0; i < tableSize; i++)
{
glyph = table[i].glyph;
if (glyph && glyph != DeletedGlyph)
FreeGlyph (glyph, glyphSet->fdepth);
}
if (!globalGlyphs[glyphSet->fdepth].tableEntries)
{
xfree (globalGlyphs[glyphSet->fdepth].table);
globalGlyphs[glyphSet->fdepth].table = 0;
globalGlyphs[glyphSet->fdepth].hashSet = 0;
}
else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
xfree (table);
if (glyphSet->devPrivates &&
glyphSet->devPrivates != (void *)(&glyphSet[1]))
xfree(glyphSet->devPrivates);
xfree (glyphSet);
}
return Success;
}
......@@ -64,20 +64,7 @@ SOFTWARE.
/* $Xorg: glyphcurs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "misc.h"
#include <X11/fonts/fontstruct.h>
#include "dixfontstr.h"
#include "scrnintstr.h"
#include "gcstruct.h"
#include "resource.h"
#include "dix.h"
#include "cursorstr.h"
#include "opaque.h"
#include "servermd.h"
#include "../../dix/glyphcurs.c"
#include "../../fb/fb.h"
#include "Pixmaps.h"
......@@ -183,57 +170,3 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns
return Success;
}
Bool
CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm)
{
CharInfoPtr pci;
unsigned long nglyphs;
CARD8 chs[2];
FontEncoding encoding;
chs[0] = ch >> 8;
chs[1] = ch;
encoding = (FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit;
if (encoding == Linear16Bit)
{
if (ch < pfont->info.firstCol || pfont->info.lastCol < ch)
return FALSE;
}
else
{
if (chs[0] < pfont->info.firstRow || pfont->info.lastRow < chs[0])
return FALSE;
if (chs[1] < pfont->info.firstCol || pfont->info.lastCol < chs[1])
return FALSE;
}
(*pfont->get_glyphs) (pfont, 1, chs, encoding, &nglyphs, &pci);
if (nglyphs == 0)
return FALSE;
cm->width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
cm->height = pci->metrics.descent + pci->metrics.ascent;
if (pci->metrics.leftSideBearing > 0)
{
cm->width += pci->metrics.leftSideBearing;
cm->xhot = 0;
}
else
{
cm->xhot = -pci->metrics.leftSideBearing;
if (pci->metrics.rightSideBearing < 0)
cm->width -= pci->metrics.rightSideBearing;
}
if (pci->metrics.ascent < 0)
{
cm->height -= pci->metrics.ascent;
cm->yhot = 0;
}
else
{
cm->yhot = pci->metrics.ascent;
if (pci->metrics.descent < 0)
cm->height -= pci->metrics.descent;
}
return TRUE;
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXAGENT, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
/*
* $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
/* this header file gets included into Xserver/render/glyphstr.h */
#ifndef NX_GLYPHSTR_GLYPHREF_H
#define NX_GLYPHSTR_GLYPHREF_H 1
typedef struct _GlyphRef {
CARD32 signature;
GlyphPtr glyph;
CARD16 corruptedGlyph;
} GlyphRefRec, *GlyphRefPtr;
#endif /* NX_GLYPHSTR_GLYPHREF_H */
......@@ -40,53 +40,10 @@
* Author: Keith Packard, SuSE, Inc.
*/
/*
* This must keep the same symbol as the original glyphstr.h
* or symbols will be redefined. The code here adds a field
* to _GlyphSet. This should be done by defining a new type
* and casting when appropriate.
*/
#ifndef _GLYPHSTR_H_
#define _GLYPHSTR_H_
#include <nx-X11/extensions/renderproto.h>
#include "../../render/picture.h"
#include "screenint.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
#define GlyphFormat8 2
#define GlyphFormat16 3
#define GlyphFormat32 4
#define GlyphFormatNum 5
typedef struct _Glyph {
CARD32 refcnt;
CARD32 size; /* info + bitmap */
xGlyphInfo info;
/* bits follow */
} GlyphRec, *GlyphPtr;
typedef struct _GlyphRef {
CARD32 signature;
GlyphPtr glyph;
CARD16 corruptedGlyph;
} GlyphRefRec, *GlyphRefPtr;
#define DeletedGlyph ((GlyphPtr) 1)
/* this header file gets included into Xserver/render/glyphstr.h */
typedef struct _GlyphHashSet {
CARD32 entries;
CARD32 size;
CARD32 rehash;
} GlyphHashSetRec, *GlyphHashSetPtr;
typedef struct _GlyphHash {
GlyphRefPtr table;
GlyphHashSetPtr hashSet;
CARD32 tableEntries;
} GlyphHashRec, *GlyphHashPtr;
#ifndef NX_GLYPHSTR_GLYPHSET_H
#define NX_GLYPHSTR_GLYPHSET_H 1
typedef struct _GlyphSet {
CARD32 refcnt;
......@@ -98,77 +55,4 @@ typedef struct _GlyphSet {
CARD32 remoteID;
} GlyphSetRec, *GlyphSetPtr;
#define GlyphSetGetPrivate(pGlyphSet,n) \
((n) > (pGlyphSet)->maxPrivate ? \
(void *) 0 : \
(pGlyphSet)->devPrivates[n])
#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
((n) > (pGlyphSet)->maxPrivate ? \
_GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
typedef struct _GlyphList {
INT16 xOff;
INT16 yOff;
CARD8 len;
PictFormatPtr format;
} GlyphListRec, *GlyphListPtr;
extern GlyphHashRec globalGlyphs[GlyphFormatNum];
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled);
int
AllocateGlyphSetPrivateIndex (void);
void
ResetGlyphSetPrivateIndex (void);
Bool
_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr);
Bool
GlyphInit (ScreenPtr pScreen);
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare);
CARD32
HashGlyph (GlyphPtr glyph);
void
FreeGlyph (GlyphPtr glyph, int format);
void
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
Bool
DeleteGlyph (GlyphSetPtr glyphSet, Glyph id);
GlyphPtr
FindGlyph (GlyphSetPtr glyphSet, Glyph id);
GlyphPtr
AllocateGlyph (xGlyphInfo *gi, int format);
Bool
AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet);
Bool
ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global);
Bool
ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change);
GlyphSetPtr
AllocateGlyphSet (int fdepth, PictFormatPtr format);
int
FreeGlyphSet (void *value,
XID gid);
#endif /* _GLYPHSTR_H_ */
#endif /* NX_GLYPHSTR_GLYPHSET_H */
......@@ -93,48 +93,9 @@ Equipment Corporation.
/* $Xorg: miexpose.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#define NEED_EVENTS
#include <nx-X11/Xproto.h>
#include <nx-X11/Xprotostr.h>
#include "misc.h"
#include "regionstr.h"
#include "scrnintstr.h"
#include "gcstruct.h"
#include "windowstr.h"
#include "pixmap.h"
#include "input.h"
#include "dixstruct.h"
#include "mi.h"
#include <nx-X11/Xmd.h>
#include "globals.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
/*
machine-independent graphics exposure code. any device that uses
the region package can call this.
*/
#ifdef NXAGENT_SERVER
#include "Windows.h"
#endif
#ifndef RECTLIMIT
#define RECTLIMIT 25 /* pick a number, any number > 8 */
#endif
#include "../../mi/miexpose.c"
/* miHandleExposures
generate a region for exposures for areas that were copied from obscured or
......@@ -181,8 +142,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable,
BoxRec expBox;
Bool extents;
#ifdef NXAGENT_SERVER
/*
* Set the elements reported by the compiler
* as uninitialized.
......@@ -193,8 +152,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable,
expBox.x2 = 0;
expBox.y2 = 0;
#endif
/* This prevents warning about pscr not being used. */
pGC->pScreen = pscr = pGC->pScreen;
......@@ -414,133 +371,14 @@ miHandleExposures(pSrcDrawable, pDstDrawable,
}
}
/* send GraphicsExpose events, or a NoExpose event, based on the region */
void
miSendGraphicsExpose (client, pRgn, drawable, major, minor)
ClientPtr client;
RegionPtr pRgn;
XID drawable;
int major;
int minor;
{
if (pRgn && !RegionNil(pRgn))
{
xEvent *pEvent;
register xEvent *pe;
register BoxPtr pBox;
register int i;
int numRects;
numRects = RegionNumRects(pRgn);
pBox = RegionRects(pRgn);
if(!(pEvent = (xEvent *)ALLOCATE_LOCAL(numRects * sizeof(xEvent))))
return;
pe = pEvent;
for (i=1; i<=numRects; i++, pe++, pBox++)
{
pe->u.u.type = GraphicsExpose;
pe->u.graphicsExposure.drawable = drawable;
pe->u.graphicsExposure.x = pBox->x1;
pe->u.graphicsExposure.y = pBox->y1;
pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
pe->u.graphicsExposure.count = numRects - i;
pe->u.graphicsExposure.majorEvent = major;
pe->u.graphicsExposure.minorEvent = minor;
}
TryClientEvents(client, pEvent, numRects,
(Mask)0, NoEventMask, NullGrab);
DEALLOCATE_LOCAL(pEvent);
}
else
{
xEvent event;
memset(&event, 0, sizeof(xEvent));
event.u.u.type = NoExpose;
event.u.noExposure.drawable = drawable;
event.u.noExposure.majorEvent = major;
event.u.noExposure.minorEvent = minor;
TryClientEvents(client, &event, 1,
(Mask)0, NoEventMask, NullGrab);
}
}
void
miSendExposures(pWin, pRgn, dx, dy)
WindowPtr pWin;
RegionPtr pRgn;
register int dx, dy;
{
register BoxPtr pBox;
int numRects;
register xEvent *pEvent, *pe;
register int i;
pBox = RegionRects(pRgn);
numRects = RegionNumRects(pRgn);
if(!(pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent))))
return;
memset(pEvent, 0, numRects * sizeof(xEvent));
for (i=numRects, pe = pEvent; --i >= 0; pe++, pBox++)
{
pe->u.u.type = Expose;
pe->u.expose.window = pWin->drawable.id;
pe->u.expose.x = pBox->x1 - dx;
pe->u.expose.y = pBox->y1 - dy;
pe->u.expose.width = pBox->x2 - pBox->x1;
pe->u.expose.height = pBox->y2 - pBox->y1;
pe->u.expose.count = i;
}
#ifdef PANORAMIX
if(!noPanoramiXExtension) {
int scrnum = pWin->drawable.pScreen->myNum;
int x = 0, y = 0;
XID realWin = 0;
if(!pWin->parent) {
x = panoramiXdataPtr[scrnum].x;
y = panoramiXdataPtr[scrnum].y;
pWin = screenInfo.screens[0]->root;
realWin = pWin->drawable.id;
} else if (scrnum) {
PanoramiXRes *win;
win = PanoramiXFindIDByScrnum(XRT_WINDOW,
pWin->drawable.id, scrnum);
if(!win) {
DEALLOCATE_LOCAL(pEvent);
return;
}
realWin = win->info[0].id;
pWin = LookupIDByType(realWin, RT_WINDOW);
}
if(x || y || scrnum)
for (i = 0; i < numRects; i++) {
pEvent[i].u.expose.window = realWin;
pEvent[i].u.expose.x += x;
pEvent[i].u.expose.y += y;
}
}
#endif
DeliverEvents(pWin, pEvent, numRects, NullWindow);
DEALLOCATE_LOCAL(pEvent);
}
void
miWindowExposures(pWin, prgn, other_exposed)
WindowPtr pWin;
register RegionPtr prgn, other_exposed;
{
#ifdef NXAGENT_SERVER
int total;
#endif
RegionPtr exposures = prgn;
if (pWin->backStorage && prgn)
/*
......@@ -576,7 +414,6 @@ miWindowExposures(pWin, prgn, other_exposed)
}
exposures = other_exposed;
}
#ifdef NXAGENT_SERVER
/*
* If the number of rectangles is greater
......@@ -587,9 +424,6 @@ miWindowExposures(pWin, prgn, other_exposed)
if (clientInterested && exposures && (total > RECTLIMIT ||
(total > 4 && nxagentExtentsPredicate(total) == 1)))
#else
if (clientInterested && exposures && (RegionNumRects(exposures) > RECTLIMIT))
#endif
{
/*
* If we have LOTS of rectangles, we decide to take the extents
......@@ -638,54 +472,6 @@ miWindowExposures(pWin, prgn, other_exposed)
RegionDestroy(exposures);
}
/*
this code is highly unlikely. it is not haile selassie.
there is some hair here. we can't just use the window's
clip region as it is, because if we are painting the border,
the border is not in the client area and so we will be excluded
when we validate the GC, and if we are painting a parent-relative
background, the area we want to paint is in some other window.
since we trust the code calling us to tell us to paint only areas
that are really ours, we will temporarily give the window a
clipList the size of the whole screen and an origin at (0,0).
this more or less assumes that ddX code will do translation
based on the window's absolute position, and that ValidateGC will
look at clipList, and that no other fields from the
window will be used. it's not possible to just draw
in the root because it may be a different depth.
to get the tile to align correctly we set the GC's tile origin to
be the (x,y) of the window's upper left corner, after which we
get the right bits when drawing into the root.
because the clip_mask is being set to None, we may call DoChangeGC with
fPointer set true, thus we no longer need to install the background or
border tile in the resource table.
*/
static RESTYPE ResType = 0;
static int numGCs = 0;
static GCPtr screenContext[MAXSCREENS];
/*ARGSUSED*/
static int
tossGC (
void * value,
XID id)
{
GCPtr pGC = (GCPtr)value;
screenContext[pGC->pScreen->myNum] = (GCPtr)NULL;
FreeGC (pGC, id);
numGCs--;
if (!numGCs)
ResType = 0;
return 0;
}
void
miPaintWindow(pWin, prgn, what)
register WindowPtr pWin;
......@@ -722,8 +508,6 @@ int what;
register xRectangle *prect;
int numRects;
#ifdef NXAGENT_SERVER
/*
* Set the elements reported by the compiler
* as uninitialized.
......@@ -739,8 +523,6 @@ int what;
oldCorner.x = 0;
oldCorner.y = 0;
#endif
gcmask = 0;
if (what == PW_BACKGROUND)
......@@ -954,27 +736,3 @@ int what;
FreeScratchGC(pGC);
}
}
/* MICLEARDRAWABLE -- sets the entire drawable to the background color of
* the GC. Useful when we have a scratch drawable and need to initialize
* it. */
void
miClearDrawable(pDraw, pGC)
DrawablePtr pDraw;
GCPtr pGC;
{
XID fg = pGC->fgPixel;
XID bg = pGC->bgPixel;
xRectangle rect;
rect.x = 0;
rect.y = 0;
rect.width = pDraw->width;
rect.height = pDraw->height;
DoChangeGC(pGC, GCForeground, &bg, 0);
ValidateGC(pDraw, pGC);
(*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect);
DoChangeGC(pGC, GCForeground, &fg, 0);
ValidateGC(pDraw, pGC);
}
......@@ -40,77 +40,9 @@
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "scrnintstr.h"
#include "gcstruct.h"
#include "pixmapstr.h"
#include "windowstr.h"
#include "mi.h"
#include "picturestr.h"
#include "mipict.h"
#ifdef NXAGENT_SERVER
#include "Render.h"
#endif
void
miGlyphExtents (int nlist,
GlyphListPtr list,
GlyphPtr *glyphs,
BoxPtr extents)
{
int x1, x2, y1, y2;
int n;
GlyphPtr glyph;
int x, y;
x = 0;
y = 0;
extents->x1 = MAXSHORT;
extents->x2 = MINSHORT;
extents->y1 = MAXSHORT;
extents->y2 = MINSHORT;
while (nlist--)
{
x += list->xOff;
y += list->yOff;
n = list->len;
list++;
while (n--)
{
glyph = *glyphs++;
x1 = x - glyph->info.x;
if (x1 < MINSHORT)
x1 = MINSHORT;
y1 = y - glyph->info.y;
if (y1 < MINSHORT)
y1 = MINSHORT;
x2 = x1 + glyph->info.width;
if (x2 > MAXSHORT)
x2 = MAXSHORT;
y2 = y1 + glyph->info.height;
if (y2 > MAXSHORT)
y2 = MAXSHORT;
if (x1 < extents->x1)
extents->x1 = x1;
if (x2 > extents->x2)
extents->x2 = x2;
if (y1 < extents->y1)
extents->y1 = y1;
if (y2 > extents->y2)
extents->y2 = y2;
x += glyph->info.xOff;
y += glyph->info.yOff;
}
}
}
#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
#include "../../render/miglyph.c"
void
miGlyphs (CARD8 op,
......@@ -137,8 +69,6 @@ miGlyphs (CARD8 op,
BoxRec extents;
CARD32 component_alpha;
#ifdef NXAGENT_SERVER
/*
* Get rid of the warning.
*/
......@@ -146,15 +76,11 @@ miGlyphs (CARD8 op,
extents.x1 = 0;
extents.y1 = 0;
#endif
if (maskFormat)
{
GCPtr pGC;
xRectangle rect;
#ifdef NXAGENT_SERVER
if (nxagentGlyphsExtents != NullBox)
{
memcpy(&extents, nxagentGlyphsExtents, sizeof(BoxRec));
......@@ -168,12 +94,6 @@ miGlyphs (CARD8 op,
memcpy(nxagentGlyphsExtents, &extents, sizeof(BoxRec));
}
#else
miGlyphExtents (nlist, list, glyphs, &extents);
#endif
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
return;
width = extents.x2 - extents.x1;
......@@ -242,8 +162,6 @@ miGlyphs (CARD8 op,
glyph->info.width, glyph->info.height,
0, 0, -1, (void *) (glyph + 1));
#ifdef NXAGENT_SERVER
/*
* The following line fixes a problem with glyphs that appeared
* as clipped. It was a side effect due the validate function
......@@ -254,8 +172,6 @@ miGlyphs (CARD8 op,
pPicture->pDrawable->serialNumber = NEXT_SERIAL_NUMBER;
#endif
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
if (maskFormat)
{
......
......@@ -39,117 +39,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "scrnintstr.h"
#include "gcstruct.h"
#include "pixmapstr.h"
#include "windowstr.h"
#include "servermd.h"
#include "mi.h"
#include "picturestr.h"
#include "mipict.h"
#ifdef NXAGENT_SERVER
#include "Render.h"
#endif
PicturePtr
miCreateAlphaPicture (ScreenPtr pScreen,
PicturePtr pDst,
PictFormatPtr pPictFormat,
CARD16 width,
CARD16 height)
{
PixmapPtr pPixmap;
PicturePtr pPicture;
GCPtr pGC;
int error;
xRectangle rect;
if (width > 32767 || height > 32767)
return 0;
if (!pPictFormat)
{
if (pDst->polyEdge == PolyEdgeSharp)
pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
else
pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
if (!pPictFormat)
return 0;
}
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
pPictFormat->depth);
if (!pPixmap)
return 0;
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
if (!pGC)
{
(*pScreen->DestroyPixmap) (pPixmap);
return 0;
}
ValidateGC (&pPixmap->drawable, pGC);
rect.x = 0;
rect.y = 0;
rect.width = width;
rect.height = height;
(*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
FreeScratchGC (pGC);
pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
0, 0, serverClient, &error);
(*pScreen->DestroyPixmap) (pPixmap);
return pPicture;
}
static xFixed
miLineFixedX (xLineFixed *l, xFixed y, Bool ceil)
{
xFixed dx = l->p2.x - l->p1.x;
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
xFixed dy = l->p2.y - l->p1.y;
if (ceil)
ex += (dy - 1);
return l->p1.x + (xFixed) (ex / dy);
}
void
miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box)
{
box->y1 = MAXSHORT;
box->y2 = MINSHORT;
box->x1 = MAXSHORT;
box->x2 = MINSHORT;
for (; ntrap; ntrap--, traps++)
{
INT16 x1, y1, x2, y2;
if (!xTrapezoidValid(traps))
continue;
y1 = xFixedToInt (traps->top);
if (y1 < box->y1)
box->y1 = y1;
y2 = xFixedToInt (xFixedCeil (traps->bottom));
if (y2 > box->y2)
box->y2 = y2;
x1 = xFixedToInt (min (miLineFixedX (&traps->left, traps->top, FALSE),
miLineFixedX (&traps->left, traps->bottom, FALSE)));
if (x1 < box->x1)
box->x1 = x1;
x2 = xFixedToInt (xFixedCeil (max (miLineFixedX (&traps->right, traps->top, TRUE),
miLineFixedX (&traps->right, traps->bottom, TRUE))));
if (x2 > box->x2)
box->x2 = x2;
}
}
#include "../../render/mitrap.c"
void
miTrapezoids (CARD8 op,
......@@ -182,8 +74,6 @@ miTrapezoids (CARD8 op,
xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16;
#ifdef NXAGENT_SERVER
if (nxagentTrapezoidExtents != NullBox)
{
memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec));
......@@ -197,12 +87,6 @@ miTrapezoids (CARD8 op,
memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec));
}
#else
miTrapezoidBounds (ntrap, traps, &bounds);
#endif
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return;
pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
......
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXAGENT, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
/* $XFree86: xc/programs/Xserver/mi/miwindow.c,v 1.9tsi Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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
OPEN GROUP 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 name of The Open Group 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 Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/* $Xorg: miwindow.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include "regionstr.h"
#include "region.h"
#include "mi.h"
#include "windowstr.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "mivalidate.h"
void
miClearToBackground(pWin, x, y, w, h, generateExposures)
WindowPtr pWin;
int x,y;
int w,h;
Bool generateExposures;
{
BoxRec box;
RegionRec reg;
RegionPtr pBSReg = NullRegion;
ScreenPtr pScreen;
BoxPtr extents;
int x1, y1, x2, y2;
/* compute everything using ints to avoid overflow */
x1 = pWin->drawable.x + x;
y1 = pWin->drawable.y + y;
if (w)
x2 = x1 + (int) w;
else
x2 = x1 + (int) pWin->drawable.width - (int) x;
if (h)
y2 = y1 + h;
else
y2 = y1 + (int) pWin->drawable.height - (int) y;
extents = &pWin->clipList.extents;
/* clip the resulting rectangle to the window clipList extents. This
* makes sure that the result will fit in a box, given that the
* screen is < 32768 on a side.
*/
if (x1 < extents->x1)
x1 = extents->x1;
if (x2 > extents->x2)
x2 = extents->x2;
if (y1 < extents->y1)
y1 = extents->y1;
if (y2 > extents->y2)
y2 = extents->y2;
if (x2 <= x1 || y2 <= y1)
{
x2 = x1 = 0;
y2 = y1 = 0;
}
box.x1 = x1;
box.x2 = x2;
box.y1 = y1;
box.y2 = y2;
pScreen = pWin->drawable.pScreen;
RegionInit(&reg, &box, 1);
if (pWin->backStorage)
{
/*
* If the window has backing-store on, call through the
* ClearToBackground vector to handle the special semantics
* (i.e. things backing store is to be cleared out and
* an Expose event is to be generated for those areas in backing
* store if generateExposures is TRUE).
*/
pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
generateExposures);
}
RegionIntersect(&reg, &reg, &pWin->clipList);
if (generateExposures)
(*pScreen->WindowExposures)(pWin, &reg, pBSReg);
else if (pWin->backgroundState != None)
(*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
RegionUninit(&reg);
if (pBSReg)
RegionDestroy(pBSReg);
}
/*
* For SaveUnders using backing-store. The idea is that when a window is mapped
* with saveUnder set TRUE, any windows it obscures will have its backing
* store turned on setting the DIXsaveUnder bit,
* The backing-store code must be written to allow for this
*/
/*-
*-----------------------------------------------------------------------
* miCheckSubSaveUnder --
* Check all the inferiors of a window for coverage by saveUnder
* windows. Called from ChangeSaveUnder and CheckSaveUnder.
* This code is very inefficient.
*
* Results:
* TRUE if any windows need to have backing-store removed.
*
* Side Effects:
* Windows may have backing-store turned on or off.
*
*-----------------------------------------------------------------------
*/
static Bool
miCheckSubSaveUnder(
register WindowPtr pParent, /* Parent to check */
WindowPtr pFirst, /* first reconfigured window */
RegionPtr pRegion) /* Initial area obscured by saveUnder */
{
register WindowPtr pChild; /* Current child */
register ScreenPtr pScreen; /* Screen to use */
RegionRec SubRegion; /* Area of children obscured */
Bool res = FALSE; /* result */
Bool subInited=FALSE;/* SubRegion initialized */
pScreen = pParent->drawable.pScreen;
if ( (pChild = pParent->firstChild) )
{
/*
* build region above first changed window
*/
for (; pChild != pFirst; pChild = pChild->nextSib)
if (pChild->viewable && pChild->saveUnder)
RegionUnion(pRegion, pRegion, &pChild->borderSize);
/*
* check region below and including first changed window
*/
for (; pChild; pChild = pChild->nextSib)
{
if (pChild->viewable)
{
/*
* don't save under nephew/niece windows;
* use a separate region
*/
if (pChild->firstChild)
{
if (!subInited)
{
RegionNull(&SubRegion);
subInited = TRUE;
}
RegionCopy(&SubRegion, pRegion);
res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
&SubRegion);
}
else
{
res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
pRegion);
}
if (pChild->saveUnder)
RegionUnion(pRegion, pRegion, &pChild->borderSize);
}
}
if (subInited)
RegionUninit(&SubRegion);
}
/*
* Check the state of this window. DIX save unders are
* enabled for viewable windows with some client expressing
* exposure interest and which intersect the save under region
*/
if (pParent->viewable &&
((pParent->eventMask | wOtherEventMasks(pParent)) & ExposureMask) &&
RegionNotEmpty(&pParent->borderSize) &&
RegionContainsRect(pRegion, RegionExtents(
&pParent->borderSize)) != rgnOUT)
{
if (!pParent->DIXsaveUnder)
{
pParent->DIXsaveUnder = TRUE;
(*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore);
}
}
else
{
if (pParent->DIXsaveUnder)
{
res = TRUE;
pParent->DIXsaveUnder = FALSE;
}
}
return res;
}
/*-
*-----------------------------------------------------------------------
* miChangeSaveUnder --
* Change the save-under state of a tree of windows. Called when
* a window with saveUnder TRUE is mapped/unmapped/reconfigured.
*
* Results:
* TRUE if any windows need to have backing-store removed (which
* means that PostChangeSaveUnder needs to be called later to
* finish the job).
*
* Side Effects:
* Windows may have backing-store turned on or off.
*
*-----------------------------------------------------------------------
*/
Bool
miChangeSaveUnder(pWin, first)
register WindowPtr pWin;
WindowPtr first; /* First window to check.
* Used when pWin was restacked */
{
RegionRec rgn; /* Area obscured by saveUnder windows */
Bool res;
if (!deltaSaveUndersViewable && !numSaveUndersViewable)
return FALSE;
numSaveUndersViewable += deltaSaveUndersViewable;
deltaSaveUndersViewable = 0;
RegionNull(&rgn);
res = miCheckSubSaveUnder (pWin->parent,
pWin->saveUnder ? first : pWin->nextSib,
&rgn);
RegionUninit(&rgn);
return res;
}
/*-
*-----------------------------------------------------------------------
* miPostChangeSaveUnder --
* Actually turn backing-store off for those windows that no longer
* need to have it on.
*
* Results:
* None.
*
* Side Effects:
* Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those
* windows affected.
*
*-----------------------------------------------------------------------
*/
void
miPostChangeSaveUnder(pWin, pFirst)
WindowPtr pWin;
WindowPtr pFirst;
{
register WindowPtr pParent, pChild;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
if (!(pParent = pWin->parent))
return;
ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes;
if (!pParent->DIXsaveUnder &&
(pParent->backingStore == NotUseful) && pParent->backStorage)
(*ChangeWindowAttributes)(pParent, CWBackingStore);
if (!(pChild = pFirst))
return;
while (1)
{
if (!pChild->DIXsaveUnder &&
(pChild->backingStore == NotUseful) && pChild->backStorage)
(*ChangeWindowAttributes)(pChild, CWBackingStore);
if (pChild->firstChild)
{
pChild = pChild->firstChild;
continue;
}
while (!pChild->nextSib)
{
pChild = pChild->parent;
if (pChild == pParent)
return;
}
pChild = pChild->nextSib;
}
}
void
miMarkWindow(pWin)
register WindowPtr pWin;
{
register ValidatePtr val;
if (pWin->valdata)
return;
val = (ValidatePtr)xnfalloc(sizeof(ValidateRec));
val->before.oldAbsCorner.x = pWin->drawable.x;
val->before.oldAbsCorner.y = pWin->drawable.y;
val->before.borderVisible = NullRegion;
val->before.resized = FALSE;
pWin->valdata = val;
}
Bool
miMarkOverlappedWindows(pWin, pFirst, ppLayerWin)
WindowPtr pWin;
WindowPtr pFirst;
WindowPtr *ppLayerWin;
{
register BoxPtr box;
register WindowPtr pChild, pLast;
Bool anyMarked = FALSE;
MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow;
/* single layered systems are easy */
if (ppLayerWin) *ppLayerWin = pWin;
if (pWin == pFirst)
{
/* Blindly mark pWin and all of its inferiors. This is a slight
* overkill if there are mapped windows that outside pWin's border,
* but it's better than wasting time on RectIn checks.
*/
pChild = pWin;
while (1)
{
if (pChild->viewable)
{
if (RegionBroken(&pChild->winSize))
SetWinSize (pChild);
if (RegionBroken(&pChild->borderSize))
SetBorderSize (pChild);
(* MarkWindow)(pChild);
if (pChild->firstChild)
{
pChild = pChild->firstChild;
continue;
}
}
while (!pChild->nextSib && (pChild != pWin))
pChild = pChild->parent;
if (pChild == pWin)
break;
pChild = pChild->nextSib;
}
anyMarked = TRUE;
pFirst = pFirst->nextSib;
}
if ( (pChild = pFirst) )
{
box = RegionExtents(&pWin->borderSize);
pLast = pChild->parent->lastChild;
while (1)
{
if (pChild->viewable)
{
if (RegionBroken(&pChild->winSize))
SetWinSize (pChild);
if (RegionBroken(&pChild->borderSize))
SetBorderSize (pChild);
if (RegionContainsRect(&pChild->borderSize, box))
{
(* MarkWindow)(pChild);
anyMarked = TRUE;
if (pChild->firstChild)
{
pChild = pChild->firstChild;
continue;
}
}
}
while (!pChild->nextSib && (pChild != pLast))
pChild = pChild->parent;
if (pChild == pLast)
break;
pChild = pChild->nextSib;
}
}
if (anyMarked)
(* MarkWindow)(pWin->parent);
return anyMarked;
}
/*****
* miHandleValidateExposures(pWin)
* starting at pWin, draw background in any windows that have exposure
* regions, translate the regions, restore any backing store,
* and then send any regions still exposed to the client
*****/
void
miHandleValidateExposures(pWin)
WindowPtr pWin;
{
register WindowPtr pChild;
register ValidatePtr val;
WindowExposuresProcPtr WindowExposures;
pChild = pWin;
WindowExposures = pChild->drawable.pScreen->WindowExposures;
while (1)
{
if ( (val = pChild->valdata) )
{
if (RegionNotEmpty(&val->after.borderExposed))
(*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
&val->after.borderExposed,
PW_BORDER);
RegionUninit(&val->after.borderExposed);
(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
RegionUninit(&val->after.exposed);
xfree(val);
pChild->valdata = (ValidatePtr)NULL;
if (pChild->firstChild)
{
pChild = pChild->firstChild;
continue;
}
}
while (!pChild->nextSib && (pChild != pWin))
pChild = pChild->parent;
if (pChild == pWin)
break;
pChild = pChild->nextSib;
}
}
void
miMoveWindow(pWin, x, y, pNextSib, kind)
register WindowPtr pWin;
int x,y;
WindowPtr pNextSib;
VTKind kind;
{
WindowPtr pParent;
Bool WasViewable = (Bool)(pWin->viewable);
short bw;
RegionPtr oldRegion = NULL;
DDXPointRec oldpt;
Bool anyMarked = FALSE;
register ScreenPtr pScreen;
WindowPtr windowToValidate;
#ifdef DO_SAVE_UNDERS
Bool dosave = FALSE;
#endif
WindowPtr pLayerWin;
/* if this is a root window, can't be moved */
if (!(pParent = pWin->parent))
return ;
pScreen = pWin->drawable.pScreen;
bw = wBorderWidth (pWin);
oldpt.x = pWin->drawable.x;
oldpt.y = pWin->drawable.y;
if (WasViewable)
{
oldRegion = RegionCreate(NullBox, 1);
RegionCopy(oldRegion, &pWin->borderClip);
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
}
pWin->origin.x = x + (int)bw;
pWin->origin.y = y + (int)bw;
x = pWin->drawable.x = pParent->drawable.x + x + (int)bw;
y = pWin->drawable.y = pParent->drawable.y + y + (int)bw;
SetWinSize (pWin);
SetBorderSize (pWin);
(*pScreen->PositionWindow)(pWin, x, y);
windowToValidate = MoveWindowInStack(pWin, pNextSib);
ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0);
if (WasViewable)
{
if (pLayerWin == pWin)
anyMarked |= (*pScreen->MarkOverlappedWindows)
(pWin, windowToValidate, (WindowPtr *)NULL);
else
anyMarked |= (*pScreen->MarkOverlappedWindows)
(pWin, pLayerWin, (WindowPtr *)NULL);
#ifdef DO_SAVE_UNDERS
if (DO_SAVE_UNDERS(pWin))
{
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, windowToValidate);
}
#endif /* DO_SAVE_UNDERS */
if (anyMarked)
{
(*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind);
(* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion);
RegionDestroy(oldRegion);
/* XXX need to retile border if ParentRelative origin */
(*pScreen->HandleExposures)(pLayerWin->parent);
}
#ifdef DO_SAVE_UNDERS
if (dosave)
(*pScreen->PostChangeSaveUnder)(pLayerWin, windowToValidate);
#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind);
}
if (pWin->realized)
WindowsRestructured ();
}
/*
* pValid is a region of the screen which has been
* successfully copied -- recomputed exposed regions for affected windows
*/
static int
miRecomputeExposures (
register WindowPtr pWin,
void * value) /* must conform to VisitWindowProcPtr */
{
RegionPtr pValid = (RegionPtr)value;
if (pWin->valdata)
{
/*
* compute exposed regions of this window
*/
RegionSubtract(&pWin->valdata->after.exposed,
&pWin->clipList, pValid);
/*
* compute exposed regions of the border
*/
RegionSubtract(&pWin->valdata->after.borderExposed,
&pWin->borderClip, &pWin->winSize);
RegionSubtract(&pWin->valdata->after.borderExposed,
&pWin->valdata->after.borderExposed, pValid);
return WT_WALKCHILDREN;
}
return WT_NOMATCH;
}
void
miSlideAndSizeWindow(pWin, x, y, w, h, pSib)
register WindowPtr pWin;
int x,y;
unsigned int w, h;
WindowPtr pSib;
{
WindowPtr pParent;
Bool WasViewable = (Bool)(pWin->viewable);
unsigned short width = pWin->drawable.width,
height = pWin->drawable.height;
short oldx = pWin->drawable.x,
oldy = pWin->drawable.y;
int bw = wBorderWidth (pWin);
short dw, dh;
DDXPointRec oldpt;
RegionPtr oldRegion = NULL;
Bool anyMarked = FALSE;
register ScreenPtr pScreen;
WindowPtr pFirstChange;
register WindowPtr pChild;
RegionPtr gravitate[StaticGravity + 1];
register unsigned g;
int nx, ny; /* destination x,y */
int newx, newy; /* new inner window position */
RegionPtr pRegion = NULL;
RegionPtr destClip; /* portions of destination already written */
RegionPtr oldWinClip = NULL; /* old clip list for window */
RegionPtr borderVisible = NullRegion; /* visible area of the border */
RegionPtr bsExposed = NullRegion; /* backing store exposures */
Bool shrunk = FALSE; /* shrunk in an inner dimension */
Bool moved = FALSE; /* window position changed */
#ifdef DO_SAVE_UNDERS
Bool dosave = FALSE;
#endif
WindowPtr pLayerWin;
/* if this is a root window, can't be resized */
if (!(pParent = pWin->parent))
return ;
pScreen = pWin->drawable.pScreen;
newx = pParent->drawable.x + x + bw;
newy = pParent->drawable.y + y + bw;
if (WasViewable)
{
anyMarked = FALSE;
/*
* save the visible region of the window
*/
oldRegion = RegionCreate(NullBox, 1);
RegionCopy(oldRegion, &pWin->winSize);
/*
* categorize child windows into regions to be moved
*/
for (g = 0; g <= StaticGravity; g++)
gravitate[g] = (RegionPtr) NULL;
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
{
g = pChild->winGravity;
if (g != UnmapGravity)
{
if (!gravitate[g])
gravitate[g] = RegionCreate(NullBox, 1);
RegionUnion(gravitate[g],
gravitate[g], &pChild->borderClip);
}
else
{
UnmapWindow(pChild, TRUE);
anyMarked = TRUE;
}
}
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
&pLayerWin);
oldWinClip = NULL;
if (pWin->bitGravity != ForgetGravity)
{
oldWinClip = RegionCreate(NullBox, 1);
RegionCopy(oldWinClip, &pWin->clipList);
}
/*
* if the window is changing size, borderExposed
* can't be computed correctly without some help.
*/
if (pWin->drawable.height > h || pWin->drawable.width > w)
shrunk = TRUE;
if (newx != oldx || newy != oldy)
moved = TRUE;
if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
HasBorder (pWin))
{
borderVisible = RegionCreate(NullBox, 1);
/* for tiled borders, we punt and draw the whole thing */
if (pWin->borderIsPixel || !moved)
{
if (shrunk || moved)
RegionSubtract(borderVisible,
&pWin->borderClip,
&pWin->winSize);
else
RegionCopy(borderVisible,
&pWin->borderClip);
}
}
}
pWin->origin.x = x + bw;
pWin->origin.y = y + bw;
pWin->drawable.height = h;
pWin->drawable.width = w;
x = pWin->drawable.x = newx;
y = pWin->drawable.y = newy;
SetWinSize (pWin);
SetBorderSize (pWin);
dw = (int)w - (int)width;
dh = (int)h - (int)height;
ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh);
/* let the hardware adjust background and border pixmaps, if any */
(*pScreen->PositionWindow)(pWin, x, y);
pFirstChange = MoveWindowInStack(pWin, pSib);
if (WasViewable)
{
pRegion = RegionCreate(NullBox, 1);
if (pWin->backStorage)
RegionCopy(pRegion, &pWin->clipList);
if (pLayerWin == pWin)
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
(WindowPtr *)NULL);
else
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
(WindowPtr *)NULL);
if (pWin->valdata)
{
pWin->valdata->before.resized = TRUE;
pWin->valdata->before.borderVisible = borderVisible;
}
#ifdef DO_SAVE_UNDERS
if (DO_SAVE_UNDERS(pWin))
{
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
}
#endif /* DO_SAVE_UNDERS */
if (anyMarked)
(*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther);
/*
* the entire window is trashed unless bitGravity
* recovers portions of it
*/
RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList);
}
GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
if (pWin->backStorage &&
((pWin->backingStore == Always) || WasViewable))
{
if (!WasViewable)
pRegion = &pWin->clipList; /* a convenient empty region */
if (pWin->bitGravity == ForgetGravity)
bsExposed = (*pScreen->TranslateBackingStore)
(pWin, 0, 0, NullRegion, oldx, oldy);
else
{
bsExposed = (*pScreen->TranslateBackingStore)
(pWin, nx - x, ny - y, pRegion, oldx, oldy);
}
}
if (WasViewable)
{
/* avoid the border */
if (HasBorder (pWin))
{
int offx, offy, dx, dy;
/* kruft to avoid double translates for each gravity */
offx = 0;
offy = 0;
for (g = 0; g <= StaticGravity; g++)
{
if (!gravitate[g])
continue;
/* align winSize to gravitate[g].
* winSize is in new coordinates,
* gravitate[g] is still in old coordinates */
GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
dx = (oldx - nx) - offx;
dy = (oldy - ny) - offy;
if (dx || dy)
{
RegionTranslate(&pWin->winSize, dx, dy);
offx += dx;
offy += dy;
}
RegionIntersect(gravitate[g], gravitate[g],
&pWin->winSize);
}
/* get winSize back where it belongs */
if (offx || offy)
RegionTranslate(&pWin->winSize, -offx, -offy);
}
/*
* add screen bits to the appropriate bucket
*/
if (oldWinClip)
{
/*
* clip to new clipList
*/
RegionCopy(pRegion, oldWinClip);
RegionTranslate(pRegion, nx - oldx, ny - oldy);
RegionIntersect(oldWinClip, pRegion, &pWin->clipList);
/*
* don't step on any gravity bits which will be copied after this
* region. Note -- this assumes that the regions will be copied
* in gravity order.
*/
for (g = pWin->bitGravity + 1; g <= StaticGravity; g++)
{
if (gravitate[g])
RegionSubtract(oldWinClip, oldWinClip,
gravitate[g]);
}
RegionTranslate(oldWinClip, oldx - nx, oldy - ny);
g = pWin->bitGravity;
if (!gravitate[g])
gravitate[g] = oldWinClip;
else
{
RegionUnion(gravitate[g], gravitate[g], oldWinClip);
RegionDestroy(oldWinClip);
}
}
/*
* move the bits on the screen
*/
destClip = NULL;
for (g = 0; g <= StaticGravity; g++)
{
if (!gravitate[g])
continue;
GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
oldpt.x = oldx + (x - nx);
oldpt.y = oldy + (y - ny);
/* Note that gravitate[g] is *translated* by CopyWindow */
/* only copy the remaining useful bits */
RegionIntersect(gravitate[g], gravitate[g], oldRegion);
/* clip to not overwrite already copied areas */
if (destClip) {
RegionTranslate(destClip, oldpt.x - x, oldpt.y - y);
RegionSubtract(gravitate[g], gravitate[g], destClip);
RegionTranslate(destClip, x - oldpt.x, y - oldpt.y);
}
/* and move those bits */
if (oldpt.x != x || oldpt.y != y
#ifdef COMPOSITE
|| pWin->redirectDraw
#endif
)
{
(*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]);
}
/* remove any overwritten bits from the remaining useful bits */
RegionSubtract(oldRegion, oldRegion, gravitate[g]);
/*
* recompute exposed regions of child windows
*/
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
{
if (pChild->winGravity != g)
continue;
RegionIntersect(pRegion,
&pChild->borderClip, gravitate[g]);
TraverseTree (pChild, miRecomputeExposures, (void *)pRegion);
}
/*
* remove the successfully copied regions of the
* window from its exposed region
*/
if (g == pWin->bitGravity)
RegionSubtract(&pWin->valdata->after.exposed,
&pWin->valdata->after.exposed, gravitate[g]);
if (!destClip)
destClip = gravitate[g];
else
{
RegionUnion(destClip, destClip, gravitate[g]);
RegionDestroy(gravitate[g]);
}
}
RegionDestroy(oldRegion);
RegionDestroy(pRegion);
if (destClip)
RegionDestroy(destClip);
if (bsExposed)
{
RegionPtr valExposed = NullRegion;
if (pWin->valdata)
valExposed = &pWin->valdata->after.exposed;
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
if (valExposed)
RegionEmpty(valExposed);
RegionDestroy(bsExposed);
}
if (anyMarked)
(*pScreen->HandleExposures)(pLayerWin->parent);
#ifdef DO_SAVE_UNDERS
if (dosave)
{
(*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
}
#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange,
VTOther);
}
else if (bsExposed)
{
(*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
RegionDestroy(bsExposed);
}
if (pWin->realized)
WindowsRestructured ();
}
WindowPtr
miGetLayerWindow(pWin)
WindowPtr pWin;
{
return pWin->firstChild;
}
#ifdef SHAPE
/******
*
* miSetShape
* The border/window shape has changed. Recompute winSize/borderSize
* and send appropriate exposure events
*/
void
miSetShape(pWin)
register WindowPtr pWin;
{
Bool WasViewable = (Bool)(pWin->viewable);
register ScreenPtr pScreen = pWin->drawable.pScreen;
Bool anyMarked = FALSE;
RegionPtr pOldClip = NULL, bsExposed;
#ifdef DO_SAVE_UNDERS
Bool dosave = FALSE;
#endif
WindowPtr pLayerWin;
if (WasViewable)
{
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
&pLayerWin);
if (pWin->valdata)
{
if (HasBorder (pWin))
{
RegionPtr borderVisible;
borderVisible = RegionCreate(NullBox, 1);
RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
pWin->valdata->before.resized = TRUE;
}
}
SetWinSize (pWin);
SetBorderSize (pWin);
ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
if (WasViewable)
{
if (pWin->backStorage)
{
pOldClip = RegionCreate(NullBox, 1);
RegionCopy(pOldClip, &pWin->clipList);
}
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
(WindowPtr *)NULL);
#ifdef DO_SAVE_UNDERS
if (DO_SAVE_UNDERS(pWin))
{
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
}
#endif /* DO_SAVE_UNDERS */
if (anyMarked)
(*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
}
if (pWin->backStorage &&
((pWin->backingStore == Always) || WasViewable))
{
if (!WasViewable)
pOldClip = &pWin->clipList; /* a convenient empty region */
bsExposed = (*pScreen->TranslateBackingStore)
(pWin, 0, 0, pOldClip,
pWin->drawable.x, pWin->drawable.y);
#ifdef NXAGENT_SERVER
/*
* We got a few, rare, segfaults here after having
* started using the backing store. It may be a
* different bug but miChangeSaveUnder() calls mi-
* CheckSubSaveUnder() that, in turn, can change
* the backing store attribute of the window. This
* means that we may try to destroy the region
* even if it was not created at the beginning of
* this function as, at the time, the backing store
* was off. miCheckSubSaveUnder() appear to get a
* pointer to the parent, so maybe doesn't change
* the attribute of the window itself. This is to
* be better investigated.
*/
if (WasViewable && pOldClip)
RegionDestroy(pOldClip);
#else
if (WasViewable)
RegionDestroy(pOldClip);
#endif
if (bsExposed)
{
RegionPtr valExposed = NullRegion;
if (pWin->valdata)
valExposed = &pWin->valdata->after.exposed;
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
if (valExposed)
RegionEmpty(valExposed);
RegionDestroy(bsExposed);
}
}
if (WasViewable)
{
if (anyMarked)
(*pScreen->HandleExposures)(pLayerWin->parent);
#ifdef DO_SAVE_UNDERS
if (dosave)
(*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther);
}
if (pWin->realized)
WindowsRestructured ();
CheckCursorConfinement(pWin);
}
#endif
/* Keeps the same inside(!) origin */
void
miChangeBorderWidth(pWin, width)
register WindowPtr pWin;
unsigned int width;
{
int oldwidth;
Bool anyMarked = FALSE;
register ScreenPtr pScreen;
Bool WasViewable = (Bool)(pWin->viewable);
Bool HadBorder;
#ifdef DO_SAVE_UNDERS
Bool dosave = FALSE;
#endif
WindowPtr pLayerWin;
oldwidth = wBorderWidth (pWin);
if (oldwidth == width)
return;
HadBorder = HasBorder(pWin);
pScreen = pWin->drawable.pScreen;
if (WasViewable && width < oldwidth)
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
pWin->borderWidth = width;
SetBorderSize (pWin);
if (WasViewable)
{
if (width > oldwidth)
{
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
&pLayerWin);
/*
* save the old border visible region to correctly compute
* borderExposed.
*/
if (pWin->valdata && HadBorder)
{
RegionPtr borderVisible;
borderVisible = RegionCreate(NULL, 1);
RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
}
#ifdef DO_SAVE_UNDERS
if (DO_SAVE_UNDERS(pWin))
{
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
}
#endif /* DO_SAVE_UNDERS */
if (anyMarked)
{
(*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
(*pScreen->HandleExposures)(pLayerWin->parent);
}
#ifdef DO_SAVE_UNDERS
if (dosave)
(*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin,
VTOther);
}
if (pWin->realized)
WindowsRestructured ();
}
void
miMarkUnrealizedWindow(pChild, pWin, fromConfigure)
WindowPtr pChild;
WindowPtr pWin;
Bool fromConfigure;
{
if ((pChild != pWin) || fromConfigure)
{
RegionEmpty(&pChild->clipList);
if (pChild->drawable.pScreen->ClipNotify)
(* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
RegionEmpty(&pChild->borderClip);
}
}
void
miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
{
WindowPtr pChild;
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
{
if (pChild->drawable.depth == depth)
RegionUnion(pReg, pReg, &pChild->borderClip);
if (pChild->firstChild)
miSegregateChildren(pChild, pReg, depth);
}
}
......@@ -40,30 +40,30 @@
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
#include "regionstr.h"
#include "validate.h"
#include "windowstr.h"
#include "input.h"
#include "resource.h"
#include "colormapst.h"
#include "cursorstr.h"
#include "dixstruct.h"
#include "gcstruct.h"
#include "servermd.h"
#include "NXpicturestr.h"
#include "picturestr.h"
#include "Screen.h"
#include "Pixmaps.h"
#include "Drawable.h"
#include "Render.h"
/* prototypes */
PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp);
PicturePtr AllocatePicture (ScreenPtr pScreen);
PicturePtr CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
Mask vmask,
XID *vlist,
ClientPtr client,
int *error);
static PicturePtr createSourcePicture(void);
int FreePicture (void *value, XID pid);
#include "../../render/picture.c"
#define PANIC
#define WARNING
#undef TEST
......@@ -73,183 +73,8 @@ void *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual);
void *nxagentMatchingFormats(PictFormatPtr pForm);
int PictureScreenPrivateIndex = -1;
int PictureWindowPrivateIndex;
int PictureGeneration;
RESTYPE PictureType;
RESTYPE PictFormatType;
RESTYPE GlyphSetType;
int PictureCmapPolicy = PictureCmapPolicyDefault;
typedef struct _formatInit {
CARD32 format;
CARD8 depth;
} FormatInitRec, *FormatInitPtr;
void nxagentPictureCreateDefaultFormats(ScreenPtr pScreen, FormatInitRec *formats, int *nformats);
/* Picture Private machinery */
static int picturePrivateCount;
void
ResetPicturePrivateIndex (void)
{
picturePrivateCount = 0;
}
int
AllocatePicturePrivateIndex (void)
{
return picturePrivateCount++;
}
Bool
AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
unsigned int oldamount;
/* Round up sizes for proper alignment */
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
if (index2 >= ps->PicturePrivateLen)
{
unsigned int *nsizes;
nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes,
(index2 + 1) * sizeof(unsigned int));
if (!nsizes)
return FALSE;
while (ps->PicturePrivateLen <= index2)
{
nsizes[ps->PicturePrivateLen++] = 0;
ps->totalPictureSize += sizeof(DevUnion);
}
ps->PicturePrivateSizes = nsizes;
}
oldamount = ps->PicturePrivateSizes[index2];
if (amount > oldamount)
{
ps->PicturePrivateSizes[index2] = amount;
ps->totalPictureSize += (amount - oldamount);
}
return TRUE;
}
Bool
PictureDestroyWindow (WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pScreen);
Bool ret;
while ((pPicture = GetPictureWindow(pWindow)))
{
SetPictureWindow(pWindow, pPicture->pNext);
if (pPicture->id)
FreeResource (pPicture->id, PictureType);
FreePicture ((void *) pPicture, pPicture->id);
}
pScreen->DestroyWindow = ps->DestroyWindow;
ret = (*pScreen->DestroyWindow) (pWindow);
ps->DestroyWindow = pScreen->DestroyWindow;
pScreen->DestroyWindow = PictureDestroyWindow;
return ret;
}
Bool
PictureCloseScreen (int index, ScreenPtr pScreen)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
Bool ret;
int n;
pScreen->CloseScreen = ps->CloseScreen;
ret = (*pScreen->CloseScreen) (index, pScreen);
PictureResetFilters (pScreen);
for (n = 0; n < ps->nformats; n++)
if (ps->formats[n].type == PictTypeIndexed)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
SetPictureScreen(pScreen, 0);
if (ps->PicturePrivateSizes)
xfree (ps->PicturePrivateSizes);
xfree (ps->formats);
xfree (ps);
return ret;
}
void
PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef)
{
ScreenPtr pScreen = pColormap->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
pScreen->StoreColors = ps->StoreColors;
(*pScreen->StoreColors) (pColormap, ndef, pdef);
ps->StoreColors = pScreen->StoreColors;
pScreen->StoreColors = PictureStoreColors;
if (pColormap->class == PseudoColor || pColormap->class == GrayScale)
{
PictFormatPtr format = ps->formats;
int nformats = ps->nformats;
while (nformats--)
{
if (format->type == PictTypeIndexed &&
format->index.pColormap == pColormap)
{
(*ps->UpdateIndexed) (pScreen, format, ndef, pdef);
break;
}
format++;
}
}
}
static int
visualDepth (ScreenPtr pScreen, VisualPtr pVisual)
{
int d, v;
DepthPtr pDepth;
for (d = 0; d < pScreen->numDepths; d++)
{
pDepth = &pScreen->allowedDepths[d];
for (v = 0; v < pDepth->numVids; v++)
if (pDepth->vids[v] == pVisual->vid)
return pDepth->depth;
}
return 0;
}
static int
addFormat (FormatInitRec formats[256],
int nformat,
CARD32 format,
CARD8 depth)
{
int n;
for (n = 0; n < nformat; n++)
if (formats[n].format == format && formats[n].depth == depth)
return nformat;
formats[nformat].format = format;
formats[nformat].depth = depth;
#ifdef DEBUG
fprintf(stderr, "addFormat: Added format [%lu] depth [%d].\n", format, depth);
#endif
return ++nformat;
}
#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1))
PictFormatPtr
PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
{
......@@ -258,164 +83,10 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
FormatInitRec formats[1024];
CARD32 format;
#ifndef NXAGENT_SERVER
CARD8 depth;
VisualPtr pVisual;
int v;
int bpp;
int type;
int r, g, b;
int d;
DepthPtr pDepth;
#endif
nformats = 0;
#ifdef NXAGENT_SERVER
nxagentPictureCreateDefaultFormats(pScreen, formats, &nformats);
#else
/* formats required by protocol */
formats[nformats].format = PICT_a1;
formats[nformats].depth = 1;
nformats++;
formats[nformats].format = PICT_a8;
formats[nformats].depth = 8;
nformats++;
formats[nformats].format = PICT_a4;
formats[nformats].depth = 4;
nformats++;
formats[nformats].format = PICT_a8r8g8b8;
formats[nformats].depth = 32;
nformats++;
formats[nformats].format = PICT_x8r8g8b8;
formats[nformats].depth = 32;
nformats++;
/* now look through the depths and visuals adding other formats */
for (v = 0; v < pScreen->numVisuals; v++)
{
pVisual = &pScreen->visuals[v];
depth = visualDepth (pScreen, pVisual);
if (!depth)
continue;
bpp = BitsPerPixel (depth);
switch (pVisual->class) {
case DirectColor:
case TrueColor:
r = Ones (pVisual->redMask);
g = Ones (pVisual->greenMask);
b = Ones (pVisual->blueMask);
type = PICT_TYPE_OTHER;
/*
* Current rendering code supports only two direct formats,
* fields must be packed together at the bottom of the pixel
* and must be either RGB or BGR
*/
if (pVisual->offsetBlue == 0 &&
pVisual->offsetGreen == b &&
pVisual->offsetRed == b + g)
{
type = PICT_TYPE_ARGB;
}
else if (pVisual->offsetRed == 0 &&
pVisual->offsetGreen == r &&
pVisual->offsetBlue == r + g)
{
type = PICT_TYPE_ABGR;
}
if (type != PICT_TYPE_OTHER)
{
format = PICT_FORMAT(bpp, type, 0, r, g, b);
nformats = addFormat (formats, nformats, format, depth);
}
break;
case StaticColor:
case PseudoColor:
format = PICT_VISFORMAT (bpp, PICT_TYPE_COLOR, v);
nformats = addFormat (formats, nformats, format, depth);
break;
case StaticGray:
case GrayScale:
format = PICT_VISFORMAT (bpp, PICT_TYPE_GRAY, v);
nformats = addFormat (formats, nformats, format, depth);
break;
}
}
/*
* Walk supported depths and add useful Direct formats
*/
for (d = 0; d < pScreen->numDepths; d++)
{
pDepth = &pScreen->allowedDepths[d];
bpp = BitsPerPixel (pDepth->depth);
format = 0;
switch (bpp) {
case 16:
/* depth 12 formats */
if (pDepth->depth >= 12)
{
nformats = addFormat (formats, nformats,
PICT_x4r4g4b4, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_x4b4g4r4, pDepth->depth);
}
/* depth 15 formats */
if (pDepth->depth >= 15)
{
nformats = addFormat (formats, nformats,
PICT_x1r5g5b5, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_x1b5g5r5, pDepth->depth);
}
/* depth 16 formats */
if (pDepth->depth >= 16)
{
nformats = addFormat (formats, nformats,
PICT_a1r5g5b5, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_a1b5g5r5, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_r5g6b5, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_b5g6r5, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_a4r4g4b4, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_a4b4g4r4, pDepth->depth);
}
break;
case 24:
if (pDepth->depth >= 24)
{
nformats = addFormat (formats, nformats,
PICT_r8g8b8, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_b8g8r8, pDepth->depth);
}
break;
case 32:
if (pDepth->depth >= 24)
{
nformats = addFormat (formats, nformats,
PICT_x8r8g8b8, pDepth->depth);
nformats = addFormat (formats, nformats,
PICT_x8b8g8r8, pDepth->depth);
}
break;
}
}
#endif
pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
if (!pFormats)
return 0;
......@@ -483,7 +154,6 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
break;
}
#ifdef NXAGENT_SERVER
if (nxagentMatchingFormats(&pFormats[f]) != NULL)
{
#ifdef DEBUG
......@@ -504,1239 +174,180 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
pFormats[f].direct.blueMask, pFormats[f].direct.alpha, pFormats[f].direct.alphaMask);
#endif
}
#endif
}
*nformatp = nformats;
return pFormats;
}
static VisualPtr
PictureFindVisual (ScreenPtr pScreen, VisualID visual)
PicturePtr
AllocatePicture (ScreenPtr pScreen)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
PicturePtr pPicture;
char *ptr;
DevUnion *ppriv;
unsigned int *sizes;
unsigned int size;
int i;
VisualPtr pVisual;
for (i = 0, pVisual = pScreen->visuals;
i < pScreen->numVisuals;
i++, pVisual++)
{
if (pVisual->vid == visual)
return pVisual;
}
return 0;
}
Bool
PictureInitIndexedFormats (ScreenPtr pScreen)
{
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
PictFormatPtr format;
int nformat;
if (!ps)
return FALSE;
format = ps->formats;
nformat = ps->nformats;
while (nformat--)
{
if (format->type == PictTypeIndexed && !format->index.pColormap)
{
if (format->index.vid == pScreen->rootVisual)
format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap,
RT_COLORMAP);
else
pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
if (!pPicture)
return 0;
ppriv = (DevUnion *)(pPicture + 1);
pPicture->devPrivates = ppriv;
sizes = ps->PicturePrivateSizes;
ptr = (char *)(ppriv + ps->PicturePrivateLen);
for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
{
VisualPtr pVisual;
pVisual = PictureFindVisual (pScreen, format->index.vid);
if (CreateColormap (FakeClientID (0), pScreen,
pVisual,
&format->index.pColormap, AllocNone,
0) != Success)
if ( (size = *sizes) )
{
return FALSE;
}
}
if (!(*ps->InitIndexed) (pScreen, format))
return FALSE;
ppriv->ptr = (void *)ptr;
ptr += size;
}
format++;
else
ppriv->ptr = (void *)NULL;
}
return TRUE;
nxagentPicturePriv(pPicture) -> picture = 0;
return pPicture;
}
Bool
PictureFinishInit (void)
PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
Mask vmask,
XID *vlist,
ClientPtr client,
int *error)
{
int s;
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
for (s = 0; s < screenInfo.numScreens; s++)
pPicture = AllocatePicture (pDrawable->pScreen);
if (!pPicture)
{
if (!PictureInitIndexedFormats (screenInfo.screens[s]))
return FALSE;
(void) AnimCurInit (screenInfo.screens[s]);
*error = BadAlloc;
return 0;
}
return TRUE;
}
pPicture->id = pid;
pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
if (pDrawable->type == DRAWABLE_PIXMAP)
{
/*
* Let picture always point to the virtual pixmap.
* For sure this is not the best way to deal with
* the virtual frame-buffer.
*/
pPicture->pDrawable = nxagentVirtualDrawable(pDrawable);
Bool
PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel)
{
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
++((PixmapPtr)pDrawable)->refcnt;
pPicture->pNext = 0;
}
else
{
pPicture->pNext = GetPictureWindow(((WindowPtr) pDrawable));
SetPictureWindow(((WindowPtr) pDrawable), pPicture);
}
if (!ps)
return FALSE;
ps->subpixel = subpixel;
return TRUE;
SetPictureToDefaults (pPicture);
if (vmask)
*error = ChangePicture (pPicture, vmask, vlist, 0, client);
else
*error = Success;
if (*error == Success)
*error = (*ps->CreatePicture) (pPicture);
if (*error != Success)
{
FreePicture (pPicture, (XID) 0);
pPicture = 0;
}
return pPicture;
}
int
PictureGetSubpixelOrder (ScreenPtr pScreen)
PicturePtr
CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
{
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
if (!ps)
return SubPixelUnknown;
return ps->subpixel;
}
PictFormatPtr
PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
{
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
PictFormatPtr format;
int nformat;
int type;
if (!ps)
return 0;
format = ps->formats;
nformat = ps->nformats;
switch (pVisual->class) {
case StaticGray:
case GrayScale:
case StaticColor:
case PseudoColor:
type = PictTypeIndexed;
break;
case TrueColor:
case DirectColor:
type = PictTypeDirect;
break;
default:
return 0;
}
while (nformat--)
{
if (format->depth == depth && format->type == type)
{
if (type == PictTypeIndexed)
{
if (format->index.vid == pVisual->vid)
return format;
}
else
{
if (format->direct.redMask << format->direct.red ==
pVisual->redMask &&
format->direct.greenMask << format->direct.green ==
pVisual->greenMask &&
format->direct.blueMask << format->direct.blue ==
pVisual->blueMask)
{
return format;
}
}
}
format++;
}
return 0;
}
PictFormatPtr
PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 f)
{
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
PictFormatPtr format;
int nformat;
if (!ps)
return 0;
format = ps->formats;
nformat = ps->nformats;
while (nformat--)
{
if (format->depth == depth && format->format == (f & 0xffffff))
return format;
format++;
}
return 0;
}
int
PictureParseCmapPolicy (const char *name)
{
if ( strcmp (name, "default" ) == 0)
return PictureCmapPolicyDefault;
else if ( strcmp (name, "mono" ) == 0)
return PictureCmapPolicyMono;
else if ( strcmp (name, "gray" ) == 0)
return PictureCmapPolicyGray;
else if ( strcmp (name, "color" ) == 0)
return PictureCmapPolicyColor;
else if ( strcmp (name, "all" ) == 0)
return PictureCmapPolicyAll;
else
return PictureCmapPolicyInvalid;
}
Bool
PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{
PictureScreenPtr ps;
int n;
CARD32 type, a, r, g, b;
if (PictureGeneration != serverGeneration)
{
PictureType = CreateNewResourceType (FreePicture);
if (!PictureType)
return FALSE;
PictFormatType = CreateNewResourceType (FreePictFormat);
if (!PictFormatType)
return FALSE;
GlyphSetType = CreateNewResourceType (FreeGlyphSet);
if (!GlyphSetType)
return FALSE;
PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
if (PictureScreenPrivateIndex < 0)
return FALSE;
PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
PictureGeneration = serverGeneration;
#ifdef XResExtension
RegisterResourceName (PictureType, "PICTURE");
RegisterResourceName (PictFormatType, "PICTFORMAT");
RegisterResourceName (GlyphSetType, "GLYPHSET");
#endif
}
if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
return FALSE;
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
if (!formats)
return FALSE;
}
for (n = 0; n < nformats; n++)
{
if (!AddResource (formats[n].id, PictFormatType, (void *) (formats+n)))
{
xfree (formats);
return FALSE;
}
if (formats[n].type == PictTypeIndexed)
{
VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
if ((pVisual->class | DynamicClass) == PseudoColor)
type = PICT_TYPE_COLOR;
else
type = PICT_TYPE_GRAY;
a = r = g = b = 0;
}
else
{
if ((formats[n].direct.redMask|
formats[n].direct.blueMask|
formats[n].direct.greenMask) == 0)
type = PICT_TYPE_A;
else if (formats[n].direct.red > formats[n].direct.blue)
type = PICT_TYPE_ARGB;
else
type = PICT_TYPE_ABGR;
a = Ones (formats[n].direct.alphaMask);
r = Ones (formats[n].direct.redMask);
g = Ones (formats[n].direct.greenMask);
b = Ones (formats[n].direct.blueMask);
}
formats[n].format = PICT_FORMAT(0,type,a,r,g,b);
}
ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec));
if (!ps)
{
xfree (formats);
return FALSE;
}
SetPictureScreen(pScreen, ps);
if (!GlyphInit (pScreen))
{
SetPictureScreen(pScreen, 0);
xfree (formats);
xfree (ps);
return FALSE;
}
ps->totalPictureSize = sizeof (PictureRec);
ps->PicturePrivateSizes = 0;
ps->PicturePrivateLen = 0;
ps->formats = formats;
ps->fallback = formats;
ps->nformats = nformats;
ps->filters = 0;
ps->nfilters = 0;
ps->filterAliases = 0;
ps->nfilterAliases = 0;
ps->subpixel = SubPixelUnknown;
ps->CloseScreen = pScreen->CloseScreen;
ps->DestroyWindow = pScreen->DestroyWindow;
ps->StoreColors = pScreen->StoreColors;
pScreen->DestroyWindow = PictureDestroyWindow;
pScreen->CloseScreen = PictureCloseScreen;
pScreen->StoreColors = PictureStoreColors;
if (!PictureSetDefaultFilters (pScreen))
{
PictureResetFilters (pScreen);
SetPictureScreen(pScreen, 0);
xfree (formats);
xfree (ps);
return FALSE;
}
return TRUE;
}
void
SetPictureToDefaults (PicturePtr pPicture)
{
pPicture->refcnt = 1;
pPicture->repeat = 0;
pPicture->graphicsExposures = FALSE;
pPicture->subWindowMode = ClipByChildren;
pPicture->polyEdge = PolyEdgeSharp;
pPicture->polyMode = PolyModePrecise;
pPicture->freeCompClip = FALSE;
pPicture->clientClipType = CT_NONE;
pPicture->componentAlpha = FALSE;
pPicture->repeatType = RepeatNone;
pPicture->alphaMap = 0;
pPicture->alphaOrigin.x = 0;
pPicture->alphaOrigin.y = 0;
pPicture->clipOrigin.x = 0;
pPicture->clipOrigin.y = 0;
pPicture->clientClip = 0;
pPicture->transform = 0;
pPicture->dither = None;
pPicture->filter = PictureGetFilterId (FilterNearest, -1, TRUE);
pPicture->filter_params = 0;
pPicture->filter_nparams = 0;
pPicture->serialNumber = GC_CHANGE_SERIAL_BIT;
pPicture->stateChanges = (1 << (CPLastBit+1)) - 1;
pPicture->pSourcePict = 0;
}
PicturePtr
AllocatePicture (ScreenPtr pScreen)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
PicturePtr pPicture;
char *ptr;
DevUnion *ppriv;
unsigned int *sizes;
unsigned int size;
int i;
pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
if (!pPicture)
return 0;
ppriv = (DevUnion *)(pPicture + 1);
pPicture->devPrivates = ppriv;
sizes = ps->PicturePrivateSizes;
ptr = (char *)(ppriv + ps->PicturePrivateLen);
for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
{
if ( (size = *sizes) )
{
ppriv->ptr = (void *)ptr;
ptr += size;
}
else
ppriv->ptr = (void *)NULL;
}
nxagentPicturePriv(pPicture) -> picture = 0;
return pPicture;
}
/*
* Let picture always point to the virtual pixmap.
* For sure this is not the best way to deal with
* the virtual frame-buffer.
*/
#define NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL
PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
Mask vmask,
XID *vlist,
ClientPtr client,
int *error)
{
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
pPicture = AllocatePicture (pDrawable->pScreen);
if (!pPicture)
{
*error = BadAlloc;
return 0;
}
pPicture->id = pid;
pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
if (pDrawable->type == DRAWABLE_PIXMAP)
{
#ifdef NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL
pPicture->pDrawable = nxagentVirtualDrawable(pDrawable);
#endif
++((PixmapPtr)pDrawable)->refcnt;
pPicture->pNext = 0;
}
else
{
pPicture->pNext = GetPictureWindow(((WindowPtr) pDrawable));
SetPictureWindow(((WindowPtr) pDrawable), pPicture);
}
SetPictureToDefaults (pPicture);
if (vmask)
*error = ChangePicture (pPicture, vmask, vlist, 0, client);
else
*error = Success;
if (*error == Success)
*error = (*ps->CreatePicture) (pPicture);
if (*error != Success)
{
FreePicture (pPicture, (XID) 0);
pPicture = 0;
}
return pPicture;
}
static CARD32 xRenderColorToCard32(xRenderColor c)
{
return
(c.alpha >> 8 << 24) |
(c.red >> 8 << 16) |
(c.green & 0xff00) |
(c.blue >> 8);
}
static unsigned int premultiply(unsigned int x)
{
unsigned int a = x >> 24;
unsigned int t = (x & 0xff00ff) * a;
t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
t &= 0xff00ff;
x = ((x >> 8) & 0xff) * a;
x = (x + ((x >> 8) & 0xff) + 0x80);
x &= 0xff00;
x |= t | (a << 24);
return x;
}
static unsigned int INTERPOLATE_PIXEL_256(unsigned int x, unsigned int a,
unsigned int y, unsigned int b)
{
CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
t >>= 8;
t &= 0xff00ff;
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
x &= 0xff00ff00;
x |= t;
return x;
}
static void initGradientColorTable(SourcePictPtr pGradient, int *error)
{
int begin_pos, end_pos;
xFixed incr, dpos;
int pos, current_stop;
PictGradientStopPtr stops = pGradient->linear.stops;
int nstops = pGradient->linear.nstops;
/* The position where the gradient begins and ends */
begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
pos = 0; /* The position in the color table. */
/* Up to first point */
while (pos <= begin_pos) {
pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color);
++pos;
}
incr = (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */
dpos = incr * pos; /* The position in terms of 0-1. */
current_stop = 0; /* We always interpolate between current and current + 1. */
/* Gradient area */
while (pos < end_pos) {
unsigned int current_color = xRenderColorToCard32(stops[current_stop].color);
unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color);
int dist = (int)(256*(dpos - stops[current_stop].x)
/ (stops[current_stop+1].x - stops[current_stop].x));
int idist = 256 - dist;
pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
++pos;
dpos += incr;
if (dpos > stops[current_stop + 1].x)
++current_stop;
}
/* After last point */
while (pos < PICT_GRADIENT_STOPTABLE_SIZE) {
pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color);
++pos;
}
}
static void initGradient(SourcePictPtr pGradient, int stopCount,
xFixed *stopPoints, xRenderColor *stopColors, int *error)
{
int i;
xFixed dpos;
if (stopCount <= 0) {
*error = BadValue;
return;
}
dpos = -1;
for (i = 0; i < stopCount; ++i) {
if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) {
*error = BadValue;
return;
}
dpos = stopPoints[i];
}
pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop));
if (!pGradient->linear.stops) {
*error = BadAlloc;
return;
}
pGradient->linear.nstops = stopCount;
for (i = 0; i < stopCount; ++i) {
pGradient->linear.stops[i].x = stopPoints[i];
pGradient->linear.stops[i].color = stopColors[i];
}
initGradientColorTable(pGradient, error);
}
static PicturePtr createSourcePicture(void)
{
PicturePtr pPicture;
extern int nxagentPicturePrivateIndex;
unsigned int totalPictureSize;
DevUnion *ppriv;
char *privPictureRecAddr;
int i;
/*
* Compute size of entire PictureRect, plus privates.
*/
totalPictureSize = sizeof(PictureRec) +
picturePrivateCount * sizeof(DevUnion) +
sizeof(nxagentPrivPictureRec);
pPicture = (PicturePtr) xalloc(totalPictureSize);
if (pPicture != NULL)
{
ppriv = (DevUnion *) (pPicture + 1);
for (i = 0; i < picturePrivateCount; ++i)
{
/*
* Other privates are inaccessible.
*/
ppriv[i].ptr = NULL;
}
privPictureRecAddr = (char *) &ppriv[picturePrivateCount];
ppriv[nxagentPicturePrivateIndex].ptr = (void *) privPictureRecAddr;
pPicture -> devPrivates = ppriv;
nxagentPicturePriv(pPicture) -> picture = 0;
}
pPicture->pDrawable = 0;
pPicture->pFormat = 0;
pPicture->pNext = 0;
SetPictureToDefaults(pPicture);
return pPicture;
}
PicturePtr
CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
{
PicturePtr pPicture;
pPicture = createSourcePicture();
if (!pPicture) {
*error = BadAlloc;
return 0;
}
pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
xfree(pPicture);
return 0;
}
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha;
pPicture->pSourcePict->solidFill.fullColor.red=color->red;
pPicture->pSourcePict->solidFill.fullColor.green=color->green;
pPicture->pSourcePict->solidFill.fullColor.blue=color->blue;
return pPicture;
}
PicturePtr
CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
int nStops, xFixed *stops, xRenderColor *colors, int *error)
{
PicturePtr pPicture;
if (nStops < 2) {
*error = BadValue;
return 0;
}
pPicture = createSourcePicture();
if (!pPicture) {
*error = BadAlloc;
return 0;
}
if (p1->x == p2->x && p1->y == p2->y) {
*error = BadValue;
return 0;
}
pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
xfree(pPicture);
return 0;
}
pPicture->pSourcePict->linear.type = SourcePictTypeLinear;
pPicture->pSourcePict->linear.p1 = *p1;
pPicture->pSourcePict->linear.p2 = *p2;
initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
if (*error) {
xfree(pPicture);
return 0;
}
return pPicture;
}
#define FixedToDouble(x) ((x)/65536.)
PicturePtr
CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer,
xFixed innerRadius, xFixed outerRadius,
int nStops, xFixed *stops, xRenderColor *colors, int *error)
{
PicturePtr pPicture;
PictRadialGradient *radial;
if (nStops < 2) {
*error = BadValue;
return 0;
}
pPicture = createSourcePicture();
if (!pPicture) {
*error = BadAlloc;
return 0;
}
{
double dx = (double)(inner->x - outer->x);
double dy = (double)(inner->y - outer->y);
if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) {
*error = BadValue;
return 0;
}
}
pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
xfree(pPicture);
return 0;
}
radial = &pPicture->pSourcePict->radial;
radial->type = SourcePictTypeRadial;
{
double x = (double)innerRadius / (double)outerRadius;
radial->dx = (outer->x - inner->x);
radial->dy = (outer->y - inner->y);
radial->fx = (inner->x) - x*radial->dx;
radial->fy = (inner->y) - x*radial->dy;
radial->m = 1./(1+x);
radial->b = -x*radial->m;
radial->dx /= 65536.;
radial->dy /= 65536.;
radial->fx /= 65536.;
radial->fy /= 65536.;
x = outerRadius/65536.;
radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy;
}
initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
if (*error) {
xfree(pPicture);
return 0;
}
return pPicture;
}
PicturePtr
CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
int nStops, xFixed *stops, xRenderColor *colors, int *error)
{
PicturePtr pPicture;
if (nStops < 2) {
*error = BadValue;
return 0;
}
pPicture = createSourcePicture();
if (!pPicture) {
*error = BadAlloc;
return 0;
}
pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
xfree(pPicture);
return 0;
}
pPicture->pSourcePict->conical.type = SourcePictTypeConical;
pPicture->pSourcePict->conical.center = *center;
pPicture->pSourcePict->conical.angle = angle;
initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
if (*error) {
xfree(pPicture);
return 0;
}
return pPicture;
}
#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val)
#define NEXT_PTR(_type) ((_type) ulist++->ptr)
int
ChangePicture (PicturePtr pPicture,
Mask vmask,
XID *vlist,
DevUnion *ulist,
ClientPtr client)
{
ScreenPtr pScreen = pPicture->pDrawable ? pPicture->pDrawable->pScreen : 0;
PictureScreenPtr ps = pScreen ? GetPictureScreen(pScreen) : 0;
BITS32 index2;
int error = 0;
BITS32 maskQ;
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
maskQ = vmask;
while (vmask && !error)
{
index2 = (BITS32) lowbit (vmask);
vmask &= ~index2;
pPicture->stateChanges |= index2;
switch (index2)
{
case CPRepeat:
{
unsigned int newr;
newr = NEXT_VAL(unsigned int);
if (newr <= RepeatReflect)
{
pPicture->repeat = (newr != RepeatNone);
pPicture->repeatType = newr;
}
else
{
client->errorValue = newr;
error = BadValue;
}
}
break;
case CPAlphaMap:
{
PicturePtr pAlpha;
if (vlist)
{
Picture pid = NEXT_VAL(Picture);
if (pid == None)
pAlpha = 0;
else
{
pAlpha = (PicturePtr) SecurityLookupIDByType(client,
pid,
PictureType,
SecurityWriteAccess|SecurityReadAccess);
if (!pAlpha)
{
client->errorValue = pid;
error = BadPixmap;
break;
}
if (pAlpha->pDrawable->type != DRAWABLE_PIXMAP)
{
client->errorValue = pid;
error = BadMatch;
break;
}
}
}
else
pAlpha = NEXT_PTR(PicturePtr);
if (!error)
{
if (pAlpha && pAlpha->pDrawable->type == DRAWABLE_PIXMAP)
pAlpha->refcnt++;
if (pPicture->alphaMap)
FreePicture ((void *) pPicture->alphaMap, (XID) 0);
pPicture->alphaMap = pAlpha;
}
}
break;
case CPAlphaXOrigin:
pPicture->alphaOrigin.x = NEXT_VAL(INT16);
break;
case CPAlphaYOrigin:
pPicture->alphaOrigin.y = NEXT_VAL(INT16);
break;
case CPClipXOrigin:
pPicture->clipOrigin.x = NEXT_VAL(INT16);
break;
case CPClipYOrigin:
pPicture->clipOrigin.y = NEXT_VAL(INT16);
break;
case CPClipMask:
{
Pixmap pid;
PixmapPtr pPixmap;
int clipType;
if (!pScreen)
return BadDrawable;
if (vlist)
{
pid = NEXT_VAL(Pixmap);
if (pid == None)
{
clipType = CT_NONE;
pPixmap = NullPixmap;
}
else
{
clipType = CT_PIXMAP;
pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
pid,
RT_PIXMAP,
SecurityReadAccess);
if (!pPixmap)
{
client->errorValue = pid;
error = BadPixmap;
break;
}
}
}
else
{
pPixmap = NEXT_PTR(PixmapPtr);
if (pPixmap)
clipType = CT_PIXMAP;
else
clipType = CT_NONE;
}
if (pPixmap)
{
if ((pPixmap->drawable.depth != 1) ||
(pPixmap->drawable.pScreen != pScreen))
{
error = BadMatch;
break;
}
else
{
clipType = CT_PIXMAP;
pPixmap->refcnt++;
}
}
#ifdef DEBUG
fprintf(stderr, "ChangePicture: Going to call ChangePictureClip with clipType [%d] pPixmap [%p].\n",
clipType, (void *) pPixmap);
#endif
error = (*ps->ChangePictureClip)(pPicture, clipType,
(void *)pPixmap, 0);
break;
}
case CPGraphicsExposure:
{
unsigned int newe;
newe = NEXT_VAL(unsigned int);
if (newe <= xTrue)
pPicture->graphicsExposures = newe;
else
{
client->errorValue = newe;
error = BadValue;
}
}
break;
case CPSubwindowMode:
{
unsigned int news;
news = NEXT_VAL(unsigned int);
if (news == ClipByChildren || news == IncludeInferiors)
pPicture->subWindowMode = news;
else
{
client->errorValue = news;
error = BadValue;
}
}
break;
case CPPolyEdge:
{
unsigned int newe;
newe = NEXT_VAL(unsigned int);
if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth)
pPicture->polyEdge = newe;
else
{
client->errorValue = newe;
error = BadValue;
}
}
break;
case CPPolyMode:
{
unsigned int newm;
newm = NEXT_VAL(unsigned int);
if (newm == PolyModePrecise || newm == PolyModeImprecise)
pPicture->polyMode = newm;
else
{
client->errorValue = newm;
error = BadValue;
}
}
break;
case CPDither:
pPicture->dither = NEXT_VAL(Atom);
break;
case CPComponentAlpha:
{
unsigned int newca;
newca = NEXT_VAL (unsigned int);
if (newca <= xTrue)
pPicture->componentAlpha = newca;
else
{
client->errorValue = newca;
error = BadValue;
}
}
break;
default:
client->errorValue = maskQ;
error = BadValue;
break;
}
PicturePtr pPicture;
pPicture = createSourcePicture();
if (!pPicture) {
*error = BadAlloc;
return 0;
}
if (ps)
(*ps->ChangePicture) (pPicture, maskQ);
return error;
}
int
SetPictureClipRects (PicturePtr pPicture,
int xOrigin,
int yOrigin,
int nRect,
xRectangle *rects)
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
RegionPtr clientClip;
int result;
clientClip = RegionFromRects(
nRect, rects, CT_UNSORTED);
if (!clientClip)
return BadAlloc;
result =(*ps->ChangePictureClip) (pPicture, CT_REGION,
(void *) clientClip, 0);
if (result == Success)
{
pPicture->clipOrigin.x = xOrigin;
pPicture->clipOrigin.y = yOrigin;
pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
xfree(pPicture);
return 0;
}
return result;
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha;
pPicture->pSourcePict->solidFill.fullColor.red=color->red;
pPicture->pSourcePict->solidFill.fullColor.green=color->green;
pPicture->pSourcePict->solidFill.fullColor.blue=color->blue;
return pPicture;
}
int
SetPictureClipRegion (PicturePtr pPicture,
int xOrigin,
int yOrigin,
RegionPtr pRegion)
static PicturePtr createSourcePicture(void)
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
RegionPtr clientClip;
int result;
int type;
if (pRegion)
{
type = CT_REGION;
clientClip = RegionCreate(
RegionExtents(pRegion),
RegionNumRects(pRegion));
if (!clientClip)
return BadAlloc;
if (!RegionCopy(clientClip, pRegion))
{
RegionDestroy(clientClip);
return BadAlloc;
}
}
else
{
type = CT_NONE;
clientClip = 0;
}
PicturePtr pPicture;
result =(*ps->ChangePictureClip) (pPicture, type,
(void *) clientClip, 0);
if (result == Success)
{
pPicture->clipOrigin.x = xOrigin;
pPicture->clipOrigin.y = yOrigin;
pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
}
return result;
}
extern int nxagentPicturePrivateIndex;
unsigned int totalPictureSize;
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform)
{
static const PictTransform identity = { {
{ xFixed1, 0x00000, 0x00000 },
{ 0x00000, xFixed1, 0x00000 },
{ 0x00000, 0x00000, xFixed1 },
} };
DevUnion *ppriv;
if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0)
transform = 0;
char *privPictureRecAddr;
if (transform)
{
if (!pPicture->transform)
{
pPicture->transform = (PictTransform *) xalloc (sizeof (PictTransform));
if (!pPicture->transform)
return BadAlloc;
}
*pPicture->transform = *transform;
}
else
{
if (pPicture->transform)
{
xfree (pPicture->transform);
pPicture->transform = 0;
}
}
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
int i;
return Success;
}
/*
* Compute size of entire PictureRect, plus privates.
*/
void
CopyPicture (PicturePtr pSrc,
Mask mask,
PicturePtr pDst)
{
PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen);
Mask origMask = mask;
totalPictureSize = sizeof(PictureRec) +
picturePrivateCount * sizeof(DevUnion) +
sizeof(nxagentPrivPictureRec);
pDst->serialNumber |= GC_CHANGE_SERIAL_BIT;
pDst->stateChanges |= mask;
pPicture = (PicturePtr) xalloc(totalPictureSize);
while (mask) {
Mask bit = lowbit(mask);
if (pPicture != NULL)
{
ppriv = (DevUnion *) (pPicture + 1);
switch (bit)
for (i = 0; i < picturePrivateCount; ++i)
{
case CPRepeat:
pDst->repeat = pSrc->repeat;
pDst->repeatType = pSrc->repeatType;
break;
case CPAlphaMap:
if (pSrc->alphaMap && pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP)
pSrc->alphaMap->refcnt++;
if (pDst->alphaMap)
FreePicture ((void *) pDst->alphaMap, (XID) 0);
pDst->alphaMap = pSrc->alphaMap;
break;
case CPAlphaXOrigin:
pDst->alphaOrigin.x = pSrc->alphaOrigin.x;
break;
case CPAlphaYOrigin:
pDst->alphaOrigin.y = pSrc->alphaOrigin.y;
break;
case CPClipXOrigin:
pDst->clipOrigin.x = pSrc->clipOrigin.x;
break;
case CPClipYOrigin:
pDst->clipOrigin.y = pSrc->clipOrigin.y;
break;
case CPClipMask:
switch (pSrc->clientClipType) {
case CT_NONE:
(*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0);
break;
case CT_REGION:
if (!pSrc->clientClip) {
(*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0);
} else {
RegionPtr clientClip;
RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip;
/*
* Other privates are inaccessible.
*/
clientClip = RegionCreate(
RegionExtents(srcClientClip),
RegionNumRects(srcClientClip));
(*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0);
}
break;
default:
/* XXX: CT_PIXMAP unimplemented */
break;
}
break;
case CPGraphicsExposure:
pDst->graphicsExposures = pSrc->graphicsExposures;
break;
case CPPolyEdge:
pDst->polyEdge = pSrc->polyEdge;
break;
case CPPolyMode:
pDst->polyMode = pSrc->polyMode;
break;
case CPDither:
pDst->dither = pSrc->dither;
break;
case CPComponentAlpha:
pDst->componentAlpha = pSrc->componentAlpha;
break;
}
mask &= ~bit;
ppriv[i].ptr = NULL;
}
(*ps->ChangePicture)(pDst, origMask);
}
privPictureRecAddr = (char *) &ppriv[picturePrivateCount];
static void
ValidateOnePicture (PicturePtr pPicture)
{
if (pPicture->pDrawable && pPicture->serialNumber != pPicture->pDrawable->serialNumber)
{
PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen);
ppriv[nxagentPicturePrivateIndex].ptr = (void *) privPictureRecAddr;
pPicture -> devPrivates = ppriv;
(*ps->ValidatePicture) (pPicture, pPicture->stateChanges);
pPicture->stateChanges = 0;
pPicture->serialNumber = pPicture->pDrawable->serialNumber;
nxagentPicturePriv(pPicture) -> picture = 0;
}
}
void
ValidatePicture(PicturePtr pPicture)
{
ValidateOnePicture (pPicture);
if (pPicture->alphaMap)
ValidateOnePicture (pPicture->alphaMap);
pPicture->pDrawable = 0;
pPicture->pFormat = 0;
pPicture->pNext = 0;
SetPictureToDefaults(pPicture);
return pPicture;
}
int
......@@ -1747,9 +358,7 @@ FreePicture (void * value,
if (--pPicture->refcnt == 0)
{
#ifdef NXAGENT_SERVER
nxagentDestroyPicture(pPicture);
#endif
if (pPicture->transform)
xfree (pPicture->transform);
......@@ -1793,264 +402,6 @@ FreePicture (void * value,
return Success;
}
int
FreePictFormat (void * pPictFormat,
XID pid)
{
return Success;
}
/**
* ReduceCompositeOp is used to choose simpler ops for cases where alpha
* channels are always one and so math on the alpha channel per pixel becomes
* unnecessary. It may also avoid destination reads sometimes if apps aren't
* being careful to avoid these cases.
*/
static CARD8
ReduceCompositeOp (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst)
{
Bool no_src_alpha, no_dst_alpha;
no_src_alpha = PICT_FORMAT_COLOR(pSrc->format) &&
PICT_FORMAT_A(pSrc->format) == 0 &&
pSrc->alphaMap == NULL &&
pMask == NULL;
no_dst_alpha = PICT_FORMAT_COLOR(pDst->format) &&
PICT_FORMAT_A(pDst->format) == 0 &&
pDst->alphaMap == NULL;
/* TODO, maybe: Conjoint and Disjoint op reductions? */
/* Deal with simplifications where the source alpha is always 1. */
if (no_src_alpha)
{
switch (op) {
case PictOpOver:
op = PictOpSrc;
break;
case PictOpInReverse:
op = PictOpDst;
break;
case PictOpOutReverse:
op = PictOpClear;
break;
case PictOpAtop:
op = PictOpIn;
break;
case PictOpAtopReverse:
op = PictOpOverReverse;
break;
case PictOpXor:
op = PictOpOut;
break;
default:
break;
}
}
/* Deal with simplifications when the destination alpha is always 1 */
if (no_dst_alpha)
{
switch (op) {
case PictOpOverReverse:
op = PictOpDst;
break;
case PictOpIn:
op = PictOpSrc;
break;
case PictOpOut:
op = PictOpClear;
break;
case PictOpAtop:
op = PictOpOver;
break;
case PictOpXor:
op = PictOpOutReverse;
break;
default:
break;
}
}
/* Reduce some con/disjoint ops to the basic names. */
switch (op) {
case PictOpDisjointClear:
case PictOpConjointClear:
op = PictOpClear;
break;
case PictOpDisjointSrc:
case PictOpConjointSrc:
op = PictOpSrc;
break;
case PictOpDisjointDst:
case PictOpConjointDst:
op = PictOpDst;
break;
default:
break;
}
return op;
}
void
CompositePicture (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pSrc);
if (pMask)
ValidatePicture (pMask);
ValidatePicture (pDst);
op = ReduceCompositeOp (op, pSrc, pMask, pDst);
if (op == PictOpDst)
return;
(*ps->Composite) (op,
pSrc,
pMask,
pDst,
xSrc,
ySrc,
xMask,
yMask,
xDst,
yDst,
width,
height);
}
void
CompositeGlyphs (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlist,
GlyphListPtr lists,
GlyphPtr *glyphs)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pSrc);
ValidatePicture (pDst);
#ifdef TEST
fprintf(stderr, "CompositeGlyphs: Going to composite glyphs with "
"source at [%p] and destination at [%p].\n",
(void *) pSrc, (void *) pDst);
#endif
(*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs);
}
void
CompositeRects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pDst);
(*ps->CompositeRects) (op, pDst, color, nRect, rects);
}
void
CompositeTrapezoids (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntrap,
xTrapezoid *traps)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pSrc);
ValidatePicture (pDst);
(*ps->Trapezoids) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps);
}
void
CompositeTriangles (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntriangles,
xTriangle *triangles)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pSrc);
ValidatePicture (pDst);
(*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntriangles, triangles);
}
void
CompositeTriStrip (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoints,
xPointFixed *points)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pSrc);
ValidatePicture (pDst);
(*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
}
void
CompositeTriFan (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoints,
xPointFixed *points)
{
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
ValidatePicture (pSrc);
ValidatePicture (pDst);
(*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
}
void
AddTraps (PicturePtr pPicture,
INT16 xOff,
INT16 yOff,
int ntrap,
xTrap *traps)
{
PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen);
ValidatePicture (pPicture);
(*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps);
}
#ifndef True
# define True 1
#endif
......
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXAGENT, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
/*
* $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
/*
* This must keep the same symbol as the original
* picturestr.h or symbols will be redefined. We
* should define a new types and cast when appro-
* priate.
*/
#ifndef _PICTURESTR_H_
#define _PICTURESTR_H_
#include "NXglyphstr.h"
#include "scrnintstr.h"
#include "resource.h"
typedef struct _DirectFormat {
CARD16 red, redMask;
CARD16 green, greenMask;
CARD16 blue, blueMask;
CARD16 alpha, alphaMask;
} DirectFormatRec;
typedef struct _IndexFormat {
VisualID vid;
ColormapPtr pColormap;
int nvalues;
xIndexValue *pValues;
void *devPrivate;
} IndexFormatRec;
typedef struct _PictFormat {
CARD32 id;
CARD32 format; /* except bpp */
unsigned char type;
unsigned char depth;
DirectFormatRec direct;
IndexFormatRec index;
} PictFormatRec;
typedef struct pixman_vector PictVector, *PictVectorPtr;
typedef struct pixman_transform PictTransform, *PictTransformPtr;
#define pict_f_transform pixman_f_transform
#define PICT_GRADIENT_STOPTABLE_SIZE 1024
#define SourcePictTypeSolidFill 0
#define SourcePictTypeLinear 1
#define SourcePictTypeRadial 2
#define SourcePictTypeConical 3
typedef struct _PictSolidFill {
unsigned int type;
CARD32 color;
xRenderColor fullColor;
} PictSolidFill, *PictSolidFillPtr;
typedef struct _PictGradientStop {
xFixed x;
xRenderColor color;
} PictGradientStop, *PictGradientStopPtr;
typedef struct _PictGradient {
unsigned int type;
int nstops;
PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
} PictGradient, *PictGradientPtr;
typedef struct _PictLinearGradient {
unsigned int type;
int nstops;
PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
xPointFixed p1;
xPointFixed p2;
} PictLinearGradient, *PictLinearGradientPtr;
typedef struct _PictRadialGradient {
unsigned int type;
int nstops;
PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
double fx;
double fy;
double dx;
double dy;
double a;
double m;
double b;
} PictRadialGradient, *PictRadialGradientPtr;
typedef struct _PictConicalGradient {
unsigned int type;
int nstops;
PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
xPointFixed center;
xFixed angle;
} PictConicalGradient, *PictConicalGradientPtr;
typedef union _SourcePict {
unsigned int type;
PictSolidFill solidFill;
PictGradient gradient;
PictLinearGradient linear;
PictRadialGradient radial;
PictConicalGradient conical;
} SourcePict, *SourcePictPtr;
typedef struct _Picture {
DrawablePtr pDrawable;
PictFormatPtr pFormat;
CARD32 format; /* PICT_FORMAT */
int refcnt;
CARD32 id;
PicturePtr pNext; /* chain on same drawable */
unsigned int repeat : 1;
unsigned int graphicsExposures : 1;
unsigned int subWindowMode : 1;
unsigned int polyEdge : 1;
unsigned int polyMode : 1;
unsigned int freeCompClip : 1;
unsigned int clientClipType : 2;
unsigned int componentAlpha : 1;
unsigned int repeatType : 2;
unsigned int unused : 21;
PicturePtr alphaMap;
DDXPointRec alphaOrigin;
DDXPointRec clipOrigin;
void * clientClip;
Atom dither;
unsigned long stateChanges;
unsigned long serialNumber;
RegionPtr pCompositeClip;
DevUnion *devPrivates;
PictTransform *transform;
int filter;
xFixed *filter_params;
int filter_nparams;
SourcePictPtr pSourcePict;
} PictureRec;
typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
xFixed *params, int nparams,
int *width, int *height);
typedef struct {
char *name;
int id;
PictFilterValidateParamsProcPtr ValidateParams;
int width, height;
} PictFilterRec, *PictFilterPtr;
#define PictFilterNearest 0
#define PictFilterBilinear 1
#define PictFilterFast 2
#define PictFilterGood 3
#define PictFilterBest 4
#define PictFilterConvolution 5
typedef struct {
char *alias;
int alias_id;
int filter_id;
} PictFilterAliasRec, *PictFilterAliasPtr;
typedef int (*CreatePictureProcPtr) (PicturePtr pPicture);
typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture);
typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture,
int clipType,
void *value,
int n);
typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture);
typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture,
PictTransform *transform);
typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture,
int filter,
xFixed *params,
int nparams);
typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture);
typedef void (*ChangePictureProcPtr) (PicturePtr pPicture,
Mask mask);
typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture,
Mask mask);
typedef void (*CompositeProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
typedef void (*GlyphsProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlists,
GlyphListPtr lists,
GlyphPtr *glyphs);
typedef void (*CompositeRectsProcPtr) (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
typedef void (*RasterizeTrapezoidProcPtr)(PicturePtr pMask,
xTrapezoid *trap,
int x_off,
int y_off);
typedef void (*TrapezoidsProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntrap,
xTrapezoid *traps);
typedef void (*TrianglesProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntri,
xTriangle *tris);
typedef void (*TriStripProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoint,
xPointFixed *points);
typedef void (*TriFanProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoint,
xPointFixed *points);
typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat);
typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat);
typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat,
int ndef,
xColorItem *pdef);
typedef void (*AddTrapsProcPtr) (PicturePtr pPicture,
INT16 xOff,
INT16 yOff,
int ntrap,
xTrap *traps);
typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture,
INT16 xOff,
INT16 yOff,
int ntri,
xTriangle *tris);
typedef struct _PictureScreen {
int totalPictureSize;
unsigned int *PicturePrivateSizes;
int PicturePrivateLen;
PictFormatPtr formats;
PictFormatPtr fallback;
int nformats;
CreatePictureProcPtr CreatePicture;
DestroyPictureProcPtr DestroyPicture;
ChangePictureClipProcPtr ChangePictureClip;
DestroyPictureClipProcPtr DestroyPictureClip;
ChangePictureProcPtr ChangePicture;
ValidatePictureProcPtr ValidatePicture;
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
CompositeRectsProcPtr CompositeRects;
DestroyWindowProcPtr DestroyWindow;
CloseScreenProcPtr CloseScreen;
StoreColorsProcPtr StoreColors;
InitIndexedProcPtr InitIndexed;
CloseIndexedProcPtr CloseIndexed;
UpdateIndexedProcPtr UpdateIndexed;
int subpixel;
PictFilterPtr filters;
int nfilters;
PictFilterAliasPtr filterAliases;
int nfilterAliases;
ChangePictureTransformProcPtr ChangePictureTransform;
/**
* Called immediately after a picture's transform is changed through the
* SetPictureFilter request. Not called for source-only pictures.
*/
ChangePictureFilterProcPtr ChangePictureFilter;
DestroyPictureFilterProcPtr DestroyPictureFilter;
TrapezoidsProcPtr Trapezoids;
TrianglesProcPtr Triangles;
TriStripProcPtr TriStrip;
TriFanProcPtr TriFan;
RasterizeTrapezoidProcPtr RasterizeTrapezoid;
AddTrianglesProcPtr AddTriangles;
AddTrapsProcPtr AddTraps;
} PictureScreenRec, *PictureScreenPtr;
extern int PictureScreenPrivateIndex;
extern int PictureWindowPrivateIndex;
extern RESTYPE PictureType;
extern RESTYPE PictFormatType;
extern RESTYPE GlyphSetType;
#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (void *) (p))
#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (void *) (p))
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
if (!pPicture) { \
client->errorValue = pid; \
return err; \
} \
}
#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
if (pid == None) \
pPicture = 0; \
else { \
VERIFY_PICTURE(pPicture, pid, client, mode, err); \
} \
} \
void
ResetPicturePrivateIndex (void);
int
AllocatePicturePrivateIndex (void);
Bool
AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
Bool
PictureDestroyWindow (WindowPtr pWindow);
Bool
PictureCloseScreen (int Index, ScreenPtr pScreen);
void
PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef);
Bool
PictureInitIndexedFormats (ScreenPtr pScreen);
Bool
PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel);
int
PictureGetSubpixelOrder (ScreenPtr pScreen);
PictFormatPtr
PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp);
PictFormatPtr
PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual);
PictFormatPtr
PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format);
Bool
PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
int
PictureGetFilterId (char *filter, int len, Bool makeit);
char *
PictureGetFilterName (int id);
int
PictureAddFilter (ScreenPtr pScreen,
char *filter,
PictFilterValidateParamsProcPtr ValidateParams);
Bool
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
Bool
PictureSetDefaultFilters (ScreenPtr pScreen);
void
PictureResetFilters (ScreenPtr pScreen);
PictFilterPtr
PictureFindFilter (ScreenPtr pScreen, char *name, int len);
int
SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
xFixed *params, int nparams);
int
SetPictureFilter (PicturePtr pPicture, char *name, int len,
xFixed *params, int nparams);
Bool
PictureFinishInit (void);
void
SetPictureToDefaults (PicturePtr pPicture);
PicturePtr
AllocatePicture (ScreenPtr pScreen);
#if 0
Bool
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
#endif
PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
Mask mask,
XID *list,
ClientPtr client,
int *error);
int
ChangePicture (PicturePtr pPicture,
Mask vmask,
XID *vlist,
DevUnion *ulist,
ClientPtr client);
int
SetPictureClipRects (PicturePtr pPicture,
int xOrigin,
int yOrigin,
int nRect,
xRectangle *rects);
int
SetPictureClipRegion (PicturePtr pPicture,
int xOrigin,
int yOrigin,
RegionPtr pRegion);
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform);
void
CopyPicture (PicturePtr pSrc,
Mask mask,
PicturePtr pDst);
void
ValidatePicture(PicturePtr pPicture);
int
FreePicture (void * pPicture,
XID pid);
int
FreePictFormat (void * pPictFormat,
XID pid);
void
CompositePicture (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void
CompositeGlyphs (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlist,
GlyphListPtr lists,
GlyphPtr *glyphs);
void
CompositeRects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
void
CompositeTrapezoids (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntrap,
xTrapezoid *traps);
void
CompositeTriangles (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntriangles,
xTriangle *triangles);
void
CompositeTriStrip (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoints,
xPointFixed *points);
void
CompositeTriFan (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoints,
xPointFixed *points);
Bool
PictureTransformPoint (PictTransformPtr transform,
PictVectorPtr vector);
Bool
PictureTransformPoint3d (PictTransformPtr transform,
PictVectorPtr vector);
void RenderExtensionInit (void);
Bool
AnimCurInit (ScreenPtr pScreen);
int
AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
void
AddTraps (PicturePtr pPicture,
INT16 xOff,
INT16 yOff,
int ntraps,
xTrap *traps);
PicturePtr
CreateSolidPicture (Picture pid,
xRenderColor *color,
int *error);
PicturePtr
CreateLinearGradientPicture (Picture pid,
xPointFixed *p1,
xPointFixed *p2,
int nStops,
xFixed *stops,
xRenderColor *colors,
int *error);
PicturePtr
CreateRadialGradientPicture (Picture pid,
xPointFixed *inner,
xPointFixed *outer,
xFixed innerRadius,
xFixed outerRadius,
int nStops,
xFixed *stops,
xRenderColor *colors,
int *error);
PicturePtr
CreateConicalGradientPicture (Picture pid,
xPointFixed *center,
xFixed angle,
int nStops,
xFixed *stops,
xRenderColor *colors,
int *error);
#ifdef PANORAMIX
void PanoramiXRenderInit (void);
void PanoramiXRenderReset (void);
#endif
/*
* matrix.c
*/
extern _X_EXPORT void
PictTransform_from_xRenderTransform(PictTransformPtr pict,
xRenderTransform * render);
extern _X_EXPORT void
xRenderTransform_from_PictTransform(xRenderTransform * render,
PictTransformPtr pict);
extern _X_EXPORT Bool
PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector);
extern _X_EXPORT Bool
PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector);
#endif /* _PICTURESTR_H_ */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXAGENT, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
/*
* $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
/* this header file gets included into Xserver/render/picturestr.h */
#ifndef NX_PICTURESTR_PICTSOLIDFILL_H
#define NX_PICTURESTR_PICTSOLIDFILL_H 1
typedef struct _PictSolidFill {
unsigned int type;
CARD32 color;
xRenderColor fullColor;
} PictSolidFill, *PictSolidFillPtr;
#endif /* NX_PICTURESTR_PICTSOLIDFILL_H */
......@@ -64,42 +64,13 @@ SOFTWARE.
******************************************************************/
/* $Xorg: property.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#define NEED_REPLIES
#define NEED_EVENTS
#include <nx-X11/Xproto.h>
#include "windowstr.h"
#include "propertyst.h"
#include "dixstruct.h"
#include "../../dix/dispatch.h"
#include "swaprep.h"
#ifdef XCSECURITY
#define _SECURITY_SERVER
#include <nx-X11/extensions/security.h>
#endif
#ifdef LBX
#include "lbxserve.h"
#include "lbxtags.h"
#endif
#include "../../dix/property.c"
#include "Options.h"
#include "Rootless.h"
#include "Client.h"
#include "Windows.h"
#if defined(LBX) || defined(LBX_COMPAT)
#if 0 /* no header in X11 environment, not used in X11 environment */
int fWriteToClient(ClientPtr client, int len, char *buf)
{
return WriteToClient(client, len, buf);
}
#endif
#endif
extern Atom clientCutProperty;
#ifdef NXAGENT_SERVER
......@@ -111,129 +82,6 @@ typedef struct
nxagentWMStateRec;
#endif
/*****************************************************************
* Property Stuff
*
* ChangeProperty, DeleteProperty, GetProperties,
* ListProperties
*
* Properties below to windows. A allocate slots each time
* a property is added. No fancy searching done.
*
*****************************************************************/
#ifdef notdef
static void
PrintPropertys(WindowPtr pWin)
{
PropertyPtr pProp;
register int j;
pProp = pWin->userProps;
while (pProp)
{
ErrorF( "%x %x\n", pProp->propertyName, pProp->type);
ErrorF("property format: %d\n", pProp->format);
ErrorF("property data: \n");
for (j=0; j<(pProp->format/8)*pProp->size; j++)
ErrorF("%c\n", pProp->data[j]);
pProp = pProp->next;
}
}
#endif
int
ProcRotateProperties(ClientPtr client)
{
int i, j, delta;
REQUEST(xRotatePropertiesReq);
WindowPtr pWin;
register Atom * atoms;
PropertyPtr * props; /* array of pointer */
PropertyPtr pProp;
xEvent event;
REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
UpdateCurrentTime();
pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
SecurityWriteAccess);
if (!pWin)
return(BadWindow);
if (!stuff->nAtoms)
return(Success);
atoms = (Atom *) & stuff[1];
props = (PropertyPtr *)ALLOCATE_LOCAL(stuff->nAtoms * sizeof(PropertyPtr));
if (!props)
return(BadAlloc);
for (i = 0; i < stuff->nAtoms; i++)
{
#ifdef XCSECURITY
char action = SecurityCheckPropertyAccess(client, pWin, atoms[i],
SecurityReadAccess|SecurityWriteAccess);
#endif
if (!ValidAtom(atoms[i])
#ifdef XCSECURITY
|| (SecurityErrorOperation == action)
#endif
)
{
DEALLOCATE_LOCAL(props);
client->errorValue = atoms[i];
return BadAtom;
}
#ifdef XCSECURITY
if (SecurityIgnoreOperation == action)
{
DEALLOCATE_LOCAL(props);
return Success;
}
#endif
for (j = i + 1; j < stuff->nAtoms; j++)
if (atoms[j] == atoms[i])
{
DEALLOCATE_LOCAL(props);
return BadMatch;
}
pProp = wUserProps (pWin);
while (pProp)
{
if (pProp->propertyName == atoms[i])
goto found;
pProp = pProp->next;
}
DEALLOCATE_LOCAL(props);
return BadMatch;
found:
props[i] = pProp;
}
delta = stuff->nPositions;
/* If the rotation is a complete 360 degrees, then moving the properties
around and generating PropertyNotify events should be skipped. */
if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 )
{
while (delta < 0) /* faster if abs value is small */
delta += stuff->nAtoms;
for (i = 0; i < stuff->nAtoms; i++)
{
/* Generate a PropertyNotify event for each property whose value
is changed in the order in which they appear in the request. */
event.u.u.type = PropertyNotify;
event.u.property.window = pWin->drawable.id;
event.u.property.state = PropertyNewValue;
event.u.property.atom = props[i]->propertyName;
event.u.property.time = currentTime.milliseconds;
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms];
}
}
DEALLOCATE_LOCAL(props);
return Success;
}
int
ProcChangeProperty(ClientPtr client)
{
......@@ -315,13 +163,8 @@ ProcChangeProperty(ClientPtr client)
}
#endif
#ifdef LBX
err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type,
(int)format, (int)mode, len, TRUE, (void *)&stuff[1], TRUE, NULL);
#else
err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format,
(int)mode, len, (void *)&stuff[1], TRUE);
#endif
if (err != Success)
return err;
else
......@@ -349,11 +192,6 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
int mode, unsigned long len, void * value,
Bool sendevent)
{
#ifdef LBX
return LbxChangeWindowProperty(NULL, pWin, property, type,
format, mode, len, TRUE, value,
sendevent, NULL);
#else
PropertyPtr pProp;
xEvent event;
int sizeInBytes;
......@@ -473,92 +311,6 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
}
return(Success);
#endif
}
int
DeleteProperty(WindowPtr pWin, Atom propName)
{
PropertyPtr pProp, prevProp;
xEvent event;
if (!(pProp = wUserProps (pWin)))
return(Success);
prevProp = (PropertyPtr)NULL;
while (pProp)
{
if (pProp->propertyName == propName)
break;
prevProp = pProp;
pProp = pProp->next;
}
if (pProp)
{
if (prevProp == (PropertyPtr)NULL) /* takes care of head */
{
if (!(pWin->optional->userProps = pProp->next))
CheckWindowOptionalNeed (pWin);
}
else
{
prevProp->next = pProp->next;
}
#ifdef LBX
if (pProp->tag_id)
TagDeleteTag(pProp->tag_id);
#endif
event.u.u.type = PropertyNotify;
event.u.property.window = pWin->drawable.id;
event.u.property.state = PropertyDelete;
event.u.property.atom = pProp->propertyName;
event.u.property.time = currentTime.milliseconds;
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
xfree(pProp->data);
xfree(pProp);
}
return(Success);
}
void
DeleteAllWindowProperties(WindowPtr pWin)
{
PropertyPtr pProp, pNextProp;
xEvent event;
pProp = wUserProps (pWin);
while (pProp)
{
#ifdef LBX
if (pProp->tag_id)
TagDeleteTag(pProp->tag_id);
#endif
event.u.u.type = PropertyNotify;
event.u.property.window = pWin->drawable.id;
event.u.property.state = PropertyDelete;
event.u.property.atom = pProp->propertyName;
event.u.property.time = currentTime.milliseconds;
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
pNextProp = pProp->next;
xfree(pProp->data);
xfree(pProp);
pProp = pNextProp;
}
}
static int
NullPropertyReply(
ClientPtr client,
ATOM propertyType,
int format,
xGetPropertyReply *reply)
{
reply->nItems = 0;
reply->length = 0;
reply->bytesAfter = 0;
reply->propertyType = propertyType;
reply->format = format;
WriteReplyToClient(client, sizeof(xGenericReply), reply);
return(client->noClientException);
}
/*****************
......@@ -712,13 +464,6 @@ ProcGetProperty(ClientPtr client)
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
return(Success);
}
#ifdef LBX
/* make sure we have the current value */
if (pProp->tag_id && pProp->owner_pid) {
LbxStallPropRequest(client, pProp);
return client->noClientException;
}
#endif
/*
* Return type, format, value to client
......@@ -769,10 +514,6 @@ ProcGetProperty(ClientPtr client)
if (stuff->delete && (reply.bytesAfter == 0))
{ /* delete the Property */
#ifdef LBX
if (pProp->tag_id)
TagDeleteTag(pProp->tag_id);
#endif
if (prevProp == (PropertyPtr)NULL) /* takes care of head */
{
if (!(pWin->optional->userProps = pProp->next))
......@@ -888,10 +629,6 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete,
if (delete && (*bytesAfter == 0))
{ /* delete the Property */
#ifdef LBX
if (pProp->tag_id)
TagDeleteTag(pProp->tag_id);
#endif
if (prevProp == (PropertyPtr)NULL) /* takes care of head */
{
if (!(pWin->optional->userProps = pProp->next))
......@@ -905,89 +642,3 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete,
return(Success);
}
#endif
int
ProcListProperties(ClientPtr client)
{
Atom *pAtoms = NULL, *temppAtoms;
xListPropertiesReply xlpr;
int numProps = 0;
WindowPtr pWin;
PropertyPtr pProp;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
pProp = wUserProps (pWin);
while (pProp)
{
pProp = pProp->next;
numProps++;
}
if (numProps)
if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom))))
return(BadAlloc);
xlpr.type = X_Reply;
xlpr.nProperties = numProps;
xlpr.length = (numProps * sizeof(Atom)) >> 2;
xlpr.sequenceNumber = client->sequence;
pProp = wUserProps (pWin);
temppAtoms = pAtoms;
while (pProp)
{
*temppAtoms++ = pProp->propertyName;
pProp = pProp->next;
}
WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
if (numProps)
{
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
DEALLOCATE_LOCAL(pAtoms);
}
return(client->noClientException);
}
int
ProcDeleteProperty(register ClientPtr client)
{
WindowPtr pWin;
REQUEST(xDeletePropertyReq);
int result;
REQUEST_SIZE_MATCH(xDeletePropertyReq);
UpdateCurrentTime();
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityWriteAccess);
if (!pWin)
return(BadWindow);
if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
return (BadAtom);
}
#ifdef XCSECURITY
switch(SecurityCheckPropertyAccess(client, pWin, stuff->property,
SecurityDestroyAccess))
{
case SecurityErrorOperation:
client->errorValue = stuff->property;
return BadAtom;;
case SecurityIgnoreOperation:
return Success;
}
#endif
result = DeleteProperty(pWin, stuff->property);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
......@@ -41,38 +41,7 @@
/* */
/**************************************************************************/
#define NEED_REPLIES
#define NEED_EVENTS
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include <nx-X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "resource.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "colormapst.h"
#include "extnsionst.h"
#include "servermd.h"
#include <nx-X11/extensions/render.h>
#include <nx-X11/extensions/renderproto.h>
#include <nx-X11/Xfuncproto.h>
#include "cursorstr.h"
#ifdef EXTMODULE
#include "xf86_ansic.h"
#endif
#if !defined(UINT32_MAX)
#define UINT32_MAX 0xffffffffU
#endif
#include "NXpicturestr.h"
#include "NXglyphstr.h"
#include "../render/render.c"
#include "Trap.h"
......@@ -99,6 +68,7 @@
* From NXmiglyph.c.
*/
extern
void miGlyphExtents(int nlist, GlyphListPtr list,
GlyphPtr *glyphs, BoxPtr extents);
......@@ -106,53 +76,49 @@ void miGlyphExtents(int nlist, GlyphListPtr list,
* From NXmitrap.c.
*/
extern
void miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box);
/*
* Functions from Render.c.
*/
int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr);
void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int);
int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr);
int nxagentCreatePicture(PicturePtr, Mask);
void nxagentChangePicture(PicturePtr, Mask);
int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int);
void nxagentComposite(CARD8, PicturePtr, PicturePtr, PicturePtr, INT16, INT16,
extern int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr);
extern void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int);
extern int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr);
extern int nxagentCreatePicture(PicturePtr, Mask);
extern void nxagentChangePicture(PicturePtr, Mask);
extern int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int);
extern void nxagentComposite(CARD8, PicturePtr, PicturePtr, PicturePtr, INT16, INT16,
INT16, INT16, INT16, INT16, CARD16, CARD16);
void nxagentCompositeRects(CARD8, PicturePtr, xRenderColor *, int, xRectangle *);
void nxagentCreateGlyphSet(GlyphSetPtr glyphSet);
void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet);
void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph);
void nxagentFreeGlyphSet(GlyphSetPtr glyphSet);
void nxagentSetPictureTransform(PicturePtr pPicture, void * transform);
void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_size,
extern void nxagentCompositeRects(CARD8, PicturePtr, xRenderColor *, int, xRectangle *);
extern void nxagentCreateGlyphSet(GlyphSetPtr glyphSet);
extern void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet);
extern void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph);
extern void nxagentFreeGlyphSet(GlyphSetPtr glyphSet);
extern void nxagentSetPictureTransform(PicturePtr pPicture, void * transform);
extern void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_size,
void * params, int nparams);
void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat,
extern void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps);
void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color);
void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1,
extern void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color);
extern void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1,
xPointFixed *p2, int nStops,
xFixed *stops,
xRenderColor *colors);
void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner,
extern void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner,
xPointFixed *outer,
xFixed innerRadius,
xFixed outerRadius,
int nStops,
xFixed *stops,
xRenderColor *colors);
void nxagentRenderCreateConicalGradient(PicturePtr pPicture,
extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture,
xPointFixed *center,
xFixed angle, int nStops,
xFixed *stops,
xRenderColor *colors);
/*
* The void pointer is actually a XGlyphElt8.
*/
......@@ -160,225 +126,6 @@ void nxagentRenderCreateConicalGradient(PicturePtr pPicture,
void nxagentGlyphs(CARD8, PicturePtr, PicturePtr, PictFormatPtr,
INT16, INT16, int, void *, int, GlyphPtr *);
static int ProcRenderQueryVersion (ClientPtr pClient);
static int ProcRenderQueryPictFormats (ClientPtr pClient);
static int ProcRenderQueryPictIndexValues (ClientPtr pClient);
static int ProcRenderQueryDithers (ClientPtr pClient);
static int ProcRenderCreatePicture (ClientPtr pClient);
static int ProcRenderChangePicture (ClientPtr pClient);
static int ProcRenderSetPictureClipRectangles (ClientPtr pClient);
static int ProcRenderFreePicture (ClientPtr pClient);
static int ProcRenderComposite (ClientPtr pClient);
static int ProcRenderScale (ClientPtr pClient);
static int ProcRenderTrapezoids (ClientPtr pClient);
static int ProcRenderTriangles (ClientPtr pClient);
static int ProcRenderTriStrip (ClientPtr pClient);
static int ProcRenderTriFan (ClientPtr pClient);
static int ProcRenderColorTrapezoids (ClientPtr pClient);
static int ProcRenderColorTriangles (ClientPtr pClient);
static int ProcRenderTransform (ClientPtr pClient);
static int ProcRenderCreateGlyphSet (ClientPtr pClient);
static int ProcRenderReferenceGlyphSet (ClientPtr pClient);
static int ProcRenderFreeGlyphSet (ClientPtr pClient);
static int ProcRenderAddGlyphs (ClientPtr pClient);
static int ProcRenderAddGlyphsFromPicture (ClientPtr pClient);
static int ProcRenderFreeGlyphs (ClientPtr pClient);
static int ProcRenderCompositeGlyphs (ClientPtr pClient);
static int ProcRenderFillRectangles (ClientPtr pClient);
static int ProcRenderCreateCursor (ClientPtr pClient);
static int ProcRenderSetPictureTransform (ClientPtr pClient);
static int ProcRenderQueryFilters (ClientPtr pClient);
static int ProcRenderSetPictureFilter (ClientPtr pClient);
static int ProcRenderCreateAnimCursor (ClientPtr pClient);
static int ProcRenderAddTraps (ClientPtr pClient);
static int ProcRenderCreateSolidFill (ClientPtr pClient);
static int ProcRenderCreateLinearGradient (ClientPtr pClient);
static int ProcRenderCreateRadialGradient (ClientPtr pClient);
static int ProcRenderCreateConicalGradient (ClientPtr pClient);
static int ProcRenderDispatch (ClientPtr pClient);
static int SProcRenderQueryVersion (ClientPtr pClient);
static int SProcRenderQueryPictFormats (ClientPtr pClient);
static int SProcRenderQueryPictIndexValues (ClientPtr pClient);
static int SProcRenderQueryDithers (ClientPtr pClient);
static int SProcRenderCreatePicture (ClientPtr pClient);
static int SProcRenderChangePicture (ClientPtr pClient);
static int SProcRenderSetPictureClipRectangles (ClientPtr pClient);
static int SProcRenderFreePicture (ClientPtr pClient);
static int SProcRenderComposite (ClientPtr pClient);
static int SProcRenderScale (ClientPtr pClient);
static int SProcRenderTrapezoids (ClientPtr pClient);
static int SProcRenderTriangles (ClientPtr pClient);
static int SProcRenderTriStrip (ClientPtr pClient);
static int SProcRenderTriFan (ClientPtr pClient);
static int SProcRenderColorTrapezoids (ClientPtr pClient);
static int SProcRenderColorTriangles (ClientPtr pClient);
static int SProcRenderTransform (ClientPtr pClient);
static int SProcRenderCreateGlyphSet (ClientPtr pClient);
static int SProcRenderReferenceGlyphSet (ClientPtr pClient);
static int SProcRenderFreeGlyphSet (ClientPtr pClient);
static int SProcRenderAddGlyphs (ClientPtr pClient);
static int SProcRenderAddGlyphsFromPicture (ClientPtr pClient);
static int SProcRenderFreeGlyphs (ClientPtr pClient);
static int SProcRenderCompositeGlyphs (ClientPtr pClient);
static int SProcRenderFillRectangles (ClientPtr pClient);
static int SProcRenderCreateCursor (ClientPtr pClient);
static int SProcRenderSetPictureTransform (ClientPtr pClient);
static int SProcRenderQueryFilters (ClientPtr pClient);
static int SProcRenderSetPictureFilter (ClientPtr pClient);
static int SProcRenderCreateAnimCursor (ClientPtr pClient);
static int SProcRenderAddTraps (ClientPtr pClient);
static int SProcRenderCreateSolidFill (ClientPtr pClient);
static int SProcRenderCreateLinearGradient (ClientPtr pClient);
static int SProcRenderCreateRadialGradient (ClientPtr pClient);
static int SProcRenderCreateConicalGradient (ClientPtr pClient);
static int SProcRenderDispatch (ClientPtr pClient);
int (*ProcRenderVector[RenderNumberRequests])(ClientPtr) = {
ProcRenderQueryVersion,
ProcRenderQueryPictFormats,
ProcRenderQueryPictIndexValues,
ProcRenderQueryDithers,
ProcRenderCreatePicture,
ProcRenderChangePicture,
ProcRenderSetPictureClipRectangles,
ProcRenderFreePicture,
ProcRenderComposite,
ProcRenderScale,
ProcRenderTrapezoids,
ProcRenderTriangles,
ProcRenderTriStrip,
ProcRenderTriFan,
ProcRenderColorTrapezoids,
ProcRenderColorTriangles,
ProcRenderTransform,
ProcRenderCreateGlyphSet,
ProcRenderReferenceGlyphSet,
ProcRenderFreeGlyphSet,
ProcRenderAddGlyphs,
ProcRenderAddGlyphsFromPicture,
ProcRenderFreeGlyphs,
ProcRenderCompositeGlyphs,
ProcRenderCompositeGlyphs,
ProcRenderCompositeGlyphs,
ProcRenderFillRectangles,
ProcRenderCreateCursor,
ProcRenderSetPictureTransform,
ProcRenderQueryFilters,
ProcRenderSetPictureFilter,
ProcRenderCreateAnimCursor,
ProcRenderAddTraps,
ProcRenderCreateSolidFill,
ProcRenderCreateLinearGradient,
ProcRenderCreateRadialGradient,
ProcRenderCreateConicalGradient
};
int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = {
SProcRenderQueryVersion,
SProcRenderQueryPictFormats,
SProcRenderQueryPictIndexValues,
SProcRenderQueryDithers,
SProcRenderCreatePicture,
SProcRenderChangePicture,
SProcRenderSetPictureClipRectangles,
SProcRenderFreePicture,
SProcRenderComposite,
SProcRenderScale,
SProcRenderTrapezoids,
SProcRenderTriangles,
SProcRenderTriStrip,
SProcRenderTriFan,
SProcRenderColorTrapezoids,
SProcRenderColorTriangles,
SProcRenderTransform,
SProcRenderCreateGlyphSet,
SProcRenderReferenceGlyphSet,
SProcRenderFreeGlyphSet,
SProcRenderAddGlyphs,
SProcRenderAddGlyphsFromPicture,
SProcRenderFreeGlyphs,
SProcRenderCompositeGlyphs,
SProcRenderCompositeGlyphs,
SProcRenderCompositeGlyphs,
SProcRenderFillRectangles,
SProcRenderCreateCursor,
SProcRenderSetPictureTransform,
SProcRenderQueryFilters,
SProcRenderSetPictureFilter,
SProcRenderCreateAnimCursor,
SProcRenderAddTraps,
SProcRenderCreateSolidFill,
SProcRenderCreateLinearGradient,
SProcRenderCreateRadialGradient,
SProcRenderCreateConicalGradient
};
static void
RenderResetProc (ExtensionEntry *extEntry);
#if 0
static CARD8 RenderReqCode;
#endif
int RenderErrBase;
int RenderClientPrivateIndex;
typedef struct _RenderClient {
int major_version;
int minor_version;
} RenderClientRec, *RenderClientPtr;
#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr)
static void
RenderClientCallback (CallbackListPtr *list,
void * closure,
void * data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
RenderClientPtr pRenderClient = GetRenderClient (pClient);
pRenderClient->major_version = 0;
pRenderClient->minor_version = 0;
}
void
RenderExtensionInit (void)
{
ExtensionEntry *extEntry;
if (!PictureType)
return;
if (!PictureFinishInit ())
return;
RenderClientPrivateIndex = AllocateClientPrivateIndex ();
if (!AllocateClientPrivate (RenderClientPrivateIndex,
sizeof (RenderClientRec)))
return;
if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
return;
extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors,
ProcRenderDispatch, SProcRenderDispatch,
RenderResetProc, StandardMinorOpcode);
if (!extEntry)
return;
#if 0
RenderReqCode = (CARD8) extEntry->base;
#endif
RenderErrBase = extEntry->errorBase;
}
static void
RenderResetProc (ExtensionEntry *extEntry)
{
ResetPicturePrivateIndex();
ResetGlyphSetPrivateIndex();
}
static int
ProcRenderQueryVersion (ClientPtr client)
{
......@@ -408,43 +155,6 @@ ProcRenderQueryVersion (ClientPtr client)
return (client->noClientException);
}
#if 0
static int
VisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
{
DepthPtr pDepth;
int d, v;
for (d = 0; d < pScreen->numDepths; d++)
{
pDepth = pScreen->allowedDepths + d;
for (v = 0; v < pDepth->numVids; v++)
{
if (pDepth->vids[v] == pVisual->vid)
return pDepth->depth;
}
}
return 0;
}
#endif
static VisualPtr
findVisual (ScreenPtr pScreen, VisualID vid)
{
VisualPtr pVisual;
int v;
for (v = 0; v < pScreen->numVisuals; v++)
{
pVisual = pScreen->visuals + v;
if (pVisual->vid == vid)
return pVisual;
}
return 0;
}
extern char *ConnectionInfo;
static int
ProcRenderQueryPictFormats (ClientPtr client)
{
......@@ -657,76 +367,6 @@ ProcRenderQueryPictFormats (ClientPtr client)
}
static int
ProcRenderQueryPictIndexValues (ClientPtr client)
{
PictFormatPtr pFormat;
int num;
int rlength;
int i, n;
REQUEST(xRenderQueryPictIndexValuesReq);
xRenderQueryPictIndexValuesReply *reply;
xIndexValue *values;
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
stuff->format,
PictFormatType,
SecurityReadAccess);
if (!pFormat)
{
client->errorValue = stuff->format;
return RenderErrBase + BadPictFormat;
}
if (pFormat->type != PictTypeIndexed)
{
client->errorValue = stuff->format;
return BadMatch;
}
num = pFormat->index.nvalues;
rlength = (sizeof (xRenderQueryPictIndexValuesReply) +
num * sizeof(xIndexValue));
reply = (xRenderQueryPictIndexValuesReply *) xalloc (rlength);
if (!reply)
return BadAlloc;
reply->type = X_Reply;
reply->sequenceNumber = client->sequence;
reply->length = (rlength - sizeof(xGenericReply)) >> 2;
reply->numIndexValues = num;
values = (xIndexValue *) (reply + 1);
memcpy (reply + 1, pFormat->index.pValues, num * sizeof (xIndexValue));
if (client->swapped)
{
for (i = 0; i < num; i++)
{
swapl (&values[i].pixel, n);
swaps (&values[i].red, n);
swaps (&values[i].green, n);
swaps (&values[i].blue, n);
swaps (&values[i].alpha, n);
}
swaps (&reply->sequenceNumber, n);
swapl (&reply->length, n);
swapl (&reply->numIndexValues, n);
}
WriteToClient(client, rlength, (char *) reply);
xfree(reply);
return (client->noClientException);
}
static int
ProcRenderQueryDithers (ClientPtr client)
{
return BadImplementation;
}
static int
ProcRenderCreatePicture (ClientPtr client)
{
PicturePtr pPicture;
......@@ -836,33 +476,6 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
return(result);
}
static int
ProcRenderFreePicture (ClientPtr client)
{
PicturePtr pPicture;
REQUEST(xRenderFreePictureReq);
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityDestroyAccess,
RenderErrBase + BadPicture);
FreeResource (stuff->picture, RT_NONE);
return(client->noClientException);
}
static Bool
PictOpValid (CARD8 op)
{
if (/*PictOpMinimum <= op && */ op <= PictOpMaximum)
return TRUE;
if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum)
return TRUE;
if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum)
return TRUE;
return FALSE;
}
/*
* Check if both pictures have drawables which are
* virtual pixmaps. See the corresponding define
......@@ -948,14 +561,8 @@ ProcRenderComposite (ClientPtr client)
RenderErrBase + BadPicture);
VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess,
RenderErrBase + BadPicture);
/*
FIXME: Imported change from newest version of Xorg. Changed pSrc to pDst.
if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) ||
(pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen))
return BadMatch;
*/
if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) ||
(pMask && pMask->pDrawable && pDst->pDrawable->pScreen != pMask->pDrawable->pScreen))
return BadMatch;
......@@ -1062,12 +669,6 @@ FIXME: Imported change from newest version of Xorg. Changed pSrc to pDst.
}
static int
ProcRenderScale (ClientPtr client)
{
return BadImplementation;
}
static int
ProcRenderTrapezoids (ClientPtr client)
{
int ntraps;
......@@ -1139,165 +740,6 @@ ProcRenderTrapezoids (ClientPtr client)
}
static int
ProcRenderTriangles (ClientPtr client)
{
int ntris;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
if (!PictOpValid (stuff->op))
{
client->errorValue = stuff->op;
return BadValue;
}
VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
if (!pDst->pDrawable)
return BadDrawable;
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
return BadMatch;
if (stuff->maskFormat)
{
pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
stuff->maskFormat,
PictFormatType,
SecurityReadAccess);
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
}
else
pFormat = 0;
ntris = (client->req_len << 2) - sizeof (xRenderTrianglesReq);
if (ntris % sizeof (xTriangle))
return BadLength;
ntris /= sizeof (xTriangle);
if (ntris)
CompositeTriangles (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
ntris, (xTriangle *) &stuff[1]);
return client->noClientException;
}
static int
ProcRenderTriStrip (ClientPtr client)
{
int npoints;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
if (!PictOpValid (stuff->op))
{
client->errorValue = stuff->op;
return BadValue;
}
VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
if (!pDst->pDrawable)
return BadDrawable;
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
return BadMatch;
if (stuff->maskFormat)
{
pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
stuff->maskFormat,
PictFormatType,
SecurityReadAccess);
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
}
else
pFormat = 0;
npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq));
if (npoints & 4)
return(BadLength);
npoints >>= 3;
if (npoints >= 3)
CompositeTriStrip (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
npoints, (xPointFixed *) &stuff[1]);
return client->noClientException;
}
static int
ProcRenderTriFan (ClientPtr client)
{
int npoints;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
if (!PictOpValid (stuff->op))
{
client->errorValue = stuff->op;
return BadValue;
}
VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
if (!pDst->pDrawable)
return BadDrawable;
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
return BadMatch;
if (stuff->maskFormat)
{
pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
stuff->maskFormat,
PictFormatType,
SecurityReadAccess);
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
}
else
pFormat = 0;
npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq));
if (npoints & 4)
return(BadLength);
npoints >>= 3;
if (npoints >= 3)
CompositeTriFan (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
npoints, (xPointFixed *) &stuff[1]);
return client->noClientException;
}
static int
ProcRenderColorTrapezoids (ClientPtr client)
{
return BadImplementation;
}
static int
ProcRenderColorTriangles (ClientPtr client)
{
return BadImplementation;
}
static int
ProcRenderTransform (ClientPtr client)
{
return BadImplementation;
}
static int
ProcRenderCreateGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
......@@ -1377,9 +819,6 @@ ProcRenderReferenceGlyphSet (ClientPtr client)
return client->noClientException;
}
#define NLOCALDELTA 64
#define NLOCALGLYPH 256
static int
ProcRenderFreeGlyphSet (ClientPtr client)
{
......@@ -1403,29 +842,16 @@ ProcRenderFreeGlyphSet (ClientPtr client)
return client->noClientException;
}
typedef struct _GlyphNew {
Glyph id;
GlyphPtr glyph;
} GlyphNewRec, *GlyphNewPtr;
static int
ProcRenderAddGlyphs (ClientPtr client)
ProcRenderFreeGlyphs (ClientPtr client)
{
REQUEST(xRenderFreeGlyphsReq);
GlyphSetPtr glyphSet;
REQUEST(xRenderAddGlyphsReq);
GlyphNewRec glyphsLocal[NLOCALGLYPH];
GlyphNewPtr glyphsBase, glyphs;
GlyphPtr glyph = NULL;
int remain, nglyphs;
int nglyph;
CARD32 *gids;
xGlyphInfo *gi;
CARD8 *bits;
int size;
int err = BadAlloc;
int totSizeImages;
CARD32 glyph;
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
stuff->glyphset,
GlyphSetType,
......@@ -1435,120 +861,12 @@ ProcRenderAddGlyphs (ClientPtr client)
client->errorValue = stuff->glyphset;
return RenderErrBase + BadGlyphSet;
}
nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2;
gids = (CARD32 *) (stuff + 1);
nglyphs = stuff->nglyphs;
if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec))
return BadAlloc;
nxagentFreeGlyphs(glyphSet, gids, nglyph);
if (nglyphs <= NLOCALGLYPH)
glyphsBase = glyphsLocal;
else
{
glyphsBase = (GlyphNewPtr) Xalloc (nglyphs * sizeof (GlyphNewRec));
if (!glyphsBase)
return BadAlloc;
}
remain = (client->req_len << 2) - sizeof (xRenderAddGlyphsReq);
glyphs = glyphsBase;
totSizeImages = 0;
gids = (CARD32 *) (stuff + 1);
gi = (xGlyphInfo *) (gids + nglyphs);
bits = (CARD8 *) (gi + nglyphs);
remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs;
while (remain >= 0 && nglyphs)
{
glyph = AllocateGlyph (gi, glyphSet->fdepth);
if (!glyph)
{
err = BadAlloc;
goto bail;
}
glyphs->glyph = glyph;
glyphs->id = *gids;
size = glyph->size - sizeof (xGlyphInfo);
if (remain < size)
break;
memcpy ((CARD8 *) (glyph + 1), bits, size);
if (size & 3)
size += 4 - (size & 3);
bits += size;
totSizeImages += size;
remain -= size;
gi++;
gids++;
glyphs++;
nglyphs--;
}
if (nglyphs || remain)
{
err = BadLength;
goto bail;
}
nglyphs = stuff->nglyphs;
if (!ResizeGlyphSet (glyphSet, nglyphs))
{
err = BadAlloc;
goto bail;
}
glyphs = glyphsBase;
while (nglyphs--) {
AddGlyph (glyphSet, glyphs->glyph, glyphs->id);
glyphs++;
}
if (glyphsBase != glyphsLocal)
Xfree (glyphsBase);
return client->noClientException;
bail:
while (glyphs != glyphsBase)
{
--glyphs;
xfree (glyphs->glyph);
}
if (glyphsBase != glyphsLocal)
Xfree (glyphsBase);
return err;
}
static int
ProcRenderAddGlyphsFromPicture (ClientPtr client)
{
return BadImplementation;
}
static int
ProcRenderFreeGlyphs (ClientPtr client)
{
REQUEST(xRenderFreeGlyphsReq);
GlyphSetPtr glyphSet;
int nglyph;
CARD32 *gids;
CARD32 glyph;
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
stuff->glyphset,
GlyphSetType,
SecurityWriteAccess);
if (!glyphSet)
{
client->errorValue = stuff->glyphset;
return RenderErrBase + BadGlyphSet;
}
nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2;
gids = (CARD32 *) (stuff + 1);
nxagentFreeGlyphs(glyphSet, gids, nglyph);
while (nglyph-- > 0)
while (nglyph-- > 0)
{
glyph = *gids++;
if (!DeleteGlyph (glyphSet, glyph))
......@@ -1866,32 +1184,6 @@ ProcRenderFillRectangles (ClientPtr client)
return client->noClientException;
}
static void
SetBit (unsigned char *line, int x, int bit)
{
unsigned char mask;
if (screenInfo.bitmapBitOrder == LSBFirst)
mask = (1 << (x & 7));
else
mask = (0x80 >> (x & 7));
/* XXX assumes byte order is host byte order */
line += (x >> 3);
if (bit)
*line |= mask;
else
*line &= ~mask;
}
#define DITHER_DIM 2
static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = {
{ 1, 3, },
{ 4, 2, },
};
#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1)
static int
ProcRenderCreateCursor (ClientPtr client)
{
......@@ -2146,115 +1438,6 @@ ProcRenderSetPictureTransform (ClientPtr client)
}
static int
ProcRenderQueryFilters (ClientPtr client)
{
REQUEST (xRenderQueryFiltersReq);
DrawablePtr pDrawable;
xRenderQueryFiltersReply *reply;
int nbytesName;
int nnames;
ScreenPtr pScreen;
PictureScreenPtr ps;
int i, j;
int len;
int total_bytes;
INT16 *aliases;
char *names;
REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, SecurityReadAccess);
pScreen = pDrawable->pScreen;
nbytesName = 0;
nnames = 0;
ps = GetPictureScreenIfSet(pScreen);
if (ps)
{
for (i = 0; i < ps->nfilters; i++)
nbytesName += 1 + strlen (ps->filters[i].name);
for (i = 0; i < ps->nfilterAliases; i++)
nbytesName += 1 + strlen (ps->filterAliases[i].alias);
nnames = ps->nfilters + ps->nfilterAliases;
}
len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2);
total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
reply = (xRenderQueryFiltersReply *) xalloc (total_bytes);
if (!reply)
return BadAlloc;
aliases = (INT16 *) (reply + 1);
names = (char *) (aliases + ((nnames + 1) & ~1));
reply->type = X_Reply;
reply->sequenceNumber = client->sequence;
reply->length = len;
reply->numAliases = nnames;
reply->numFilters = nnames;
if (ps)
{
/* fill in alias values */
for (i = 0; i < ps->nfilters; i++)
aliases[i] = FilterAliasNone;
for (i = 0; i < ps->nfilterAliases; i++)
{
for (j = 0; j < ps->nfilters; j++)
if (ps->filterAliases[i].filter_id == ps->filters[j].id)
break;
if (j == ps->nfilters)
{
for (j = 0; j < ps->nfilterAliases; j++)
if (ps->filterAliases[i].filter_id ==
ps->filterAliases[j].alias_id)
{
break;
}
if (j == ps->nfilterAliases)
j = FilterAliasNone;
else
j = j + ps->nfilters;
}
aliases[i + ps->nfilters] = j;
}
/* fill in filter names */
for (i = 0; i < ps->nfilters; i++)
{
j = strlen (ps->filters[i].name);
*names++ = j;
strncpy (names, ps->filters[i].name, j);
names += j;
}
/* fill in filter alias names */
for (i = 0; i < ps->nfilterAliases; i++)
{
j = strlen (ps->filterAliases[i].alias);
*names++ = j;
strncpy (names, ps->filterAliases[i].alias, j);
names += j;
}
}
if (client->swapped)
{
register int n;
for (i = 0; i < (int)reply->numAliases; i++)
{
swaps (&aliases[i], n);
}
swaps(&reply->sequenceNumber, n);
swapl(&reply->length, n);
swapl(&reply->numAliases, n);
swapl(&reply->numFilters, n);
}
WriteToClient(client, total_bytes, (char *) reply);
xfree (reply);
return(client->noClientException);
}
static int
ProcRenderSetPictureFilter (ClientPtr client)
{
REQUEST (xRenderSetPictureFilterReq);
......@@ -2329,29 +1512,6 @@ ProcRenderCreateAnimCursor (ClientPtr client)
return BadAlloc;
}
static int
ProcRenderAddTraps (ClientPtr client)
{
int ntraps;
PicturePtr pPicture;
REQUEST(xRenderAddTrapsReq);
REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
if (!pPicture->pDrawable)
return BadDrawable;
ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq);
if (ntraps % sizeof (xTrap))
return BadLength;
ntraps /= sizeof (xTrap);
if (ntraps)
AddTraps (pPicture,
stuff->xOff, stuff->yOff,
ntraps, (xTrap *) &stuff[1]);
return client->noClientException;
}
static int ProcRenderCreateSolidFill(ClientPtr client)
{
PicturePtr pPicture;
......@@ -2530,1348 +1690,38 @@ ProcRenderDispatch (ClientPtr client)
}
static int
SProcRenderQueryVersion (ClientPtr client)
{
register int n;
REQUEST(xRenderQueryVersionReq);
REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
swaps(&stuff->length, n);
swapl(&stuff->majorVersion, n);
swapl(&stuff->minorVersion, n);
return (*ProcRenderVector[stuff->renderReqType])(client);
}
static int
SProcRenderQueryPictFormats (ClientPtr client)
{
register int n;
REQUEST(xRenderQueryPictFormatsReq);
REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
swaps(&stuff->length, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderQueryPictIndexValues (ClientPtr client)
{
register int n;
REQUEST(xRenderQueryPictIndexValuesReq);
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
swaps(&stuff->length, n);
swapl(&stuff->format, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderQueryDithers (ClientPtr client)
{
return BadImplementation;
}
static int
SProcRenderCreatePicture (ClientPtr client)
{
register int n;
REQUEST(xRenderCreatePictureReq);
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
swaps(&stuff->length, n);
swapl(&stuff->pid, n);
swapl(&stuff->drawable, n);
swapl(&stuff->format, n);
swapl(&stuff->mask, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderChangePicture (ClientPtr client)
{
register int n;
REQUEST(xRenderChangePictureReq);
REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
swaps(&stuff->length, n);
swapl(&stuff->picture, n);
swapl(&stuff->mask, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderSetPictureClipRectangles (ClientPtr client)
{
register int n;
REQUEST(xRenderSetPictureClipRectanglesReq);
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
swaps(&stuff->length, n);
swapl(&stuff->picture, n);
SwapRestS(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderFreePicture (ClientPtr client)
{
register int n;
REQUEST(xRenderFreePictureReq);
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
swaps(&stuff->length, n);
swapl(&stuff->picture, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderComposite (ClientPtr client)
{
register int n;
REQUEST(xRenderCompositeReq);
REQUEST_SIZE_MATCH(xRenderCompositeReq);
swaps(&stuff->length, n);
swapl(&stuff->src, n);
swapl(&stuff->mask, n);
swapl(&stuff->dst, n);
swaps(&stuff->xSrc, n);
swaps(&stuff->ySrc, n);
swaps(&stuff->xMask, n);
swaps(&stuff->yMask, n);
swaps(&stuff->xDst, n);
swaps(&stuff->yDst, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderScale (ClientPtr client)
{
register int n;
REQUEST(xRenderScaleReq);
REQUEST_SIZE_MATCH(xRenderScaleReq);
swaps(&stuff->length, n);
swapl(&stuff->src, n);
swapl(&stuff->dst, n);
swapl(&stuff->colorScale, n);
swapl(&stuff->alphaScale, n);
swaps(&stuff->xSrc, n);
swaps(&stuff->ySrc, n);
swaps(&stuff->xDst, n);
swaps(&stuff->yDst, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderTrapezoids (ClientPtr client)
SProcRenderDispatch (ClientPtr client)
{
register int n;
REQUEST(xRenderTrapezoidsReq);
int result;
REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
swaps (&stuff->length, n);
swapl (&stuff->src, n);
swapl (&stuff->dst, n);
swapl (&stuff->maskFormat, n);
swaps (&stuff->xSrc, n);
swaps (&stuff->ySrc, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
REQUEST(xReq);
static int
SProcRenderTriangles (ClientPtr client)
{
register int n;
REQUEST(xRenderTrianglesReq);
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
swaps (&stuff->length, n);
swapl (&stuff->src, n);
swapl (&stuff->dst, n);
swapl (&stuff->maskFormat, n);
swaps (&stuff->xSrc, n);
swaps (&stuff->ySrc, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
/*
* Let the client fail if we are
* hiding the RENDER extension.
*/
static int
SProcRenderTriStrip (ClientPtr client)
{
register int n;
REQUEST(xRenderTriStripReq);
REQUEST_AT_LEAST_SIZE(xRenderTriStripReq);
swaps (&stuff->length, n);
swapl (&stuff->src, n);
swapl (&stuff->dst, n);
swapl (&stuff->maskFormat, n);
swaps (&stuff->xSrc, n);
swaps (&stuff->ySrc, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
if (nxagentRenderTrap)
{
return BadRequest;
}
static int
SProcRenderTriFan (ClientPtr client)
{
register int n;
REQUEST(xRenderTriFanReq);
REQUEST_AT_LEAST_SIZE(xRenderTriFanReq);
swaps (&stuff->length, n);
swapl (&stuff->src, n);
swapl (&stuff->dst, n);
swapl (&stuff->maskFormat, n);
swaps (&stuff->xSrc, n);
swaps (&stuff->ySrc, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
if (stuff->data < RenderNumberRequests)
{
/*
* Set the nxagentGCTrap flag while
* dispatching a render operation to
* avoid reentrancy in GCOps.c.
*/
static int
SProcRenderColorTrapezoids (ClientPtr client)
{
return BadImplementation;
}
nxagentGCTrap = 1;
static int
SProcRenderColorTriangles (ClientPtr client)
{
return BadImplementation;
}
result = (*SProcRenderVector[stuff->data]) (client);
static int
SProcRenderTransform (ClientPtr client)
{
return BadImplementation;
}
nxagentGCTrap = 0;
static int
SProcRenderCreateGlyphSet (ClientPtr client)
{
register int n;
REQUEST(xRenderCreateGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
swaps(&stuff->length, n);
swapl(&stuff->gsid, n);
swapl(&stuff->format, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
return result;
}
else
return BadRequest;
}
static int
SProcRenderReferenceGlyphSet (ClientPtr client)
{
register int n;
REQUEST(xRenderReferenceGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
swaps(&stuff->length, n);
swapl(&stuff->gsid, n);
swapl(&stuff->existing, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderFreeGlyphSet (ClientPtr client)
{
register int n;
REQUEST(xRenderFreeGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
swaps(&stuff->length, n);
swapl(&stuff->glyphset, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderAddGlyphs (ClientPtr client)
{
register int n;
register unsigned int i;
CARD32 *gids;
void *end;
xGlyphInfo *gi;
REQUEST(xRenderAddGlyphsReq);
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
swaps(&stuff->length, n);
swapl(&stuff->glyphset, n);
swapl(&stuff->nglyphs, n);
if (stuff->nglyphs & 0xe0000000)
return BadLength;
end = (CARD8 *) stuff + (client->req_len << 2);
gids = (CARD32 *) (stuff + 1);
gi = (xGlyphInfo *) (gids + stuff->nglyphs);
if ((char *) end - (char *) (gids + stuff->nglyphs) < 0)
return BadLength;
if ((char *) end - (char *) (gi + stuff->nglyphs) < 0)
return BadLength;
for (i = 0; i < stuff->nglyphs; i++)
{
swapl (&gids[i], n);
swaps (&gi[i].width, n);
swaps (&gi[i].height, n);
swaps (&gi[i].x, n);
swaps (&gi[i].y, n);
swaps (&gi[i].xOff, n);
swaps (&gi[i].yOff, n);
}
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderAddGlyphsFromPicture (ClientPtr client)
{
return BadImplementation;
}
static int
SProcRenderFreeGlyphs (ClientPtr client)
{
register int n;
REQUEST(xRenderFreeGlyphsReq);
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
swaps(&stuff->length, n);
swapl(&stuff->glyphset, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderCompositeGlyphs (ClientPtr client)
{
register int n;
xGlyphElt *elt;
CARD8 *buffer;
CARD8 *end;
int space;
int i;
int size;
REQUEST(xRenderCompositeGlyphsReq);
REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
switch (stuff->renderReqType) {
default: size = 1; break;
case X_RenderCompositeGlyphs16: size = 2; break;
case X_RenderCompositeGlyphs32: size = 4; break;
}
swaps(&stuff->length, n);
swapl(&stuff->src, n);
swapl(&stuff->dst, n);
swapl(&stuff->maskFormat, n);
swapl(&stuff->glyphset, n);
swaps(&stuff->xSrc, n);
swaps(&stuff->ySrc, n);
buffer = (CARD8 *) (stuff + 1);
end = (CARD8 *) stuff + (client->req_len << 2);
while (buffer + sizeof (xGlyphElt) < end)
{
elt = (xGlyphElt *) buffer;
buffer += sizeof (xGlyphElt);
swaps (&elt->deltax, n);
swaps (&elt->deltay, n);
i = elt->len;
if (i == 0xff)
{
swapl (buffer, n);
buffer += 4;
}
else
{
space = size * i;
switch (size) {
case 1:
buffer += i;
break;
case 2:
while (i--)
{
swaps (buffer, n);
buffer += 2;
}
break;
case 4:
while (i--)
{
swapl (buffer, n);
buffer += 4;
}
break;
}
if (space & 3)
buffer += 4 - (space & 3);
}
}
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderFillRectangles (ClientPtr client)
{
register int n;
REQUEST(xRenderFillRectanglesReq);
REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq);
swaps(&stuff->length, n);
swapl(&stuff->dst, n);
swaps(&stuff->color.red, n);
swaps(&stuff->color.green, n);
swaps(&stuff->color.blue, n);
swaps(&stuff->color.alpha, n);
SwapRestS(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderCreateCursor (ClientPtr client)
{
register int n;
REQUEST(xRenderCreateCursorReq);
REQUEST_SIZE_MATCH (xRenderCreateCursorReq);
swaps(&stuff->length, n);
swapl(&stuff->cid, n);
swapl(&stuff->src, n);
swaps(&stuff->x, n);
swaps(&stuff->y, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderSetPictureTransform (ClientPtr client)
{
register int n;
REQUEST(xRenderSetPictureTransformReq);
REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
swaps(&stuff->length, n);
swapl(&stuff->picture, n);
swapl(&stuff->transform.matrix11, n);
swapl(&stuff->transform.matrix12, n);
swapl(&stuff->transform.matrix13, n);
swapl(&stuff->transform.matrix21, n);
swapl(&stuff->transform.matrix22, n);
swapl(&stuff->transform.matrix23, n);
swapl(&stuff->transform.matrix31, n);
swapl(&stuff->transform.matrix32, n);
swapl(&stuff->transform.matrix33, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderQueryFilters (ClientPtr client)
{
register int n;
REQUEST (xRenderQueryFiltersReq);
REQUEST_SIZE_MATCH (xRenderQueryFiltersReq);
swaps(&stuff->length, n);
swapl(&stuff->drawable, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderSetPictureFilter (ClientPtr client)
{
register int n;
REQUEST (xRenderSetPictureFilterReq);
REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq);
swaps(&stuff->length, n);
swapl(&stuff->picture, n);
swaps(&stuff->nbytes, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderCreateAnimCursor (ClientPtr client)
{
register int n;
REQUEST (xRenderCreateAnimCursorReq);
REQUEST_AT_LEAST_SIZE (xRenderCreateAnimCursorReq);
swaps(&stuff->length, n);
swapl(&stuff->cid, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderAddTraps (ClientPtr client)
{
register int n;
REQUEST (xRenderAddTrapsReq);
REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq);
swaps(&stuff->length, n);
swapl(&stuff->picture, n);
swaps(&stuff->xOff, n);
swaps(&stuff->yOff, n);
SwapRestL(stuff);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderCreateSolidFill(ClientPtr client)
{
register int n;
REQUEST (xRenderCreateSolidFillReq);
REQUEST_AT_LEAST_SIZE (xRenderCreateSolidFillReq);
swaps(&stuff->length, n);
swapl(&stuff->pid, n);
swaps(&stuff->color.alpha, n);
swaps(&stuff->color.red, n);
swaps(&stuff->color.green, n);
swaps(&stuff->color.blue, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static void swapStops(void *stuff, int num)
{
int i, n;
CARD32 *stops;
stops = (CARD32 *)(stuff);
for (i = 0; i < num; ++i) {
swapl(stops, n);
++stops;
}
for (i = 0; i < 4*num; ++i) {
swaps(stops, n);
++stops;
}
}
static int
SProcRenderCreateLinearGradient (ClientPtr client)
{
register int n;
int len;
REQUEST (xRenderCreateLinearGradientReq);
REQUEST_AT_LEAST_SIZE (xRenderCreateLinearGradientReq);
swaps(&stuff->length, n);
swapl(&stuff->pid, n);
swapl(&stuff->p1.x, n);
swapl(&stuff->p1.y, n);
swapl(&stuff->p2.x, n);
swapl(&stuff->p2.y, n);
swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
swapStops(stuff+1, stuff->nStops);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderCreateRadialGradient (ClientPtr client)
{
register int n;
int len;
REQUEST (xRenderCreateRadialGradientReq);
REQUEST_AT_LEAST_SIZE (xRenderCreateRadialGradientReq);
swaps(&stuff->length, n);
swapl(&stuff->pid, n);
swapl(&stuff->inner.x, n);
swapl(&stuff->inner.y, n);
swapl(&stuff->outer.x, n);
swapl(&stuff->outer.y, n);
swapl(&stuff->inner_radius, n);
swapl(&stuff->outer_radius, n);
swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
swapStops(stuff+1, stuff->nStops);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderCreateConicalGradient (ClientPtr client)
{
register int n;
int len;
REQUEST (xRenderCreateConicalGradientReq);
REQUEST_AT_LEAST_SIZE (xRenderCreateConicalGradientReq);
swaps(&stuff->length, n);
swapl(&stuff->pid, n);
swapl(&stuff->center.x, n);
swapl(&stuff->center.y, n);
swapl(&stuff->angle, n);
swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
swapStops(stuff+1, stuff->nStops);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
static int
SProcRenderDispatch (ClientPtr client)
{
int result;
REQUEST(xReq);
/*
* Let the client fail if we are
* hiding the RENDER extension.
*/
if (nxagentRenderTrap)
{
return BadRequest;
}
if (stuff->data < RenderNumberRequests)
{
/*
* Set the nxagentGCTrap flag while
* dispatching a render operation to
* avoid reentrancy in GCOps.c.
*/
nxagentGCTrap = 1;
result = (*SProcRenderVector[stuff->data]) (client);
nxagentGCTrap = 0;
return result;
}
else
return BadRequest;
}
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\
if (!pPicture) { \
client->errorValue = pid; \
return err; \
} \
}
#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\
if (pid == None) \
pPicture = 0; \
else { \
VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err); \
} \
} \
int (*PanoramiXSaveRenderVector[RenderNumberRequests])(ClientPtr);
unsigned long XRT_PICTURE;
static int
PanoramiXRenderCreatePicture (ClientPtr client)
{
REQUEST(xRenderCreatePictureReq);
PanoramiXRes *refDraw, *newPict;
int result = Success, j;
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
newPict->info[0].id = stuff->pid;
if (refDraw->type == XRT_WINDOW &&
stuff->drawable == screenInfo.screens[0]->root->drawable.id)
{
newPict->u.pict.root = TRUE;
}
else
newPict->u.pict.root = FALSE;
for(j = 1; j < PanoramiXNumScreens; j++)
newPict->info[j].id = FakeClientID(client->index);
FOR_NSCREENS_BACKWARD(j) {
stuff->pid = newPict->info[j].id;
stuff->drawable = refDraw->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client);
if(result != Success) break;
}
if (result == Success)
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
else
xfree(newPict);
return (result);
}
static int
PanoramiXRenderChangePicture (ClientPtr client)
{
PanoramiXRes *pict;
int result = Success, j;
REQUEST(xRenderChangePictureReq);
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client);
if(result != Success) break;
}
return (result);
}
static int
PanoramiXRenderSetPictureClipRectangles (ClientPtr client)
{
REQUEST(xRenderSetPictureClipRectanglesReq);
int result = Success, j;
PanoramiXRes *pict;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles]) (client);
if(result != Success) break;
}
return (result);
}
static int
PanoramiXRenderSetPictureTransform (ClientPtr client)
{
REQUEST(xRenderSetPictureTransformReq);
int result = Success, j;
PanoramiXRes *pict;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq);
VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client);
if(result != Success) break;
}
return (result);
}
static int
PanoramiXRenderSetPictureFilter (ClientPtr client)
{
REQUEST(xRenderSetPictureFilterReq);
int result = Success, j;
PanoramiXRes *pict;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);
if(result != Success) break;
}
return (result);
}
static int
PanoramiXRenderFreePicture (ClientPtr client)
{
PanoramiXRes *pict;
int result = Success, j;
REQUEST(xRenderFreePictureReq);
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
client->errorValue = stuff->picture;
VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityDestroyAccess,
RenderErrBase + BadPicture);
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client);
if(result != Success) break;
}
/* Since ProcRenderFreePicture is using FreeResource, it will free
our resource for us on the last pass through the loop above */
return (result);
}
static int
PanoramiXRenderComposite (ClientPtr client)
{
PanoramiXRes *src, *msk, *dst;
int result = Success, j;
xRenderCompositeReq orig;
REQUEST(xRenderCompositeReq);
REQUEST_SIZE_MATCH(xRenderCompositeReq);
VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_ALPHA (msk, stuff->mask, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
orig = *stuff;
FOR_NSCREENS_FORWARD(j) {
stuff->src = src->info[j].id;
if (src->u.pict.root)
{
stuff->xSrc = orig.xSrc - panoramiXdataPtr[j].x;
stuff->ySrc = orig.ySrc - panoramiXdataPtr[j].y;
}
stuff->dst = dst->info[j].id;
if (dst->u.pict.root)
{
stuff->xDst = orig.xDst - panoramiXdataPtr[j].x;
stuff->yDst = orig.yDst - panoramiXdataPtr[j].y;
}
if (msk)
{
stuff->mask = msk->info[j].id;
if (msk->u.pict.root)
{
stuff->xMask = orig.xMask - panoramiXdataPtr[j].x;
stuff->yMask = orig.yMask - panoramiXdataPtr[j].y;
}
}
result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
if(result != Success) break;
}
return result;
}
static int
PanoramiXRenderCompositeGlyphs (ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderCompositeGlyphsReq);
xGlyphElt origElt, *elt;
INT16 xSrc, ySrc;
REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) +
sizeof (xGlyphElt)))
{
elt = (xGlyphElt *) (stuff + 1);
origElt = *elt;
xSrc = stuff->xSrc;
ySrc = stuff->ySrc;
FOR_NSCREENS_FORWARD(j) {
stuff->src = src->info[j].id;
if (src->u.pict.root)
{
stuff->xSrc = xSrc - panoramiXdataPtr[j].x;
stuff->ySrc = ySrc - panoramiXdataPtr[j].y;
}
stuff->dst = dst->info[j].id;
if (dst->u.pict.root)
{
elt->deltax = origElt.deltax - panoramiXdataPtr[j].x;
elt->deltay = origElt.deltay - panoramiXdataPtr[j].y;
}
result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
if(result != Success) break;
}
}
return result;
}
static int
PanoramiXRenderFillRectangles (ClientPtr client)
{
PanoramiXRes *dst;
int result = Success, j;
REQUEST(xRenderFillRectanglesReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len)))
{
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root)
{
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
xRectangle *rects = (xRectangle *) (stuff + 1);
int i = extra_len / sizeof (xRectangle);
while (i--)
{
rects->x -= x_off;
rects->y -= y_off;
rects++;
}
}
}
stuff->dst = dst->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
static int
PanoramiXRenderTrapezoids(ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderTrapezoidsReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq);
VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
xTrapezoid *trap = (xTrapezoid *) (stuff + 1);
int i = extra_len / sizeof (xTrapezoid);
while (i--) {
trap->top -= y_off;
trap->bottom -= y_off;
trap->left.p1.x -= x_off;
trap->left.p1.y -= y_off;
trap->left.p2.x -= x_off;
trap->left.p2.y -= y_off;
trap->right.p1.x -= x_off;
trap->right.p1.y -= y_off;
trap->right.p2.x -= x_off;
trap->right.p2.y -= y_off;
trap++;
}
}
}
stuff->src = src->info[j].id;
stuff->dst = dst->info[j].id;
result =
(*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
static int
PanoramiXRenderTriangles(ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderTrianglesReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq);
VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
xTriangle *tri = (xTriangle *) (stuff + 1);
int i = extra_len / sizeof (xTriangle);
while (i--) {
tri->p1.x -= x_off;
tri->p1.y -= y_off;
tri->p2.x -= x_off;
tri->p2.y -= y_off;
tri->p3.x -= x_off;
tri->p3.y -= y_off;
tri++;
}
}
}
stuff->src = src->info[j].id;
stuff->dst = dst->info[j].id;
result =
(*PanoramiXSaveRenderVector[X_RenderTriangles]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
static int
PanoramiXRenderTriStrip(ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderTriStripReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderTriStripReq);
VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
xPointFixed *fixed = (xPointFixed *) (stuff + 1);
int i = extra_len / sizeof (xPointFixed);
while (i--) {
fixed->x -= x_off;
fixed->y -= y_off;
fixed++;
}
}
}
stuff->src = src->info[j].id;
stuff->dst = dst->info[j].id;
result =
(*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
static int
PanoramiXRenderTriFan(ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderTriFanReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderTriFanReq);
VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
RenderErrBase + BadPicture);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
xPointFixed *fixed = (xPointFixed *) (stuff + 1);
int i = extra_len / sizeof (xPointFixed);
while (i--) {
fixed->x -= x_off;
fixed->y -= y_off;
fixed++;
}
}
}
stuff->src = src->info[j].id;
stuff->dst = dst->info[j].id;
result =
(*PanoramiXSaveRenderVector[X_RenderTriFan]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
#if 0 /* Not implemented yet */
static int
PanoramiXRenderColorTrapezoids(ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderColorTrapezoidsReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
....;
}
}
stuff->dst = dst->info[j].id;
result =
(*PanoramiXSaveRenderVector[X_RenderColorTrapezoids]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
static int
PanoramiXRenderColorTriangles(ClientPtr client)
{
PanoramiXRes *src, *dst;
int result = Success, j;
REQUEST(xRenderColorTrianglesReq);
char *extra;
int extra_len;
REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq);
VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
int x_off = panoramiXdataPtr[j].x;
int y_off = panoramiXdataPtr[j].y;
if(x_off || y_off) {
....;
}
}
stuff->dst = dst->info[j].id;
result =
(*PanoramiXSaveRenderVector[X_RenderColorTriangles]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
#endif
static int
PanoramiXRenderAddTraps (ClientPtr client)
{
PanoramiXRes *picture;
int result = Success, j;
REQUEST(xRenderAddTrapsReq);
char *extra;
int extra_len;
INT16 x_off, y_off;
REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq);
VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq);
if (extra_len &&
(extra = (char *) ALLOCATE_LOCAL (extra_len)))
{
memcpy (extra, stuff + 1, extra_len);
x_off = stuff->xOff;
y_off = stuff->yOff;
FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
stuff->picture = picture->info[j].id;
if (picture->u.pict.root)
{
stuff->xOff = x_off + panoramiXdataPtr[j].x;
stuff->yOff = y_off + panoramiXdataPtr[j].y;
}
result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
if(result != Success) break;
}
DEALLOCATE_LOCAL(extra);
}
return result;
}
void
PanoramiXRenderInit (void)
{
int i;
XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource);
for (i = 0; i < RenderNumberRequests; i++)
PanoramiXSaveRenderVector[i] = ProcRenderVector[i];
/*
* Stuff in Xinerama aware request processing hooks
*/
ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture;
ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture;
ProcRenderVector[X_RenderSetPictureTransform] = PanoramiXRenderSetPictureTransform;
ProcRenderVector[X_RenderSetPictureFilter] = PanoramiXRenderSetPictureFilter;
ProcRenderVector[X_RenderSetPictureClipRectangles] = PanoramiXRenderSetPictureClipRectangles;
ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture;
ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite;
ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs;
ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs;
ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs;
ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles;
ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids;
ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles;
ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip;
ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan;
ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps;
}
void
PanoramiXRenderReset (void)
{
int i;
for (i = 0; i < RenderNumberRequests; i++)
ProcRenderVector[i] = PanoramiXSaveRenderVector[i];
}
#endif /* PANORAMIX */
......@@ -118,31 +118,7 @@ Equipment Corporation.
*/
/* $XFree86: xc/programs/Xserver/dix/resource.c,v 3.13 2003/09/24 02:43:13 dawes Exp $ */
#define NEED_EVENTS
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include "misc.h"
#include "os.h"
#include "resource.h"
#include "dixstruct.h"
#include "opaque.h"
#include "windowstr.h"
#include "dixfont.h"
#include "colormap.h"
#include "inputstr.h"
#include "dixevents.h"
#include "dixgrabs.h"
#include "cursor.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#include <assert.h>
#ifdef NXAGENT_SERVER
#include "../../dix/resource.c"
#include "Agent.h"
#include "Font.h"
......@@ -154,311 +130,11 @@ Equipment Corporation.
#undef TEST
#undef DEBUG
#endif
static void RebuildTable(
int /*client*/
);
#define SERVER_MINID 32
#define INITBUCKETS 64
#define INITHASHSIZE 6
#define MAXHASHSIZE 11
typedef struct _Resource {
struct _Resource *next;
XID id;
RESTYPE type;
void * value;
} ResourceRec, *ResourcePtr;
#define NullResource ((ResourcePtr)NULL)
typedef struct _ClientResource {
ResourcePtr *resources;
int elements;
int buckets;
int hashsize; /* log(2)(buckets) */
XID fakeID;
XID endFakeID;
XID expectID;
} ClientResourceRec;
RESTYPE lastResourceType;
static RESTYPE lastResourceClass;
RESTYPE TypeMask;
static DeleteType *DeleteFuncs = (DeleteType *)NULL;
#ifdef XResExtension
Atom * ResourceNames = NULL;
void RegisterResourceName (RESTYPE type, char *name)
{
ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE);
}
#endif
#ifdef NXAGENT_SERVER
static int nxagentResChangedFlag = 0;
#endif
RESTYPE
CreateNewResourceType(DeleteType deleteFunc)
{
RESTYPE next = lastResourceType + 1;
DeleteType *funcs;
if (next & lastResourceClass)
return 0;
funcs = (DeleteType *)xrealloc(DeleteFuncs,
(next + 1) * sizeof(DeleteType));
if (!funcs)
return 0;
#ifdef XResExtension
{
Atom *newnames;
newnames = xrealloc(ResourceNames, (next + 1) * sizeof(Atom));
if(!newnames)
return 0;
ResourceNames = newnames;
ResourceNames[next] = 0;
}
#endif
lastResourceType = next;
DeleteFuncs = funcs;
DeleteFuncs[next] = deleteFunc;
return next;
}
RESTYPE
CreateNewResourceClass()
{
RESTYPE next = lastResourceClass >> 1;
if (next & lastResourceType)
return 0;
lastResourceClass = next;
TypeMask = next - 1;
return next;
}
ClientResourceRec clientTable[MAXCLIENTS];
/*****************
* InitClientResources
* When a new client is created, call this to allocate space
* in resource table
*****************/
Bool
InitClientResources(ClientPtr client)
{
register int i, j;
if (client == serverClient)
{
lastResourceType = RT_LASTPREDEF;
lastResourceClass = RC_LASTPREDEF;
TypeMask = RC_LASTPREDEF - 1;
if (DeleteFuncs)
xfree(DeleteFuncs);
DeleteFuncs = (DeleteType *)xalloc((lastResourceType + 1) *
sizeof(DeleteType));
if (!DeleteFuncs)
return FALSE;
DeleteFuncs[RT_NONE & TypeMask] = (DeleteType)NoopDDA;
DeleteFuncs[RT_WINDOW & TypeMask] = DeleteWindow;
DeleteFuncs[RT_PIXMAP & TypeMask] = dixDestroyPixmap;
DeleteFuncs[RT_GC & TypeMask] = FreeGC;
DeleteFuncs[RT_FONT & TypeMask] = CloseFont;
DeleteFuncs[RT_CURSOR & TypeMask] = FreeCursor;
DeleteFuncs[RT_COLORMAP & TypeMask] = FreeColormap;
DeleteFuncs[RT_CMAPENTRY & TypeMask] = FreeClientPixels;
DeleteFuncs[RT_OTHERCLIENT & TypeMask] = OtherClientGone;
DeleteFuncs[RT_PASSIVEGRAB & TypeMask] = DeletePassiveGrab;
#ifdef XResExtension
if(ResourceNames)
xfree(ResourceNames);
ResourceNames = xalloc((lastResourceType + 1) * sizeof(Atom));
if(!ResourceNames)
return FALSE;
#endif
}
clientTable[i = client->index].resources =
(ResourcePtr *)xalloc(INITBUCKETS*sizeof(ResourcePtr));
if (!clientTable[i].resources)
return FALSE;
clientTable[i].buckets = INITBUCKETS;
clientTable[i].elements = 0;
clientTable[i].hashsize = INITHASHSIZE;
/* Many IDs allocated from the server client are visible to clients,
* so we don't use the SERVER_BIT for them, but we have to start
* past the magic value constants used in the protocol. For normal
* clients, we can start from zero, with SERVER_BIT set.
*/
clientTable[i].fakeID = client->clientAsMask |
(client->index ? SERVER_BIT : SERVER_MINID);
clientTable[i].endFakeID = (clientTable[i].fakeID | RESOURCE_ID_MASK) + 1;
clientTable[i].expectID = client->clientAsMask;
for (j=0; j<INITBUCKETS; j++)
{
clientTable[i].resources[j] = NullResource;
}
return TRUE;
}
static int
Hash(int client, register XID id)
{
id &= RESOURCE_ID_MASK;
switch (clientTable[client].hashsize)
{
case 6:
return ((int)(0x03F & (id ^ (id>>6) ^ (id>>12))));
case 7:
return ((int)(0x07F & (id ^ (id>>7) ^ (id>>13))));
case 8:
return ((int)(0x0FF & (id ^ (id>>8) ^ (id>>16))));
case 9:
return ((int)(0x1FF & (id ^ (id>>9))));
case 10:
return ((int)(0x3FF & (id ^ (id>>10))));
case 11:
return ((int)(0x7FF & (id ^ (id>>11))));
}
return -1;
}
static XID
AvailableID(
register int client,
register XID id,
register XID maxid,
register XID goodid)
{
register ResourcePtr res;
if ((goodid >= id) && (goodid <= maxid))
return goodid;
for (; id <= maxid; id++)
{
res = clientTable[client].resources[Hash(client, id)];
while (res && (res->id != id))
res = res->next;
if (!res)
return id;
}
return 0;
}
void
GetXIDRange(int client, Bool server, XID *minp, XID *maxp)
{
register XID id, maxid;
register ResourcePtr *resp;
register ResourcePtr res;
register int i;
XID goodid;
id = (Mask)client << CLIENTOFFSET;
if (server)
id |= client ? SERVER_BIT : SERVER_MINID;
maxid = id | RESOURCE_ID_MASK;
goodid = 0;
for (resp = clientTable[client].resources, i = clientTable[client].buckets;
--i >= 0;)
{
for (res = *resp++; res; res = res->next)
{
if ((res->id < id) || (res->id > maxid))
continue;
if (((res->id - id) >= (maxid - res->id)) ?
(goodid = AvailableID(client, id, res->id - 1, goodid)) :
!(goodid = AvailableID(client, res->id + 1, maxid, goodid)))
maxid = res->id - 1;
else
id = res->id + 1;
}
}
if (id > maxid)
id = maxid = 0;
*minp = id;
*maxp = maxid;
}
/**
* GetXIDList is called by the XC-MISC extension's MiscGetXIDList function.
* This function tries to find count unused XIDs for the given client. It
* puts the IDs in the array pids and returns the number found, which should
* almost always be the number requested.
*
* The circumstances that lead to a call to this function are very rare.
* Xlib must run out of IDs while trying to generate a request that wants
* multiple ID's, like the Multi-buffering CreateImageBuffers request.
*
* No rocket science in the implementation; just iterate over all
* possible IDs for the given client and pick the first count IDs
* that aren't in use. A more efficient algorithm could probably be
* invented, but this will be used so rarely that this should suffice.
*/
unsigned int
GetXIDList(ClientPtr pClient, unsigned count, XID *pids)
{
unsigned int found = 0;
XID id = pClient->clientAsMask;
XID maxid;
maxid = id | RESOURCE_ID_MASK;
while ( (found < count) && (id <= maxid) )
{
if (!LookupIDByClass(id, RC_ANY))
{
pids[found++] = id;
}
id++;
}
return found;
}
/*
* Return the next usable fake client ID.
*
* Normally this is just the next one in line, but if we've used the last
* in the range, we need to find a new range of safe IDs to avoid
* over-running another client.
*/
XID
FakeClientID(register int client)
{
XID id, maxid;
id = clientTable[client].fakeID++;
if (id != clientTable[client].endFakeID)
return id;
GetXIDRange(client, TRUE, &id, &maxid);
if (!id) {
if (!client)
FatalError("FakeClientID: server internal ids exhausted\n");
MarkClientException(clients[client]);
id = ((Mask)client << CLIENTOFFSET) | (SERVER_BIT * 3);
maxid = id | RESOURCE_ID_MASK;
}
clientTable[client].fakeID = id + 1;
clientTable[client].endFakeID = maxid + 1;
return id;
}
#ifdef NXAGENT_SERVER
int nxagentFindClientResource(int client, RESTYPE type, void * value)
{
ResourcePtr pResource;
......@@ -548,8 +224,7 @@ int nxagentSwitchResourceType(int client, RESTYPE type, void * value)
return 0;
}
#endif
#endif /* NXAGENT_SERVER */
Bool
AddResource(XID id, RESTYPE type, void * value)
......@@ -602,55 +277,6 @@ AddResource(XID id, RESTYPE type, void * value)
return TRUE;
}
static void
RebuildTable(int client)
{
register int j;
register ResourcePtr res, next;
ResourcePtr **tails, *resources;
register ResourcePtr **tptr, *rptr;
/*
* For now, preserve insertion order, since some ddx layers depend
* on resources being free in the opposite order they are added.
*/
j = 2 * clientTable[client].buckets;
tails = (ResourcePtr **)ALLOCATE_LOCAL(j * sizeof(ResourcePtr *));
if (!tails)
return;
resources = (ResourcePtr *)xalloc(j * sizeof(ResourcePtr));
if (!resources)
{
DEALLOCATE_LOCAL(tails);
return;
}
for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++)
{
*rptr = NullResource;
*tptr = rptr;
}
clientTable[client].hashsize++;
for (j = clientTable[client].buckets,
rptr = clientTable[client].resources;
--j >= 0;
rptr++)
{
for (res = *rptr; res; res = next)
{
next = res->next;
res->next = NullResource;
tptr = &tails[Hash(client, res->id)];
**tptr = res;
*tptr = &res->next;
}
}
DEALLOCATE_LOCAL(tails);
clientTable[client].buckets *= 2;
xfree(clientTable[client].resources);
clientTable[client].resources = resources;
}
void
FreeResource(XID id, RESTYPE skipDeleteFuncType)
{
......@@ -732,32 +358,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
}
}
/*
* Change the value associated with a resource id. Caller
* is responsible for "doing the right thing" with the old
* data
*/
Bool
ChangeResourceValue (XID id, RESTYPE rtype, void * value)
{
int cid;
register ResourcePtr res;
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
{
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if ((res->id == id) && (res->type == rtype))
{
res->value = value;
return TRUE;
}
}
return FALSE;
}
/* Note: if func adds or deletes resources, then func can get called
* more than once for some resources. If func adds new resources,
* func might or might not get called for them. func cannot both
......@@ -988,243 +588,3 @@ RestartLoop:
}
return NULL;
}
void
FreeClientNeverRetainResources(ClientPtr client)
{
ResourcePtr *resources;
ResourcePtr this;
ResourcePtr *prev;
int j;
if (!client)
return;
resources = clientTable[client->index].resources;
for (j=0; j < clientTable[client->index].buckets; j++)
{
prev = &resources[j];
while ( (this = *prev) )
{
RESTYPE rtype = this->type;
if (rtype & RC_NEVERRETAIN)
{
*prev = this->next;
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this);
}
else
prev = &this->next;
}
}
}
void
FreeClientResources(ClientPtr client)
{
register ResourcePtr *resources;
register ResourcePtr this;
int j;
/* This routine shouldn't be called with a null client, but just in
case ... */
if (!client)
return;
HandleSaveSet(client);
resources = clientTable[client->index].resources;
for (j=0; j < clientTable[client->index].buckets; j++)
{
/* It may seem silly to update the head of this resource list as
we delete the members, since the entire list will be deleted any way,
but there are some resource deletion functions "FreeClientPixels" for
one which do a LookupID on another resource id (a Colormap id in this
case), so the resource list must be kept valid up to the point that
it is deleted, so every time we delete a resource, we must update the
head, just like in FreeResource. I hope that this doesn't slow down
mass deletion appreciably. PRH */
ResourcePtr *head;
head = &resources[j];
for (this = *head; this; this = *head)
{
RESTYPE rtype = this->type;
*head = this->next;
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this);
}
}
xfree(clientTable[client->index].resources);
clientTable[client->index].resources = NULL;
clientTable[client->index].buckets = 0;
}
void
FreeAllResources()
{
int i;
for (i = currentMaxClients; --i >= 0; )
{
if (clientTable[i].buckets)
FreeClientResources(clients[i]);
}
}
Bool
LegalNewID(XID id, register ClientPtr client)
{
#ifdef PANORAMIX
XID minid, maxid;
if (!noPanoramiXExtension) {
minid = client->clientAsMask | (client->index ?
SERVER_BIT : SERVER_MINID);
maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1;
if ((id >= minid) && (id <= maxid))
return TRUE;
}
#endif /* PANORAMIX */
return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) &&
((clientTable[client->index].expectID <= id) ||
!LookupIDByClass(id, RC_ANY)));
}
#ifdef XCSECURITY
/* SecurityLookupIDByType and SecurityLookupIDByClass:
* These are the heart of the resource ID security system. They take
* two additional arguments compared to the old LookupID functions:
* the client doing the lookup, and the access mode (see resource.h).
* The resource is returned if it exists and the client is allowed access,
* else NULL is returned.
*/
void *
SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode)
{
int cid;
register ResourcePtr res;
void * retval = NULL;
assert(client == NullClient ||
(client->index <= currentMaxClients && clients[client->index] == client));
assert( (rtype & TypeMask) <= lastResourceType);
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
clientTable[cid].buckets)
{
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if ((res->id == id) && (res->type == rtype))
{
retval = res->value;
break;
}
}
if (retval && client && client->CheckAccess)
retval = (* client->CheckAccess)(client, id, rtype, mode, retval);
return retval;
}
void *
SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode)
{
int cid;
register ResourcePtr res = NULL;
void * retval = NULL;
assert(client == NullClient ||
(client->index <= currentMaxClients && clients[client->index] == client));
assert (classes >= lastResourceClass);
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
clientTable[cid].buckets)
{
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if ((res->id == id) && (res->type & classes))
{
retval = res->value;
break;
}
}
if (retval && client && client->CheckAccess)
retval = (* client->CheckAccess)(client, id, res->type, mode, retval);
return retval;
}
/* We can't replace the LookupIDByType and LookupIDByClass functions with
* macros because of compatibility with loadable servers.
*/
void *
LookupIDByType(XID id, RESTYPE rtype)
{
return SecurityLookupIDByType(NullClient, id, rtype,
SecurityUnknownAccess);
}
void *
LookupIDByClass(XID id, RESTYPE classes)
{
return SecurityLookupIDByClass(NullClient, id, classes,
SecurityUnknownAccess);
}
#else /* not XCSECURITY */
/*
* LookupIDByType returns the object with the given id and type, else NULL.
*/
void *
LookupIDByType(XID id, RESTYPE rtype)
{
int cid;
register ResourcePtr res;
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
clientTable[cid].buckets)
{
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if ((res->id == id) && (res->type == rtype))
return res->value;
}
return (void *)NULL;
}
/*
* LookupIDByClass returns the object with the given id and any one of the
* given classes, else NULL.
*/
void *
LookupIDByClass(XID id, RESTYPE classes)
{
int cid;
register ResourcePtr res;
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
clientTable[cid].buckets)
{
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if ((res->id == id) && (res->type & classes))
return res->value;
}
return (void *)NULL;
}
#endif /* XCSECURITY */
......@@ -46,55 +46,16 @@ in this Software without prior written authorization from The Open Group.
/* $Xorg: shm.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
#define SHM
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <sys/types.h>
#ifndef Lynx
#include <sys/ipc.h>
#include <sys/shm.h>
#else
#include <ipc.h>
#include <shm.h>
#endif
#include <unistd.h>
#include <sys/stat.h>
#define NEED_REPLIES
#define NEED_EVENTS
#include <nx-X11/X.h>
#include <nx-X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "resource.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "gcstruct.h"
#include "extnsionst.h"
#include "servermd.h"
#define _XSHM_SERVER_
#include <nx-X11/extensions/shmstr.h>
#include <nx-X11/Xfuncproto.h>
#ifdef EXTMODULE
#include "xf86_ansic.h"
#endif
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#include "modinit.h"
#include "Trap.h"
#include "Agent.h"
#include "Drawable.h"
#include "Pixmaps.h"
#include "../../Xext/shm.c"
/*
* Set here the required log level.
*/
......@@ -115,135 +76,6 @@ extern void fbPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
int x, int y, int w, int h, int leftPad, int format,
char *pImage);
typedef struct _ShmDesc {
struct _ShmDesc *next;
int shmid;
int refcnt;
char *addr;
Bool writable;
unsigned long size;
} ShmDescRec, *ShmDescPtr;
static void miShmPutImage(XSHM_PUT_IMAGE_ARGS);
static void fbShmPutImage(XSHM_PUT_IMAGE_ARGS);
static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS);
static int ShmDetachSegment(
void * /* value */,
XID /* shmseg */
);
static void ShmResetProc(
ExtensionEntry * /* extEntry */
);
static void SShmCompletionEvent(
xShmCompletionEvent * /* from */,
xShmCompletionEvent * /* to */
);
static Bool ShmDestroyPixmap (PixmapPtr pPixmap);
static DISPATCH_PROC(ProcShmAttach);
static DISPATCH_PROC(ProcShmCreatePixmap);
static DISPATCH_PROC(ProcShmDetach);
static DISPATCH_PROC(ProcShmDispatch);
static DISPATCH_PROC(ProcShmGetImage);
static DISPATCH_PROC(ProcShmPutImage);
static DISPATCH_PROC(ProcShmQueryVersion);
static DISPATCH_PROC(SProcShmAttach);
static DISPATCH_PROC(SProcShmCreatePixmap);
static DISPATCH_PROC(SProcShmDetach);
static DISPATCH_PROC(SProcShmDispatch);
static DISPATCH_PROC(SProcShmGetImage);
static DISPATCH_PROC(SProcShmPutImage);
static DISPATCH_PROC(SProcShmQueryVersion);
static unsigned char ShmReqCode;
int ShmCompletionCode;
int BadShmSegCode;
RESTYPE ShmSegType;
static ShmDescPtr Shmsegs;
static Bool sharedPixmaps;
static int pixmapFormat;
static int shmPixFormat[MAXSCREENS];
static ShmFuncsPtr shmFuncs[MAXSCREENS];
static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS];
#ifdef PIXPRIV
static int shmPixmapPrivate;
#endif
static ShmFuncs miFuncs = {NULL, miShmPutImage};
static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
#define VERIFY_SHMSEG(shmseg,shmdesc,client) \
{ \
shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \
if (!shmdesc) \
{ \
client->errorValue = shmseg; \
return BadShmSegCode; \
} \
}
#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
{ \
VERIFY_SHMSEG(shmseg, shmdesc, client); \
if ((offset & 3) || (offset > shmdesc->size)) \
{ \
client->errorValue = offset; \
return BadValue; \
} \
if (needwrite && !shmdesc->writable) \
return BadAccess; \
}
#define VERIFY_SHMSIZE(shmdesc,offset,len,client) \
{ \
if ((offset + len) > shmdesc->size) \
{ \
return BadAccess; \
} \
}
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
#include <sys/signal.h>
static Bool badSysCall = FALSE;
static void
SigSysHandler(signo)
int signo;
{
badSysCall = TRUE;
}
static Bool CheckForShmSyscall()
{
void (*oldHandler)();
int shmid = -1;
/* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
oldHandler = signal(SIGSYS, SigSysHandler);
badSysCall = FALSE;
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
if (shmid != -1)
{
/* Successful allocation - clean up */
shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL);
}
else
{
/* Allocation failed */
badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
return(!badSysCall);
}
#define MUST_CHECK_FOR_SHM_SYSCALL
#endif
void
ShmExtensionInit(INITARGS)
{
......@@ -318,245 +150,6 @@ ShmExtensionInit(INITARGS)
}
}
/*ARGSUSED*/
static void
ShmResetProc (extEntry)
ExtensionEntry *extEntry;
{
int i;
for (i = 0; i < MAXSCREENS; i++)
{
shmFuncs[i] = (ShmFuncsPtr)NULL;
shmPixFormat[i] = 0;
}
}
void
ShmRegisterFuncs(
ScreenPtr pScreen,
ShmFuncsPtr funcs)
{
shmFuncs[pScreen->myNum] = funcs;
}
void
ShmSetPixmapFormat(
ScreenPtr pScreen,
int format)
{
shmPixFormat[pScreen->myNum] = format;
}
static Bool
ShmDestroyPixmap (PixmapPtr pPixmap)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
Bool ret;
if (pPixmap->refcnt == 1)
{
ShmDescPtr shmdesc;
#ifdef PIXPRIV
shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr;
#else
char *base = (char *) pPixmap->devPrivate.ptr;
if (base != (void *) (pPixmap + 1))
{
for (shmdesc = Shmsegs; shmdesc; shmdesc = shmdesc->next)
{
if (shmdesc->addr <= base && base <= shmdesc->addr + shmdesc->size)
break;
}
}
else
shmdesc = 0;
#endif
if (shmdesc)
ShmDetachSegment ((void *) shmdesc, pPixmap->drawable.id);
}
pScreen->DestroyPixmap = destroyPixmap[pScreen->myNum];
ret = (*pScreen->DestroyPixmap) (pPixmap);
destroyPixmap[pScreen->myNum] = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = ShmDestroyPixmap;
return ret;
}
void
ShmRegisterFbFuncs(pScreen)
ScreenPtr pScreen;
{
#ifdef TEST
fprintf(stderr, "ShmRegisterFbFuncs: Registering shmFuncs as fbFuncs.\n");
#endif
shmFuncs[pScreen->myNum] = &fbFuncs;
}
static int
ProcShmQueryVersion(client)
register ClientPtr client;
{
xShmQueryVersionReply rep;
register int n;
REQUEST_SIZE_MATCH(xShmQueryVersionReq);
memset(&rep, 0, sizeof(xShmQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.sharedPixmaps = sharedPixmaps;
rep.pixmapFormat = pixmapFormat;
rep.majorVersion = SHM_MAJOR_VERSION;
rep.minorVersion = SHM_MINOR_VERSION;
rep.uid = geteuid();
rep.gid = getegid();
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
swaps(&rep.uid, n);
swaps(&rep.gid, n);
}
WriteToClient(client, sizeof(xShmQueryVersionReply), (char *)&rep);
return (client->noClientException);
}
/*
* Simulate the access() system call for a shared memory segement,
* using the credentials from the client if available
*/
static int
shm_access(ClientPtr client, struct ipc_perm *perm, int readonly)
{
int uid, gid;
mode_t mask;
if (LocalClientCred(client, &uid, &gid) != -1) {
/* User id 0 always gets access */
if (uid == 0) {
return 0;
}
/* Check the owner */
if (perm->uid == uid || perm->cuid == uid) {
mask = S_IRUSR;
if (!readonly) {
mask |= S_IWUSR;
}
return (perm->mode & mask) == mask ? 0 : -1;
}
/* Check the group */
if (perm->gid == gid || perm->cgid == gid) {
mask = S_IRGRP;
if (!readonly) {
mask |= S_IWGRP;
}
return (perm->mode & mask) == mask ? 0 : -1;
}
}
/* Otherwise, check everyone else */
mask = S_IROTH;
if (!readonly) {
mask |= S_IWOTH;
}
return (perm->mode & mask) == mask ? 0 : -1;
}
static int
ProcShmAttach(client)
register ClientPtr client;
{
struct shmid_ds buf;
ShmDescPtr shmdesc;
REQUEST(xShmAttachReq);
REQUEST_SIZE_MATCH(xShmAttachReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse))
{
client->errorValue = stuff->readOnly;
return(BadValue);
}
for (shmdesc = Shmsegs;
shmdesc && (shmdesc->shmid != stuff->shmid);
shmdesc = shmdesc->next)
;
if (shmdesc)
{
if (!stuff->readOnly && !shmdesc->writable)
return BadAccess;
shmdesc->refcnt++;
}
else
{
shmdesc = (ShmDescPtr) xalloc(sizeof(ShmDescRec));
if (!shmdesc)
return BadAlloc;
shmdesc->addr = shmat(stuff->shmid, 0,
stuff->readOnly ? SHM_RDONLY : 0);
if ((shmdesc->addr == ((char *)-1)) ||
shmctl(stuff->shmid, IPC_STAT, &buf))
{
xfree(shmdesc);
return BadAccess;
}
/* The attach was performed with root privs. We must
* do manual checking of access rights for the credentials
* of the client */
if (shm_access(client, &(buf.shm_perm), stuff->readOnly) == -1) {
shmdt(shmdesc->addr);
xfree(shmdesc);
return BadAccess;
}
shmdesc->shmid = stuff->shmid;
shmdesc->refcnt = 1;
shmdesc->writable = !stuff->readOnly;
shmdesc->size = buf.shm_segsz;
shmdesc->next = Shmsegs;
Shmsegs = shmdesc;
}
if (!AddResource(stuff->shmseg, ShmSegType, (void *)shmdesc))
return BadAlloc;
return(client->noClientException);
}
/*ARGSUSED*/
static int
ShmDetachSegment(value, shmseg)
void * value; /* must conform to DeleteType */
XID shmseg;
{
ShmDescPtr shmdesc = (ShmDescPtr)value;
ShmDescPtr *prev;
if (--shmdesc->refcnt)
return TRUE;
shmdt(shmdesc->addr);
for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next)
;
*prev = shmdesc->next;
xfree(shmdesc);
return Success;
}
static int
ProcShmDetach(client)
register ClientPtr client;
{
ShmDescPtr shmdesc;
REQUEST(xShmDetachReq);
REQUEST_SIZE_MATCH(xShmDetachReq);
VERIFY_SHMSEG(stuff->shmseg, shmdesc, client);
FreeResource(stuff->shmseg, RT_NONE);
return(client->noClientException);
}
static void
miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
DrawablePtr dst;
......@@ -668,266 +261,6 @@ fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
}
}
#ifdef PANORAMIX
static int
ProcPanoramiXShmPutImage(register ClientPtr client)
{
int j, result = 0, orig_x, orig_y;
PanoramiXRes *draw, *gc;
Bool sendEvent, isRoot;
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->gc, XRT_GC, SecurityReadAccess)))
return BadGC;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
orig_x = stuff->dstX;
orig_y = stuff->dstY;
sendEvent = stuff->sendEvent;
stuff->sendEvent = 0;
FOR_NSCREENS(j) {
if(!j) stuff->sendEvent = sendEvent;
stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
if (isRoot) {
stuff->dstX = orig_x - panoramiXdataPtr[j].x;
stuff->dstY = orig_y - panoramiXdataPtr[j].y;
}
result = ProcShmPutImage(client);
if(result != client->noClientException) break;
}
return(result);
}
static int
ProcPanoramiXShmGetImage(ClientPtr client)
{
PanoramiXRes *draw;
DrawablePtr drawables[MAXSCREENS];
DrawablePtr pDraw;
xShmGetImageReply xgi;
ShmDescPtr shmdesc;
int i, x, y, w, h, format;
Mask plane = 0, planemask;
long lenPer = 0, length, widthBytesLine;
Bool isRoot;
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format;
return(BadValue);
}
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if (draw->type == XRT_PIXMAP)
return ProcShmGetImage(client);
VERIFY_DRAWABLE(pDraw, stuff->drawable, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
x = stuff->x;
y = stuff->y;
w = stuff->width;
h = stuff->height;
format = stuff->format;
planemask = stuff->planeMask;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
if(isRoot) {
if( /* check for being onscreen */
x < 0 || x + w > PanoramiXPixWidth ||
y < 0 || y + h > PanoramiXPixHeight )
return(BadMatch);
} else {
if( /* check for being onscreen */
panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
/* check for being inside of border */
x < - wBorderWidth((WindowPtr)pDraw) ||
x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
y < -wBorderWidth((WindowPtr)pDraw) ||
y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height)
return(BadMatch);
}
drawables[0] = pDraw;
for(i = 1; i < PanoramiXNumScreens; i++)
VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client);
xgi.visual = wVisual(((WindowPtr)pDraw));
xgi.type = X_Reply;
xgi.length = 0;
xgi.sequenceNumber = client->sequence;
xgi.depth = pDraw->depth;
if(format == ZPixmap) {
widthBytesLine = PixmapBytePad(w, pDraw->depth);
length = widthBytesLine * h;
} else {
widthBytesLine = PixmapBytePad(w, 1);
lenPer = widthBytesLine * h;
plane = ((Mask)1) << (pDraw->depth - 1);
length = lenPer * Ones(planemask & (plane | (plane - 1)));
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
xgi.size = length;
if (length == 0) {/* nothing to do */ }
else if (format == ZPixmap) {
XineramaGetImageData(drawables, x, y, w, h, format, planemask,
shmdesc->addr + stuff->offset,
widthBytesLine, isRoot);
} else {
length = stuff->offset;
for (; plane; plane >>= 1) {
if (planemask & plane) {
XineramaGetImageData(drawables, x, y, w, h,
format, plane, shmdesc->addr + length,
widthBytesLine, isRoot);
length += lenPer;
}
}
}
if (client->swapped) {
register int n;
swaps(&xgi.sequenceNumber, n);
swapl(&xgi.length, n);
swapl(&xgi.visual, n);
swapl(&xgi.size, n);
}
WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi);
return(client->noClientException);
}
static int
ProcPanoramiXShmCreatePixmap(
register ClientPtr client)
{
ScreenPtr pScreen = NULL;
PixmapPtr pMap = NULL;
DrawablePtr pDraw;
DepthPtr pDepth;
int i, j, result;
ShmDescPtr shmdesc;
REQUEST(xShmCreatePixmapReq);
unsigned int width, height, depth;
unsigned long size;
PanoramiXRes *newPix;
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid;
if (!sharedPixmaps)
return BadImplementation;
LEGAL_NEW_RESOURCE(stuff->pid, client);
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
width = stuff->width;
height = stuff->height;
depth = stuff->depth;
if (!width || !height || !depth)
{
client->errorValue = 0;
return BadValue;
}
if (width > 32767 || height > 32767)
return BadAlloc;
if (stuff->depth != 1)
{
pDepth = pDraw->pScreen->allowedDepths;
for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
if (pDepth->depth == stuff->depth)
goto CreatePmap;
client->errorValue = stuff->depth;
return BadValue;
}
CreatePmap:
size = PixmapBytePad(width, depth) * height;
if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
if (size < width * height)
return BadAlloc;
/* thankfully, offset is unsigned */
if (stuff->offset + size < size)
return BadAlloc;
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPix->type = XRT_PIXMAP;
newPix->u.pix.shared = TRUE;
newPix->info[0].id = stuff->pid;
for(j = 1; j < PanoramiXNumScreens; j++)
newPix->info[j].id = FakeClientID(client->index);
result = (client->noClientException);
FOR_NSCREENS(j) {
pScreen = screenInfo.screens[j];
pMap = (*shmFuncs[j]->CreatePixmap)(pScreen,
stuff->width, stuff->height, stuff->depth,
shmdesc->addr + stuff->offset);
if (pMap) {
#ifdef PIXPRIV
pMap->devPrivates[shmPixmapPrivate].ptr = (void *) shmdesc;
#endif
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id;
if (!AddResource(newPix->info[j].id, RT_PIXMAP, (void *)pMap)) {
(*pScreen->DestroyPixmap)(pMap);
result = BadAlloc;
break;
}
} else {
result = BadAlloc;
break;
}
}
if(result == BadAlloc) {
while(j--) {
(*pScreen->DestroyPixmap)(pMap);
FreeResource(newPix->info[j].id, RT_NONE);
}
xfree(newPix);
} else
AddResource(stuff->pid, XRT_PIXMAP, newPix);
return result;
}
#endif
static int
ProcShmPutImage(client)
register ClientPtr client;
......@@ -1036,117 +369,6 @@ ProcShmPutImage(client)
}
static int
ProcShmGetImage(client)
register ClientPtr client;
{
register DrawablePtr pDraw;
long lenPer = 0, length;
Mask plane = 0;
xShmGetImageReply xgi;
ShmDescPtr shmdesc;
int n;
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap))
{
client->errorValue = stuff->format;
return(BadValue);
}
VERIFY_DRAWABLE(pDraw, stuff->drawable, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
if (pDraw->type == DRAWABLE_WINDOW)
{
if( /* check for being viewable */
!((WindowPtr) pDraw)->realized ||
/* check for being on screen */
pDraw->x + stuff->x < 0 ||
pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width ||
pDraw->y + stuff->y < 0 ||
pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height ||
/* check for being inside of border */
stuff->x < - wBorderWidth((WindowPtr)pDraw) ||
stuff->x + (int)stuff->width >
wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
stuff->y < -wBorderWidth((WindowPtr)pDraw) ||
stuff->y + (int)stuff->height >
wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height
)
return(BadMatch);
xgi.visual = wVisual(((WindowPtr)pDraw));
}
else
{
if (stuff->x < 0 ||
stuff->x+(int)stuff->width > pDraw->width ||
stuff->y < 0 ||
stuff->y+(int)stuff->height > pDraw->height
)
return(BadMatch);
xgi.visual = None;
}
xgi.type = X_Reply;
xgi.length = 0;
xgi.sequenceNumber = client->sequence;
xgi.depth = pDraw->depth;
if(stuff->format == ZPixmap)
{
length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
}
else
{
lenPer = PixmapBytePad(stuff->width, 1) * stuff->height;
plane = ((Mask)1) << (pDraw->depth - 1);
/* only planes asked for */
length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1)));
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
xgi.size = length;
if (length == 0)
{
/* nothing to do */
}
else if (stuff->format == ZPixmap)
{
(*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y,
stuff->width, stuff->height,
stuff->format, stuff->planeMask,
shmdesc->addr + stuff->offset);
}
else
{
length = stuff->offset;
for (; plane; plane >>= 1)
{
if (stuff->planeMask & plane)
{
(*pDraw->pScreen->GetImage)(pDraw,
stuff->x, stuff->y,
stuff->width, stuff->height,
stuff->format, plane,
shmdesc->addr + length);
length += lenPer;
}
}
}
if (client->swapped) {
swaps(&xgi.sequenceNumber, n);
swapl(&xgi.length, n);
swapl(&xgi.visual, n);
swapl(&xgi.size, n);
}
WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi);
return(client->noClientException);
}
static PixmapPtr
fbShmCreatePixmap (pScreen, width, height, depth, addr)
ScreenPtr pScreen;
......@@ -1191,78 +413,6 @@ fbShmCreatePixmap (pScreen, width, height, depth, addr)
return pPixmap;
}
static int
ProcShmCreatePixmap(client)
register ClientPtr client;
{
PixmapPtr pMap;
register DrawablePtr pDraw;
DepthPtr pDepth;
register int i;
ShmDescPtr shmdesc;
REQUEST(xShmCreatePixmapReq);
unsigned int width, height, depth;
unsigned long size;
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid;
if (!sharedPixmaps)
return BadImplementation;
LEGAL_NEW_RESOURCE(stuff->pid, client);
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
width = stuff->width;
height = stuff->height;
depth = stuff->depth;
if (!width || !height || !depth)
{
client->errorValue = 0;
return BadValue;
}
if (width > 32767 || height > 32767)
return BadAlloc;
if (stuff->depth != 1)
{
pDepth = pDraw->pScreen->allowedDepths;
for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
if (pDepth->depth == stuff->depth)
goto CreatePmap;
client->errorValue = stuff->depth;
return BadValue;
}
CreatePmap:
size = PixmapBytePad(width, depth) * height;
if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
if (size < width * height)
return BadAlloc;
/* thankfully, offset is unsigned */
if (stuff->offset + size < size)
return BadAlloc;
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(
pDraw->pScreen, stuff->width,
stuff->height, stuff->depth,
shmdesc->addr + stuff->offset);
if (pMap)
{
#ifdef PIXPRIV
pMap->devPrivates[shmPixmapPrivate].ptr = (void *) shmdesc;
#endif
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
if (AddResource(stuff->pid, RT_PIXMAP, (void *)pMap))
{
return(client->noClientException);
}
}
return (BadAlloc);
}
static int
ProcShmDispatch (client)
......@@ -1339,114 +489,6 @@ ProcShmDispatch (client)
}
}
static void
SShmCompletionEvent(from, to)
xShmCompletionEvent *from, *to;
{
to->type = from->type;
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswapl(from->drawable, to->drawable);
cpswaps(from->minorEvent, to->minorEvent);
to->majorEvent = from->majorEvent;
cpswapl(from->shmseg, to->shmseg);
cpswapl(from->offset, to->offset);
}
static int
SProcShmQueryVersion(client)
register ClientPtr client;
{
register int n;
REQUEST(xShmQueryVersionReq);
swaps(&stuff->length, n);
return ProcShmQueryVersion(client);
}
static int
SProcShmAttach(client)
ClientPtr client;
{
register int n;
REQUEST(xShmAttachReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xShmAttachReq);
swapl(&stuff->shmseg, n);
swapl(&stuff->shmid, n);
return ProcShmAttach(client);
}
static int
SProcShmDetach(client)
ClientPtr client;
{
register int n;
REQUEST(xShmDetachReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xShmDetachReq);
swapl(&stuff->shmseg, n);
return ProcShmDetach(client);
}
static int
SProcShmPutImage(client)
ClientPtr client;
{
register int n;
REQUEST(xShmPutImageReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xShmPutImageReq);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swaps(&stuff->totalWidth, n);
swaps(&stuff->totalHeight, n);
swaps(&stuff->srcX, n);
swaps(&stuff->srcY, n);
swaps(&stuff->srcWidth, n);
swaps(&stuff->srcHeight, n);
swaps(&stuff->dstX, n);
swaps(&stuff->dstY, n);
swapl(&stuff->shmseg, n);
swapl(&stuff->offset, n);
return ProcShmPutImage(client);
}
static int
SProcShmGetImage(client)
ClientPtr client;
{
register int n;
REQUEST(xShmGetImageReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xShmGetImageReq);
swapl(&stuff->drawable, n);
swaps(&stuff->x, n);
swaps(&stuff->y, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
swapl(&stuff->planeMask, n);
swapl(&stuff->shmseg, n);
swapl(&stuff->offset, n);
return ProcShmGetImage(client);
}
static int
SProcShmCreatePixmap(client)
ClientPtr client;
{
register int n;
REQUEST(xShmCreatePixmapReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
swapl(&stuff->pid, n);
swapl(&stuff->drawable, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
swapl(&stuff->shmseg, n);
swapl(&stuff->offset, n);
return ProcShmCreatePixmap(client);
}
static int
SProcShmDispatch (client)
register ClientPtr client;
......@@ -1496,4 +538,3 @@ SProcShmDispatch (client)
return BadRequest;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -41,206 +41,15 @@ SOFTWARE.
******************************************************************/
/* $XFree86: xc/programs/Xserver/Xext/xvdisp.c,v 1.27 2003/07/16 01:38:31 dawes Exp $ */
/*
** File:
**
** xvdisp.c --- Xv server extension dispatch module.
**
** Author:
**
** David Carver (Digital Workstation Engineering/Project Athena)
**
** Revisions:
**
** 11.06.91 Carver
** - changed SetPortControl to SetPortAttribute
** - changed GetPortControl to GetPortAttribute
** - changed QueryBestSize
**
** 15.05.91 Carver
** - version 2.0 upgrade
**
** 24.01.91 Carver
** - version 1.4 upgrade
**
*/
#if !defined(__sun) && !defined(__CYGWIN__)
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include <nx-X11/Xproto.h>
#include "misc.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "gcstruct.h"
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
#include <nx-X11/extensions/Xv.h>
#include <nx-X11/extensions/Xvproto.h>
#include "xvdix.h"
#ifdef MITSHM
#define _XSHM_SERVER_
#include <nx-X11/extensions/shmstr.h>
#endif
#include "Trap.h"
#include "../../Xext/xvdisp.c"
#undef TEST
#undef DEBUG
#ifdef EXTMODULE
#include "xf86_ansic.h"
#endif
#include "xvdisp.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
unsigned long XvXRTPort;
#ifdef MITSHM
static int XineramaXvShmPutImage(ClientPtr);
#endif
static int XineramaXvPutImage(ClientPtr);
static int XineramaXvPutVideo(ClientPtr);
static int XineramaXvPutStill(ClientPtr);
static int XineramaXvSetPortAttribute(ClientPtr);
static int XineramaXvStopVideo(ClientPtr);
#endif
/* INTERNAL */
static int ProcXvQueryExtension(ClientPtr);
static int ProcXvQueryAdaptors(ClientPtr);
static int ProcXvQueryEncodings(ClientPtr);
static int ProcXvPutVideo(ClientPtr);
static int ProcXvPutStill(ClientPtr);
static int ProcXvGetVideo(ClientPtr);
static int ProcXvGetStill(ClientPtr);
static int ProcXvGrabPort(ClientPtr);
static int ProcXvUngrabPort(ClientPtr);
static int ProcXvSelectVideoNotify(ClientPtr);
static int ProcXvSelectPortNotify(ClientPtr);
static int ProcXvStopVideo(ClientPtr);
static int ProcXvSetPortAttribute(ClientPtr);
static int ProcXvGetPortAttribute(ClientPtr);
static int ProcXvQueryBestSize(ClientPtr);
static int ProcXvQueryPortAttributes(ClientPtr);
static int ProcXvPutImage(ClientPtr);
#ifdef MITSHM
static int ProcXvShmPutImage(ClientPtr);
#endif
static int ProcXvQueryImageAttributes(ClientPtr);
static int ProcXvListImageFormats(ClientPtr);
static int SProcXvQueryExtension(ClientPtr);
static int SProcXvQueryAdaptors(ClientPtr);
static int SProcXvQueryEncodings(ClientPtr);
static int SProcXvPutVideo(ClientPtr);
static int SProcXvPutStill(ClientPtr);
static int SProcXvGetVideo(ClientPtr);
static int SProcXvGetStill(ClientPtr);
static int SProcXvGrabPort(ClientPtr);
static int SProcXvUngrabPort(ClientPtr);
static int SProcXvSelectVideoNotify(ClientPtr);
static int SProcXvSelectPortNotify(ClientPtr);
static int SProcXvStopVideo(ClientPtr);
static int SProcXvSetPortAttribute(ClientPtr);
static int SProcXvGetPortAttribute(ClientPtr);
static int SProcXvQueryBestSize(ClientPtr);
static int SProcXvQueryPortAttributes(ClientPtr);
static int SProcXvPutImage(ClientPtr);
#ifdef MITSHM
static int SProcXvShmPutImage(ClientPtr);
#endif
static int SProcXvQueryImageAttributes(ClientPtr);
static int SProcXvListImageFormats(ClientPtr);
static int SWriteQueryAdaptorsReply(ClientPtr, xvQueryAdaptorsReply *);
static int SWriteQueryExtensionReply(ClientPtr, xvQueryExtensionReply *);
static int SWriteQueryEncodingsReply(ClientPtr, xvQueryEncodingsReply *);
static int SWriteAdaptorInfo(ClientPtr, xvAdaptorInfo *);
static int SWriteEncodingInfo(ClientPtr, xvEncodingInfo *);
static int SWriteFormat(ClientPtr, xvFormat *);
static int SWriteAttributeInfo(ClientPtr, xvAttributeInfo *);
static int SWriteGrabPortReply(ClientPtr, xvGrabPortReply *);
static int SWriteGetPortAttributeReply(ClientPtr, xvGetPortAttributeReply *);
static int SWriteQueryBestSizeReply(ClientPtr, xvQueryBestSizeReply *);
static int SWriteQueryPortAttributesReply(
ClientPtr, xvQueryPortAttributesReply *);
static int SWriteQueryImageAttributesReply(
ClientPtr, xvQueryImageAttributesReply*);
static int SWriteListImageFormatsReply(ClientPtr, xvListImageFormatsReply*);
static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*);
#define _WriteQueryAdaptorsReply(_c,_d) \
if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d)
#define _WriteQueryExtensionReply(_c,_d) \
if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d)
#define _WriteQueryEncodingsReply(_c,_d) \
if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d)
#define _WriteAdaptorInfo(_c,_d) \
if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d)
#define _WriteAttributeInfo(_c,_d) \
if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d)
#define _WriteEncodingInfo(_c,_d) \
if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d)
#define _WriteFormat(_c,_d) \
if ((_c)->swapped) SWriteFormat(_c, _d); \
else WriteToClient(_c, sz_xvFormat, (char*)_d)
#define _WriteGrabPortReply(_c,_d) \
if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d)
#define _WriteGetPortAttributeReply(_c,_d) \
if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d)
#define _WriteQueryBestSizeReply(_c,_d) \
if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d)
#define _WriteQueryPortAttributesReply(_c,_d) \
if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d)
#define _WriteQueryImageAttributesReply(_c,_d) \
if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d)
#define _WriteListImageFormatsReply(_c,_d) \
if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d)
#define _WriteImageFormatInfo(_c,_d) \
if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d)
#define _AllocatePort(_i,_p) \
((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
/*
** ProcXvDispatch
**
......@@ -427,1889 +236,4 @@ SProcXvDispatch(ClientPtr client)
return result;
}
static int
ProcXvQueryExtension(ClientPtr client)
{
xvQueryExtensionReply rep;
/* REQUEST(xvQueryExtensionReq); */
REQUEST_SIZE_MATCH(xvQueryExtensionReq);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.version = XvVersion;
rep.revision = XvRevision;
_WriteQueryExtensionReply(client, &rep);
return Success;
}
static int
ProcXvQueryAdaptors(ClientPtr client)
{
xvFormat format;
xvAdaptorInfo ainfo;
xvQueryAdaptorsReply rep;
int totalSize;
int na;
XvAdaptorPtr pa;
int nf;
XvFormatPtr pf;
WindowPtr pWin;
ScreenPtr pScreen;
XvScreenPtr pxvs;
REQUEST(xvQueryAdaptorsReq);
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
if(!(pWin = (WindowPtr)LookupWindow(stuff->window, client) ))
{
client->errorValue = stuff->window;
return (BadWindow);
}
pScreen = pWin->drawable.pScreen;
pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
if (!pxvs)
{
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_adaptors = 0;
rep.length = 0;
_WriteQueryAdaptorsReply(client, &rep);
return Success;
}
(* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_adaptors = pxvs->nAdaptors;
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--)
{
totalSize += (strlen(pa->name) + 3) & ~3;
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
rep.length = totalSize >> 2;
_WriteQueryAdaptorsReply(client, &rep);
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--)
{
ainfo.base_id = pa->base_id;
ainfo.num_ports = pa->nPorts;
ainfo.type = pa->type;
ainfo.name_size = strlen(pa->name);
ainfo.num_formats = pa->nFormats;
_WriteAdaptorInfo(client, &ainfo);
WriteToClient(client, ainfo.name_size, pa->name);
nf = pa->nFormats;
pf = pa->pFormats;
while (nf--)
{
format.depth = pf->depth;
format.visual = pf->visual;
_WriteFormat(client, &format);
pf++;
}
pa++;
}
return (client->noClientException);
}
static int
ProcXvQueryEncodings(ClientPtr client)
{
xvEncodingInfo einfo;
xvQueryEncodingsReply rep;
int totalSize;
XvPortPtr pPort;
int ne;
XvEncodingPtr pe;
int status;
REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_encodings = pPort->pAdaptor->nEncodings;
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
totalSize = ne * sz_xvEncodingInfo;
while (ne--)
{
totalSize += (strlen(pe->name) + 3) & ~3;
pe++;
}
rep.length = totalSize >> 2;
_WriteQueryEncodingsReply(client, &rep);
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
while (ne--)
{
einfo.encoding = pe->id;
einfo.name_size = strlen(pe->name);
einfo.width = pe->width;
einfo.height = pe->height;
einfo.rate.numerator = pe->rate.numerator;
einfo.rate.denominator = pe->rate.denominator;
_WriteEncodingInfo(client, &einfo);
WriteToClient(client, einfo.name_size, pe->name);
pe++;
}
return (client->noClientException);
}
static int
ProcXvPutVideo(ClientPtr client)
{
register DrawablePtr pDraw;
XvPortPtr pPort;
register GCPtr pGC;
int status;
REQUEST(xvPutVideoReq);
REQUEST_SIZE_MATCH(xvPutVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvVideoMask))
{
client->errorValue = stuff->port;
return (BadMatch);
}
status = XVCALL(diMatchPort)(pPort, pDraw);
if (status != Success)
{
return status;
}
return XVCALL(diPutVideo)(client, pDraw, pPort, pGC,
stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h,
stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
static int
ProcXvPutStill(ClientPtr client)
{
register DrawablePtr pDraw;
XvPortPtr pPort;
register GCPtr pGC;
int status;
REQUEST(xvPutStillReq);
REQUEST_SIZE_MATCH(xvPutStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvStillMask))
{
client->errorValue = stuff->port;
return (BadMatch);
}
status = XVCALL(diMatchPort)(pPort, pDraw);
if (status != Success)
{
return status;
}
return XVCALL(diPutStill)(client, pDraw, pPort, pGC,
stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h,
stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
static int
ProcXvGetVideo(ClientPtr client)
{
register DrawablePtr pDraw;
XvPortPtr pPort;
register GCPtr pGC;
int status;
REQUEST(xvGetVideoReq);
REQUEST_SIZE_MATCH(xvGetVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvVideoMask))
{
client->errorValue = stuff->port;
return (BadMatch);
}
status = XVCALL(diMatchPort)(pPort, pDraw);
if (status != Success)
{
return status;
}
return XVCALL(diGetVideo)(client, pDraw, pPort, pGC,
stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h,
stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
static int
ProcXvGetStill(ClientPtr client)
{
register DrawablePtr pDraw;
XvPortPtr pPort;
register GCPtr pGC;
int status;
REQUEST(xvGetStillReq);
REQUEST_SIZE_MATCH(xvGetStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvStillMask))
{
client->errorValue = stuff->port;
return (BadMatch);
}
status = XVCALL(diMatchPort)(pPort, pDraw);
if (status != Success)
{
return status;
}
return XVCALL(diGetStill)(client, pDraw, pPort, pGC,
stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h,
stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
static int
ProcXvSelectVideoNotify(ClientPtr client)
{
register DrawablePtr pDraw;
REQUEST(xvSelectVideoNotifyReq);
REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
if(!(pDraw = (DrawablePtr)LOOKUP_DRAWABLE(stuff->drawable, client) ))
{
client->errorValue = stuff->drawable;
return (BadWindow);
}
return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff);
}
static int
ProcXvSelectPortNotify(ClientPtr client)
{
int status;
XvPortPtr pPort;
REQUEST(xvSelectPortNotifyReq);
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
return XVCALL(diSelectPortNotify)(client, pPort, stuff->onoff);
}
static int
ProcXvGrabPort(ClientPtr client)
{
int result, status;
XvPortPtr pPort;
xvGrabPortReply rep;
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
status = XVCALL(diGrabPort)(client, pPort, stuff->time, &result);
if (status != Success)
{
return status;
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.result = result;
_WriteGrabPortReply(client, &rep);
return Success;
}
static int
ProcXvUngrabPort(ClientPtr client)
{
int status;
XvPortPtr pPort;
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
return XVCALL(diUngrabPort)(client, pPort, stuff->time);
}
static int
ProcXvStopVideo(ClientPtr client)
{
int status;
register DrawablePtr pDraw;
XvPortPtr pPort;
REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if(!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client) ))
{
client->errorValue = stuff->drawable;
return (BadDrawable);
}
return XVCALL(diStopVideo)(client, pPort, pDraw);
}
static int
ProcXvSetPortAttribute(ClientPtr client)
{
int status;
XvPortPtr pPort;
REQUEST(xvSetPortAttributeReq);
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!ValidAtom(stuff->attribute))
{
client->errorValue = stuff->attribute;
return(BadAtom);
}
status = XVCALL(diSetPortAttribute)(client, pPort,
stuff->attribute, stuff->value);
if (status == BadMatch)
client->errorValue = stuff->attribute;
else
client->errorValue = stuff->value;
return status;
}
static int
ProcXvGetPortAttribute(ClientPtr client)
{
INT32 value;
int status;
XvPortPtr pPort;
xvGetPortAttributeReply rep;
REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!ValidAtom(stuff->attribute))
{
client->errorValue = stuff->attribute;
return(BadAtom);
}
status = XVCALL(diGetPortAttribute)(client, pPort, stuff->attribute, &value);
if (status != Success)
{
client->errorValue = stuff->attribute;
return status;
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.value = value;
_WriteGetPortAttributeReply(client, &rep);
return Success;
}
static int
ProcXvQueryBestSize(ClientPtr client)
{
int status;
unsigned int actual_width, actual_height;
XvPortPtr pPort;
xvQueryBestSizeReply rep;
REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
(* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion,
stuff->vid_w, stuff->vid_h,
stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height);
rep.actual_width = actual_width;
rep.actual_height = actual_height;
_WriteQueryBestSizeReply(client, &rep);
return Success;
}
static int
ProcXvQueryPortAttributes(ClientPtr client)
{
int status, size, i;
XvPortPtr pPort;
XvAttributePtr pAtt;
xvQueryPortAttributesReply rep;
xvAttributeInfo Info;
REQUEST(xvQueryPortAttributesReq);
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_attributes = pPort->pAdaptor->nAttributes;
rep.text_size = 0;
for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < rep.num_attributes; i++, pAtt++)
{
rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L;
}
rep.length = (rep.num_attributes * sz_xvAttributeInfo) + rep.text_size;
rep.length >>= 2;
_WriteQueryPortAttributesReply(client, &rep);
for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < rep.num_attributes; i++, pAtt++)
{
size = strlen(pAtt->name) + 1; /* pass the NULL */
Info.flags = pAtt->flags;
Info.min = pAtt->min_value;
Info.max = pAtt->max_value;
Info.size = (size + 3) & ~3L;
_WriteAttributeInfo(client, &Info);
WriteToClient(client, size, pAtt->name);
}
return Success;
}
static int
ProcXvPutImage(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
XvImagePtr pImage = NULL;
GCPtr pGC;
int status, i, size;
CARD16 width, height;
REQUEST(xvPutImageReq);
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!(pPort->pAdaptor->type & XvImageMask) ||
!(pPort->pAdaptor->type & XvInputMask))
{
client->errorValue = stuff->port;
return (BadMatch);
}
status = XVCALL(diMatchPort)(pPort, pDraw);
if (status != Success)
{
return status;
}
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
pImage = &(pPort->pAdaptor->pImages[i]);
break;
}
}
if(!pImage)
return BadMatch;
width = stuff->width;
height = stuff->height;
size = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
pPort, pImage, &width, &height, NULL, NULL);
size += sizeof(xvPutImageReq);
size = (size + 3) >> 2;
if((width < stuff->width) || (height < stuff->height))
return BadValue;
if(client->req_len < size)
return BadLength;
return XVCALL(diPutImage)(client, pDraw, pPort, pGC,
stuff->src_x, stuff->src_y,
stuff->src_w, stuff->src_h,
stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h,
pImage, (unsigned char*)(&stuff[1]), FALSE,
stuff->width, stuff->height);
}
#ifdef MITSHM
/* redefined here since it's not in any header file */
typedef struct _ShmDesc {
struct _ShmDesc *next;
int shmid;
int refcnt;
char *addr;
Bool writable;
unsigned long size;
} ShmDescRec, *ShmDescPtr;
extern RESTYPE ShmSegType;
extern int BadShmSegCode;
extern int ShmCompletionCode;
static int
ProcXvShmPutImage(ClientPtr client)
{
ShmDescPtr shmdesc;
DrawablePtr pDraw;
XvPortPtr pPort;
XvImagePtr pImage = NULL;
GCPtr pGC;
int status, size_needed, i;
CARD16 width, height;
REQUEST(xvShmPutImageReq);
REQUEST_SIZE_MATCH(xvShmPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
return (status);
}
if (!(pPort->pAdaptor->type & XvImageMask) ||
!(pPort->pAdaptor->type & XvInputMask))
{
client->errorValue = stuff->port;
return (BadMatch);
}
status = XVCALL(diMatchPort)(pPort, pDraw);
if (status != Success)
{
return status;
}
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
pImage = &(pPort->pAdaptor->pImages[i]);
break;
}
}
if(!pImage)
return BadMatch;
if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType)))
{
client->errorValue = stuff->shmseg;
return BadShmSegCode;
}
width = stuff->width;
height = stuff->height;
size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
pPort, pImage, &width, &height, NULL, NULL);
if((size_needed + stuff->offset) > shmdesc->size)
return BadAccess;
if((width < stuff->width) || (height < stuff->height))
return BadValue;
status = XVCALL(diPutImage)(client, pDraw, pPort, pGC,
stuff->src_x, stuff->src_y,
stuff->src_w, stuff->src_h,
stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h, pImage,
(unsigned char *)shmdesc->addr + stuff->offset,
stuff->send_event, stuff->width, stuff->height);
if((status == Success) && stuff->send_event) {
xShmCompletionEvent ev;
ev.type = ShmCompletionCode;
ev.drawable = stuff->drawable;
ev.sequenceNumber = client->sequence;
ev.minorEvent = xv_ShmPutImage;
ev.majorEvent = XvReqCode;
ev.shmseg = stuff->shmseg;
ev.offset = stuff->offset;
WriteEventsToClient(client, 1, (xEvent *) &ev);
}
return status;
}
#endif
#ifdef XvMCExtension
#include "xvmcext.h"
#endif
static int
ProcXvQueryImageAttributes(ClientPtr client)
{
xvQueryImageAttributesReply rep;
int size, num_planes, i;
CARD16 width, height;
XvImagePtr pImage = NULL;
XvPortPtr pPort;
int *offsets;
int *pitches;
REQUEST(xvQueryImageAttributesReq);
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
pImage = &(pPort->pAdaptor->pImages[i]);
break;
}
}
#ifdef XvMCExtension
if(!pImage)
pImage = XvMCFindXvImage(pPort, stuff->id);
#endif
if(!pImage)
return BadMatch;
num_planes = pImage->num_planes;
if(!(offsets = xalloc(num_planes << 3)))
return BadAlloc;
pitches = offsets + num_planes;
width = stuff->width;
height = stuff->height;
size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage,
&width, &height, offsets, pitches);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = num_planes << 1;
rep.num_planes = num_planes;
rep.width = width;
rep.height = height;
rep.data_size = size;
_WriteQueryImageAttributesReply(client, &rep);
if(client->swapped)
SwapLongs((CARD32*)offsets, rep.length);
WriteToClient(client, rep.length << 2, (char*)offsets);
xfree(offsets);
return Success;
}
static int
ProcXvListImageFormats(ClientPtr client)
{
XvPortPtr pPort;
XvImagePtr pImage;
int i;
xvListImageFormatsReply rep;
xvImageFormatInfo info;
REQUEST(xvListImageFormatsReq);
REQUEST_SIZE_MATCH(xvListImageFormatsReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_formats = pPort->pAdaptor->nImages;
rep.length = rep.num_formats * sz_xvImageFormatInfo >> 2;
_WriteListImageFormatsReply(client, &rep);
pImage = pPort->pAdaptor->pImages;
for(i = 0; i < rep.num_formats; i++, pImage++) {
info.id = pImage->id;
info.type = pImage->type;
info.byte_order = pImage->byte_order;
memcpy(&info.guid, pImage->guid, 16);
info.bpp = pImage->bits_per_pixel;
info.num_planes = pImage->num_planes;
info.depth = pImage->depth;
info.red_mask = pImage->red_mask;
info.green_mask = pImage->green_mask;
info.blue_mask = pImage->blue_mask;
info.format = pImage->format;
info.y_sample_bits = pImage->y_sample_bits;
info.u_sample_bits = pImage->u_sample_bits;
info.v_sample_bits = pImage->v_sample_bits;
info.horz_y_period = pImage->horz_y_period;
info.horz_u_period = pImage->horz_u_period;
info.horz_v_period = pImage->horz_v_period;
info.vert_y_period = pImage->vert_y_period;
info.vert_u_period = pImage->vert_u_period;
info.vert_v_period = pImage->vert_v_period;
memcpy(&info.comp_order, pImage->component_order, 32);
info.scanline_order = pImage->scanline_order;
_WriteImageFormatInfo(client, &info);
}
return Success;
}
/* Swapped Procs */
static int
SProcXvQueryExtension(ClientPtr client)
{
register char n;
REQUEST(xvQueryExtensionReq);
REQUEST_SIZE_MATCH(xvQueryExtensionReq);
swaps(&stuff->length, n);
return ProcXvQueryExtension(client);
}
static int
SProcXvQueryAdaptors(ClientPtr client)
{
register char n;
REQUEST(xvQueryAdaptorsReq);
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
swaps(&stuff->length, n);
swapl(&stuff->window, n);
return ProcXvQueryAdaptors(client);
}
static int
SProcXvQueryEncodings(ClientPtr client)
{
register char n;
REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
return ProcXvQueryEncodings(client);
}
static int
SProcXvGrabPort(ClientPtr client)
{
register char n;
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->time, n);
return ProcXvGrabPort(client);
}
static int
SProcXvUngrabPort(ClientPtr client)
{
register char n;
REQUEST(xvUngrabPortReq);
REQUEST_SIZE_MATCH(xvUngrabPortReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->time, n);
return ProcXvUngrabPort(client);
}
static int
SProcXvPutVideo(ClientPtr client)
{
register char n;
REQUEST(xvPutVideoReq);
REQUEST_SIZE_MATCH(xvPutVideoReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swaps(&stuff->vid_x, n);
swaps(&stuff->vid_y, n);
swaps(&stuff->vid_w, n);
swaps(&stuff->vid_h, n);
swaps(&stuff->drw_x, n);
swaps(&stuff->drw_y, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
return ProcXvPutVideo(client);
}
static int
SProcXvPutStill(ClientPtr client)
{
register char n;
REQUEST(xvPutStillReq);
REQUEST_SIZE_MATCH(xvPutStillReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swaps(&stuff->vid_x, n);
swaps(&stuff->vid_y, n);
swaps(&stuff->vid_w, n);
swaps(&stuff->vid_h, n);
swaps(&stuff->drw_x, n);
swaps(&stuff->drw_y, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
return ProcXvPutStill(client);
}
static int
SProcXvGetVideo(ClientPtr client)
{
register char n;
REQUEST(xvGetVideoReq);
REQUEST_SIZE_MATCH(xvGetVideoReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swaps(&stuff->vid_x, n);
swaps(&stuff->vid_y, n);
swaps(&stuff->vid_w, n);
swaps(&stuff->vid_h, n);
swaps(&stuff->drw_x, n);
swaps(&stuff->drw_y, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
return ProcXvGetVideo(client);
}
static int
SProcXvGetStill(ClientPtr client)
{
register char n;
REQUEST(xvGetStillReq);
REQUEST_SIZE_MATCH(xvGetStillReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swaps(&stuff->vid_x, n);
swaps(&stuff->vid_y, n);
swaps(&stuff->vid_w, n);
swaps(&stuff->vid_h, n);
swaps(&stuff->drw_x, n);
swaps(&stuff->drw_y, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
return ProcXvGetStill(client);
}
static int
SProcXvPutImage(ClientPtr client)
{
register char n;
REQUEST(xvPutImageReq);
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swapl(&stuff->id, n);
swaps(&stuff->src_x, n);
swaps(&stuff->src_y, n);
swaps(&stuff->src_w, n);
swaps(&stuff->src_h, n);
swaps(&stuff->drw_x, n);
swaps(&stuff->drw_y, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
return ProcXvPutImage(client);
}
#ifdef MITSHM
static int
SProcXvShmPutImage(ClientPtr client)
{
register char n;
REQUEST(xvShmPutImageReq);
REQUEST_SIZE_MATCH(xvShmPutImageReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
swapl(&stuff->gc, n);
swapl(&stuff->shmseg, n);
swapl(&stuff->id, n);
swaps(&stuff->src_x, n);
swaps(&stuff->src_y, n);
swaps(&stuff->src_w, n);
swaps(&stuff->src_h, n);
swaps(&stuff->drw_x, n);
swaps(&stuff->drw_y, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
swaps(&stuff->offset, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
return ProcXvShmPutImage(client);
}
#endif
static int
SProcXvSelectVideoNotify(ClientPtr client)
{
register char n;
REQUEST(xvSelectVideoNotifyReq);
REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
swaps(&stuff->length, n);
swapl(&stuff->drawable, n);
return ProcXvSelectVideoNotify(client);
}
static int
SProcXvSelectPortNotify(ClientPtr client)
{
register char n;
REQUEST(xvSelectPortNotifyReq);
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
return ProcXvSelectPortNotify(client);
}
static int
SProcXvStopVideo(ClientPtr client)
{
register char n;
REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->drawable, n);
return ProcXvStopVideo(client);
}
static int
SProcXvSetPortAttribute(ClientPtr client)
{
register char n;
REQUEST(xvSetPortAttributeReq);
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->attribute, n);
return ProcXvSetPortAttribute(client);
}
static int
SProcXvGetPortAttribute(ClientPtr client)
{
register char n;
REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swapl(&stuff->attribute, n);
return ProcXvGetPortAttribute(client);
}
static int
SProcXvQueryBestSize(ClientPtr client)
{
register char n;
REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
swaps(&stuff->vid_w, n);
swaps(&stuff->vid_h, n);
swaps(&stuff->drw_w, n);
swaps(&stuff->drw_h, n);
return ProcXvQueryBestSize(client);
}
static int
SProcXvQueryPortAttributes(ClientPtr client)
{
register char n;
REQUEST(xvQueryPortAttributesReq);
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
return ProcXvQueryPortAttributes(client);
}
static int
SProcXvQueryImageAttributes(ClientPtr client)
{
register char n;
REQUEST(xvQueryImageAttributesReq);
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
swaps(&stuff->length, n);
swapl(&stuff->id, n);
swaps(&stuff->width, n);
swaps(&stuff->width, n);
return ProcXvQueryImageAttributes(client);
}
static int
SProcXvListImageFormats(ClientPtr client)
{
register char n;
REQUEST(xvListImageFormatsReq);
REQUEST_SIZE_MATCH(xvListImageFormatsReq);
swaps(&stuff->length, n);
swapl(&stuff->port, n);
return ProcXvListImageFormats(client);
}
static int
SWriteQueryExtensionReply(
ClientPtr client,
xvQueryExtensionReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->version, n);
swaps(&rep->revision, n);
(void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)&rep);
return Success;
}
static int
SWriteQueryAdaptorsReply(
ClientPtr client,
xvQueryAdaptorsReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->num_adaptors, n);
(void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)&rep);
return Success;
}
static int
SWriteQueryEncodingsReply(
ClientPtr client,
xvQueryEncodingsReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->num_encodings, n);
(void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)&rep);
return Success;
}
static int
SWriteAdaptorInfo(
ClientPtr client,
xvAdaptorInfo *pAdaptor
){
register char n;
swapl(&pAdaptor->base_id, n);
swaps(&pAdaptor->name_size, n);
swaps(&pAdaptor->num_ports, n);
swaps(&pAdaptor->num_formats, n);
(void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor);
return Success;
}
static int
SWriteEncodingInfo(
ClientPtr client,
xvEncodingInfo *pEncoding
){
register char n;
swapl(&pEncoding->encoding, n);
swaps(&pEncoding->name_size, n);
swaps(&pEncoding->width, n);
swaps(&pEncoding->height, n);
swapl(&pEncoding->rate.numerator, n);
swapl(&pEncoding->rate.denominator, n);
(void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding);
return Success;
}
static int
SWriteFormat(
ClientPtr client,
xvFormat *pFormat
){
register char n;
swapl(&pFormat->visual, n);
(void)WriteToClient(client, sz_xvFormat, (char *)pFormat);
return Success;
}
static int
SWriteAttributeInfo(
ClientPtr client,
xvAttributeInfo *pAtt
){
register char n;
swapl(&pAtt->flags, n);
swapl(&pAtt->size, n);
swapl(&pAtt->min, n);
swapl(&pAtt->max, n);
(void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt);
return Success;
}
static int
SWriteImageFormatInfo(
ClientPtr client,
xvImageFormatInfo *pImage
){
register char n;
swapl(&pImage->id, n);
swapl(&pImage->red_mask, n);
swapl(&pImage->green_mask, n);
swapl(&pImage->blue_mask, n);
swapl(&pImage->y_sample_bits, n);
swapl(&pImage->u_sample_bits, n);
swapl(&pImage->v_sample_bits, n);
swapl(&pImage->horz_y_period, n);
swapl(&pImage->horz_u_period, n);
swapl(&pImage->horz_v_period, n);
swapl(&pImage->vert_y_period, n);
swapl(&pImage->vert_u_period, n);
swapl(&pImage->vert_v_period, n);
(void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage);
return Success;
}
static int
SWriteGrabPortReply(
ClientPtr client,
xvGrabPortReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
(void)WriteToClient(client, sz_xvGrabPortReply, (char *)&rep);
return Success;
}
static int
SWriteGetPortAttributeReply(
ClientPtr client,
xvGetPortAttributeReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swapl(&rep->value, n);
(void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)&rep);
return Success;
}
static int
SWriteQueryBestSizeReply(
ClientPtr client,
xvQueryBestSizeReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->actual_width, n);
swaps(&rep->actual_height, n);
(void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)&rep);
return Success;
}
static int
SWriteQueryPortAttributesReply(
ClientPtr client,
xvQueryPortAttributesReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swapl(&rep->num_attributes, n);
swapl(&rep->text_size, n);
(void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)&rep);
return Success;
}
static int
SWriteQueryImageAttributesReply(
ClientPtr client,
xvQueryImageAttributesReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swapl(&rep->num_planes, n);
swapl(&rep->data_size, n);
swaps(&rep->width, n);
swaps(&rep->height, n);
(void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)&rep);
return Success;
}
static int
SWriteListImageFormatsReply(
ClientPtr client,
xvListImageFormatsReply *rep
){
register char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swapl(&rep->num_formats, n);
(void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)&rep);
return Success;
}
#ifdef PANORAMIX
static int
XineramaXvStopVideo(ClientPtr client)
{
int result = Success, i;
PanoramiXRes *draw, *port;
REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->port, XvXRTPort, SecurityReadAccess)))
return _XvBadPort;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id;
result = ProcXvStopVideo(client);
}
}
return result;
}
static int
XineramaXvSetPortAttribute(ClientPtr client)
{
REQUEST(xvSetPortAttributeReq);
PanoramiXRes *port;
int result = Success, i;
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->port, XvXRTPort, SecurityReadAccess)))
return _XvBadPort;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
stuff->port = port->info[i].id;
result = ProcXvSetPortAttribute(client);
}
}
return result;
}
#ifdef MITSHM
static int
XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool send_event = stuff->send_event;
Bool isRoot;
int result = Success, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->gc, XRT_GC, SecurityReadAccess)))
return BadGC;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->port, XvXRTPort, SecurityReadAccess)))
return _XvBadPort;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
x = stuff->drw_x;
y = stuff->drw_y;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id;
stuff->gc = gc->info[i].id;
stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
stuff->drw_x -= panoramiXdataPtr[i].x;
stuff->drw_y -= panoramiXdataPtr[i].y;
}
stuff->send_event = (send_event && !i) ? 1 : 0;
result = ProcXvShmPutImage(client);
}
}
return result;
}
#endif
static int
XineramaXvPutImage(ClientPtr client)
{
REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool isRoot;
int result = Success, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->gc, XRT_GC, SecurityReadAccess)))
return BadGC;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->port, XvXRTPort, SecurityReadAccess)))
return _XvBadPort;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
x = stuff->drw_x;
y = stuff->drw_y;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id;
stuff->gc = gc->info[i].id;
stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
stuff->drw_x -= panoramiXdataPtr[i].x;
stuff->drw_y -= panoramiXdataPtr[i].y;
}
result = ProcXvPutImage(client);
}
}
return result;
}
static int
XineramaXvPutVideo(ClientPtr client)
{
REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool isRoot;
int result = Success, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->gc, XRT_GC, SecurityReadAccess)))
return BadGC;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->port, XvXRTPort, SecurityReadAccess)))
return _XvBadPort;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
x = stuff->drw_x;
y = stuff->drw_y;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id;
stuff->gc = gc->info[i].id;
stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
stuff->drw_x -= panoramiXdataPtr[i].x;
stuff->drw_y -= panoramiXdataPtr[i].y;
}
result = ProcXvPutVideo(client);
}
}
return result;
}
static int
XineramaXvPutStill(ClientPtr client)
{
REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool isRoot;
int result = Success, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
return BadDrawable;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->gc, XRT_GC, SecurityReadAccess)))
return BadGC;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
client, stuff->port, XvXRTPort, SecurityReadAccess)))
return _XvBadPort;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
x = stuff->drw_x;
y = stuff->drw_y;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id;
stuff->gc = gc->info[i].id;
stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
stuff->drw_x -= panoramiXdataPtr[i].x;
stuff->drw_y -= panoramiXdataPtr[i].y;
}
result = ProcXvPutStill(client);
}
}
return result;
}
void XineramifyXv(void)
{
ScreenPtr pScreen, screen0 = screenInfo.screens[0];
XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr;
XvAdaptorPtr refAdapt, pAdapt;
XvAttributePtr pAttr;
XvScreenPtr xvsp;
Bool isOverlay, hasOverlay;
PanoramiXRes *port;
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
int i, j, k, l;
XvXRTPort = CreateNewResourceType(XineramaDeleteResource);
if(!xvsp0) return;
for(i = 0; i < xvsp0->nAdaptors; i++) {
refAdapt = xvsp0->pAdaptors + i;
bzero(MatchingAdaptors, sizeof(XvAdaptorPtr) * MAXSCREENS);
MatchingAdaptors[0] = refAdapt;
if(!(refAdapt->type & XvInputMask)) continue;
isOverlay = FALSE;
for(j = 0; j < refAdapt->nAttributes; j++) {
pAttr = refAdapt->pAttributes + j;
if(!strcmp(pAttr->name, "XV_COLORKEY")) {
isOverlay = TRUE;
break;
}
}
for(j = 1; j < PanoramiXNumScreens; j++) {
pScreen = screenInfo.screens[j];
xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
/* Do not try to go on if xv is not supported on this screen */
if (xvsp==NULL) continue ;
/* if the adaptor has the same name it's a perfect match */
for(k = 0; k < xvsp->nAdaptors; k++) {
pAdapt = xvsp->pAdaptors + k;
if(!strcmp(refAdapt->name, pAdapt->name)) {
MatchingAdaptors[j] = pAdapt;
break;
}
}
if(MatchingAdaptors[j]) continue; /* found it */
/* otherwise we only look for XvImage adaptors */
if(!(refAdapt->type & XvImageMask)) continue;
if(refAdapt->nImages <= 0) continue;
/* prefer overlay/overlay non-overlay/non-overlay pairing */
for(k = 0; k < xvsp->nAdaptors; k++) {
pAdapt = xvsp->pAdaptors + k;
if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
hasOverlay = FALSE;
for(l = 0; l < pAdapt->nAttributes; l++) {
if(!strcmp(pAdapt->name, "XV_COLORKEY")) {
hasOverlay = TRUE;
break;
}
}
if(isOverlay && hasOverlay) {
MatchingAdaptors[j] = pAdapt;
break;
}
else if(!isOverlay && !hasOverlay) {
MatchingAdaptors[j] = pAdapt;
break;
}
}
}
if(MatchingAdaptors[j]) continue; /* found it */
/* but we'll take any XvImage pairing if we can get it */
for(k = 0; k < xvsp->nAdaptors; k++) {
pAdapt = xvsp->pAdaptors + k;
if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
MatchingAdaptors[j] = pAdapt;
break;
}
}
}
/* now create a resource for each port */
for(j = 0; j < refAdapt->nPorts; j++) {
if(!(port = xalloc(sizeof(PanoramiXRes))))
break;
port->info[0].id = MatchingAdaptors[0]->base_id + j;
AddResource(port->info[0].id, XvXRTPort, port);
for(k = 1; k < PanoramiXNumScreens; k++) {
if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
port->info[k].id = MatchingAdaptors[k]->base_id + j;
else
port->info[k].id = 0;
}
}
}
}
#endif
#endif /* !defined(__sun) && !defined(__CYGWIN__) */
......@@ -18,6 +18,7 @@
#ifndef __Pixmap_H__
#define __Pixmap_H__
#include "resource.h"
#include "Split.h"
extern RESTYPE RT_NX_PIXMAP;
......
......@@ -15,8 +15,8 @@
/* */
/**************************************************************************/
#include "NXpicturestr.h"
#include "NXglyphstr.h"
#include "picturestr.h"
#include "glyphstr.h"
#include "Render.h"
......@@ -39,7 +39,7 @@
#define Atom XlibAtom
#define Pixmap XlibPixmap
#include "NXrenderint.h"
#include "X11/include/Xrenderint_nxagent.h"
#undef Atom
#undef Pixmap
......
......@@ -19,10 +19,11 @@
#define __Render_H__
#include "screenint.h"
#include "cursor.h"
#include "picture.h"
#include "renderproto.h"
#include "NXglyphstr.h"
#include "glyphstr.h"
#include "Agent.h"
......
......@@ -32,6 +32,8 @@ is" without express or implied warranty.
#ifndef __Screen_H__
#define __Screen_H__
#include "scrnintstr.h"
#define MIN_NXAGENT_WIDTH 80
#define MIN_NXAGENT_HEIGHT 60
#define NXAGENT_FRAME_WIDTH 2000
......
/*
* $Id: Xcomposite.h,v 1.3 2005/07/03 07:00:56 daniels Exp $
* Copyright (c) 2006, Oracle and/or its affiliates. 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 (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.
*/
/*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
......@@ -22,22 +42,32 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* This file is a reduced version of the header file of
* <X11/extensions/Xcomposite.h>
*
* This copy of code has been introduced to allow a clear namespace
* separation between <X11/...> and <nx-X11/...> header files.
*
* This version of the Xcomposite library header file only contains symbols
* required by nxagent and strictly avoids indirectly including
* from an X11 library that is also shipped in nx-X11/lib/.
*
* When using <X11/extensions/Xcomposite.h> instead for inclusion in
* nxagent, it will attempt pulling in the <X11/extensions/Xlib.h>.
* However, the headers of the same name from <nx-X11/...> should be
* used instead.
*
* FIXME: Once the nxagent Xserver starts using libX11 from X.Org, this
* hack can be removed.
*
* 2016/04/07, Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
*/
#ifndef _XCOMPOSITE_H_
#define _XCOMPOSITE_H_
#ifdef NXAGENT_SERVER
#define XserverRegion XID
#include "NXcompositeext.h"
#else
#include <nx-X11/extensions/composite.h>
#include "X11/include/Xfixes_nxagent.h"
#endif
#include <X11/extensions/composite.h>
#include <nx-X11/Xfuncproto.h>
/*
......@@ -46,18 +76,18 @@
*/
#define XCOMPOSITE_MAJOR COMPOSITE_MAJOR
#define XCOMPOSITE_MINOR COMPOSITE_MINOR
#define XCOMPOSITE_REVISION 0
#define XCOMPOSITE_REVISION 2
#define XCOMPOSITE_VERSION ((XCOMPOSITE_MAJOR * 10000) + (XCOMPOSITE_MINOR * 100) + (XCOMPOSITE_REVISION))
_XFUNCPROTOBEGIN
Bool XCompositeQueryExtension (Display *dpy, int *event_basep, int *error_basep);
Bool XCompositeQueryExtension (Display *dpy,
int *event_base_return,
int *error_base_return);
Status XCompositeQueryVersion (Display *dpy,
int *major_versionp,
int *minor_versionp);
int XCompositeVersion (void);
int *major_version_return,
int *minor_version_return);
void
XCompositeRedirectWindow (Display *dpy, Window window, int update);
......@@ -71,12 +101,6 @@ XCompositeUnredirectWindow (Display *dpy, Window window, int update);
void
XCompositeUnredirectSubwindows (Display *dpy, Window window, int update);
XserverRegion
XCompositeCreateRegionFromBorderClip (Display *dpy, Window window);
Pixmap
XCompositeNameWindowPixmap (Display *dpy, Window window);
_XFUNCPROTOEND
#endif /* _XCOMPOSITE_H_ */
......@@ -28,7 +28,7 @@
#include <nx-X11/Xlibint.h>
#include <nx-X11/Xutil.h>
#include <nx-X11/extensions/renderproto.h>
#include "X11/include/Xrender_nxagent.h"
#include "Xrender_nxagent.h"
typedef struct {
Visual *visual;
......
......@@ -16,12 +16,10 @@
/**************************************************************************/
XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:36 cpqbld Exp $
XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.34 2002/05/22 21:38:31 herrb Exp $
NULL =
#include <Server.tmpl>
#if ! HasCbrt
......@@ -40,27 +38,94 @@ MIINITEXTSRC = miinitext.c
MIINITEXTOBJ = miinitext.o
#endif
SRCS = $(CBRT_SRC) mivaltree.c mipolyseg.c mipolyrect.c \
mipoly.c mipolycon.c mipolygen.c mipolyutil.c \
mifillrct.c miwideline.c mispans.c \
miarc.c mizerarc.c mifillarc.c \
miwindow.c micursor.c \
mipolytext.c mibitblt.c mipolypnt.c mipushpxl.c \
miexpose.c miglblt.c mizerline.c mizerclip.c mifpolycon.c \
midash.c mibstore.c mibank.c $(MIINITEXTSRC) mieq.c \
mipointer.c misprite.c midispcur.c miscrinit.c miclipn.c migc.c \
micmap.c mioverlay.c
OBJS = $(CBRT_OBJ) mivaltree.o mipolyseg.o mipolyrect.o \
mipoly.o mipolycon.o mipolygen.o mipolyutil.o \
mifillrct.o miwideline.o mispans.o \
miarc.o mizerarc.o mifillarc.o \
miwindow.o micursor.o \
mipolytext.o mibitblt.o mipolypnt.o mipushpxl.o \
miexpose.o miglblt.o mizerline.o mizerclip.o mifpolycon.o \
midash.o mibstore.o mibank.o $(MIINITEXTOBJ) mieq.o \
mipointer.o misprite.o midispcur.o miscrinit.o miclipn.o migc.o \
micmap.o mioverlay.o
#if (!(defined(NXAgentServer) && NXAgentServer))
NXAGENT_SKIP_SRCS = \
miexpose.c \
$(NULL)
NXAGENT_SKIP_OBJS = \
miexpose.o \
$(NULL)
#endif
SRCS = $(CBRT_SRC) \
mivaltree.c \
mipolyseg.c \
mipolyrect.c \
mipoly.c \
mipolycon.c \
mipolygen.c \
mipolyutil.c \
mifillrct.c \
miwideline.c \
mispans.c \
miarc.c \
mizerarc.c \
mifillarc.c \
miwindow.c \
micursor.c \
mipolytext.c \
mibitblt.c \
mipolypnt.c \
mipushpxl.c \
miglblt.c \
mizerline.c \
mizerclip.c \
mifpolycon.c \
midash.c \
mibstore.c \
mibank.c \
$(MIINITEXTSRC) \
mieq.c \
mipointer.c \
misprite.c \
midispcur.c \
miscrinit.c \
miclipn.c \
migc.c \
micmap.c \
mioverlay.c \
$(NXAGENT_SKIP_SRCS) \
$(NULL)
OBJS = $(CBRT_OBJ) \
mivaltree.o \
mipolyseg.o \
mipolyrect.o \
mipoly.o \
mipolycon.o \
mipolygen.o \
mipolyutil.o \
mifillrct.o \
miwideline.o \
mispans.o \
miarc.o \
mizerarc.o \
mifillarc.o \
miwindow.o \
micursor.o \
mipolytext.o \
mibitblt.o \
mipolypnt.o \
mipushpxl.o \
miglblt.o \
mizerline.o \
mizerclip.o \
mifpolycon.o \
midash.o \
mibstore.o \
mibank.o \
$(MIINITEXTOBJ) \
mieq.o \
mipointer.o \
misprite.o \
midispcur.o \
miscrinit.o \
miclipn.o \
migc.o \
micmap.o \
mioverlay.o \
$(NXAGENT_SKIP_OBJS) \
$(NULL)
#if defined(XorgVersion)
/*
......@@ -83,16 +148,27 @@ EXT_DEFINES = ExtensionDefines \
EXT_DEFINES = ExtensionDefines -UXINPUT \
-UXFree86LOADER
#endif
#endif
INCLUDES = -I. -I../include -I../render \
-I../xfixes -I../damageext -I../miext/damage \
-I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
`pkg-config --cflags-only-I pixman-1`
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
INCLUDES = -I. \
-I../include \
-I../render \
-I../xfixes \
-I../damageext \
-I../miext/damage \
-I$(XINCLUDESRC) \
-I$(EXTINCSRC) \
-I$(SERVERSRC)/Xext \
`pkg-config --cflags-only-I pixman-1` \
$(NULL)
LINTLIBS = \
../dix/llib-ldix.ln \
../os/llib-los.ln \
$(NULL)
DEFINES = $(FFS_DEFINES)
NormalLibraryObjectRule()
......
......@@ -130,6 +130,7 @@ exposing is done by the backing store's GraphicsExpose function, of course.
*/
#ifndef NXAGENT_SERVER
RegionPtr
miHandleExposures(pSrcDrawable, pDstDrawable,
pGC, srcx, srcy, width, height, dstx, dsty, plane)
......@@ -376,6 +377,7 @@ miHandleExposures(pSrcDrawable, pDstDrawable,
return NULL;
}
}
#endif
/* send GraphicsExpose events, or a NoExpose event, based on the region */
......@@ -495,6 +497,7 @@ miSendExposures(pWin, pRgn, dx, dy)
DEALLOCATE_LOCAL(pEvent);
}
#ifndef NXAGENT_SERVER
void
miWindowExposures(pWin, prgn, other_exposed)
WindowPtr pWin;
......@@ -583,7 +586,7 @@ miWindowExposures(pWin, prgn, other_exposed)
else if (exposures && exposures != prgn)
RegionDestroy(exposures);
}
#endif
/*
this code is highly unlikely. it is not haile selassie.
......@@ -631,7 +634,7 @@ tossGC (
return 0;
}
#ifndef NXAGENT_SERVER
void
miPaintWindow(pWin, prgn, what)
register WindowPtr pWin;
......@@ -654,7 +657,7 @@ int what;
#define COUNT_BITS 8
ChangeGCVal gcval[7];
ChangeGCVal newValues [COUNT_BITS];
ChangeGCVal newValues [COUNT_BITS] = {{ 0 }};
BITS32 gcmask, index, mask;
RegionRec prgnWin;
......@@ -881,7 +884,7 @@ int what;
FreeScratchGC(pGC);
}
}
#endif
/* MICLEARDRAWABLE -- sets the entire drawable to the background color of
* the GC. Useful when we have a scratch drawable and need to initialize
......
......@@ -1048,7 +1048,25 @@ miSetShape(pWin)
bsExposed = (*pScreen->TranslateBackingStore)
(pWin, 0, 0, pOldClip,
pWin->drawable.x, pWin->drawable.y);
if (WasViewable)
/*
* Applies to NXAGENT_SERVER builds:
*
* We got a few, rare, segfaults here after having
* started using the backing store. It may be a
* different bug but miChangeSaveUnder() calls mi-
* CheckSubSaveUnder() that, in turn, can change
* the backing store attribute of the window. This
* means that we may try to destroy the region
* even if it was not created at the beginning of
* this function as, at the time, the backing store
* was off. miCheckSubSaveUnder() appear to get a
* pointer to the parent, so maybe doesn't change
* the attribute of the window itself. This is to
* be better investigated.
*/
if (WasViewable && pOldClip)
RegionDestroy(pOldClip);
if (bsExposed)
{
......
......@@ -5,6 +5,7 @@
DEFINES = -DROOTLESS_WORKAROUND
#endif
#if (!(defined(NXAgentServer) && NXAgentServer))
SRCS = damage.c
OBJS = damage.o
......@@ -21,6 +22,7 @@ NormalLibraryTarget(damage,$(OBJS))
LintLibraryTarget(damage,$(SRCS))
NormalLintTarget($(SRCS))
#endif
DependTarget()
......
......@@ -1324,6 +1324,8 @@ damageDamageChars (DrawablePtr pDrawable,
#define TT_POLY16 2
#define TT_IMAGE16 3
#ifndef NXAGENT_SERVER
static int
damageText (DrawablePtr pDrawable,
GCPtr pGC,
......@@ -1445,6 +1447,7 @@ damageImageText16(DrawablePtr pDrawable,
DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
}
#endif /* NXAGENT_SERVER */
static void
damageImageGlyphBlt(DrawablePtr pDrawable,
......
XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15 keithp Exp $
NULL =
#include <Server.tmpl>
#if (!(defined(NXAgentServer) && NXAgentServer))
NXAGENT_SKIP_SRCS = \
glyph.c \
miglyph.c \
mitrap.c \
picture.c \
render.c \
$(NULL)
NXAGENT_SKIP_OBJS = \
glyph.o \
miglyph.o \
mitrap.o \
picture.o \
render.o \
$(NULL)
#else
DEFINES = -DNXAGENT_SERVER
#endif
SRCS = animcur.c \
filter.c \
glyph.c \
matrix.c \
miglyph.c \
miindex.c \
mipict.c \
mirect.c \
mitrap.c \
mitri.c \
picture.c \
render.c \
renderedge.c
renderedge.c \
$(NXAGENT_SKIP_SRCS) \
$(NULL)
OBJS = animcur.o \
filter.o \
glyph.o \
matrix.o \
miglyph.o \
miindex.o \
mipict.o \
mirect.o \
mitrap.o \
mitri.o \
picture.o \
render.o \
renderedge.o
renderedge.o \
$(NXAGENT_SKIP_OBJS) \
$(NULL)
INCLUDES = -I. -I../include -I../mi \
-I../fb -I../hw/kdrive -I$(EXTINCSRC) -I$(XINCLUDESRC) \
......@@ -46,4 +64,3 @@ InstallDriverSDKNonExecFile(glyphstr.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(mipict.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(picture.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(picturestr.h,$(DRIVERSDKINCLUDEDIR))
......@@ -268,6 +268,7 @@ FreeGlyph (GlyphPtr glyph, int format)
}
}
#ifndef NXAGENT_SERVER
void
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
{
......@@ -301,6 +302,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
gr->signature = id;
CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom");
}
#endif /* NXAGENT_SERVER */
Bool
DeleteGlyph (GlyphSetPtr glyphSet, Glyph id)
......@@ -320,6 +322,7 @@ DeleteGlyph (GlyphSetPtr glyphSet, Glyph id)
return FALSE;
}
#ifndef NXAGENT_SERVER
GlyphPtr
FindGlyph (GlyphSetPtr glyphSet, Glyph id)
{
......@@ -330,6 +333,7 @@ FindGlyph (GlyphSetPtr glyphSet, Glyph id)
glyph = 0;
return glyph;
}
#endif /* NXAGENT_SERVER */
GlyphPtr
AllocateGlyph (xGlyphInfo *gi, int fdepth)
......@@ -363,6 +367,8 @@ AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
return TRUE;
}
#ifndef NXAGENT_SERVER
Bool
ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
{
......@@ -405,6 +411,7 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
CheckDuplicates (hash, "ResizeGlyphHash bottom");
return TRUE;
}
#endif /* NXAGENT_SERVER */
Bool
ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change)
......
......@@ -44,10 +44,14 @@ typedef struct _Glyph {
/* bits follow */
} GlyphRec, *GlyphPtr;
#ifdef NXAGENT_SERVER
#include "../hw/nxagent/NXglyphstr_GlyphRef.h"
#else
typedef struct _GlyphRef {
CARD32 signature;
GlyphPtr glyph;
} GlyphRefRec, *GlyphRefPtr;
#endif /* NXAGENT_SERVER */
#define DeletedGlyph ((GlyphPtr) 1)
......@@ -63,6 +67,9 @@ typedef struct _GlyphHash {
CARD32 tableEntries;
} GlyphHashRec, *GlyphHashPtr;
#ifdef NXAGENT_SERVER
#include "../hw/nxagent/NXglyphstr_GlyphSet.h"
#else
typedef struct _GlyphSet {
CARD32 refcnt;
PictFormatPtr format;
......@@ -71,6 +78,7 @@ typedef struct _GlyphSet {
int maxPrivate;
void **devPrivates;
} GlyphSetRec, *GlyphSetPtr;
#endif /* NXAGENT_SERVER */
#define GlyphSetGetPrivate(pGlyphSet,n) \
((n) > (pGlyphSet)->maxPrivate ? \
......
......@@ -89,6 +89,7 @@ miGlyphExtents (int nlist,
#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
#ifndef NXAGENT_SERVER
void
miGlyphs (CARD8 op,
PicturePtr pSrc,
......@@ -241,3 +242,4 @@ miGlyphs (CARD8 op,
(*pScreen->DestroyPixmap) (pMaskPixmap);
}
}
#endif
......@@ -128,6 +128,7 @@ miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box)
}
}
#ifndef NXAGENT_SERVER
void
miTrapezoids (CARD8 op,
PicturePtr pSrc,
......@@ -188,3 +189,4 @@ miTrapezoids (CARD8 op,
miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
}
}
#endif
......@@ -40,7 +40,10 @@
#include "dixstruct.h"
#include "gcstruct.h"
#include "servermd.h"
#ifndef NXAGENT_SERVER
#include "picturestr.h"
#endif
int PictureScreenPrivateIndex = -1;
int PictureWindowPrivateIndex;
......@@ -212,6 +215,7 @@ addFormat (FormatInitRec formats[256],
#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1))
#ifndef NXAGENT_SERVER
PictFormatPtr
PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
{
......@@ -431,6 +435,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
*nformatp = nformats;
return pFormats;
}
#endif
static VisualPtr
PictureFindVisual (ScreenPtr pScreen, VisualID visual)
......@@ -767,6 +772,7 @@ SetPictureToDefaults (PicturePtr pPicture)
pPicture->pSourcePict = 0;
}
#ifndef NXAGENT_SERVER
PicturePtr
AllocatePicture (ScreenPtr pScreen)
{
......@@ -847,6 +853,7 @@ CreatePicture (Picture pid,
}
return pPicture;
}
#endif
static CARD32 xRenderColorToCard32(xRenderColor c)
{
......@@ -969,6 +976,7 @@ static void initGradient(SourcePictPtr pGradient, int stopCount,
initGradientColorTable(pGradient, error);
}
#ifndef NXAGENT_SERVER
static PicturePtr createSourcePicture(void)
{
PicturePtr pPicture;
......@@ -1002,6 +1010,7 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
return pPicture;
}
#endif
PicturePtr
CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
......@@ -1592,6 +1601,7 @@ ValidatePicture(PicturePtr pPicture)
ValidateOnePicture (pPicture->alphaMap);
}
#ifndef NXAGENT_SERVER
int
FreePicture (void * value,
XID pid)
......@@ -1641,6 +1651,7 @@ FreePicture (void * value,
}
return Success;
}
#endif
int
FreePictFormat (void * pPictFormat,
......
......@@ -65,10 +65,14 @@ typedef struct pixman_transform PictTransform, *PictTransformPtr;
#define SourcePictTypeRadial 2
#define SourcePictTypeConical 3
#ifdef NXAGENT_SERVER
#include "../hw/nxagent/NXpicturestr_PictSolidFill.h"
#else
typedef struct _PictSolidFill {
unsigned int type;
CARD32 color;
} PictSolidFill, *PictSolidFillPtr;
#endif /* NXAGENT_SERVER */
typedef struct _PictGradientStop {
xFixed x;
......
......@@ -275,6 +275,7 @@ RenderResetProc (ExtensionEntry *extEntry)
ResetGlyphSetPrivateIndex();
}
#ifndef NXAGENT_SERVER
static int
ProcRenderQueryVersion (ClientPtr client)
{
......@@ -303,6 +304,7 @@ ProcRenderQueryVersion (ClientPtr client)
WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep);
return (client->noClientException);
}
#endif /* NXAGENT_SERVER */
#if 0
static int
......@@ -341,6 +343,7 @@ findVisual (ScreenPtr pScreen, VisualID vid)
extern char *ConnectionInfo;
#ifndef NXAGENT_SERVER
static int
ProcRenderQueryPictFormats (ClientPtr client)
{
......@@ -550,6 +553,7 @@ ProcRenderQueryPictFormats (ClientPtr client)
xfree (reply);
return client->noClientException;
}
#endif /* NXAGENT_SERVER */
static int
ProcRenderQueryPictIndexValues (ClientPtr client)
......@@ -621,6 +625,7 @@ ProcRenderQueryDithers (ClientPtr client)
return BadImplementation;
}
#ifndef NXAGENT_SERVER
static int
ProcRenderCreatePicture (ClientPtr client)
{
......@@ -710,6 +715,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
else
return(result);
}
#endif /* NXAGENT_SERVER */
static int
ProcRenderFreePicture (ClientPtr client)
......@@ -737,6 +743,7 @@ PictOpValid (CARD8 op)
return FALSE;
}
#ifndef NXAGENT_SERVER
static int
ProcRenderComposite (ClientPtr client)
{
......@@ -774,6 +781,7 @@ ProcRenderComposite (ClientPtr client)
stuff->height);
return Success;
}
#endif /* NXAGENT_SERVER */
static int
ProcRenderScale (ClientPtr client)
......@@ -781,6 +789,7 @@ ProcRenderScale (ClientPtr client)
return BadImplementation;
}
#ifndef NXAGENT_SERVER
static int
ProcRenderTrapezoids (ClientPtr client)
{
......@@ -827,6 +836,7 @@ ProcRenderTrapezoids (ClientPtr client)
ntraps, (xTrapezoid *) &stuff[1]);
return client->noClientException;
}
#endif /* NXAGENT_SERVER */
static int
ProcRenderTriangles (ClientPtr client)
......@@ -987,6 +997,7 @@ ProcRenderTransform (ClientPtr client)
return BadImplementation;
}
#ifndef NXAGENT_SERVER
static int
ProcRenderCreateGlyphSet (ClientPtr client)
{
......@@ -1060,10 +1071,12 @@ ProcRenderReferenceGlyphSet (ClientPtr client)
return BadAlloc;
return client->noClientException;
}
#endif /* NXAGENT_SERVER */
#define NLOCALDELTA 64
#define NLOCALGLYPH 256
#ifndef NXAGENT_SERVER
static int
ProcRenderFreeGlyphSet (ClientPtr client)
{
......@@ -1083,6 +1096,7 @@ ProcRenderFreeGlyphSet (ClientPtr client)
FreeResource (stuff->glyphset, RT_NONE);
return client->noClientException;
}
#endif /* NXAGENT_SERVER */
typedef struct _GlyphNew {
Glyph id;
......@@ -1096,7 +1110,7 @@ ProcRenderAddGlyphs (ClientPtr client)
REQUEST(xRenderAddGlyphsReq);
GlyphNewRec glyphsLocal[NLOCALGLYPH];
GlyphNewPtr glyphsBase, glyphs;
GlyphPtr glyph;
GlyphPtr glyph = NULL;
int remain, nglyphs;
CARD32 *gids;
xGlyphInfo *gi;
......@@ -1199,6 +1213,7 @@ ProcRenderAddGlyphsFromPicture (ClientPtr client)
return BadImplementation;
}
#ifndef NXAGENT_SERVER
static int
ProcRenderFreeGlyphs (ClientPtr client)
{
......@@ -1454,6 +1469,7 @@ ProcRenderFillRectangles (ClientPtr client)
return client->noClientException;
}
#endif /* NXAGENT_SERVER */
static void
SetBit (unsigned char *line, int x, int bit)
......@@ -1481,6 +1497,7 @@ static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = {
#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1)
#ifndef NXAGENT_SERVER
static int
ProcRenderCreateCursor (ClientPtr client)
{
......@@ -1694,6 +1711,7 @@ ProcRenderSetPictureTransform (ClientPtr client)
else
return(result);
}
#endif /* NXAGENT_SERVER */
static int
ProcRenderQueryFilters (ClientPtr client)
......@@ -1804,6 +1822,7 @@ ProcRenderQueryFilters (ClientPtr client)
return(client->noClientException);
}
#ifndef NXAGENT_SERVER
static int
ProcRenderSetPictureFilter (ClientPtr client)
{
......@@ -1868,6 +1887,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
return client->noClientException;
return BadAlloc;
}
#endif /* NXAGENT_SERVER */
static int
ProcRenderAddTraps (ClientPtr client)
......@@ -1892,6 +1912,7 @@ ProcRenderAddTraps (ClientPtr client)
return client->noClientException;
}
#ifndef NXAGENT_SERVER
static int ProcRenderCreateSolidFill(ClientPtr client)
{
PicturePtr pPicture;
......@@ -2011,6 +2032,7 @@ ProcRenderDispatch (ClientPtr client)
else
return BadRequest;
}
#endif /* NXAGENT_SERVER */
static int
SProcRenderQueryVersion (ClientPtr client)
......@@ -2516,13 +2538,11 @@ static void swapStops(void *stuff, int num)
{
int i, n;
CARD32 *stops;
CARD16 *colors;
stops = (CARD32 *)(stuff);
for (i = 0; i < num; ++i) {
swapl(stops, n);
++stops;
}
colors = (CARD16 *)(stops);
for (i = 0; i < 4*num; ++i) {
swaps(stops, n);
++stops;
......@@ -2611,6 +2631,7 @@ SProcRenderCreateConicalGradient (ClientPtr client)
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
#ifndef NXAGENT_SERVER
static int
SProcRenderDispatch (ClientPtr client)
{
......@@ -2621,6 +2642,7 @@ SProcRenderDispatch (ClientPtr client)
else
return BadRequest;
}
#endif /* NXAGENT_SERVER */
#ifdef PANORAMIX
#include "panoramiX.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment