aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/render
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/render')
-rw-r--r--xorg-server/render/animcur.c860
-rw-r--r--xorg-server/render/filter.c718
-rw-r--r--xorg-server/render/glyph.c1508
-rw-r--r--xorg-server/render/miindex.c716
-rw-r--r--xorg-server/render/mipict.c1286
-rw-r--r--xorg-server/render/mirect.c371
-rw-r--r--xorg-server/render/mitri.c382
-rw-r--r--xorg-server/render/picture.c56
-rw-r--r--xorg-server/render/render.c164
9 files changed, 3026 insertions, 3035 deletions
diff --git a/xorg-server/render/animcur.c b/xorg-server/render/animcur.c
index 276e5e4af..dd44bd17f 100644
--- a/xorg-server/render/animcur.c
+++ b/xorg-server/render/animcur.c
@@ -1,430 +1,430 @@
-/*
- *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 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.
- */
-
-/*
- * Animated cursors for X. Not specific to Render in any way, but
- * stuck there because Render has the other cool cursor extension.
- * Besides, everyone has Render.
- *
- * Implemented as a simple layer over the core cursor code; it
- * creates composite cursors out of a set of static cursors and
- * delta times between each image.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "servermd.h"
-#include "scrnintstr.h"
-#include "dixstruct.h"
-#include "cursorstr.h"
-#include "dixfontstr.h"
-#include "opaque.h"
-#include "picturestr.h"
-#include "inputstr.h"
-#include "xace.h"
-
-typedef struct _AnimCurElt {
- CursorPtr pCursor; /* cursor to show */
- CARD32 delay; /* in ms */
-} AnimCurElt;
-
-typedef struct _AnimCur {
- int nelt; /* number of elements in the elts array */
- AnimCurElt *elts; /* actually allocated right after the structure */
-} AnimCurRec, *AnimCurPtr;
-
-typedef struct _AnimScrPriv {
- CursorPtr pCursor;
- int elt;
- CARD32 time;
-
- CloseScreenProcPtr CloseScreen;
-
- ScreenBlockHandlerProcPtr BlockHandler;
-
- CursorLimitsProcPtr CursorLimits;
- DisplayCursorProcPtr DisplayCursor;
- SetCursorPositionProcPtr SetCursorPosition;
- RealizeCursorProcPtr RealizeCursor;
- UnrealizeCursorProcPtr UnrealizeCursor;
- RecolorCursorProcPtr RecolorCursor;
-} AnimCurScreenRec, *AnimCurScreenPtr;
-
-typedef struct _AnimCurState {
- CursorPtr pCursor;
- ScreenPtr pScreen;
- int elt;
- CARD32 time;
-} AnimCurStateRec, *AnimCurStatePtr;
-
-/* What a waste. But we need an API change to alloc it per device only. */
-static AnimCurStateRec animCurState[MAXDEVICES];
-
-static unsigned char empty[4];
-
-static CursorBits animCursorBits = {
- empty, empty, 2, 1, 1, 0, 0, 1
-};
-
-static int AnimCurGeneration;
-
-static int AnimCurScreenPrivateKeyIndex;
-static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
-
-#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
-#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
-#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
-#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
-#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
-
-#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
-#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
-
-
-static Bool
-AnimCurCloseScreen (int index, ScreenPtr pScreen)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap(as, pScreen, CloseScreen);
-
- Unwrap(as, pScreen, BlockHandler);
-
- Unwrap(as, pScreen, CursorLimits);
- Unwrap(as, pScreen, DisplayCursor);
- Unwrap(as, pScreen, SetCursorPosition);
- Unwrap(as, pScreen, RealizeCursor);
- Unwrap(as, pScreen, UnrealizeCursor);
- Unwrap(as, pScreen, RecolorCursor);
- SetAnimCurScreen(pScreen,0);
- ret = (*pScreen->CloseScreen) (index, pScreen);
- xfree (as);
- return ret;
-}
-
-static void
-AnimCurCursorLimits (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor,
- BoxPtr pHotBox,
- BoxPtr pTopLeftBox)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
-
- Unwrap (as, pScreen, CursorLimits);
- if (IsAnimCur(pCursor))
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
-
- (*pScreen->CursorLimits) (pDev, pScreen, ac->elts[0].pCursor,
- pHotBox, pTopLeftBox);
- }
- else
- {
- (*pScreen->CursorLimits) (pDev, pScreen, pCursor,
- pHotBox, pTopLeftBox);
- }
- Wrap (as, pScreen, CursorLimits, AnimCurCursorLimits);
-}
-
-/*
- * This has to be a screen block handler instead of a generic
- * block handler so that it is well ordered with respect to the DRI
- * block handler responsible for releasing the hardware to DRI clients
- */
-
-static void
-AnimCurScreenBlockHandler (int screenNum,
- pointer blockData,
- pointer pTimeout,
- pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- DeviceIntPtr dev;
- CARD32 now = 0,
- soonest = ~0; /* earliest time to wakeup again */
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (IsPointerDevice(dev) && pScreen == animCurState[dev->id].pScreen)
- {
- if (!now) now = GetTimeInMillis ();
-
- if ((INT32) (now - animCurState[dev->id].time) >= 0)
- {
- AnimCurPtr ac = GetAnimCur(animCurState[dev->id].pCursor);
- int elt = (animCurState[dev->id].elt + 1) % ac->nelt;
- DisplayCursorProcPtr DisplayCursor;
-
- /*
- * Not a simple Unwrap/Wrap as this
- * isn't called along the DisplayCursor
- * wrapper chain.
- */
- DisplayCursor = pScreen->DisplayCursor;
- pScreen->DisplayCursor = as->DisplayCursor;
- (void) (*pScreen->DisplayCursor) (dev,
- pScreen,
- ac->elts[elt].pCursor);
- as->DisplayCursor = pScreen->DisplayCursor;
- pScreen->DisplayCursor = DisplayCursor;
-
- animCurState[dev->id].elt = elt;
- animCurState[dev->id].time = now + ac->elts[elt].delay;
- }
-
- if (soonest > animCurState[dev->id].time)
- soonest = animCurState[dev->id].time;
- }
- }
-
- if (now)
- AdjustWaitForDelay (pTimeout, soonest - now);
-
- Unwrap (as, pScreen, BlockHandler);
- (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
- Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
-}
-
-static Bool
-AnimCurDisplayCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, DisplayCursor);
- if (IsAnimCur(pCursor))
- {
- if (pCursor != animCurState[pDev->id].pCursor)
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
-
- ret = (*pScreen->DisplayCursor)
- (pDev, pScreen, ac->elts[0].pCursor);
- if (ret)
- {
- animCurState[pDev->id].elt = 0;
- animCurState[pDev->id].time = GetTimeInMillis () + ac->elts[0].delay;
- animCurState[pDev->id].pCursor = pCursor;
- animCurState[pDev->id].pScreen = pScreen;
- }
- }
- else
- ret = TRUE;
- }
- else
- {
- animCurState[pDev->id].pCursor = 0;
- animCurState[pDev->id].pScreen = 0;
- ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
- }
- Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
- return ret;
-}
-
-static Bool
-AnimCurSetCursorPosition (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- int x,
- int y,
- Bool generateEvent)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, SetCursorPosition);
- if (animCurState[pDev->id].pCursor)
- animCurState[pDev->id].pScreen = pScreen;
- ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
- Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
- return ret;
-}
-
-static Bool
-AnimCurRealizeCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, RealizeCursor);
- if (IsAnimCur(pCursor))
- ret = TRUE;
- else
- ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
- Wrap (as, pScreen, RealizeCursor, AnimCurRealizeCursor);
- return ret;
-}
-
-static Bool
-AnimCurUnrealizeCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, UnrealizeCursor);
- if (IsAnimCur(pCursor))
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
- int i;
-
- if (pScreen->myNum == 0)
- for (i = 0; i < ac->nelt; i++)
- FreeCursor (ac->elts[i].pCursor, 0);
- ret = TRUE;
- }
- else
- ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
- Wrap (as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
- return ret;
-}
-
-static void
-AnimCurRecolorCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor,
- Bool displayed)
-{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
-
- Unwrap (as, pScreen, RecolorCursor);
- if (IsAnimCur(pCursor))
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
- int i;
-
- for (i = 0; i < ac->nelt; i++)
- (*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
- displayed &&
- animCurState[pDev->id].elt == i);
- }
- else
- (*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
- Wrap (as, pScreen, RecolorCursor, AnimCurRecolorCursor);
-}
-
-Bool
-AnimCurInit (ScreenPtr pScreen)
-{
- AnimCurScreenPtr as;
-
- if (AnimCurGeneration != serverGeneration)
- {
- int i;
- AnimCurGeneration = serverGeneration;
- for (i = 0; i < MAXDEVICES; i++) {
- animCurState[i].pCursor = 0;
- animCurState[i].pScreen = 0;
- animCurState[i].elt = 0;
- animCurState[i].time = 0;
- }
- }
- as = (AnimCurScreenPtr) xalloc (sizeof (AnimCurScreenRec));
- if (!as)
- return FALSE;
- Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
-
- Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
-
- Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
- Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
- Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
- Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
- Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
- Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
- SetAnimCurScreen(pScreen,as);
- return TRUE;
-}
-
-int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid)
-{
- CursorPtr pCursor;
- int rc, i;
- AnimCurPtr ac;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- if (!GetAnimCurScreenIfSet (screenInfo.screens[i]))
- return BadImplementation;
-
- for (i = 0; i < ncursor; i++)
- if (IsAnimCur (cursors[i]))
- return BadMatch;
-
- pCursor = (CursorPtr) xalloc (sizeof (CursorRec) +
- sizeof (AnimCurRec) +
- ncursor * sizeof (AnimCurElt));
- if (!pCursor)
- return BadAlloc;
- pCursor->bits = &animCursorBits;
- pCursor->refcnt = 1;
-
- pCursor->foreRed = cursors[0]->foreRed;
- pCursor->foreGreen = cursors[0]->foreGreen;
- pCursor->foreBlue = cursors[0]->foreBlue;
-
- pCursor->backRed = cursors[0]->backRed;
- pCursor->backGreen = cursors[0]->backGreen;
- pCursor->backBlue = cursors[0]->backBlue;
-
- pCursor->id = cid;
- pCursor->devPrivates = NULL;
-
- /* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
- RT_NONE, NULL, DixCreateAccess);
- if (rc != Success) {
- dixFreePrivates(pCursor->devPrivates);
- xfree(pCursor);
- return rc;
- }
-
- /*
- * Fill in the AnimCurRec
- */
- animCursorBits.refcnt++;
- ac = GetAnimCur (pCursor);
- ac->nelt = ncursor;
- ac->elts = (AnimCurElt *) (ac + 1);
-
- for (i = 0; i < ncursor; i++)
- {
- cursors[i]->refcnt++;
- ac->elts[i].pCursor = cursors[i];
- ac->elts[i].delay = deltas[i];
- }
-
- *ppCursor = pCursor;
- return Success;
-}
+/*
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 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.
+ */
+
+/*
+ * Animated cursors for X. Not specific to Render in any way, but
+ * stuck there because Render has the other cool cursor extension.
+ * Besides, everyone has Render.
+ *
+ * Implemented as a simple layer over the core cursor code; it
+ * creates composite cursors out of a set of static cursors and
+ * delta times between each image.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "dixfontstr.h"
+#include "opaque.h"
+#include "picturestr.h"
+#include "inputstr.h"
+#include "xace.h"
+
+typedef struct _AnimCurElt {
+ CursorPtr pCursor; /* cursor to show */
+ CARD32 delay; /* in ms */
+} AnimCurElt;
+
+typedef struct _AnimCur {
+ int nelt; /* number of elements in the elts array */
+ AnimCurElt *elts; /* actually allocated right after the structure */
+} AnimCurRec, *AnimCurPtr;
+
+typedef struct _AnimScrPriv {
+ CursorPtr pCursor;
+ int elt;
+ CARD32 time;
+
+ CloseScreenProcPtr CloseScreen;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+
+ CursorLimitsProcPtr CursorLimits;
+ DisplayCursorProcPtr DisplayCursor;
+ SetCursorPositionProcPtr SetCursorPosition;
+ RealizeCursorProcPtr RealizeCursor;
+ UnrealizeCursorProcPtr UnrealizeCursor;
+ RecolorCursorProcPtr RecolorCursor;
+} AnimCurScreenRec, *AnimCurScreenPtr;
+
+typedef struct _AnimCurState {
+ CursorPtr pCursor;
+ ScreenPtr pScreen;
+ int elt;
+ CARD32 time;
+} AnimCurStateRec, *AnimCurStatePtr;
+
+/* What a waste. But we need an API change to alloc it per device only. */
+static AnimCurStateRec animCurState[MAXDEVICES];
+
+static unsigned char empty[4];
+
+static CursorBits animCursorBits = {
+ empty, empty, 2, 1, 1, 0, 0, 1
+};
+
+static int AnimCurGeneration;
+
+static int AnimCurScreenPrivateKeyIndex;
+static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
+
+#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
+#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
+#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
+#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
+
+#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
+#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
+
+
+static Bool
+AnimCurCloseScreen (int index, ScreenPtr pScreen)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap(as, pScreen, CloseScreen);
+
+ Unwrap(as, pScreen, BlockHandler);
+
+ Unwrap(as, pScreen, CursorLimits);
+ Unwrap(as, pScreen, DisplayCursor);
+ Unwrap(as, pScreen, SetCursorPosition);
+ Unwrap(as, pScreen, RealizeCursor);
+ Unwrap(as, pScreen, UnrealizeCursor);
+ Unwrap(as, pScreen, RecolorCursor);
+ SetAnimCurScreen(pScreen,0);
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ free(as);
+ return ret;
+}
+
+static void
+AnimCurCursorLimits (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ BoxPtr pHotBox,
+ BoxPtr pTopLeftBox)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+
+ Unwrap (as, pScreen, CursorLimits);
+ if (IsAnimCur(pCursor))
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+
+ (*pScreen->CursorLimits) (pDev, pScreen, ac->elts[0].pCursor,
+ pHotBox, pTopLeftBox);
+ }
+ else
+ {
+ (*pScreen->CursorLimits) (pDev, pScreen, pCursor,
+ pHotBox, pTopLeftBox);
+ }
+ Wrap (as, pScreen, CursorLimits, AnimCurCursorLimits);
+}
+
+/*
+ * This has to be a screen block handler instead of a generic
+ * block handler so that it is well ordered with respect to the DRI
+ * block handler responsible for releasing the hardware to DRI clients
+ */
+
+static void
+AnimCurScreenBlockHandler (int screenNum,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ DeviceIntPtr dev;
+ CARD32 now = 0,
+ soonest = ~0; /* earliest time to wakeup again */
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (IsPointerDevice(dev) && pScreen == animCurState[dev->id].pScreen)
+ {
+ if (!now) now = GetTimeInMillis ();
+
+ if ((INT32) (now - animCurState[dev->id].time) >= 0)
+ {
+ AnimCurPtr ac = GetAnimCur(animCurState[dev->id].pCursor);
+ int elt = (animCurState[dev->id].elt + 1) % ac->nelt;
+ DisplayCursorProcPtr DisplayCursor;
+
+ /*
+ * Not a simple Unwrap/Wrap as this
+ * isn't called along the DisplayCursor
+ * wrapper chain.
+ */
+ DisplayCursor = pScreen->DisplayCursor;
+ pScreen->DisplayCursor = as->DisplayCursor;
+ (void) (*pScreen->DisplayCursor) (dev,
+ pScreen,
+ ac->elts[elt].pCursor);
+ as->DisplayCursor = pScreen->DisplayCursor;
+ pScreen->DisplayCursor = DisplayCursor;
+
+ animCurState[dev->id].elt = elt;
+ animCurState[dev->id].time = now + ac->elts[elt].delay;
+ }
+
+ if (soonest > animCurState[dev->id].time)
+ soonest = animCurState[dev->id].time;
+ }
+ }
+
+ if (now)
+ AdjustWaitForDelay (pTimeout, soonest - now);
+
+ Unwrap (as, pScreen, BlockHandler);
+ (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
+ Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+}
+
+static Bool
+AnimCurDisplayCursor (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, DisplayCursor);
+ if (IsAnimCur(pCursor))
+ {
+ if (pCursor != animCurState[pDev->id].pCursor)
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+
+ ret = (*pScreen->DisplayCursor)
+ (pDev, pScreen, ac->elts[0].pCursor);
+ if (ret)
+ {
+ animCurState[pDev->id].elt = 0;
+ animCurState[pDev->id].time = GetTimeInMillis () + ac->elts[0].delay;
+ animCurState[pDev->id].pCursor = pCursor;
+ animCurState[pDev->id].pScreen = pScreen;
+ }
+ }
+ else
+ ret = TRUE;
+ }
+ else
+ {
+ animCurState[pDev->id].pCursor = 0;
+ animCurState[pDev->id].pScreen = 0;
+ ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
+ }
+ Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
+ return ret;
+}
+
+static Bool
+AnimCurSetCursorPosition (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, SetCursorPosition);
+ if (animCurState[pDev->id].pCursor)
+ animCurState[pDev->id].pScreen = pScreen;
+ ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
+ Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
+ return ret;
+}
+
+static Bool
+AnimCurRealizeCursor (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, RealizeCursor);
+ if (IsAnimCur(pCursor))
+ ret = TRUE;
+ else
+ ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
+ Wrap (as, pScreen, RealizeCursor, AnimCurRealizeCursor);
+ return ret;
+}
+
+static Bool
+AnimCurUnrealizeCursor (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, UnrealizeCursor);
+ if (IsAnimCur(pCursor))
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+ int i;
+
+ if (pScreen->myNum == 0)
+ for (i = 0; i < ac->nelt; i++)
+ FreeCursor (ac->elts[i].pCursor, 0);
+ ret = TRUE;
+ }
+ else
+ ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
+ Wrap (as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
+ return ret;
+}
+
+static void
+AnimCurRecolorCursor (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+
+ Unwrap (as, pScreen, RecolorCursor);
+ if (IsAnimCur(pCursor))
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+ int i;
+
+ for (i = 0; i < ac->nelt; i++)
+ (*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
+ displayed &&
+ animCurState[pDev->id].elt == i);
+ }
+ else
+ (*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
+ Wrap (as, pScreen, RecolorCursor, AnimCurRecolorCursor);
+}
+
+Bool
+AnimCurInit (ScreenPtr pScreen)
+{
+ AnimCurScreenPtr as;
+
+ if (AnimCurGeneration != serverGeneration)
+ {
+ int i;
+ AnimCurGeneration = serverGeneration;
+ for (i = 0; i < MAXDEVICES; i++) {
+ animCurState[i].pCursor = 0;
+ animCurState[i].pScreen = 0;
+ animCurState[i].elt = 0;
+ animCurState[i].time = 0;
+ }
+ }
+ as = (AnimCurScreenPtr) malloc(sizeof (AnimCurScreenRec));
+ if (!as)
+ return FALSE;
+ Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
+
+ Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+
+ Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
+ Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
+ Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
+ Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
+ Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
+ Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
+ SetAnimCurScreen(pScreen,as);
+ return TRUE;
+}
+
+int
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid)
+{
+ CursorPtr pCursor;
+ int rc, i;
+ AnimCurPtr ac;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ if (!GetAnimCurScreenIfSet (screenInfo.screens[i]))
+ return BadImplementation;
+
+ for (i = 0; i < ncursor; i++)
+ if (IsAnimCur (cursors[i]))
+ return BadMatch;
+
+ pCursor = (CursorPtr) malloc(sizeof (CursorRec) +
+ sizeof (AnimCurRec) +
+ ncursor * sizeof (AnimCurElt));
+ if (!pCursor)
+ return BadAlloc;
+ pCursor->bits = &animCursorBits;
+ pCursor->refcnt = 1;
+
+ pCursor->foreRed = cursors[0]->foreRed;
+ pCursor->foreGreen = cursors[0]->foreGreen;
+ pCursor->foreBlue = cursors[0]->foreBlue;
+
+ pCursor->backRed = cursors[0]->backRed;
+ pCursor->backGreen = cursors[0]->backGreen;
+ pCursor->backBlue = cursors[0]->backBlue;
+
+ pCursor->id = cid;
+ pCursor->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
+ RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ dixFreePrivates(pCursor->devPrivates);
+ free(pCursor);
+ return rc;
+ }
+
+ /*
+ * Fill in the AnimCurRec
+ */
+ animCursorBits.refcnt++;
+ ac = GetAnimCur (pCursor);
+ ac->nelt = ncursor;
+ ac->elts = (AnimCurElt *) (ac + 1);
+
+ for (i = 0; i < ncursor; i++)
+ {
+ cursors[i]->refcnt++;
+ ac->elts[i].pCursor = cursors[i];
+ ac->elts[i].delay = deltas[i];
+ }
+
+ *ppCursor = pCursor;
+ return Success;
+}
diff --git a/xorg-server/render/filter.c b/xorg-server/render/filter.c
index 89cc0646a..53fb86f3d 100644
--- a/xorg-server/render/filter.c
+++ b/xorg-server/render/filter.c
@@ -1,359 +1,359 @@
-/*
- * Copyright © 2002 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.
- */
-
-#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 "picturestr.h"
-
-static char **filterNames;
-static int nfilterNames;
-
-/*
- * standard but not required filters don't have constant indices
- */
-
-int
-PictureGetFilterId (char *filter, int len, Bool makeit)
-{
- int i;
- char *name;
- char **names;
-
- if (len < 0)
- len = strlen (filter);
- for (i = 0; i < nfilterNames; i++)
- if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len))
- return i;
- if (!makeit)
- return -1;
- name = xalloc (len + 1);
- if (!name)
- return -1;
- memcpy (name, filter, len);
- name[len] = '\0';
- if (filterNames)
- names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
- else
- names = xalloc (sizeof (char *));
- if (!names)
- {
- xfree (name);
- return -1;
- }
- filterNames = names;
- i = nfilterNames++;
- filterNames[i] = name;
- return i;
-}
-
-static Bool
-PictureSetDefaultIds (void)
-{
- /* careful here -- this list must match the #define values */
-
- if (PictureGetFilterId (FilterNearest, -1, TRUE) != PictFilterNearest)
- return FALSE;
- if (PictureGetFilterId (FilterBilinear, -1, TRUE) != PictFilterBilinear)
- return FALSE;
-
- if (PictureGetFilterId (FilterFast, -1, TRUE) != PictFilterFast)
- return FALSE;
- if (PictureGetFilterId (FilterGood, -1, TRUE) != PictFilterGood)
- return FALSE;
- if (PictureGetFilterId (FilterBest, -1, TRUE) != PictFilterBest)
- return FALSE;
-
- if (PictureGetFilterId (FilterConvolution, -1, TRUE) != PictFilterConvolution)
- return FALSE;
- return TRUE;
-}
-
-char *
-PictureGetFilterName (int id)
-{
- if (0 <= id && id < nfilterNames)
- return filterNames[id];
- else
- return 0;
-}
-
-static void
-PictureFreeFilterIds (void)
-{
- int i;
-
- for (i = 0; i < nfilterNames; i++)
- xfree (filterNames[i]);
- xfree (filterNames);
- nfilterNames = 0;
- filterNames = 0;
-}
-
-int
-PictureAddFilter (ScreenPtr pScreen,
- char *filter,
- PictFilterValidateParamsProcPtr ValidateParams,
- int width,
- int height)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- int id = PictureGetFilterId (filter, -1, TRUE);
- int i;
- PictFilterPtr filters;
-
- if (id < 0)
- return -1;
- /*
- * It's an error to attempt to reregister a filter
- */
- for (i = 0; i < ps->nfilters; i++)
- if (ps->filters[i].id == id)
- return -1;
- if (ps->filters)
- filters = xrealloc (ps->filters, (ps->nfilters + 1) * sizeof (PictFilterRec));
- else
- filters = xalloc (sizeof (PictFilterRec));
- if (!filters)
- return -1;
- ps->filters = filters;
- i = ps->nfilters++;
- ps->filters[i].name = PictureGetFilterName (id);
- ps->filters[i].id = id;
- ps->filters[i].ValidateParams = ValidateParams;
- ps->filters[i].width = width;
- ps->filters[i].height = height;
- return id;
-}
-
-Bool
-PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- int filter_id = PictureGetFilterId (filter, -1, FALSE);
- int alias_id = PictureGetFilterId (alias, -1, TRUE);
- int i;
-
- if (filter_id < 0 || alias_id < 0)
- return FALSE;
- for (i = 0; i < ps->nfilterAliases; i++)
- if (ps->filterAliases[i].alias_id == alias_id)
- break;
- if (i == ps->nfilterAliases)
- {
- PictFilterAliasPtr aliases;
-
- if (ps->filterAliases)
- aliases = xrealloc (ps->filterAliases,
- (ps->nfilterAliases + 1) *
- sizeof (PictFilterAliasRec));
- else
- aliases = xalloc (sizeof (PictFilterAliasRec));
- if (!aliases)
- return FALSE;
- ps->filterAliases = aliases;
- ps->filterAliases[i].alias = PictureGetFilterName (alias_id);
- ps->filterAliases[i].alias_id = alias_id;
- ps->nfilterAliases++;
- }
- ps->filterAliases[i].filter_id = filter_id;
- return TRUE;
-}
-
-PictFilterPtr
-PictureFindFilter (ScreenPtr pScreen, char *name, int len)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- int id = PictureGetFilterId (name, len, FALSE);
- int i;
-
- if (id < 0)
- return 0;
- /* Check for an alias, allow them to recurse */
- for (i = 0; i < ps->nfilterAliases; i++)
- if (ps->filterAliases[i].alias_id == id)
- {
- id = ps->filterAliases[i].filter_id;
- i = 0;
- }
- /* find the filter */
- for (i = 0; i < ps->nfilters; i++)
- if (ps->filters[i].id == id)
- return &ps->filters[i];
- return 0;
-}
-
-static Bool
-convolutionFilterValidateParams (ScreenPtr pScreen,
- int filter,
- xFixed *params,
- int nparams,
- int *width,
- int *height)
-{
- int w, h;
- if (nparams < 3)
- return FALSE;
-
- if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
- return FALSE;
-
- w = xFixedToInt (params[0]);
- h = xFixedToInt (params[1]);
-
- nparams -= 2;
- if (w * h > nparams)
- return FALSE;
-
- *width = w;
- *height = h;
- return TRUE;
-}
-
-
-Bool
-PictureSetDefaultFilters (ScreenPtr pScreen)
-{
- if (!filterNames)
- if (!PictureSetDefaultIds ())
- return FALSE;
- if (PictureAddFilter (pScreen, FilterNearest, 0, 1, 1) < 0)
- return FALSE;
- if (PictureAddFilter (pScreen, FilterBilinear, 0, 2, 2) < 0)
- return FALSE;
-
- if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
- return FALSE;
- if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterGood))
- return FALSE;
- if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
- return FALSE;
-
- if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams, 0, 0) < 0)
- return FALSE;
-
- return TRUE;
-}
-
-void
-PictureResetFilters (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- xfree (ps->filters);
- xfree (ps->filterAliases);
- PictureFreeFilterIds ();
-}
-
-int
-SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
-{
- PictFilterPtr pFilter;
- ScreenPtr pScreen;
-
- if (pPicture->pDrawable != NULL)
- pScreen = pPicture->pDrawable->pScreen;
- else
- pScreen = screenInfo.screens[0];
-
- pFilter = PictureFindFilter (pScreen, name, len);
-
- if (!pFilter)
- return BadName;
-
- if (pPicture->pDrawable == NULL)
- {
- int s;
- /* For source pictures, the picture isn't tied to a screen. So, ensure
- * that all screens can handle a filter we set for the picture.
- */
- for (s = 1; s < screenInfo.numScreens; s++)
- {
- PictFilterPtr pScreenFilter;
- pScreenFilter = PictureFindFilter (screenInfo.screens[s],
- name, len);
- if (!pScreenFilter || pScreenFilter->id != pFilter->id)
- return BadMatch;
- }
- }
- return SetPicturePictFilter (pPicture, pFilter, params, nparams);
-}
-
-int
-SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
- xFixed *params, int nparams)
-{
- ScreenPtr pScreen;
- int i;
-
- if (pPicture->pDrawable)
- pScreen = pPicture->pDrawable->pScreen;
- else
- pScreen = screenInfo.screens[0];
-
- if (pFilter->ValidateParams)
- {
- int width, height;
- if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height))
- return BadMatch;
- }
- else if (nparams)
- return BadMatch;
-
- if (nparams != pPicture->filter_nparams)
- {
- xFixed *new_params = xalloc (nparams * sizeof (xFixed));
- if (!new_params && nparams)
- return BadAlloc;
- xfree (pPicture->filter_params);
- pPicture->filter_params = new_params;
- pPicture->filter_nparams = nparams;
- }
- for (i = 0; i < nparams; i++)
- pPicture->filter_params[i] = params[i];
- pPicture->filter = pFilter->id;
-
- if (pPicture->pDrawable)
- {
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- int result;
-
- result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
- params, nparams);
- return result;
- }
- return Success;
-}
+/*
+ * Copyright © 2002 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.
+ */
+
+#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 "picturestr.h"
+
+static char **filterNames;
+static int nfilterNames;
+
+/*
+ * standard but not required filters don't have constant indices
+ */
+
+int
+PictureGetFilterId (char *filter, int len, Bool makeit)
+{
+ int i;
+ char *name;
+ char **names;
+
+ if (len < 0)
+ len = strlen (filter);
+ for (i = 0; i < nfilterNames; i++)
+ if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len))
+ return i;
+ if (!makeit)
+ return -1;
+ name = malloc(len + 1);
+ if (!name)
+ return -1;
+ memcpy (name, filter, len);
+ name[len] = '\0';
+ if (filterNames)
+ names = realloc(filterNames, (nfilterNames + 1) * sizeof (char *));
+ else
+ names = malloc(sizeof (char *));
+ if (!names)
+ {
+ free(name);
+ return -1;
+ }
+ filterNames = names;
+ i = nfilterNames++;
+ filterNames[i] = name;
+ return i;
+}
+
+static Bool
+PictureSetDefaultIds (void)
+{
+ /* careful here -- this list must match the #define values */
+
+ if (PictureGetFilterId (FilterNearest, -1, TRUE) != PictFilterNearest)
+ return FALSE;
+ if (PictureGetFilterId (FilterBilinear, -1, TRUE) != PictFilterBilinear)
+ return FALSE;
+
+ if (PictureGetFilterId (FilterFast, -1, TRUE) != PictFilterFast)
+ return FALSE;
+ if (PictureGetFilterId (FilterGood, -1, TRUE) != PictFilterGood)
+ return FALSE;
+ if (PictureGetFilterId (FilterBest, -1, TRUE) != PictFilterBest)
+ return FALSE;
+
+ if (PictureGetFilterId (FilterConvolution, -1, TRUE) != PictFilterConvolution)
+ return FALSE;
+ return TRUE;
+}
+
+char *
+PictureGetFilterName (int id)
+{
+ if (0 <= id && id < nfilterNames)
+ return filterNames[id];
+ else
+ return 0;
+}
+
+static void
+PictureFreeFilterIds (void)
+{
+ int i;
+
+ for (i = 0; i < nfilterNames; i++)
+ free(filterNames[i]);
+ free(filterNames);
+ nfilterNames = 0;
+ filterNames = 0;
+}
+
+int
+PictureAddFilter (ScreenPtr pScreen,
+ char *filter,
+ PictFilterValidateParamsProcPtr ValidateParams,
+ int width,
+ int height)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int id = PictureGetFilterId (filter, -1, TRUE);
+ int i;
+ PictFilterPtr filters;
+
+ if (id < 0)
+ return -1;
+ /*
+ * It's an error to attempt to reregister a filter
+ */
+ for (i = 0; i < ps->nfilters; i++)
+ if (ps->filters[i].id == id)
+ return -1;
+ if (ps->filters)
+ filters = realloc(ps->filters, (ps->nfilters + 1) * sizeof (PictFilterRec));
+ else
+ filters = malloc(sizeof (PictFilterRec));
+ if (!filters)
+ return -1;
+ ps->filters = filters;
+ i = ps->nfilters++;
+ ps->filters[i].name = PictureGetFilterName (id);
+ ps->filters[i].id = id;
+ ps->filters[i].ValidateParams = ValidateParams;
+ ps->filters[i].width = width;
+ ps->filters[i].height = height;
+ return id;
+}
+
+Bool
+PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int filter_id = PictureGetFilterId (filter, -1, FALSE);
+ int alias_id = PictureGetFilterId (alias, -1, TRUE);
+ int i;
+
+ if (filter_id < 0 || alias_id < 0)
+ return FALSE;
+ for (i = 0; i < ps->nfilterAliases; i++)
+ if (ps->filterAliases[i].alias_id == alias_id)
+ break;
+ if (i == ps->nfilterAliases)
+ {
+ PictFilterAliasPtr aliases;
+
+ if (ps->filterAliases)
+ aliases = realloc(ps->filterAliases,
+ (ps->nfilterAliases + 1) *
+ sizeof (PictFilterAliasRec));
+ else
+ aliases = malloc(sizeof (PictFilterAliasRec));
+ if (!aliases)
+ return FALSE;
+ ps->filterAliases = aliases;
+ ps->filterAliases[i].alias = PictureGetFilterName (alias_id);
+ ps->filterAliases[i].alias_id = alias_id;
+ ps->nfilterAliases++;
+ }
+ ps->filterAliases[i].filter_id = filter_id;
+ return TRUE;
+}
+
+PictFilterPtr
+PictureFindFilter (ScreenPtr pScreen, char *name, int len)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int id = PictureGetFilterId (name, len, FALSE);
+ int i;
+
+ if (id < 0)
+ return 0;
+ /* Check for an alias, allow them to recurse */
+ for (i = 0; i < ps->nfilterAliases; i++)
+ if (ps->filterAliases[i].alias_id == id)
+ {
+ id = ps->filterAliases[i].filter_id;
+ i = 0;
+ }
+ /* find the filter */
+ for (i = 0; i < ps->nfilters; i++)
+ if (ps->filters[i].id == id)
+ return &ps->filters[i];
+ return 0;
+}
+
+static Bool
+convolutionFilterValidateParams (ScreenPtr pScreen,
+ int filter,
+ xFixed *params,
+ int nparams,
+ int *width,
+ int *height)
+{
+ int w, h;
+ if (nparams < 3)
+ return FALSE;
+
+ if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
+ return FALSE;
+
+ w = xFixedToInt (params[0]);
+ h = xFixedToInt (params[1]);
+
+ nparams -= 2;
+ if (w * h > nparams)
+ return FALSE;
+
+ *width = w;
+ *height = h;
+ return TRUE;
+}
+
+
+Bool
+PictureSetDefaultFilters (ScreenPtr pScreen)
+{
+ if (!filterNames)
+ if (!PictureSetDefaultIds ())
+ return FALSE;
+ if (PictureAddFilter (pScreen, FilterNearest, 0, 1, 1) < 0)
+ return FALSE;
+ if (PictureAddFilter (pScreen, FilterBilinear, 0, 2, 2) < 0)
+ return FALSE;
+
+ if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
+ return FALSE;
+ if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterGood))
+ return FALSE;
+ if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
+ return FALSE;
+
+ if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams, 0, 0) < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+PictureResetFilters (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ free(ps->filters);
+ free(ps->filterAliases);
+ PictureFreeFilterIds ();
+}
+
+int
+SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
+{
+ PictFilterPtr pFilter;
+ ScreenPtr pScreen;
+
+ if (pPicture->pDrawable != NULL)
+ pScreen = pPicture->pDrawable->pScreen;
+ else
+ pScreen = screenInfo.screens[0];
+
+ pFilter = PictureFindFilter (pScreen, name, len);
+
+ if (!pFilter)
+ return BadName;
+
+ if (pPicture->pDrawable == NULL)
+ {
+ int s;
+ /* For source pictures, the picture isn't tied to a screen. So, ensure
+ * that all screens can handle a filter we set for the picture.
+ */
+ for (s = 1; s < screenInfo.numScreens; s++)
+ {
+ PictFilterPtr pScreenFilter;
+ pScreenFilter = PictureFindFilter (screenInfo.screens[s],
+ name, len);
+ if (!pScreenFilter || pScreenFilter->id != pFilter->id)
+ return BadMatch;
+ }
+ }
+ return SetPicturePictFilter (pPicture, pFilter, params, nparams);
+}
+
+int
+SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
+ xFixed *params, int nparams)
+{
+ ScreenPtr pScreen;
+ int i;
+
+ if (pPicture->pDrawable)
+ pScreen = pPicture->pDrawable->pScreen;
+ else
+ pScreen = screenInfo.screens[0];
+
+ if (pFilter->ValidateParams)
+ {
+ int width, height;
+ if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height))
+ return BadMatch;
+ }
+ else if (nparams)
+ return BadMatch;
+
+ if (nparams != pPicture->filter_nparams)
+ {
+ xFixed *new_params = malloc(nparams * sizeof (xFixed));
+ if (!new_params && nparams)
+ return BadAlloc;
+ free(pPicture->filter_params);
+ pPicture->filter_params = new_params;
+ pPicture->filter_nparams = nparams;
+ }
+ for (i = 0; i < nparams; i++)
+ pPicture->filter_params[i] = params[i];
+ pPicture->filter = pFilter->id;
+
+ if (pPicture->pDrawable)
+ {
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int result;
+
+ result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
+ params, nparams);
+ return result;
+ }
+ return Success;
+}
diff --git a/xorg-server/render/glyph.c b/xorg-server/render/glyph.c
index 6b81118ec..b147331c8 100644
--- a/xorg-server/render/glyph.c
+++ b/xorg-server/render/glyph.c
@@ -1,754 +1,754 @@
-/*
- *
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xsha1.h"
-
-#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 "picturestr.h"
-#include "glyphstr.h"
-#include "mipict.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]))
-
-static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
-
-static GlyphHashRec globalGlyphs[GlyphFormatNum];
-
-static void
-FreeGlyphPrivates (GlyphPtr glyph)
-{
- dixFreePrivates(glyph->devPrivates);
- glyph->devPrivates = NULL;
-}
-
-void
-GlyphUninit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
- GlyphPtr glyph;
- int fdepth, i;
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- (*ps->UnrealizeGlyph) (pScreen, glyph);
- FreeGlyphPrivates(glyph);
- }
- }
- }
-}
-
-GlyphHashSetPtr
-FindGlyphHashSet (CARD32 filled)
-{
- int i;
-
- for (i = 0; i < NGLYPHHASHSETS; i++)
- if (glyphHashSets[i].entries >= filled)
- return &glyphHashSets[i];
- return 0;
-}
-
-GlyphRefPtr
-FindGlyphRef (GlyphHashPtr hash,
- CARD32 signature,
- Bool match,
- unsigned char sha1[20])
-{
- 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 (glyph->sha1, sha1, 20) == 0))
- {
- break;
- }
- if (!step)
- {
- step = signature % hash->hashSet->rehash;
- if (!step)
- step = 1;
- }
- elt += step;
- if (elt >= tableSize)
- elt -= tableSize;
- }
- return gr;
-}
-
-int
-HashGlyph (xGlyphInfo *gi,
- CARD8 *bits,
- unsigned long size,
- unsigned char sha1[20])
-{
- void *ctx = x_sha1_init();
- int success;
-
- if (!ctx)
- return BadAlloc;
-
- success = x_sha1_update(ctx, gi, sizeof(xGlyphInfo));
- if (!success)
- return BadAlloc;
- success = x_sha1_update(ctx, bits, size);
- if (!success)
- return BadAlloc;
- success = x_sha1_final(ctx, sha1);
- if (!success)
- return BadAlloc;
- return Success;
-}
-
-GlyphPtr
-FindGlyphByHash (unsigned char sha1[20], int format)
-{
- GlyphRefPtr gr;
- CARD32 signature = *(CARD32 *) sha1;
-
- if (!globalGlyphs[format].hashSet)
- return NULL;
-
- gr = FindGlyphRef (&globalGlyphs[format],
- signature, TRUE, sha1);
-
- if (gr->glyph && gr->glyph != DeletedGlyph)
- return gr->glyph;
- else
- return NULL;
-}
-
-#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
-
-static void
-FreeGlyphPicture(GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- int i;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ScreenPtr pScreen = screenInfo.screens[i];
-
- if (GlyphPicture(glyph)[i])
- FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
-
- ps = GetPictureScreenIfSet (pScreen);
- if (ps)
- (*ps->UnrealizeGlyph) (pScreen, glyph);
- }
-}
-
-
-void
-FreeGlyph (GlyphPtr glyph, int format)
-{
- CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
- if (--glyph->refcnt == 0)
- {
- GlyphRefPtr gr;
- int i;
- int first;
- CARD32 signature;
-
- 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;
- }
-
- signature = *(CARD32 *) glyph->sha1;
- gr = FindGlyphRef (&globalGlyphs[format], signature,
- TRUE, glyph->sha1);
- 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--;
- }
-
- FreeGlyphPicture(glyph);
- FreeGlyphPrivates(glyph);
- xfree (glyph);
- }
-}
-
-void
-AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
-{
- GlyphRefPtr gr;
- CARD32 signature;
-
- CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph top global");
- /* Locate existing matching glyph */
- signature = *(CARD32 *) glyph->sha1;
- gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], signature,
- TRUE, glyph->sha1);
- if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
- {
- FreeGlyphPicture(glyph);
- FreeGlyphPrivates(glyph);
- xfree (glyph);
- glyph = gr->glyph;
- }
- else if (gr->glyph != glyph)
- {
- gr->glyph = glyph;
- gr->signature = signature;
- globalGlyphs[glyphSet->fdepth].tableEntries++;
- }
-
- /* Insert/replace glyphset value */
- gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
- ++glyph->refcnt;
- if (gr->glyph && gr->glyph != DeletedGlyph)
- FreeGlyph (gr->glyph, glyphSet->fdepth);
- else
- glyphSet->hash.tableEntries++;
- gr->glyph = glyph;
- gr->signature = 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;
-}
-
-GlyphPtr
-FindGlyph (GlyphSetPtr glyphSet, Glyph id)
-{
- GlyphPtr glyph;
-
- glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph;
- if (glyph == DeletedGlyph)
- glyph = 0;
- return glyph;
-}
-
-GlyphPtr
-AllocateGlyph (xGlyphInfo *gi, int fdepth)
-{
- PictureScreenPtr ps;
- int size;
- GlyphPtr glyph;
- int i;
-
- size = screenInfo.numScreens * sizeof (PicturePtr);
- glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
- if (!glyph)
- return 0;
- glyph->refcnt = 0;
- glyph->size = size + sizeof (xGlyphInfo);
- glyph->info = *gi;
- glyph->devPrivates = NULL;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- GlyphPicture(glyph)[i] = NULL;
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
-
- if (ps)
- {
- if (!(*ps->RealizeGlyph) (screenInfo.screens[i], glyph))
- goto bail;
- }
- }
-
- return glyph;
-
-bail:
- while (i--)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps)
- (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
- }
-
- FreeGlyphPrivates(glyph);
- xfree (glyph);
- return 0;
-}
-
-Bool
-AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
-{
- hash->table = xcalloc (hashSet->size, sizeof (GlyphRefRec));
- if (!hash->table)
- return FALSE;
- hash->hashSet = hashSet;
- hash->tableEntries = 0;
- return TRUE;
-}
-
-Bool
-ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
-{
- CARD32 tableEntries;
- GlyphHashSetPtr hashSet;
- GlyphHashRec newHash;
- GlyphRefPtr gr;
- GlyphPtr glyph;
- int i;
- int oldSize;
- CARD32 s;
-
- tableEntries = hash->tableEntries + change;
- hashSet = FindGlyphHashSet (tableEntries);
- if (hashSet == hash->hashSet)
- return TRUE;
- if (global)
- CheckDuplicates (hash, "ResizeGlyphHash top");
- if (!AllocateGlyphHash (&newHash, hashSet))
- return FALSE;
- if (hash->table)
- {
- oldSize = hash->hashSet->size;
- for (i = 0; i < oldSize; i++)
- {
- glyph = hash->table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- s = hash->table[i].signature;
- gr = FindGlyphRef (&newHash, s, global, glyph->sha1);
- gr->signature = s;
- gr->glyph = glyph;
- ++newHash.tableEntries;
- }
- }
- xfree (hash->table);
- }
- *hash = newHash;
- if (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);
- glyphSet = xcalloc (1, size);
- if (!glyphSet)
- return FALSE;
-
- if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
- {
- xfree (glyphSet);
- return FALSE;
- }
- glyphSet->refcnt = 1;
- glyphSet->fdepth = fdepth;
- glyphSet->format = format;
- return glyphSet;
-}
-
-int
-FreeGlyphSet (pointer 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);
- dixFreePrivates(glyphSet->devPrivates);
- xfree (glyphSet);
- }
- return Success;
-}
-
-static void
-GlyphExtents (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)
-
-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);
- (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs);
-}
-
-Bool
-miRealizeGlyph (ScreenPtr pScreen,
- GlyphPtr glyph)
-{
- return TRUE;
-}
-
-void
-miUnrealizeGlyph (ScreenPtr pScreen,
- GlyphPtr glyph)
-{
-}
-
-void
-miGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs)
-{
- PicturePtr pPicture;
- PixmapPtr pMaskPixmap = 0;
- PicturePtr pMask;
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- int width = 0, height = 0;
- int x, y;
- int xDst = list->xOff, yDst = list->yOff;
- int n;
- GlyphPtr glyph;
- int error;
- BoxRec extents = {0, 0, 0, 0};
- CARD32 component_alpha;
-
- if (maskFormat)
- {
- GCPtr pGC;
- xRectangle rect;
-
- GlyphExtents (nlist, list, glyphs, &extents);
-
- if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
- return;
- width = extents.x2 - extents.x1;
- height = extents.y2 - extents.y1;
- pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
- maskFormat->depth,
- CREATE_PIXMAP_USAGE_SCRATCH);
- if (!pMaskPixmap)
- return;
- component_alpha = NeedsComponent(maskFormat->format);
- pMask = CreatePicture (0, &pMaskPixmap->drawable,
- maskFormat, CPComponentAlpha, &component_alpha,
- serverClient, &error);
- if (!pMask)
- {
- (*pScreen->DestroyPixmap) (pMaskPixmap);
- return;
- }
- pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen);
- ValidateGC (&pMaskPixmap->drawable, pGC);
- rect.x = 0;
- rect.y = 0;
- rect.width = width;
- rect.height = height;
- (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
- FreeScratchGC (pGC);
- x = -extents.x1;
- y = -extents.y1;
- }
- else
- {
- pMask = pDst;
- x = 0;
- y = 0;
- }
- while (nlist--)
- {
- x += list->xOff;
- y += list->yOff;
- n = list->len;
- while (n--)
- {
- glyph = *glyphs++;
- pPicture = GlyphPicture (glyph)[pScreen->myNum];
-
- if (pPicture)
- {
- if (maskFormat)
- {
- CompositePicture (PictOpAdd,
- pPicture,
- None,
- pMask,
- 0, 0,
- 0, 0,
- x - glyph->info.x,
- y - glyph->info.y,
- glyph->info.width,
- glyph->info.height);
- }
- else
- {
- CompositePicture (op,
- pSrc,
- pPicture,
- pDst,
- xSrc + (x - glyph->info.x) - xDst,
- ySrc + (y - glyph->info.y) - yDst,
- 0, 0,
- x - glyph->info.x,
- y - glyph->info.y,
- glyph->info.width,
- glyph->info.height);
- }
- }
-
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- }
- list++;
- }
- if (maskFormat)
- {
- x = extents.x1;
- y = extents.y1;
- CompositePicture (op,
- pSrc,
- pMask,
- pDst,
- xSrc + x - xDst,
- ySrc + y - yDst,
- 0, 0,
- x, y,
- width, height);
- FreePicture ((pointer) pMask, (XID) 0);
- (*pScreen->DestroyPixmap) (pMaskPixmap);
- }
-}
+/*
+ *
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xsha1.h"
+
+#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 "picturestr.h"
+#include "glyphstr.h"
+#include "mipict.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]))
+
+static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
+
+static GlyphHashRec globalGlyphs[GlyphFormatNum];
+
+static void
+FreeGlyphPrivates (GlyphPtr glyph)
+{
+ dixFreePrivates(glyph->devPrivates);
+ glyph->devPrivates = NULL;
+}
+
+void
+GlyphUninit (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+ GlyphPtr glyph;
+ int fdepth, i;
+
+ for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
+ {
+ if (!globalGlyphs[fdepth].hashSet)
+ continue;
+
+ for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
+ {
+ glyph = globalGlyphs[fdepth].table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ (*ps->UnrealizeGlyph) (pScreen, glyph);
+ FreeGlyphPrivates(glyph);
+ }
+ }
+ }
+}
+
+GlyphHashSetPtr
+FindGlyphHashSet (CARD32 filled)
+{
+ int i;
+
+ for (i = 0; i < NGLYPHHASHSETS; i++)
+ if (glyphHashSets[i].entries >= filled)
+ return &glyphHashSets[i];
+ return 0;
+}
+
+GlyphRefPtr
+FindGlyphRef (GlyphHashPtr hash,
+ CARD32 signature,
+ Bool match,
+ unsigned char sha1[20])
+{
+ 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 (glyph->sha1, sha1, 20) == 0))
+ {
+ break;
+ }
+ if (!step)
+ {
+ step = signature % hash->hashSet->rehash;
+ if (!step)
+ step = 1;
+ }
+ elt += step;
+ if (elt >= tableSize)
+ elt -= tableSize;
+ }
+ return gr;
+}
+
+int
+HashGlyph (xGlyphInfo *gi,
+ CARD8 *bits,
+ unsigned long size,
+ unsigned char sha1[20])
+{
+ void *ctx = x_sha1_init();
+ int success;
+
+ if (!ctx)
+ return BadAlloc;
+
+ success = x_sha1_update(ctx, gi, sizeof(xGlyphInfo));
+ if (!success)
+ return BadAlloc;
+ success = x_sha1_update(ctx, bits, size);
+ if (!success)
+ return BadAlloc;
+ success = x_sha1_final(ctx, sha1);
+ if (!success)
+ return BadAlloc;
+ return Success;
+}
+
+GlyphPtr
+FindGlyphByHash (unsigned char sha1[20], int format)
+{
+ GlyphRefPtr gr;
+ CARD32 signature = *(CARD32 *) sha1;
+
+ if (!globalGlyphs[format].hashSet)
+ return NULL;
+
+ gr = FindGlyphRef (&globalGlyphs[format],
+ signature, TRUE, sha1);
+
+ if (gr->glyph && gr->glyph != DeletedGlyph)
+ return gr->glyph;
+ else
+ return NULL;
+}
+
+#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
+
+static void
+FreeGlyphPicture(GlyphPtr glyph)
+{
+ PictureScreenPtr ps;
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen = screenInfo.screens[i];
+
+ if (GlyphPicture(glyph)[i])
+ FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
+
+ ps = GetPictureScreenIfSet (pScreen);
+ if (ps)
+ (*ps->UnrealizeGlyph) (pScreen, glyph);
+ }
+}
+
+
+void
+FreeGlyph (GlyphPtr glyph, int format)
+{
+ CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
+ if (--glyph->refcnt == 0)
+ {
+ GlyphRefPtr gr;
+ int i;
+ int first;
+ CARD32 signature;
+
+ 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;
+ }
+
+ signature = *(CARD32 *) glyph->sha1;
+ gr = FindGlyphRef (&globalGlyphs[format], signature,
+ TRUE, glyph->sha1);
+ 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--;
+ }
+
+ FreeGlyphPicture(glyph);
+ FreeGlyphPrivates(glyph);
+ free(glyph);
+ }
+}
+
+void
+AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
+{
+ GlyphRefPtr gr;
+ CARD32 signature;
+
+ CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph top global");
+ /* Locate existing matching glyph */
+ signature = *(CARD32 *) glyph->sha1;
+ gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], signature,
+ TRUE, glyph->sha1);
+ if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
+ {
+ FreeGlyphPicture(glyph);
+ FreeGlyphPrivates(glyph);
+ free(glyph);
+ glyph = gr->glyph;
+ }
+ else if (gr->glyph != glyph)
+ {
+ gr->glyph = glyph;
+ gr->signature = signature;
+ globalGlyphs[glyphSet->fdepth].tableEntries++;
+ }
+
+ /* Insert/replace glyphset value */
+ gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
+ ++glyph->refcnt;
+ if (gr->glyph && gr->glyph != DeletedGlyph)
+ FreeGlyph (gr->glyph, glyphSet->fdepth);
+ else
+ glyphSet->hash.tableEntries++;
+ gr->glyph = glyph;
+ gr->signature = 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;
+}
+
+GlyphPtr
+FindGlyph (GlyphSetPtr glyphSet, Glyph id)
+{
+ GlyphPtr glyph;
+
+ glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph;
+ if (glyph == DeletedGlyph)
+ glyph = 0;
+ return glyph;
+}
+
+GlyphPtr
+AllocateGlyph (xGlyphInfo *gi, int fdepth)
+{
+ PictureScreenPtr ps;
+ int size;
+ GlyphPtr glyph;
+ int i;
+
+ size = screenInfo.numScreens * sizeof (PicturePtr);
+ glyph = (GlyphPtr) malloc(size + sizeof (GlyphRec));
+ if (!glyph)
+ return 0;
+ glyph->refcnt = 0;
+ glyph->size = size + sizeof (xGlyphInfo);
+ glyph->info = *gi;
+ glyph->devPrivates = NULL;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ GlyphPicture(glyph)[i] = NULL;
+ ps = GetPictureScreenIfSet (screenInfo.screens[i]);
+
+ if (ps)
+ {
+ if (!(*ps->RealizeGlyph) (screenInfo.screens[i], glyph))
+ goto bail;
+ }
+ }
+
+ return glyph;
+
+bail:
+ while (i--)
+ {
+ ps = GetPictureScreenIfSet (screenInfo.screens[i]);
+ if (ps)
+ (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
+ }
+
+ FreeGlyphPrivates(glyph);
+ free(glyph);
+ return 0;
+}
+
+Bool
+AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
+{
+ hash->table = calloc(hashSet->size, sizeof (GlyphRefRec));
+ if (!hash->table)
+ return FALSE;
+ hash->hashSet = hashSet;
+ hash->tableEntries = 0;
+ return TRUE;
+}
+
+Bool
+ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
+{
+ CARD32 tableEntries;
+ GlyphHashSetPtr hashSet;
+ GlyphHashRec newHash;
+ GlyphRefPtr gr;
+ GlyphPtr glyph;
+ int i;
+ int oldSize;
+ CARD32 s;
+
+ tableEntries = hash->tableEntries + change;
+ hashSet = FindGlyphHashSet (tableEntries);
+ if (hashSet == hash->hashSet)
+ return TRUE;
+ if (global)
+ CheckDuplicates (hash, "ResizeGlyphHash top");
+ if (!AllocateGlyphHash (&newHash, hashSet))
+ return FALSE;
+ if (hash->table)
+ {
+ oldSize = hash->hashSet->size;
+ for (i = 0; i < oldSize; i++)
+ {
+ glyph = hash->table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ s = hash->table[i].signature;
+ gr = FindGlyphRef (&newHash, s, global, glyph->sha1);
+ gr->signature = s;
+ gr->glyph = glyph;
+ ++newHash.tableEntries;
+ }
+ }
+ free(hash->table);
+ }
+ *hash = newHash;
+ if (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);
+ glyphSet = calloc(1, size);
+ if (!glyphSet)
+ return FALSE;
+
+ if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
+ {
+ free(glyphSet);
+ return FALSE;
+ }
+ glyphSet->refcnt = 1;
+ glyphSet->fdepth = fdepth;
+ glyphSet->format = format;
+ return glyphSet;
+}
+
+int
+FreeGlyphSet (pointer 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)
+ {
+ free(globalGlyphs[glyphSet->fdepth].table);
+ globalGlyphs[glyphSet->fdepth].table = 0;
+ globalGlyphs[glyphSet->fdepth].hashSet = 0;
+ }
+ else
+ ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
+ free(table);
+ dixFreePrivates(glyphSet->devPrivates);
+ free(glyphSet);
+ }
+ return Success;
+}
+
+static void
+GlyphExtents (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)
+
+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);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs);
+}
+
+Bool
+miRealizeGlyph (ScreenPtr pScreen,
+ GlyphPtr glyph)
+{
+ return TRUE;
+}
+
+void
+miUnrealizeGlyph (ScreenPtr pScreen,
+ GlyphPtr glyph)
+{
+}
+
+void
+miGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ PicturePtr pPicture;
+ PixmapPtr pMaskPixmap = 0;
+ PicturePtr pMask;
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ int width = 0, height = 0;
+ int x, y;
+ int xDst = list->xOff, yDst = list->yOff;
+ int n;
+ GlyphPtr glyph;
+ int error;
+ BoxRec extents = {0, 0, 0, 0};
+ CARD32 component_alpha;
+
+ if (maskFormat)
+ {
+ GCPtr pGC;
+ xRectangle rect;
+
+ GlyphExtents (nlist, list, glyphs, &extents);
+
+ if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+ return;
+ width = extents.x2 - extents.x1;
+ height = extents.y2 - extents.y1;
+ pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+ maskFormat->depth,
+ CREATE_PIXMAP_USAGE_SCRATCH);
+ if (!pMaskPixmap)
+ return;
+ component_alpha = NeedsComponent(maskFormat->format);
+ pMask = CreatePicture (0, &pMaskPixmap->drawable,
+ maskFormat, CPComponentAlpha, &component_alpha,
+ serverClient, &error);
+ if (!pMask)
+ {
+ (*pScreen->DestroyPixmap) (pMaskPixmap);
+ return;
+ }
+ pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen);
+ ValidateGC (&pMaskPixmap->drawable, pGC);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = width;
+ rect.height = height;
+ (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
+ FreeScratchGC (pGC);
+ x = -extents.x1;
+ y = -extents.y1;
+ }
+ else
+ {
+ pMask = pDst;
+ x = 0;
+ y = 0;
+ }
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ pPicture = GlyphPicture (glyph)[pScreen->myNum];
+
+ if (pPicture)
+ {
+ if (maskFormat)
+ {
+ CompositePicture (PictOpAdd,
+ pPicture,
+ None,
+ pMask,
+ 0, 0,
+ 0, 0,
+ x - glyph->info.x,
+ y - glyph->info.y,
+ glyph->info.width,
+ glyph->info.height);
+ }
+ else
+ {
+ CompositePicture (op,
+ pSrc,
+ pPicture,
+ pDst,
+ xSrc + (x - glyph->info.x) - xDst,
+ ySrc + (y - glyph->info.y) - yDst,
+ 0, 0,
+ x - glyph->info.x,
+ y - glyph->info.y,
+ glyph->info.width,
+ glyph->info.height);
+ }
+ }
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ }
+ if (maskFormat)
+ {
+ x = extents.x1;
+ y = extents.y1;
+ CompositePicture (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc + x - xDst,
+ ySrc + y - yDst,
+ 0, 0,
+ x, y,
+ width, height);
+ FreePicture ((pointer) pMask, (XID) 0);
+ (*pScreen->DestroyPixmap) (pMaskPixmap);
+ }
+}
diff --git a/xorg-server/render/miindex.c b/xorg-server/render/miindex.c
index 4e0cf0084..75f941477 100644
--- a/xorg-server/render/miindex.c
+++ b/xorg-server/render/miindex.c
@@ -1,358 +1,358 @@
-/*
- *
- * Copyright © 2001 Keith Packard, member of The XFree86 Project, 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 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _MIINDEX_H_
-#define _MIINDEX_H_
-
-#include "scrnintstr.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "mi.h"
-#include "picturestr.h"
-#include "mipict.h"
-#include "colormapst.h"
-
-#define NUM_CUBE_LEVELS 4
-#define NUM_GRAY_LEVELS 13
-
-static Bool
-miBuildRenderColormap (ColormapPtr pColormap, Pixel *pixels, int *nump)
-{
- int r, g, b;
- unsigned short red, green, blue;
- Pixel pixel;
- Bool used[MI_MAX_INDEXED];
- int needed;
- int policy;
- int cube, gray;
- int i, n;
-
- if (pColormap->mid != pColormap->pScreen->defColormap)
- {
- policy = PictureCmapPolicyAll;
- }
- else
- {
- int avail = pColormap->pVisual->ColormapEntries;
- policy = PictureCmapPolicy;
- if (policy == PictureCmapPolicyDefault)
- {
- if (avail >= 256 && (pColormap->pVisual->class|DynamicClass) == PseudoColor)
- policy = PictureCmapPolicyColor;
- else if (avail >= 64)
- policy = PictureCmapPolicyGray;
- else
- policy = PictureCmapPolicyMono;
- }
- }
- /*
- * Make sure enough cells are free for the chosen policy
- */
- for (;;)
- {
- switch (policy) {
- case PictureCmapPolicyAll:
- needed = 0;
- break;
- case PictureCmapPolicyColor:
- needed = 71;
- break;
- case PictureCmapPolicyGray:
- needed = 11;
- break;
- case PictureCmapPolicyMono:
- default:
- needed = 0;
- break;
- }
- if (needed <= pColormap->freeRed)
- break;
- policy--;
- }
-
- /*
- * Compute size of cube and gray ramps
- */
- cube = gray = 0;
- switch (policy) {
- case PictureCmapPolicyAll:
- /*
- * Allocate as big a cube as possible
- */
- if ((pColormap->pVisual->class|DynamicClass) == PseudoColor)
- {
- for (cube = 1; cube * cube * cube < pColormap->pVisual->ColormapEntries; cube++)
- ;
- cube--;
- if (cube == 1)
- cube = 0;
- }
- else
- cube = 0;
- /*
- * Figure out how many gray levels to use so that they
- * line up neatly with the cube
- */
- if (cube)
- {
- needed = pColormap->pVisual->ColormapEntries - (cube*cube*cube);
- /* levels to fill in with */
- gray = needed / (cube - 1);
- /* total levels */
- gray = (gray + 1) * (cube - 1) + 1;
- }
- else
- gray = pColormap->pVisual->ColormapEntries;
- break;
-
- case PictureCmapPolicyColor:
- cube = NUM_CUBE_LEVELS;
- /* fall through ... */
- case PictureCmapPolicyGray:
- gray = NUM_GRAY_LEVELS;
- break;
- case PictureCmapPolicyMono:
- default:
- gray = 2;
- break;
- }
-
- memset (used, '\0', pColormap->pVisual->ColormapEntries * sizeof (Bool));
- for (r = 0; r < cube; r++)
- for (g = 0; g < cube; g++)
- for (b = 0; b < cube; b++)
- {
- pixel = 0;
- red = (r * 65535 + (cube-1)/2) / (cube - 1);
- green = (g * 65535 + (cube-1)/2) / (cube - 1);
- blue = (b * 65535 + (cube-1)/2) / (cube - 1);
- if (AllocColor (pColormap, &red, &green,
- &blue, &pixel, 0) != Success)
- return FALSE;
- used[pixel] = TRUE;
- }
- for (g = 0; g < gray; g++)
- {
- pixel = 0;
- red = green = blue = (g * 65535 + (gray-1)/2) / (gray - 1);
- if (AllocColor (pColormap, &red, &green, &blue, &pixel, 0) != Success)
- return FALSE;
- used[pixel] = TRUE;
- }
- n = 0;
- for (i = 0; i < pColormap->pVisual->ColormapEntries; i++)
- if (used[i])
- pixels[n++] = i;
-
- *nump = n;
-
- return TRUE;
-}
-
-/* 0 <= red, green, blue < 32 */
-static Pixel
-FindBestColor (miIndexedPtr pIndexed, Pixel *pixels, int num,
- int red, int green, int blue)
-{
- Pixel best = pixels[0];
- int bestDist = 1 << 30;
- int dist;
- int dr, dg, db;
- while (num--)
- {
- Pixel pixel = *pixels++;
- CARD32 v = pIndexed->rgba[pixel];
-
- dr = ((v >> 19) & 0x1f);
- dg = ((v >> 11) & 0x1f);
- db = ((v >> 3) & 0x1f);
- dr = dr - red;
- dg = dg - green;
- db = db - blue;
- dist = dr * dr + dg * dg + db * db;
- if (dist < bestDist)
- {
- bestDist = dist;
- best = pixel;
- }
- }
- return best;
-}
-
-/* 0 <= gray < 32768 */
-static Pixel
-FindBestGray (miIndexedPtr pIndexed, Pixel *pixels, int num, int gray)
-{
- Pixel best = pixels[0];
- int bestDist = 1 << 30;
- int dist;
- int dr;
- int r;
-
- while (num--)
- {
- Pixel pixel = *pixels++;
- CARD32 v = pIndexed->rgba[pixel];
-
- r = v & 0xff;
- r = r | (r << 8);
- dr = gray - (r >> 1);
- dist = dr * dr;
- if (dist < bestDist)
- {
- bestDist = dist;
- best = pixel;
- }
- }
- return best;
-}
-
-Bool
-miInitIndexed (ScreenPtr pScreen,
- PictFormatPtr pFormat)
-{
- ColormapPtr pColormap = pFormat->index.pColormap;
- VisualPtr pVisual = pColormap->pVisual;
- miIndexedPtr pIndexed;
- Pixel pixels[MI_MAX_INDEXED];
- xrgb rgb[MI_MAX_INDEXED];
- int num;
- int i;
- Pixel p, r, g, b;
-
- if (pVisual->ColormapEntries > MI_MAX_INDEXED)
- return FALSE;
-
- if (pVisual->class & DynamicClass)
- {
- if (!miBuildRenderColormap (pColormap, pixels, &num))
- return FALSE;
- }
- else
- {
- num = pVisual->ColormapEntries;
- for (p = 0; p < num; p++)
- pixels[p] = p;
- }
-
- pIndexed = xalloc (sizeof (miIndexedRec));
- if (!pIndexed)
- return FALSE;
-
- pFormat->index.nvalues = num;
- pFormat->index.pValues = xalloc (num * sizeof (xIndexValue));
- if (!pFormat->index.pValues)
- {
- xfree (pIndexed);
- return FALSE;
- }
-
-
- /*
- * Build mapping from pixel value to ARGB
- */
- QueryColors (pColormap, num, pixels, rgb);
- for (i = 0; i < num; i++)
- {
- p = pixels[i];
- pFormat->index.pValues[i].pixel = p;
- pFormat->index.pValues[i].red = rgb[i].red;
- pFormat->index.pValues[i].green = rgb[i].green;
- pFormat->index.pValues[i].blue = rgb[i].blue;
- pFormat->index.pValues[i].alpha = 0xffff;
- pIndexed->rgba[p] = (0xff000000 |
- ((rgb[i].red & 0xff00) << 8) |
- ((rgb[i].green & 0xff00) ) |
- ((rgb[i].blue & 0xff00) >> 8));
- }
-
- /*
- * Build mapping from RGB to pixel value. This could probably be
- * done a bit quicker...
- */
- switch (pVisual->class | DynamicClass) {
- case GrayScale:
- pIndexed->color = FALSE;
- for (r = 0; r < 32768; r++)
- pIndexed->ent[r] = FindBestGray (pIndexed, pixels, num, r);
- break;
- case PseudoColor:
- pIndexed->color = TRUE;
- p = 0;
- for (r = 0; r < 32; r++)
- for (g = 0; g < 32; g++)
- for (b = 0; b < 32; b++)
- {
- pIndexed->ent[p] = FindBestColor (pIndexed, pixels, num,
- r, g, b);
- p++;
- }
- break;
- }
- pFormat->index.devPrivate = pIndexed;
- return TRUE;
-}
-
-void
-miCloseIndexed (ScreenPtr pScreen,
- PictFormatPtr pFormat)
-{
- if (pFormat->index.devPrivate)
- {
- xfree (pFormat->index.devPrivate);
- pFormat->index.devPrivate = 0;
- }
- if (pFormat->index.pValues)
- {
- xfree (pFormat->index.pValues);
- pFormat->index.pValues = 0;
- }
-}
-
-void
-miUpdateIndexed (ScreenPtr pScreen,
- PictFormatPtr pFormat,
- int ndef,
- xColorItem *pdef)
-{
- miIndexedPtr pIndexed = pFormat->index.devPrivate;
-
- if (pIndexed)
- {
- while (ndef--)
- {
- pIndexed->rgba[pdef->pixel] = (0xff000000 |
- ((pdef->red & 0xff00) << 8) |
- ((pdef->green & 0xff00) ) |
- ((pdef->blue & 0xff00) >> 8));
- pdef++;
- }
- }
-}
-
-#endif /* _MIINDEX_H_ */
+/*
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, 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 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _MIINDEX_H_
+#define _MIINDEX_H_
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "colormapst.h"
+
+#define NUM_CUBE_LEVELS 4
+#define NUM_GRAY_LEVELS 13
+
+static Bool
+miBuildRenderColormap (ColormapPtr pColormap, Pixel *pixels, int *nump)
+{
+ int r, g, b;
+ unsigned short red, green, blue;
+ Pixel pixel;
+ Bool used[MI_MAX_INDEXED];
+ int needed;
+ int policy;
+ int cube, gray;
+ int i, n;
+
+ if (pColormap->mid != pColormap->pScreen->defColormap)
+ {
+ policy = PictureCmapPolicyAll;
+ }
+ else
+ {
+ int avail = pColormap->pVisual->ColormapEntries;
+ policy = PictureCmapPolicy;
+ if (policy == PictureCmapPolicyDefault)
+ {
+ if (avail >= 256 && (pColormap->pVisual->class|DynamicClass) == PseudoColor)
+ policy = PictureCmapPolicyColor;
+ else if (avail >= 64)
+ policy = PictureCmapPolicyGray;
+ else
+ policy = PictureCmapPolicyMono;
+ }
+ }
+ /*
+ * Make sure enough cells are free for the chosen policy
+ */
+ for (;;)
+ {
+ switch (policy) {
+ case PictureCmapPolicyAll:
+ needed = 0;
+ break;
+ case PictureCmapPolicyColor:
+ needed = 71;
+ break;
+ case PictureCmapPolicyGray:
+ needed = 11;
+ break;
+ case PictureCmapPolicyMono:
+ default:
+ needed = 0;
+ break;
+ }
+ if (needed <= pColormap->freeRed)
+ break;
+ policy--;
+ }
+
+ /*
+ * Compute size of cube and gray ramps
+ */
+ cube = gray = 0;
+ switch (policy) {
+ case PictureCmapPolicyAll:
+ /*
+ * Allocate as big a cube as possible
+ */
+ if ((pColormap->pVisual->class|DynamicClass) == PseudoColor)
+ {
+ for (cube = 1; cube * cube * cube < pColormap->pVisual->ColormapEntries; cube++)
+ ;
+ cube--;
+ if (cube == 1)
+ cube = 0;
+ }
+ else
+ cube = 0;
+ /*
+ * Figure out how many gray levels to use so that they
+ * line up neatly with the cube
+ */
+ if (cube)
+ {
+ needed = pColormap->pVisual->ColormapEntries - (cube*cube*cube);
+ /* levels to fill in with */
+ gray = needed / (cube - 1);
+ /* total levels */
+ gray = (gray + 1) * (cube - 1) + 1;
+ }
+ else
+ gray = pColormap->pVisual->ColormapEntries;
+ break;
+
+ case PictureCmapPolicyColor:
+ cube = NUM_CUBE_LEVELS;
+ /* fall through ... */
+ case PictureCmapPolicyGray:
+ gray = NUM_GRAY_LEVELS;
+ break;
+ case PictureCmapPolicyMono:
+ default:
+ gray = 2;
+ break;
+ }
+
+ memset (used, '\0', pColormap->pVisual->ColormapEntries * sizeof (Bool));
+ for (r = 0; r < cube; r++)
+ for (g = 0; g < cube; g++)
+ for (b = 0; b < cube; b++)
+ {
+ pixel = 0;
+ red = (r * 65535 + (cube-1)/2) / (cube - 1);
+ green = (g * 65535 + (cube-1)/2) / (cube - 1);
+ blue = (b * 65535 + (cube-1)/2) / (cube - 1);
+ if (AllocColor (pColormap, &red, &green,
+ &blue, &pixel, 0) != Success)
+ return FALSE;
+ used[pixel] = TRUE;
+ }
+ for (g = 0; g < gray; g++)
+ {
+ pixel = 0;
+ red = green = blue = (g * 65535 + (gray-1)/2) / (gray - 1);
+ if (AllocColor (pColormap, &red, &green, &blue, &pixel, 0) != Success)
+ return FALSE;
+ used[pixel] = TRUE;
+ }
+ n = 0;
+ for (i = 0; i < pColormap->pVisual->ColormapEntries; i++)
+ if (used[i])
+ pixels[n++] = i;
+
+ *nump = n;
+
+ return TRUE;
+}
+
+/* 0 <= red, green, blue < 32 */
+static Pixel
+FindBestColor (miIndexedPtr pIndexed, Pixel *pixels, int num,
+ int red, int green, int blue)
+{
+ Pixel best = pixels[0];
+ int bestDist = 1 << 30;
+ int dist;
+ int dr, dg, db;
+ while (num--)
+ {
+ Pixel pixel = *pixels++;
+ CARD32 v = pIndexed->rgba[pixel];
+
+ dr = ((v >> 19) & 0x1f);
+ dg = ((v >> 11) & 0x1f);
+ db = ((v >> 3) & 0x1f);
+ dr = dr - red;
+ dg = dg - green;
+ db = db - blue;
+ dist = dr * dr + dg * dg + db * db;
+ if (dist < bestDist)
+ {
+ bestDist = dist;
+ best = pixel;
+ }
+ }
+ return best;
+}
+
+/* 0 <= gray < 32768 */
+static Pixel
+FindBestGray (miIndexedPtr pIndexed, Pixel *pixels, int num, int gray)
+{
+ Pixel best = pixels[0];
+ int bestDist = 1 << 30;
+ int dist;
+ int dr;
+ int r;
+
+ while (num--)
+ {
+ Pixel pixel = *pixels++;
+ CARD32 v = pIndexed->rgba[pixel];
+
+ r = v & 0xff;
+ r = r | (r << 8);
+ dr = gray - (r >> 1);
+ dist = dr * dr;
+ if (dist < bestDist)
+ {
+ bestDist = dist;
+ best = pixel;
+ }
+ }
+ return best;
+}
+
+Bool
+miInitIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat)
+{
+ ColormapPtr pColormap = pFormat->index.pColormap;
+ VisualPtr pVisual = pColormap->pVisual;
+ miIndexedPtr pIndexed;
+ Pixel pixels[MI_MAX_INDEXED];
+ xrgb rgb[MI_MAX_INDEXED];
+ int num;
+ int i;
+ Pixel p, r, g, b;
+
+ if (pVisual->ColormapEntries > MI_MAX_INDEXED)
+ return FALSE;
+
+ if (pVisual->class & DynamicClass)
+ {
+ if (!miBuildRenderColormap (pColormap, pixels, &num))
+ return FALSE;
+ }
+ else
+ {
+ num = pVisual->ColormapEntries;
+ for (p = 0; p < num; p++)
+ pixels[p] = p;
+ }
+
+ pIndexed = malloc(sizeof (miIndexedRec));
+ if (!pIndexed)
+ return FALSE;
+
+ pFormat->index.nvalues = num;
+ pFormat->index.pValues = malloc(num * sizeof (xIndexValue));
+ if (!pFormat->index.pValues)
+ {
+ free(pIndexed);
+ return FALSE;
+ }
+
+
+ /*
+ * Build mapping from pixel value to ARGB
+ */
+ QueryColors (pColormap, num, pixels, rgb, serverClient);
+ for (i = 0; i < num; i++)
+ {
+ p = pixels[i];
+ pFormat->index.pValues[i].pixel = p;
+ pFormat->index.pValues[i].red = rgb[i].red;
+ pFormat->index.pValues[i].green = rgb[i].green;
+ pFormat->index.pValues[i].blue = rgb[i].blue;
+ pFormat->index.pValues[i].alpha = 0xffff;
+ pIndexed->rgba[p] = (0xff000000 |
+ ((rgb[i].red & 0xff00) << 8) |
+ ((rgb[i].green & 0xff00) ) |
+ ((rgb[i].blue & 0xff00) >> 8));
+ }
+
+ /*
+ * Build mapping from RGB to pixel value. This could probably be
+ * done a bit quicker...
+ */
+ switch (pVisual->class | DynamicClass) {
+ case GrayScale:
+ pIndexed->color = FALSE;
+ for (r = 0; r < 32768; r++)
+ pIndexed->ent[r] = FindBestGray (pIndexed, pixels, num, r);
+ break;
+ case PseudoColor:
+ pIndexed->color = TRUE;
+ p = 0;
+ for (r = 0; r < 32; r++)
+ for (g = 0; g < 32; g++)
+ for (b = 0; b < 32; b++)
+ {
+ pIndexed->ent[p] = FindBestColor (pIndexed, pixels, num,
+ r, g, b);
+ p++;
+ }
+ break;
+ }
+ pFormat->index.devPrivate = pIndexed;
+ return TRUE;
+}
+
+void
+miCloseIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat)
+{
+ if (pFormat->index.devPrivate)
+ {
+ free(pFormat->index.devPrivate);
+ pFormat->index.devPrivate = 0;
+ }
+ if (pFormat->index.pValues)
+ {
+ free(pFormat->index.pValues);
+ pFormat->index.pValues = 0;
+ }
+}
+
+void
+miUpdateIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat,
+ int ndef,
+ xColorItem *pdef)
+{
+ miIndexedPtr pIndexed = pFormat->index.devPrivate;
+
+ if (pIndexed)
+ {
+ while (ndef--)
+ {
+ pIndexed->rgba[pdef->pixel] = (0xff000000 |
+ ((pdef->red & 0xff00) << 8) |
+ ((pdef->green & 0xff00) ) |
+ ((pdef->blue & 0xff00) >> 8));
+ pdef++;
+ }
+ }
+}
+
+#endif /* _MIINDEX_H_ */
diff --git a/xorg-server/render/mipict.c b/xorg-server/render/mipict.c
index 3dc04a88a..9051de5c1 100644
--- a/xorg-server/render/mipict.c
+++ b/xorg-server/render/mipict.c
@@ -1,643 +1,643 @@
-/*
- *
- * Copyright © 1999 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.
- */
-
-#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"
-
-#ifndef __GNUC__
-#define __inline
-#endif
-
-int
-miCreatePicture (PicturePtr pPicture)
-{
- return Success;
-}
-
-void
-miDestroyPicture (PicturePtr pPicture)
-{
- if (pPicture->freeCompClip)
- REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->pCompositeClip);
-}
-
-void
-miDestroyPictureClip (PicturePtr pPicture)
-{
- switch (pPicture->clientClipType) {
- case CT_NONE:
- return;
- case CT_PIXMAP:
- (*pPicture->pDrawable->pScreen->DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
- break;
- default:
- /*
- * we know we'll never have a list of rectangles, since ChangeClip
- * immediately turns them into a region
- */
- REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->clientClip);
- break;
- }
- pPicture->clientClip = NULL;
- pPicture->clientClipType = CT_NONE;
-}
-
-int
-miChangePictureClip (PicturePtr pPicture,
- int type,
- pointer value,
- int n)
-{
- ScreenPtr pScreen = pPicture->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- pointer clientClip;
- int clientClipType;
-
- switch (type) {
- case CT_PIXMAP:
- /* convert the pixmap to a region */
- clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
- if (!clientClip)
- return BadAlloc;
- clientClipType = CT_REGION;
- (*pScreen->DestroyPixmap) ((PixmapPtr) value);
- break;
- case CT_REGION:
- clientClip = value;
- clientClipType = CT_REGION;
- break;
- case CT_NONE:
- clientClip = 0;
- clientClipType = CT_NONE;
- break;
- default:
- clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
- (xRectangle *) value,
- type);
- if (!clientClip)
- return BadAlloc;
- clientClipType = CT_REGION;
- xfree(value);
- break;
- }
- (*ps->DestroyPictureClip) (pPicture);
- pPicture->clientClip = clientClip;
- pPicture->clientClipType = clientClipType;
- pPicture->stateChanges |= CPClipMask;
- return Success;
-}
-
-void
-miChangePicture (PicturePtr pPicture,
- Mask mask)
-{
- return;
-}
-
-void
-miValidatePicture (PicturePtr pPicture,
- Mask mask)
-{
- DrawablePtr pDrawable = pPicture->pDrawable;
-
- if ((mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode)) ||
- (pDrawable->serialNumber != (pPicture->serialNumber & DRAWABLE_SERIAL_BITS)))
- {
- if (pDrawable->type == DRAWABLE_WINDOW)
- {
- WindowPtr pWin = (WindowPtr) pDrawable;
- RegionPtr pregWin;
- Bool freeTmpClip, freeCompClip;
-
- if (pPicture->subWindowMode == IncludeInferiors)
- {
- pregWin = NotClippedByChildren(pWin);
- freeTmpClip = TRUE;
- }
- else
- {
- pregWin = &pWin->clipList;
- freeTmpClip = FALSE;
- }
- freeCompClip = pPicture->freeCompClip;
-
- /*
- * if there is no client clip, we can get by with just keeping the
- * pointer we got, and remembering whether or not should destroy
- * (or maybe re-use) it later. this way, we avoid unnecessary
- * copying of regions. (this wins especially if many clients clip
- * by children and have no client clip.)
- */
- if (pPicture->clientClipType == CT_NONE)
- {
- if (freeCompClip)
- REGION_DESTROY(pScreen, pPicture->pCompositeClip);
- pPicture->pCompositeClip = pregWin;
- pPicture->freeCompClip = freeTmpClip;
- }
- else
- {
- /*
- * we need one 'real' region to put into the composite clip. if
- * pregWin the current composite clip are real, we can get rid of
- * one. if pregWin is real and the current composite clip isn't,
- * use pregWin for the composite clip. if the current composite
- * clip is real and pregWin isn't, use the current composite
- * clip. if neither is real, create a new region.
- */
-
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
- pDrawable->x + pPicture->clipOrigin.x,
- pDrawable->y + pPicture->clipOrigin.y);
-
- if (freeCompClip)
- {
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
- pregWin, pPicture->clientClip);
- if (freeTmpClip)
- REGION_DESTROY(pScreen, pregWin);
- }
- else if (freeTmpClip)
- {
- REGION_INTERSECT(pScreen, pregWin, pregWin, pPicture->clientClip);
- pPicture->pCompositeClip = pregWin;
- }
- else
- {
- pPicture->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
- pregWin, pPicture->clientClip);
- }
- pPicture->freeCompClip = TRUE;
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
- -(pDrawable->x + pPicture->clipOrigin.x),
- -(pDrawable->y + pPicture->clipOrigin.y));
- }
- } /* end of composite clip for a window */
- else
- {
- BoxRec pixbounds;
-
- /* XXX should we translate by drawable.x/y here ? */
- /* If you want pixmaps in offscreen memory, yes */
- pixbounds.x1 = pDrawable->x;
- pixbounds.y1 = pDrawable->y;
- pixbounds.x2 = pDrawable->x + pDrawable->width;
- pixbounds.y2 = pDrawable->y + pDrawable->height;
-
- if (pPicture->freeCompClip)
- {
- REGION_RESET(pScreen, pPicture->pCompositeClip, &pixbounds);
- }
- else
- {
- pPicture->freeCompClip = TRUE;
- pPicture->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
- }
-
- if (pPicture->clientClipType == CT_REGION)
- {
- if(pDrawable->x || pDrawable->y) {
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
- pDrawable->x + pPicture->clipOrigin.x,
- pDrawable->y + pPicture->clipOrigin.y);
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
- pPicture->pCompositeClip, pPicture->clientClip);
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
- -(pDrawable->x + pPicture->clipOrigin.x),
- -(pDrawable->y + pPicture->clipOrigin.y));
- } else {
- REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
- -pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
- pPicture->pCompositeClip, pPicture->clientClip);
- REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
- pPicture->clipOrigin.x, pPicture->clipOrigin.y);
- }
- }
- } /* end of composite clip for pixmap */
- }
-}
-
-int
-miChangePictureTransform (PicturePtr pPicture,
- PictTransform *transform)
-{
- return Success;
-}
-
-int
-miChangePictureFilter (PicturePtr pPicture,
- int filter,
- xFixed *params,
- int nparams)
-{
- return Success;
-}
-
-#define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
-
-static __inline pixman_bool_t
-miClipPictureReg (pixman_region16_t * pRegion,
- pixman_region16_t * pClip,
- int dx,
- int dy)
-{
- if (pixman_region_n_rects(pRegion) == 1 &&
- pixman_region_n_rects(pClip) == 1)
- {
- pixman_box16_t * pRbox = pixman_region_rectangles(pRegion, NULL);
- pixman_box16_t * pCbox = pixman_region_rectangles(pClip, NULL);
- int v;
-
- if (pRbox->x1 < (v = pCbox->x1 + dx))
- pRbox->x1 = BOUND(v);
- if (pRbox->x2 > (v = pCbox->x2 + dx))
- pRbox->x2 = BOUND(v);
- if (pRbox->y1 < (v = pCbox->y1 + dy))
- pRbox->y1 = BOUND(v);
- if (pRbox->y2 > (v = pCbox->y2 + dy))
- pRbox->y2 = BOUND(v);
- if (pRbox->x1 >= pRbox->x2 ||
- pRbox->y1 >= pRbox->y2)
- {
- pixman_region_init (pRegion);
- }
- }
- else if (!pixman_region_not_empty (pClip))
- return FALSE;
- else
- {
- if (dx || dy)
- pixman_region_translate (pRegion, -dx, -dy);
- if (!pixman_region_intersect (pRegion, pRegion, pClip))
- return FALSE;
- if (dx || dy)
- pixman_region_translate(pRegion, dx, dy);
- }
- return pixman_region_not_empty(pRegion);
-}
-
-static __inline Bool
-miClipPictureSrc (RegionPtr pRegion,
- PicturePtr pPicture,
- int dx,
- int dy)
-{
- if (pPicture->clientClipType != CT_NONE)
- {
- Bool result;
-
- pixman_region_translate ( pPicture->clientClip,
- pPicture->clipOrigin.x + dx,
- pPicture->clipOrigin.y + dy);
-
- result = REGION_INTERSECT (pScreen, pRegion, pRegion, pPicture->clientClip);
-
- pixman_region_translate ( pPicture->clientClip,
- - (pPicture->clipOrigin.x + dx),
- - (pPicture->clipOrigin.y + dy));
-
- if (!result)
- return FALSE;
- }
- return TRUE;
-}
-
-void
-miCompositeSourceValidate (PicturePtr pPicture,
- INT16 x,
- INT16 y,
- CARD16 width,
- CARD16 height)
-{
- DrawablePtr pDrawable = pPicture->pDrawable;
- ScreenPtr pScreen;
-
- if (!pDrawable)
- return;
-
- pScreen = pDrawable->pScreen;
-
- if (pScreen->SourceValidate)
- {
- if (pPicture->transform)
- {
- xPoint points[4];
- int i;
- int xmin, ymin, xmax, ymax;
-
-#define VectorSet(i,_x,_y) { points[i].x = _x; points[i].y = _y; }
- VectorSet (0, x, y);
- VectorSet (1, x + width, y);
- VectorSet (2, x, y + height);
- VectorSet (3, x + width, y + height);
- xmin = ymin = 32767;
- xmax = ymax = -32737;
- for (i = 0; i < 4; i++)
- {
- PictVector t;
- t.vector[0] = IntToxFixed (points[i].x);
- t.vector[1] = IntToxFixed (points[i].y);
- t.vector[2] = xFixed1;
- if (pixman_transform_point (pPicture->transform, &t))
- {
- int tx = xFixedToInt (t.vector[0]);
- int ty = xFixedToInt (t.vector[1]);
- if (tx < xmin) xmin = tx;
- if (tx > xmax) xmax = tx;
- if (ty < ymin) ymin = ty;
- if (ty > ymax) ymax = ty;
- }
- }
- x = xmin;
- y = ymin;
- width = xmax - xmin;
- height = ymax - ymin;
- }
- x += pPicture->pDrawable->x;
- y += pPicture->pDrawable->y;
- (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
- }
-}
-
-/*
- * returns FALSE if the final region is empty. Indistinguishable from
- * an allocation failure, but rendering ignores those anyways.
- */
-
-Bool
-miComputeCompositeRegion (RegionPtr pRegion,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
-{
-
- int v;
-
- pRegion->extents.x1 = xDst;
- v = xDst + width;
- pRegion->extents.x2 = BOUND(v);
- pRegion->extents.y1 = yDst;
- v = yDst + height;
- pRegion->extents.y2 = BOUND(v);
- pRegion->data = 0;
- /* Check for empty operation */
- if (pRegion->extents.x1 >= pRegion->extents.x2 ||
- pRegion->extents.y1 >= pRegion->extents.y2)
- {
- pixman_region_init (pRegion);
- return FALSE;
- }
- /* clip against dst */
- if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0))
- {
- pixman_region_fini (pRegion);
- return FALSE;
- }
- if (pDst->alphaMap)
- {
- if (!miClipPictureReg (pRegion, pDst->alphaMap->pCompositeClip,
- -pDst->alphaOrigin.x,
- -pDst->alphaOrigin.y))
- {
- pixman_region_fini (pRegion);
- return FALSE;
- }
- }
- /* clip against src */
- if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc))
- {
- pixman_region_fini (pRegion);
- return FALSE;
- }
- if (pSrc->alphaMap)
- {
- if (!miClipPictureSrc (pRegion, pSrc->alphaMap,
- xDst - (xSrc - pSrc->alphaOrigin.x),
- yDst - (ySrc - pSrc->alphaOrigin.y)))
- {
- pixman_region_fini (pRegion);
- return FALSE;
- }
- }
- /* clip against mask */
- if (pMask)
- {
- if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask))
- {
- pixman_region_fini (pRegion);
- return FALSE;
- }
- if (pMask->alphaMap)
- {
- if (!miClipPictureSrc (pRegion, pMask->alphaMap,
- xDst - (xMask - pMask->alphaOrigin.x),
- yDst - (yMask - pMask->alphaOrigin.y)))
- {
- pixman_region_fini (pRegion);
- return FALSE;
- }
- }
- }
-
-
- miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height);
- if (pMask)
- miCompositeSourceValidate (pMask, xMask, yMask, width, height);
-
- return TRUE;
-}
-
-void
-miRenderColorToPixel (PictFormatPtr format,
- xRenderColor *color,
- CARD32 *pixel)
-{
- CARD32 r, g, b, a;
- miIndexedPtr pIndexed;
-
- switch (format->type) {
- case PictTypeDirect:
- r = color->red >> (16 - Ones (format->direct.redMask));
- g = color->green >> (16 - Ones (format->direct.greenMask));
- b = color->blue >> (16 - Ones (format->direct.blueMask));
- a = color->alpha >> (16 - Ones (format->direct.alphaMask));
- r = r << format->direct.red;
- g = g << format->direct.green;
- b = b << format->direct.blue;
- a = a << format->direct.alpha;
- *pixel = r|g|b|a;
- break;
- case PictTypeIndexed:
- pIndexed = (miIndexedPtr) (format->index.devPrivate);
- if (pIndexed->color)
- {
- r = color->red >> 11;
- g = color->green >> 11;
- b = color->blue >> 11;
- *pixel = miIndexToEnt15 (pIndexed, (r << 10) | (g << 5) | b);
- }
- else
- {
- r = color->red >> 8;
- g = color->green >> 8;
- b = color->blue >> 8;
- *pixel = miIndexToEntY24 (pIndexed, (r << 16) | (g << 8) | b);
- }
- break;
- }
-}
-
-static CARD16
-miFillColor (CARD32 pixel, int bits)
-{
- while (bits < 16)
- {
- pixel |= pixel << bits;
- bits <<= 1;
- }
- return (CARD16) pixel;
-}
-
-Bool
-miIsSolidAlpha (PicturePtr pSrc)
-{
- ScreenPtr pScreen;
- char line[1];
-
- if (!pSrc->pDrawable)
- return FALSE;
-
- pScreen = pSrc->pDrawable->pScreen;
-
- /* Alpha-only */
- if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A)
- return FALSE;
- /* repeat */
- if (!pSrc->repeat)
- return FALSE;
- /* 1x1 */
- if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1)
- return FALSE;
- line[0] = 1;
- (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line);
- switch (pSrc->pDrawable->bitsPerPixel) {
- case 1:
- return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80;
- case 4:
- return (CARD8) line[0] == 0xf || (CARD8) line[0] == 0xf0;
- case 8:
- return (CARD8) line[0] == 0xff;
- default:
- return FALSE;
- }
-}
-
-void
-miRenderPixelToColor (PictFormatPtr format,
- CARD32 pixel,
- xRenderColor *color)
-{
- CARD32 r, g, b, a;
- miIndexedPtr pIndexed;
-
- switch (format->type) {
- case PictTypeDirect:
- r = (pixel >> format->direct.red) & format->direct.redMask;
- g = (pixel >> format->direct.green) & format->direct.greenMask;
- b = (pixel >> format->direct.blue) & format->direct.blueMask;
- a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
- color->red = miFillColor (r, Ones (format->direct.redMask));
- color->green = miFillColor (g, Ones (format->direct.greenMask));
- color->blue = miFillColor (b, Ones (format->direct.blueMask));
- color->alpha = miFillColor (a, Ones (format->direct.alphaMask));
- break;
- case PictTypeIndexed:
- pIndexed = (miIndexedPtr) (format->index.devPrivate);
- pixel = pIndexed->rgba[pixel & (MI_MAX_INDEXED-1)];
- r = (pixel >> 16) & 0xff;
- g = (pixel >> 8) & 0xff;
- b = (pixel ) & 0xff;
- color->red = miFillColor (r, 8);
- color->green = miFillColor (g, 8);
- color->blue = miFillColor (b, 8);
- color->alpha = 0xffff;
- break;
- }
-}
-
-Bool
-miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
-{
- PictureScreenPtr ps;
-
- if (!PictureInit (pScreen, formats, nformats))
- return FALSE;
- ps = GetPictureScreen(pScreen);
- ps->CreatePicture = miCreatePicture;
- ps->DestroyPicture = miDestroyPicture;
- ps->ChangePictureClip = miChangePictureClip;
- ps->DestroyPictureClip = miDestroyPictureClip;
- ps->ChangePicture = miChangePicture;
- ps->ValidatePicture = miValidatePicture;
- ps->InitIndexed = miInitIndexed;
- ps->CloseIndexed = miCloseIndexed;
- ps->UpdateIndexed = miUpdateIndexed;
- ps->ChangePictureTransform = miChangePictureTransform;
- ps->ChangePictureFilter = miChangePictureFilter;
- ps->RealizeGlyph = miRealizeGlyph;
- ps->UnrealizeGlyph = miUnrealizeGlyph;
-
- /* MI rendering routines */
- ps->Composite = 0; /* requires DDX support */
- ps->Glyphs = miGlyphs;
- ps->CompositeRects = miCompositeRects;
- ps->Trapezoids = miTrapezoids;
- ps->Triangles = miTriangles;
- ps->TriStrip = miTriStrip;
- ps->TriFan = miTriFan;
-
- ps->RasterizeTrapezoid = 0; /* requires DDX support */
- ps->AddTraps = 0; /* requires DDX support */
- ps->AddTriangles = 0; /* requires DDX support */
-
- return TRUE;
-}
+/*
+ *
+ * Copyright © 1999 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.
+ */
+
+#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"
+
+#ifndef __GNUC__
+#define __inline
+#endif
+
+int
+miCreatePicture (PicturePtr pPicture)
+{
+ return Success;
+}
+
+void
+miDestroyPicture (PicturePtr pPicture)
+{
+ if (pPicture->freeCompClip)
+ REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->pCompositeClip);
+}
+
+void
+miDestroyPictureClip (PicturePtr pPicture)
+{
+ switch (pPicture->clientClipType) {
+ case CT_NONE:
+ return;
+ case CT_PIXMAP:
+ (*pPicture->pDrawable->pScreen->DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
+ break;
+ default:
+ /*
+ * we know we'll never have a list of rectangles, since ChangeClip
+ * immediately turns them into a region
+ */
+ REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->clientClip);
+ break;
+ }
+ pPicture->clientClip = NULL;
+ pPicture->clientClipType = CT_NONE;
+}
+
+int
+miChangePictureClip (PicturePtr pPicture,
+ int type,
+ pointer value,
+ int n)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ pointer clientClip;
+ int clientClipType;
+
+ switch (type) {
+ case CT_PIXMAP:
+ /* convert the pixmap to a region */
+ clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
+ if (!clientClip)
+ return BadAlloc;
+ clientClipType = CT_REGION;
+ (*pScreen->DestroyPixmap) ((PixmapPtr) value);
+ break;
+ case CT_REGION:
+ clientClip = value;
+ clientClipType = CT_REGION;
+ break;
+ case CT_NONE:
+ clientClip = 0;
+ clientClipType = CT_NONE;
+ break;
+ default:
+ clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
+ (xRectangle *) value,
+ type);
+ if (!clientClip)
+ return BadAlloc;
+ clientClipType = CT_REGION;
+ free(value);
+ break;
+ }
+ (*ps->DestroyPictureClip) (pPicture);
+ pPicture->clientClip = clientClip;
+ pPicture->clientClipType = clientClipType;
+ pPicture->stateChanges |= CPClipMask;
+ return Success;
+}
+
+void
+miChangePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ return;
+}
+
+void
+miValidatePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ DrawablePtr pDrawable = pPicture->pDrawable;
+
+ if ((mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode)) ||
+ (pDrawable->serialNumber != (pPicture->serialNumber & DRAWABLE_SERIAL_BITS)))
+ {
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pPicture->subWindowMode == IncludeInferiors)
+ {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ }
+ else
+ {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pPicture->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy
+ * (or maybe re-use) it later. this way, we avoid unnecessary
+ * copying of regions. (this wins especially if many clients clip
+ * by children and have no client clip.)
+ */
+ if (pPicture->clientClipType == CT_NONE)
+ {
+ if (freeCompClip)
+ REGION_DESTROY(pScreen, pPicture->pCompositeClip);
+ pPicture->pCompositeClip = pregWin;
+ pPicture->freeCompClip = freeTmpClip;
+ }
+ else
+ {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ pDrawable->x + pPicture->clipOrigin.x,
+ pDrawable->y + pPicture->clipOrigin.y);
+
+ if (freeCompClip)
+ {
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pregWin, pPicture->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pScreen, pregWin);
+ }
+ else if (freeTmpClip)
+ {
+ REGION_INTERSECT(pScreen, pregWin, pregWin, pPicture->clientClip);
+ pPicture->pCompositeClip = pregWin;
+ }
+ else
+ {
+ pPicture->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pregWin, pPicture->clientClip);
+ }
+ pPicture->freeCompClip = TRUE;
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ -(pDrawable->x + pPicture->clipOrigin.x),
+ -(pDrawable->y + pPicture->clipOrigin.y));
+ }
+ } /* end of composite clip for a window */
+ else
+ {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ /* If you want pixmaps in offscreen memory, yes */
+ pixbounds.x1 = pDrawable->x;
+ pixbounds.y1 = pDrawable->y;
+ pixbounds.x2 = pDrawable->x + pDrawable->width;
+ pixbounds.y2 = pDrawable->y + pDrawable->height;
+
+ if (pPicture->freeCompClip)
+ {
+ REGION_RESET(pScreen, pPicture->pCompositeClip, &pixbounds);
+ }
+ else
+ {
+ pPicture->freeCompClip = TRUE;
+ pPicture->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+ }
+
+ if (pPicture->clientClipType == CT_REGION)
+ {
+ if(pDrawable->x || pDrawable->y) {
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ pDrawable->x + pPicture->clipOrigin.x,
+ pDrawable->y + pPicture->clipOrigin.y);
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pPicture->pCompositeClip, pPicture->clientClip);
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ -(pDrawable->x + pPicture->clipOrigin.x),
+ -(pDrawable->y + pPicture->clipOrigin.y));
+ } else {
+ REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+ -pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pPicture->pCompositeClip, pPicture->clientClip);
+ REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+ pPicture->clipOrigin.x, pPicture->clipOrigin.y);
+ }
+ }
+ } /* end of composite clip for pixmap */
+ }
+}
+
+int
+miChangePictureTransform (PicturePtr pPicture,
+ PictTransform *transform)
+{
+ return Success;
+}
+
+int
+miChangePictureFilter (PicturePtr pPicture,
+ int filter,
+ xFixed *params,
+ int nparams)
+{
+ return Success;
+}
+
+#define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
+
+static __inline pixman_bool_t
+miClipPictureReg (pixman_region16_t * pRegion,
+ pixman_region16_t * pClip,
+ int dx,
+ int dy)
+{
+ if (pixman_region_n_rects(pRegion) == 1 &&
+ pixman_region_n_rects(pClip) == 1)
+ {
+ pixman_box16_t * pRbox = pixman_region_rectangles(pRegion, NULL);
+ pixman_box16_t * pCbox = pixman_region_rectangles(pClip, NULL);
+ int v;
+
+ if (pRbox->x1 < (v = pCbox->x1 + dx))
+ pRbox->x1 = BOUND(v);
+ if (pRbox->x2 > (v = pCbox->x2 + dx))
+ pRbox->x2 = BOUND(v);
+ if (pRbox->y1 < (v = pCbox->y1 + dy))
+ pRbox->y1 = BOUND(v);
+ if (pRbox->y2 > (v = pCbox->y2 + dy))
+ pRbox->y2 = BOUND(v);
+ if (pRbox->x1 >= pRbox->x2 ||
+ pRbox->y1 >= pRbox->y2)
+ {
+ pixman_region_init (pRegion);
+ }
+ }
+ else if (!pixman_region_not_empty (pClip))
+ return FALSE;
+ else
+ {
+ if (dx || dy)
+ pixman_region_translate (pRegion, -dx, -dy);
+ if (!pixman_region_intersect (pRegion, pRegion, pClip))
+ return FALSE;
+ if (dx || dy)
+ pixman_region_translate(pRegion, dx, dy);
+ }
+ return pixman_region_not_empty(pRegion);
+}
+
+static __inline Bool
+miClipPictureSrc (RegionPtr pRegion,
+ PicturePtr pPicture,
+ int dx,
+ int dy)
+{
+ if (pPicture->clientClipType != CT_NONE)
+ {
+ Bool result;
+
+ pixman_region_translate ( pPicture->clientClip,
+ pPicture->clipOrigin.x + dx,
+ pPicture->clipOrigin.y + dy);
+
+ result = REGION_INTERSECT (pScreen, pRegion, pRegion, pPicture->clientClip);
+
+ pixman_region_translate ( pPicture->clientClip,
+ - (pPicture->clipOrigin.x + dx),
+ - (pPicture->clipOrigin.y + dy));
+
+ if (!result)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+miCompositeSourceValidate (PicturePtr pPicture,
+ INT16 x,
+ INT16 y,
+ CARD16 width,
+ CARD16 height)
+{
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ ScreenPtr pScreen;
+
+ if (!pDrawable)
+ return;
+
+ pScreen = pDrawable->pScreen;
+
+ if (pScreen->SourceValidate)
+ {
+ if (pPicture->transform)
+ {
+ xPoint points[4];
+ int i;
+ int xmin, ymin, xmax, ymax;
+
+#define VectorSet(i,_x,_y) { points[i].x = _x; points[i].y = _y; }
+ VectorSet (0, x, y);
+ VectorSet (1, x + width, y);
+ VectorSet (2, x, y + height);
+ VectorSet (3, x + width, y + height);
+ xmin = ymin = 32767;
+ xmax = ymax = -32737;
+ for (i = 0; i < 4; i++)
+ {
+ PictVector t;
+ t.vector[0] = IntToxFixed (points[i].x);
+ t.vector[1] = IntToxFixed (points[i].y);
+ t.vector[2] = xFixed1;
+ if (pixman_transform_point (pPicture->transform, &t))
+ {
+ int tx = xFixedToInt (t.vector[0]);
+ int ty = xFixedToInt (t.vector[1]);
+ if (tx < xmin) xmin = tx;
+ if (tx > xmax) xmax = tx;
+ if (ty < ymin) ymin = ty;
+ if (ty > ymax) ymax = ty;
+ }
+ }
+ x = xmin;
+ y = ymin;
+ width = xmax - xmin;
+ height = ymax - ymin;
+ }
+ x += pPicture->pDrawable->x;
+ y += pPicture->pDrawable->y;
+ (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
+ }
+}
+
+/*
+ * returns FALSE if the final region is empty. Indistinguishable from
+ * an allocation failure, but rendering ignores those anyways.
+ */
+
+Bool
+miComputeCompositeRegion (RegionPtr pRegion,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+
+ int v;
+
+ pRegion->extents.x1 = xDst;
+ v = xDst + width;
+ pRegion->extents.x2 = BOUND(v);
+ pRegion->extents.y1 = yDst;
+ v = yDst + height;
+ pRegion->extents.y2 = BOUND(v);
+ pRegion->data = 0;
+ /* Check for empty operation */
+ if (pRegion->extents.x1 >= pRegion->extents.x2 ||
+ pRegion->extents.y1 >= pRegion->extents.y2)
+ {
+ pixman_region_init (pRegion);
+ return FALSE;
+ }
+ /* clip against dst */
+ if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0))
+ {
+ pixman_region_fini (pRegion);
+ return FALSE;
+ }
+ if (pDst->alphaMap)
+ {
+ if (!miClipPictureReg (pRegion, pDst->alphaMap->pCompositeClip,
+ -pDst->alphaOrigin.x,
+ -pDst->alphaOrigin.y))
+ {
+ pixman_region_fini (pRegion);
+ return FALSE;
+ }
+ }
+ /* clip against src */
+ if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc))
+ {
+ pixman_region_fini (pRegion);
+ return FALSE;
+ }
+ if (pSrc->alphaMap)
+ {
+ if (!miClipPictureSrc (pRegion, pSrc->alphaMap,
+ xDst - (xSrc - pSrc->alphaOrigin.x),
+ yDst - (ySrc - pSrc->alphaOrigin.y)))
+ {
+ pixman_region_fini (pRegion);
+ return FALSE;
+ }
+ }
+ /* clip against mask */
+ if (pMask)
+ {
+ if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask))
+ {
+ pixman_region_fini (pRegion);
+ return FALSE;
+ }
+ if (pMask->alphaMap)
+ {
+ if (!miClipPictureSrc (pRegion, pMask->alphaMap,
+ xDst - (xMask - pMask->alphaOrigin.x),
+ yDst - (yMask - pMask->alphaOrigin.y)))
+ {
+ pixman_region_fini (pRegion);
+ return FALSE;
+ }
+ }
+ }
+
+
+ miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height);
+ if (pMask)
+ miCompositeSourceValidate (pMask, xMask, yMask, width, height);
+
+ return TRUE;
+}
+
+void
+miRenderColorToPixel (PictFormatPtr format,
+ xRenderColor *color,
+ CARD32 *pixel)
+{
+ CARD32 r, g, b, a;
+ miIndexedPtr pIndexed;
+
+ switch (format->type) {
+ case PictTypeDirect:
+ r = color->red >> (16 - Ones (format->direct.redMask));
+ g = color->green >> (16 - Ones (format->direct.greenMask));
+ b = color->blue >> (16 - Ones (format->direct.blueMask));
+ a = color->alpha >> (16 - Ones (format->direct.alphaMask));
+ r = r << format->direct.red;
+ g = g << format->direct.green;
+ b = b << format->direct.blue;
+ a = a << format->direct.alpha;
+ *pixel = r|g|b|a;
+ break;
+ case PictTypeIndexed:
+ pIndexed = (miIndexedPtr) (format->index.devPrivate);
+ if (pIndexed->color)
+ {
+ r = color->red >> 11;
+ g = color->green >> 11;
+ b = color->blue >> 11;
+ *pixel = miIndexToEnt15 (pIndexed, (r << 10) | (g << 5) | b);
+ }
+ else
+ {
+ r = color->red >> 8;
+ g = color->green >> 8;
+ b = color->blue >> 8;
+ *pixel = miIndexToEntY24 (pIndexed, (r << 16) | (g << 8) | b);
+ }
+ break;
+ }
+}
+
+static CARD16
+miFillColor (CARD32 pixel, int bits)
+{
+ while (bits < 16)
+ {
+ pixel |= pixel << bits;
+ bits <<= 1;
+ }
+ return (CARD16) pixel;
+}
+
+Bool
+miIsSolidAlpha (PicturePtr pSrc)
+{
+ ScreenPtr pScreen;
+ char line[1];
+
+ if (!pSrc->pDrawable)
+ return FALSE;
+
+ pScreen = pSrc->pDrawable->pScreen;
+
+ /* Alpha-only */
+ if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A)
+ return FALSE;
+ /* repeat */
+ if (!pSrc->repeat)
+ return FALSE;
+ /* 1x1 */
+ if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1)
+ return FALSE;
+ line[0] = 1;
+ (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line);
+ switch (pSrc->pDrawable->bitsPerPixel) {
+ case 1:
+ return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80;
+ case 4:
+ return (CARD8) line[0] == 0xf || (CARD8) line[0] == 0xf0;
+ case 8:
+ return (CARD8) line[0] == 0xff;
+ default:
+ return FALSE;
+ }
+}
+
+void
+miRenderPixelToColor (PictFormatPtr format,
+ CARD32 pixel,
+ xRenderColor *color)
+{
+ CARD32 r, g, b, a;
+ miIndexedPtr pIndexed;
+
+ switch (format->type) {
+ case PictTypeDirect:
+ r = (pixel >> format->direct.red) & format->direct.redMask;
+ g = (pixel >> format->direct.green) & format->direct.greenMask;
+ b = (pixel >> format->direct.blue) & format->direct.blueMask;
+ a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
+ color->red = miFillColor (r, Ones (format->direct.redMask));
+ color->green = miFillColor (g, Ones (format->direct.greenMask));
+ color->blue = miFillColor (b, Ones (format->direct.blueMask));
+ color->alpha = miFillColor (a, Ones (format->direct.alphaMask));
+ break;
+ case PictTypeIndexed:
+ pIndexed = (miIndexedPtr) (format->index.devPrivate);
+ pixel = pIndexed->rgba[pixel & (MI_MAX_INDEXED-1)];
+ r = (pixel >> 16) & 0xff;
+ g = (pixel >> 8) & 0xff;
+ b = (pixel ) & 0xff;
+ color->red = miFillColor (r, 8);
+ color->green = miFillColor (g, 8);
+ color->blue = miFillColor (b, 8);
+ color->alpha = 0xffff;
+ break;
+ }
+}
+
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+ PictureScreenPtr ps;
+
+ if (!PictureInit (pScreen, formats, nformats))
+ return FALSE;
+ ps = GetPictureScreen(pScreen);
+ ps->CreatePicture = miCreatePicture;
+ ps->DestroyPicture = miDestroyPicture;
+ ps->ChangePictureClip = miChangePictureClip;
+ ps->DestroyPictureClip = miDestroyPictureClip;
+ ps->ChangePicture = miChangePicture;
+ ps->ValidatePicture = miValidatePicture;
+ ps->InitIndexed = miInitIndexed;
+ ps->CloseIndexed = miCloseIndexed;
+ ps->UpdateIndexed = miUpdateIndexed;
+ ps->ChangePictureTransform = miChangePictureTransform;
+ ps->ChangePictureFilter = miChangePictureFilter;
+ ps->RealizeGlyph = miRealizeGlyph;
+ ps->UnrealizeGlyph = miUnrealizeGlyph;
+
+ /* MI rendering routines */
+ ps->Composite = 0; /* requires DDX support */
+ ps->Glyphs = miGlyphs;
+ ps->CompositeRects = miCompositeRects;
+ ps->Trapezoids = miTrapezoids;
+ ps->Triangles = miTriangles;
+ ps->TriStrip = miTriStrip;
+ ps->TriFan = miTriFan;
+
+ ps->RasterizeTrapezoid = 0; /* requires DDX support */
+ ps->AddTraps = 0; /* requires DDX support */
+ ps->AddTriangles = 0; /* requires DDX support */
+
+ return TRUE;
+}
diff --git a/xorg-server/render/mirect.c b/xorg-server/render/mirect.c
index b54fe6fe6..70bdf63f6 100644
--- a/xorg-server/render/mirect.c
+++ b/xorg-server/render/mirect.c
@@ -1,185 +1,186 @@
-/*
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, 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 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.
- */
-
-#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"
-
-static void
-miColorRects (PicturePtr pDst,
- PicturePtr pClipPict,
- xRenderColor *color,
- int nRect,
- xRectangle *rects,
- int xoff,
- int yoff)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- CARD32 pixel;
- GCPtr pGC;
- CARD32 tmpval[5];
- RegionPtr pClip;
- unsigned long mask;
-
- miRenderColorToPixel (pDst->pFormat, color, &pixel);
-
- pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
- if (!pGC)
- return;
- tmpval[0] = GXcopy;
- tmpval[1] = pixel;
- tmpval[2] = pDst->subWindowMode;
- mask = GCFunction | GCForeground | GCSubwindowMode;
- if (pClipPict->clientClipType == CT_REGION)
- {
- tmpval[3] = pDst->clipOrigin.x - xoff;
- tmpval[4] = pDst->clipOrigin.y - yoff;
- mask |= GCClipXOrigin|GCClipYOrigin;
-
- pClip = REGION_CREATE (pScreen, NULL, 1);
- REGION_COPY (pScreen, pClip,
- (RegionPtr) pClipPict->clientClip);
- (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
- }
-
- ChangeGC (pGC, mask, tmpval);
- ValidateGC (pDst->pDrawable, pGC);
- if (xoff || yoff)
- {
- int i;
- for (i = 0; i < nRect; i++)
- {
- rects[i].x -= xoff;
- rects[i].y -= yoff;
- }
- }
- (*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects);
- if (xoff || yoff)
- {
- int i;
- for (i = 0; i < nRect; i++)
- {
- rects[i].x += xoff;
- rects[i].y += yoff;
- }
- }
- FreeScratchGC (pGC);
-}
-
-void
-miCompositeRects (CARD8 op,
- PicturePtr pDst,
- xRenderColor *color,
- int nRect,
- xRectangle *rects)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
-
- if (color->alpha == 0xffff)
- {
- if (op == PictOpOver)
- op = PictOpSrc;
- }
- if (op == PictOpClear)
- color->red = color->green = color->blue = color->alpha = 0;
-
- if (op == PictOpSrc || op == PictOpClear)
- {
- miColorRects (pDst, pDst, color, nRect, rects, 0, 0);
- if (pDst->alphaMap)
- miColorRects (pDst->alphaMap, pDst,
- color, nRect, rects,
- pDst->alphaOrigin.x,
- pDst->alphaOrigin.y);
- }
- else
- {
- PictFormatPtr rgbaFormat;
- PixmapPtr pPixmap;
- PicturePtr pSrc;
- xRectangle one;
- int error;
- Pixel pixel;
- GCPtr pGC;
- CARD32 tmpval[2];
-
- rgbaFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
- if (!rgbaFormat)
- goto bail1;
-
- pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, rgbaFormat->depth,
- CREATE_PIXMAP_USAGE_SCRATCH);
- if (!pPixmap)
- goto bail2;
-
- miRenderColorToPixel (rgbaFormat, color, &pixel);
-
- pGC = GetScratchGC (rgbaFormat->depth, pScreen);
- if (!pGC)
- goto bail3;
- tmpval[0] = GXcopy;
- tmpval[1] = pixel;
-
- ChangeGC (pGC, GCFunction | GCForeground, tmpval);
- ValidateGC (&pPixmap->drawable, pGC);
- one.x = 0;
- one.y = 0;
- one.width = 1;
- one.height = 1;
- (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
-
- tmpval[0] = xTrue;
- pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
- CPRepeat, tmpval, serverClient, &error);
-
- if (!pSrc)
- goto bail4;
-
- while (nRect--)
- {
- CompositePicture (op, pSrc, 0, pDst, 0, 0, 0, 0,
- rects->x,
- rects->y,
- rects->width,
- rects->height);
- rects++;
- }
-
- FreePicture ((pointer) pSrc, 0);
-bail4:
- FreeScratchGC (pGC);
-bail3:
- (*pScreen->DestroyPixmap) (pPixmap);
-bail2:
-bail1:
- ;
- }
-}
+/*
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, 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 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.
+ */
+
+#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"
+
+static void
+miColorRects (PicturePtr pDst,
+ PicturePtr pClipPict,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects,
+ int xoff,
+ int yoff)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ CARD32 pixel;
+ GCPtr pGC;
+ ChangeGCVal tmpval[5];
+ RegionPtr pClip;
+ unsigned long mask;
+
+ miRenderColorToPixel (pDst->pFormat, color, &pixel);
+
+ pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
+ if (!pGC)
+ return;
+ tmpval[0].val = GXcopy;
+ tmpval[1].val = pixel;
+ tmpval[2].val = pDst->subWindowMode;
+ mask = GCFunction | GCForeground | GCSubwindowMode;
+ if (pClipPict->clientClipType == CT_REGION)
+ {
+ tmpval[3].val = pDst->clipOrigin.x - xoff;
+ tmpval[4].val = pDst->clipOrigin.y - yoff;
+ mask |= GCClipXOrigin|GCClipYOrigin;
+
+ pClip = REGION_CREATE (pScreen, NULL, 1);
+ REGION_COPY (pScreen, pClip,
+ (RegionPtr) pClipPict->clientClip);
+ (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
+ }
+
+ ChangeGC (NullClient, pGC, mask, tmpval);
+ ValidateGC (pDst->pDrawable, pGC);
+ if (xoff || yoff)
+ {
+ int i;
+ for (i = 0; i < nRect; i++)
+ {
+ rects[i].x -= xoff;
+ rects[i].y -= yoff;
+ }
+ }
+ (*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects);
+ if (xoff || yoff)
+ {
+ int i;
+ for (i = 0; i < nRect; i++)
+ {
+ rects[i].x += xoff;
+ rects[i].y += yoff;
+ }
+ }
+ FreeScratchGC (pGC);
+}
+
+void
+miCompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+
+ if (color->alpha == 0xffff)
+ {
+ if (op == PictOpOver)
+ op = PictOpSrc;
+ }
+ if (op == PictOpClear)
+ color->red = color->green = color->blue = color->alpha = 0;
+
+ if (op == PictOpSrc || op == PictOpClear)
+ {
+ miColorRects (pDst, pDst, color, nRect, rects, 0, 0);
+ if (pDst->alphaMap)
+ miColorRects (pDst->alphaMap, pDst,
+ color, nRect, rects,
+ pDst->alphaOrigin.x,
+ pDst->alphaOrigin.y);
+ }
+ else
+ {
+ PictFormatPtr rgbaFormat;
+ PixmapPtr pPixmap;
+ PicturePtr pSrc;
+ xRectangle one;
+ int error;
+ Pixel pixel;
+ GCPtr pGC;
+ ChangeGCVal gcvals[2];
+ XID tmpval[1];
+
+ rgbaFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+ if (!rgbaFormat)
+ goto bail1;
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, rgbaFormat->depth,
+ CREATE_PIXMAP_USAGE_SCRATCH);
+ if (!pPixmap)
+ goto bail2;
+
+ miRenderColorToPixel (rgbaFormat, color, &pixel);
+
+ pGC = GetScratchGC (rgbaFormat->depth, pScreen);
+ if (!pGC)
+ goto bail3;
+ gcvals[0].val = GXcopy;
+ gcvals[1].val = pixel;
+
+ ChangeGC (NullClient, pGC, GCFunction | GCForeground, gcvals);
+ ValidateGC (&pPixmap->drawable, pGC);
+ one.x = 0;
+ one.y = 0;
+ one.width = 1;
+ one.height = 1;
+ (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
+
+ tmpval[0] = xTrue;
+ pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
+ CPRepeat, tmpval, serverClient, &error);
+
+ if (!pSrc)
+ goto bail4;
+
+ while (nRect--)
+ {
+ CompositePicture (op, pSrc, 0, pDst, 0, 0, 0, 0,
+ rects->x,
+ rects->y,
+ rects->width,
+ rects->height);
+ rects++;
+ }
+
+ FreePicture ((pointer) pSrc, 0);
+bail4:
+ FreeScratchGC (pGC);
+bail3:
+ (*pScreen->DestroyPixmap) (pPixmap);
+bail2:
+bail1:
+ ;
+ }
+}
diff --git a/xorg-server/render/mitri.c b/xorg-server/render/mitri.c
index a92c19b7e..3e11cffd9 100644
--- a/xorg-server/render/mitri.c
+++ b/xorg-server/render/mitri.c
@@ -1,191 +1,191 @@
-/*
- *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 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.
- */
-
-#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"
-
-void
-miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds)
-{
- bounds->x1 = xFixedToInt (points->x);
- bounds->x2 = xFixedToInt (xFixedCeil (points->x));
- bounds->y1 = xFixedToInt (points->y);
- bounds->y2 = xFixedToInt (xFixedCeil (points->y));
- points++;
- npoint--;
- while (npoint-- > 0)
- {
- INT16 x1 = xFixedToInt (points->x);
- INT16 x2 = xFixedToInt (xFixedCeil (points->x));
- INT16 y1 = xFixedToInt (points->y);
- INT16 y2 = xFixedToInt (xFixedCeil (points->y));
-
- if (x1 < bounds->x1)
- bounds->x1 = x1;
- else if (x2 > bounds->x2)
- bounds->x2 = x2;
- if (y1 < bounds->y1)
- bounds->y1 = y1;
- else if (y2 > bounds->y2)
- bounds->y2 = y2;
- points++;
- }
-}
-
-void
-miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds)
-{
- miPointFixedBounds (ntri * 3, (xPointFixed *) tris, bounds);
-}
-
-void
-miTriangles (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int ntri,
- xTriangle *tris)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- /*
- * Check for solid alpha add
- */
- if (op == PictOpAdd && miIsSolidAlpha (pSrc))
- {
- (*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
- }
- else if (maskFormat)
- {
- BoxRec bounds;
- PicturePtr pPicture;
- INT16 xDst, yDst;
- INT16 xRel, yRel;
-
- xDst = tris[0].p1.x >> 16;
- yDst = tris[0].p1.y >> 16;
-
- miTriangleBounds (ntri, tris, &bounds);
- if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
- return;
- pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
- bounds.x2 - bounds.x1,
- bounds.y2 - bounds.y1);
- if (!pPicture)
- return;
- (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
-
- xRel = bounds.x1 + xSrc - xDst;
- yRel = bounds.y1 + ySrc - yDst;
- CompositePicture (op, pSrc, pPicture, pDst,
- xRel, yRel, 0, 0, bounds.x1, bounds.y1,
- bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
- FreePicture (pPicture, 0);
- }
- else
- {
- if (pDst->polyEdge == PolyEdgeSharp)
- maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
- else
- maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
-
- for (; ntri; ntri--, tris++)
- miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
- }
-}
-
-void
-miTriStrip (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int npoint,
- xPointFixed *points)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- xTriangle *tris, *tri;
- int ntri;
-
- if (npoint < 3)
- return;
- ntri = npoint - 2;
- tris = xalloc (ntri * sizeof (xTriangle));
- if (!tris)
- return;
- for (tri = tris; npoint >= 3; npoint--, points++, tri++)
- {
- tri->p1 = points[0];
- tri->p2 = points[1];
- tri->p3 = points[2];
- }
- (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
- xfree (tris);
-}
-
-void
-miTriFan (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int npoint,
- xPointFixed *points)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- xTriangle *tris, *tri;
- xPointFixed *first;
- int ntri;
-
- if (npoint < 3)
- return;
- ntri = npoint - 2;
- tris = xalloc (ntri * sizeof (xTriangle));
- if (!tris)
- return;
- first = points++;
- for (tri = tris; npoint >= 3; npoint--, points++, tri++)
- {
- tri->p1 = *first;
- tri->p2 = points[0];
- tri->p3 = points[1];
- }
- (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
- xfree (tris);
-}
+/*
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 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.
+ */
+
+#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"
+
+void
+miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds)
+{
+ bounds->x1 = xFixedToInt (points->x);
+ bounds->x2 = xFixedToInt (xFixedCeil (points->x));
+ bounds->y1 = xFixedToInt (points->y);
+ bounds->y2 = xFixedToInt (xFixedCeil (points->y));
+ points++;
+ npoint--;
+ while (npoint-- > 0)
+ {
+ INT16 x1 = xFixedToInt (points->x);
+ INT16 x2 = xFixedToInt (xFixedCeil (points->x));
+ INT16 y1 = xFixedToInt (points->y);
+ INT16 y2 = xFixedToInt (xFixedCeil (points->y));
+
+ if (x1 < bounds->x1)
+ bounds->x1 = x1;
+ else if (x2 > bounds->x2)
+ bounds->x2 = x2;
+ if (y1 < bounds->y1)
+ bounds->y1 = y1;
+ else if (y2 > bounds->y2)
+ bounds->y2 = y2;
+ points++;
+ }
+}
+
+void
+miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds)
+{
+ miPointFixedBounds (ntri * 3, (xPointFixed *) tris, bounds);
+}
+
+void
+miTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntri,
+ xTriangle *tris)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ /*
+ * Check for solid alpha add
+ */
+ if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+ {
+ (*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
+ }
+ else if (maskFormat)
+ {
+ BoxRec bounds;
+ PicturePtr pPicture;
+ INT16 xDst, yDst;
+ INT16 xRel, yRel;
+
+ xDst = tris[0].p1.x >> 16;
+ yDst = tris[0].p1.y >> 16;
+
+ miTriangleBounds (ntri, tris, &bounds);
+ if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
+ return;
+ pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ if (!pPicture)
+ return;
+ (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
+
+ xRel = bounds.x1 + xSrc - xDst;
+ yRel = bounds.y1 + ySrc - yDst;
+ CompositePicture (op, pSrc, pPicture, pDst,
+ xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+ FreePicture (pPicture, 0);
+ }
+ else
+ {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+
+ for (; ntri; ntri--, tris++)
+ miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
+ }
+}
+
+void
+miTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ xTriangle *tris, *tri;
+ int ntri;
+
+ if (npoint < 3)
+ return;
+ ntri = npoint - 2;
+ tris = malloc(ntri * sizeof (xTriangle));
+ if (!tris)
+ return;
+ for (tri = tris; npoint >= 3; npoint--, points++, tri++)
+ {
+ tri->p1 = points[0];
+ tri->p2 = points[1];
+ tri->p3 = points[2];
+ }
+ (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
+ free(tris);
+}
+
+void
+miTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ xTriangle *tris, *tri;
+ xPointFixed *first;
+ int ntri;
+
+ if (npoint < 3)
+ return;
+ ntri = npoint - 2;
+ tris = malloc(ntri * sizeof (xTriangle));
+ if (!tris)
+ return;
+ first = points++;
+ for (tri = tris; npoint >= 3; npoint--, points++, tri++)
+ {
+ tri->p1 = *first;
+ tri->p2 = points[0];
+ tri->p3 = points[1];
+ }
+ (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
+ free(tris);
+}
diff --git a/xorg-server/render/picture.c b/xorg-server/render/picture.c
index 6005683c0..12d1cee93 100644
--- a/xorg-server/render/picture.c
+++ b/xorg-server/render/picture.c
@@ -89,8 +89,8 @@ PictureCloseScreen (int index, ScreenPtr pScreen)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
GlyphUninit (pScreen);
SetPictureScreen(pScreen, 0);
- xfree (ps->formats);
- xfree (ps);
+ free(ps->formats);
+ free(ps);
return ret;
}
@@ -337,7 +337,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
}
- pFormats = xcalloc (nformats, sizeof (PictFormatRec));
+ pFormats = calloc(nformats, sizeof (PictFormatRec));
if (!pFormats)
return 0;
for (f = 0; f < nformats; f++)
@@ -638,7 +638,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{
if (!AddResource (formats[n].id, PictFormatType, (pointer) (formats+n)))
{
- xfree (formats);
+ free(formats);
return FALSE;
}
if (formats[n].type == PictTypeIndexed)
@@ -669,10 +669,10 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
}
formats[n].format = PICT_FORMAT(0,type,a,r,g,b);
}
- ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec));
+ ps = (PictureScreenPtr) malloc(sizeof (PictureScreenRec));
if (!ps)
{
- xfree (formats);
+ free(formats);
return FALSE;
}
SetPictureScreen(pScreen, ps);
@@ -699,8 +699,8 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{
PictureResetFilters (pScreen);
SetPictureScreen(pScreen, 0);
- xfree (formats);
- xfree (ps);
+ free(formats);
+ free(ps);
return FALSE;
}
@@ -753,7 +753,7 @@ CreatePicture (Picture pid,
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = (PicturePtr)xalloc(sizeof(PictureRec));
+ pPicture = (PicturePtr)malloc(sizeof(PictureRec));
if (!pPicture)
{
*error = BadAlloc;
@@ -874,7 +874,7 @@ static void initGradient(SourcePictPtr pGradient, int stopCount,
dpos = stopPoints[i];
}
- pGradient->gradient.stops = xalloc(stopCount*sizeof(PictGradientStop));
+ pGradient->gradient.stops = malloc(stopCount*sizeof(PictGradientStop));
if (!pGradient->gradient.stops) {
*error = BadAlloc;
return;
@@ -896,7 +896,7 @@ static void initGradient(SourcePictPtr pGradient, int stopCount,
static PicturePtr createSourcePicture(void)
{
PicturePtr pPicture;
- pPicture = (PicturePtr) xalloc(sizeof(PictureRec));
+ pPicture = (PicturePtr) malloc(sizeof(PictureRec));
pPicture->pDrawable = 0;
pPicture->pFormat = 0;
pPicture->pNext = 0;
@@ -918,10 +918,10 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
}
pPicture->id = pid;
- pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill));
+ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictSolidFill));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
- xfree(pPicture);
+ free(pPicture);
return 0;
}
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
@@ -947,10 +947,10 @@ CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
}
pPicture->id = pid;
- pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient));
+ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictLinearGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
- xfree(pPicture);
+ free(pPicture);
return 0;
}
@@ -960,7 +960,7 @@ CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
if (*error) {
- xfree(pPicture);
+ free(pPicture);
return 0;
}
return pPicture;
@@ -988,10 +988,10 @@ CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer
}
pPicture->id = pid;
- pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient));
+ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictRadialGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
- xfree(pPicture);
+ free(pPicture);
return 0;
}
radial = &pPicture->pSourcePict->radial;
@@ -1012,7 +1012,7 @@ CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer
initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
if (*error) {
- xfree(pPicture);
+ free(pPicture);
return 0;
}
return pPicture;
@@ -1036,10 +1036,10 @@ CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
}
pPicture->id = pid;
- pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient));
+ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictConicalGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
- xfree(pPicture);
+ free(pPicture);
return 0;
}
@@ -1049,7 +1049,7 @@ CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
if (*error) {
- xfree(pPicture);
+ free(pPicture);
return 0;
}
return pPicture;
@@ -1385,7 +1385,7 @@ SetPictureTransform (PicturePtr pPicture,
{
if (!pPicture->transform)
{
- pPicture->transform = (PictTransform *) xalloc (sizeof (PictTransform));
+ pPicture->transform = (PictTransform *) malloc(sizeof (PictTransform));
if (!pPicture->transform)
return BadAlloc;
}
@@ -1395,7 +1395,7 @@ SetPictureTransform (PicturePtr pPicture,
{
if (pPicture->transform)
{
- xfree (pPicture->transform);
+ free(pPicture->transform);
pPicture->transform = 0;
}
}
@@ -1527,14 +1527,14 @@ FreePicture (pointer value,
if (--pPicture->refcnt == 0)
{
if (pPicture->transform)
- xfree (pPicture->transform);
+ free(pPicture->transform);
if (pPicture->pSourcePict)
{
if (pPicture->pSourcePict->type != SourcePictTypeSolidFill)
- xfree(pPicture->pSourcePict->linear.stops);
+ free(pPicture->pSourcePict->linear.stops);
- xfree(pPicture->pSourcePict);
+ free(pPicture->pSourcePict);
}
if (pPicture->pDrawable)
@@ -1569,7 +1569,7 @@ FreePicture (pointer value,
}
}
dixFreePrivates(pPicture->devPrivates);
- xfree (pPicture);
+ free(pPicture);
}
return Success;
}
diff --git a/xorg-server/render/render.c b/xorg-server/render/render.c
index 9ccbf3937..9bbff1b6d 100644
--- a/xorg-server/render/render.c
+++ b/xorg-server/render/render.c
@@ -290,7 +290,7 @@ ProcRenderQueryVersion (ClientPtr client)
swapl(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep);
- return (client->noClientException);
+ return Success;
}
static VisualPtr
@@ -375,7 +375,7 @@ ProcRenderQueryPictFormats (ClientPtr client)
ndepth * sizeof (xPictDepth) +
nvisual * sizeof (xPictVisual) +
numSubpixel * sizeof (CARD32));
- reply = (xRenderQueryPictFormatsReply *) xcalloc (1, rlength);
+ reply = (xRenderQueryPictFormatsReply *) calloc(1, rlength);
if (!reply)
return BadAlloc;
reply->type = X_Reply;
@@ -512,8 +512,8 @@ ProcRenderQueryPictFormats (ClientPtr client)
swapl (&reply->numSubpixel, n);
}
WriteToClient(client, rlength, (char *) reply);
- xfree (reply);
- return client->noClientException;
+ free(reply);
+ return Success;
}
static int
@@ -542,7 +542,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
num = pFormat->index.nvalues;
rlength = (sizeof (xRenderQueryPictIndexValuesReply) +
num * sizeof(xIndexValue));
- reply = (xRenderQueryPictIndexValuesReply *) xalloc (rlength);
+ reply = (xRenderQueryPictIndexValuesReply *) malloc(rlength);
if (!reply)
return BadAlloc;
@@ -571,8 +571,8 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
}
WriteToClient(client, rlength, (char *) reply);
- xfree(reply);
- return (client->noClientException);
+ free(reply);
+ return Success;
}
static int
@@ -647,7 +647,6 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
REQUEST(xRenderSetPictureClipRectanglesReq);
PicturePtr pPicture;
int nr;
- int result;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess);
@@ -658,13 +657,9 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
if (nr & 4)
return BadLength;
nr >>= 3;
- result = SetPictureClipRects (pPicture,
+ return SetPictureClipRects (pPicture,
stuff->xOrigin, stuff->yOrigin,
nr, (xRectangle *) &stuff[1]);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
}
static int
@@ -677,7 +672,7 @@ ProcRenderFreePicture (ClientPtr client)
VERIFY_PICTURE (pPicture, stuff->picture, client, DixDestroyAccess);
FreeResource (stuff->picture, RT_NONE);
- return(client->noClientException);
+ return Success;
}
static Bool
@@ -772,7 +767,7 @@ ProcRenderTrapezoids (ClientPtr client)
CompositeTrapezoids (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
ntraps, (xTrapezoid *) &stuff[1]);
- return client->noClientException;
+ return Success;
}
static int
@@ -812,7 +807,7 @@ ProcRenderTriangles (ClientPtr client)
CompositeTriangles (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
ntris, (xTriangle *) &stuff[1]);
- return client->noClientException;
+ return Success;
}
static int
@@ -852,7 +847,7 @@ ProcRenderTriStrip (ClientPtr client)
CompositeTriStrip (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
npoints, (xPointFixed *) &stuff[1]);
- return client->noClientException;
+ return Success;
}
static int
@@ -892,7 +887,7 @@ ProcRenderTriFan (ClientPtr client)
CompositeTriFan (stuff->op, pSrc, pDst, pFormat,
stuff->xSrc, stuff->ySrc,
npoints, (xPointFixed *) &stuff[1]);
- return client->noClientException;
+ return Success;
}
static int
@@ -984,7 +979,7 @@ ProcRenderReferenceGlyphSet (ClientPtr client)
glyphSet->refcnt++;
if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
return BadAlloc;
- return client->noClientException;
+ return Success;
}
#define NLOCALDELTA 64
@@ -1006,7 +1001,7 @@ ProcRenderFreeGlyphSet (ClientPtr client)
return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
FreeResource (stuff->glyphset, RT_NONE);
- return client->noClientException;
+ return Success;
}
typedef struct _GlyphNew {
@@ -1058,7 +1053,7 @@ ProcRenderAddGlyphs (ClientPtr client)
}
else
{
- glyphsBase = (GlyphNewPtr) Xcalloc (nglyphs * sizeof (GlyphNewRec));
+ glyphsBase = (GlyphNewPtr)calloc(nglyphs, sizeof (GlyphNewRec));
if (!glyphsBase)
return BadAlloc;
}
@@ -1200,8 +1195,8 @@ ProcRenderAddGlyphs (ClientPtr client)
AddGlyph (glyphSet, glyphs[i].glyph, glyphs[i].id);
if (glyphsBase != glyphsLocal)
- Xfree (glyphsBase);
- return client->noClientException;
+ free(glyphsBase);
+ return Success;
bail:
if (pSrc)
FreePicture ((pointer) pSrc, 0);
@@ -1209,9 +1204,9 @@ bail:
FreeScratchPixmapHeader (pSrcPix);
for (i = 0; i < nglyphs; i++)
if (glyphs[i].glyph && ! glyphs[i].found)
- xfree (glyphs[i].glyph);
+ free(glyphs[i].glyph);
if (glyphsBase != glyphsLocal)
- Xfree (glyphsBase);
+ free(glyphsBase);
return err;
}
@@ -1249,7 +1244,7 @@ ProcRenderFreeGlyphs (ClientPtr client)
return RenderErrBase + BadGlyph;
}
}
- return client->noClientException;
+ return Success;
}
static int
@@ -1335,7 +1330,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphsBase = glyphsLocal;
else
{
- glyphsBase = (GlyphPtr *) xalloc (nglyph * sizeof (GlyphPtr));
+ glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof (GlyphPtr));
if (!glyphsBase)
return BadAlloc;
}
@@ -1343,7 +1338,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
listsBase = listsLocal;
else
{
- listsBase = (GlyphListPtr) xalloc (nlist * sizeof (GlyphListRec));
+ listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec));
if (!listsBase)
return BadAlloc;
}
@@ -1366,9 +1361,9 @@ ProcRenderCompositeGlyphs (ClientPtr client)
if (rc != Success)
{
if (glyphsBase != glyphsLocal)
- xfree (glyphsBase);
+ free(glyphsBase);
if (listsBase != listsLocal)
- xfree (listsBase);
+ free(listsBase);
return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
}
@@ -1422,11 +1417,11 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphsBase);
if (glyphsBase != glyphsLocal)
- xfree (glyphsBase);
+ free(glyphsBase);
if (listsBase != listsLocal)
- xfree (listsBase);
+ free(listsBase);
- return client->noClientException;
+ return Success;
}
static int
@@ -1457,7 +1452,7 @@ ProcRenderFillRectangles (ClientPtr client)
things,
(xRectangle *) &stuff[1]);
- return client->noClientException;
+ return Success;
}
static void
@@ -1518,23 +1513,23 @@ ProcRenderCreateCursor (ClientPtr client)
if ( stuff->x > width
|| stuff->y > height )
return (BadMatch);
- argbbits = xalloc (width * height * sizeof (CARD32));
+ argbbits = malloc(width * height * sizeof (CARD32));
if (!argbbits)
return (BadAlloc);
stride = BitmapBytePad(width);
nbytes_mono = stride*height;
- srcbits = xcalloc(1, nbytes_mono);
+ srcbits = calloc(1, nbytes_mono);
if (!srcbits)
{
- xfree (argbbits);
+ free(argbbits);
return (BadAlloc);
}
- mskbits = xcalloc(1, nbytes_mono);
+ mskbits = calloc(1, nbytes_mono);
if (!mskbits)
{
- xfree(argbbits);
- xfree(srcbits);
+ free(argbbits);
+ free(srcbits);
return (BadAlloc);
}
@@ -1554,27 +1549,27 @@ ProcRenderCreateCursor (ClientPtr client)
pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
if (!pFormat)
{
- xfree (argbbits);
- xfree (srcbits);
- xfree (mskbits);
+ free(argbbits);
+ free(srcbits);
+ free(mskbits);
return (BadImplementation);
}
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32,
CREATE_PIXMAP_USAGE_SCRATCH);
if (!pPixmap)
{
- xfree (argbbits);
- xfree (srcbits);
- xfree (mskbits);
+ free(argbbits);
+ free(srcbits);
+ free(mskbits);
return (BadAlloc);
}
pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0,
client, &error);
if (!pPicture)
{
- xfree (argbbits);
- xfree (srcbits);
- xfree (mskbits);
+ free(argbbits);
+ free(srcbits);
+ free(mskbits);
return error;
}
(*pScreen->DestroyPixmap) (pPixmap);
@@ -1658,7 +1653,7 @@ ProcRenderCreateCursor (ClientPtr client)
}
else
{
- xfree (argbbits);
+ free(argbbits);
argbbits = 0;
}
@@ -1682,7 +1677,7 @@ ProcRenderCreateCursor (ClientPtr client)
if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
return BadAlloc;
- return client->noClientException;
+ return Success;
}
static int
@@ -1690,15 +1685,10 @@ ProcRenderSetPictureTransform (ClientPtr client)
{
REQUEST(xRenderSetPictureTransformReq);
PicturePtr pPicture;
- int result;
REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess);
- result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
+ return SetPictureTransform (pPicture, (PictTransform *) &stuff->transform);
}
static int
@@ -1735,7 +1725,7 @@ ProcRenderQueryFilters (ClientPtr client)
}
len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName);
total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
- reply = (xRenderQueryFiltersReply *) xalloc (total_bytes);
+ reply = (xRenderQueryFiltersReply *) malloc(total_bytes);
if (!reply)
return BadAlloc;
aliases = (INT16 *) (reply + 1);
@@ -1806,9 +1796,9 @@ ProcRenderQueryFilters (ClientPtr client)
swapl(&reply->numFilters, n);
}
WriteToClient(client, total_bytes, (char *) reply);
- xfree (reply);
+ free(reply);
- return(client->noClientException);
+ return Success;
}
static int
@@ -1847,7 +1837,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
if (client->req_len & 1)
return BadLength;
ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
- cursors = xalloc (ncursor * (sizeof (CursorPtr) + sizeof (CARD32)));
+ cursors = malloc(ncursor * (sizeof (CursorPtr) + sizeof (CARD32)));
if (!cursors)
return BadAlloc;
deltas = (CARD32 *) (cursors + ncursor);
@@ -1858,7 +1848,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
RT_CURSOR, client, DixReadAccess);
if (ret != Success)
{
- xfree (cursors);
+ free(cursors);
return (ret == BadValue) ? BadCursor : ret;
}
deltas[i] = elt->delay;
@@ -1866,12 +1856,12 @@ ProcRenderCreateAnimCursor (ClientPtr client)
}
ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client,
stuff->cid);
- xfree (cursors);
+ free(cursors);
if (ret != Success)
return ret;
if (AddResource (stuff->cid, RT_CURSOR, (pointer)pCursor))
- return client->noClientException;
+ return Success;
return BadAlloc;
}
@@ -1894,7 +1884,7 @@ ProcRenderAddTraps (ClientPtr client)
AddTraps (pPicture,
stuff->xOff, stuff->yOff,
ntraps, (xTrap *) &stuff[1]);
- return client->noClientException;
+ return Success;
}
static int ProcRenderCreateSolidFill(ClientPtr client)
@@ -2669,7 +2659,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success)
return (result == BadValue) ? BadDrawable : result;
- if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
newPict->info[0].id = stuff->pid;
@@ -2695,7 +2685,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
if (result == Success)
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
else
- xfree(newPict);
+ free(newPict);
return (result);
}
@@ -2905,7 +2895,7 @@ PanoramiXRenderFillRectangles (ClientPtr client)
VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess);
extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq);
if (extra_len &&
- (extra = (char *) xalloc (extra_len)))
+ (extra = (char *) malloc(extra_len)))
{
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
@@ -2931,7 +2921,7 @@ PanoramiXRenderFillRectangles (ClientPtr client)
result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
if(result != Success) break;
}
- xfree(extra);
+ free(extra);
}
return result;
@@ -2954,7 +2944,7 @@ PanoramiXRenderTrapezoids(ClientPtr client)
extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq);
if (extra_len &&
- (extra = (char *) xalloc (extra_len))) {
+ (extra = (char *) malloc(extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
@@ -2991,7 +2981,7 @@ PanoramiXRenderTrapezoids(ClientPtr client)
if(result != Success) break;
}
- xfree(extra);
+ free(extra);
}
return result;
@@ -3014,7 +3004,7 @@ PanoramiXRenderTriangles(ClientPtr client)
extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq);
if (extra_len &&
- (extra = (char *) xalloc (extra_len))) {
+ (extra = (char *) malloc(extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
@@ -3047,7 +3037,7 @@ PanoramiXRenderTriangles(ClientPtr client)
if(result != Success) break;
}
- xfree(extra);
+ free(extra);
}
return result;
@@ -3070,7 +3060,7 @@ PanoramiXRenderTriStrip(ClientPtr client)
extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq);
if (extra_len &&
- (extra = (char *) xalloc (extra_len))) {
+ (extra = (char *) malloc(extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
@@ -3099,7 +3089,7 @@ PanoramiXRenderTriStrip(ClientPtr client)
if(result != Success) break;
}
- xfree(extra);
+ free(extra);
}
return result;
@@ -3122,7 +3112,7 @@ PanoramiXRenderTriFan(ClientPtr client)
extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq);
if (extra_len &&
- (extra = (char *) xalloc (extra_len))) {
+ (extra = (char *) malloc(extra_len))) {
memcpy (extra, stuff + 1, extra_len);
FOR_NSCREENS_FORWARD(j) {
@@ -3151,7 +3141,7 @@ PanoramiXRenderTriFan(ClientPtr client)
if(result != Success) break;
}
- xfree(extra);
+ free(extra);
}
return result;
@@ -3171,7 +3161,7 @@ PanoramiXRenderAddTraps (ClientPtr client)
VERIFY_XIN_PICTURE (picture, stuff->picture, client, DixWriteAccess);
extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq);
if (extra_len &&
- (extra = (char *) xalloc (extra_len)))
+ (extra = (char *) malloc(extra_len)))
{
memcpy (extra, stuff + 1, extra_len);
x_off = stuff->xOff;
@@ -3188,7 +3178,7 @@ PanoramiXRenderAddTraps (ClientPtr client)
result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
if(result != Success) break;
}
- xfree(extra);
+ free(extra);
}
return result;
@@ -3203,7 +3193,7 @@ PanoramiXRenderCreateSolidFill (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
- if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
@@ -3222,7 +3212,7 @@ PanoramiXRenderCreateSolidFill (ClientPtr client)
if (result == Success)
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
else
- xfree(newPict);
+ free(newPict);
return result;
}
@@ -3236,7 +3226,7 @@ PanoramiXRenderCreateLinearGradient (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
- if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
@@ -3255,7 +3245,7 @@ PanoramiXRenderCreateLinearGradient (ClientPtr client)
if (result == Success)
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
else
- xfree(newPict);
+ free(newPict);
return result;
}
@@ -3269,7 +3259,7 @@ PanoramiXRenderCreateRadialGradient (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
- if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
@@ -3288,7 +3278,7 @@ PanoramiXRenderCreateRadialGradient (ClientPtr client)
if (result == Success)
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
else
- xfree(newPict);
+ free(newPict);
return result;
}
@@ -3302,7 +3292,7 @@ PanoramiXRenderCreateConicalGradient (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
- if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
@@ -3321,7 +3311,7 @@ PanoramiXRenderCreateConicalGradient (ClientPtr client)
if (result == Success)
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
else
- xfree(newPict);
+ free(newPict);
return result;
}