From 500544f827c266f6a9c16d8669f62e54cdfd1f48 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 8 Apr 2016 09:38:20 +0200 Subject: hw/nxagent/NXmitrap.c: Shrink file, drop duplicate code that can identically be found in render/mitrap.c. --- nx-X11/programs/Xserver/render/Imakefile | 23 ++++++++++++++++++----- nx-X11/programs/Xserver/render/mitrap.c | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index ff272ecbd..d6e2f4c40 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -1,6 +1,18 @@ XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15 keithp Exp $ + +NULL = + #include +#if (!(defined(NXAgentServer) && NXAgentServer)) +NXAGENT_SKIP_SRCS = \ + mitrap.c \ + $(NULL) +NXAGENT_SKIP_OBJS = \ + mitrap.o \ + $(NULL) +#endif + SRCS = animcur.c \ filter.c \ glyph.c \ @@ -9,11 +21,12 @@ XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15 miindex.c \ mipict.c \ mirect.c \ - mitrap.c \ mitri.c \ picture.c \ render.c \ - renderedge.c + renderedge.c \ + $(NXAGENT_SKIP_SRCS) \ + $(NULL) OBJS = animcur.o \ filter.o \ @@ -23,11 +36,12 @@ XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15 miindex.o \ mipict.o \ mirect.o \ - mitrap.o \ mitri.o \ picture.o \ render.o \ - renderedge.o + renderedge.o \ + $(NXAGENT_SKIP_OBJS) \ + $(NULL) INCLUDES = -I. -I../include -I../mi \ -I../fb -I../hw/kdrive -I$(EXTINCSRC) -I$(XINCLUDESRC) \ @@ -46,4 +60,3 @@ InstallDriverSDKNonExecFile(glyphstr.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(mipict.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(picture.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(picturestr.h,$(DRIVERSDKINCLUDEDIR)) - diff --git a/nx-X11/programs/Xserver/render/mitrap.c b/nx-X11/programs/Xserver/render/mitrap.c index be1712420..96f1159a4 100644 --- a/nx-X11/programs/Xserver/render/mitrap.c +++ b/nx-X11/programs/Xserver/render/mitrap.c @@ -128,6 +128,7 @@ miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box) } } +#ifndef NXAGENT_SERVER void miTrapezoids (CARD8 op, PicturePtr pSrc, @@ -188,3 +189,4 @@ miTrapezoids (CARD8 op, miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps); } } +#endif -- cgit v1.2.3 From ae1a218d16b65194c522ef8ffc998184863321f9 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 8 Apr 2016 09:45:32 +0200 Subject: hw/nxagent/NXmiglyph.c: Shrink file, drop code that can be identically found in render/miglyph.c. --- nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c | 86 +------------------------- nx-X11/programs/Xserver/render/Imakefile | 4 +- nx-X11/programs/Xserver/render/miglyph.c | 2 + 3 files changed, 5 insertions(+), 87 deletions(-) (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c index f86c81de6..bdc0bc316 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c @@ -40,77 +40,9 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "scrnintstr.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "mi.h" -#include "picturestr.h" -#include "mipict.h" - -#ifdef NXAGENT_SERVER - #include "Render.h" -#endif - -void -miGlyphExtents (int nlist, - GlyphListPtr list, - GlyphPtr *glyphs, - BoxPtr extents) -{ - int x1, x2, y1, y2; - int n; - GlyphPtr glyph; - int x, y; - - x = 0; - y = 0; - extents->x1 = MAXSHORT; - extents->x2 = MINSHORT; - extents->y1 = MAXSHORT; - extents->y2 = MINSHORT; - while (nlist--) - { - x += list->xOff; - y += list->yOff; - n = list->len; - list++; - while (n--) - { - glyph = *glyphs++; - x1 = x - glyph->info.x; - if (x1 < MINSHORT) - x1 = MINSHORT; - y1 = y - glyph->info.y; - if (y1 < MINSHORT) - y1 = MINSHORT; - x2 = x1 + glyph->info.width; - if (x2 > MAXSHORT) - x2 = MAXSHORT; - y2 = y1 + glyph->info.height; - if (y2 > MAXSHORT) - y2 = MAXSHORT; - if (x1 < extents->x1) - extents->x1 = x1; - if (x2 > extents->x2) - extents->x2 = x2; - if (y1 < extents->y1) - extents->y1 = y1; - if (y2 > extents->y2) - extents->y2 = y2; - x += glyph->info.xOff; - y += glyph->info.yOff; - } - } -} - -#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0) +#include "../../render/miglyph.c" void miGlyphs (CARD8 op, @@ -137,8 +69,6 @@ miGlyphs (CARD8 op, BoxRec extents; CARD32 component_alpha; - #ifdef NXAGENT_SERVER - /* * Get rid of the warning. */ @@ -146,15 +76,11 @@ miGlyphs (CARD8 op, extents.x1 = 0; extents.y1 = 0; - #endif - if (maskFormat) { GCPtr pGC; xRectangle rect; - #ifdef NXAGENT_SERVER - if (nxagentGlyphsExtents != NullBox) { memcpy(&extents, nxagentGlyphsExtents, sizeof(BoxRec)); @@ -168,12 +94,6 @@ miGlyphs (CARD8 op, memcpy(nxagentGlyphsExtents, &extents, sizeof(BoxRec)); } - #else - - miGlyphExtents (nlist, list, glyphs, &extents); - - #endif - if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) return; width = extents.x2 - extents.x1; @@ -242,8 +162,6 @@ miGlyphs (CARD8 op, glyph->info.width, glyph->info.height, 0, 0, -1, (void *) (glyph + 1)); - #ifdef NXAGENT_SERVER - /* * The following line fixes a problem with glyphs that appeared * as clipped. It was a side effect due the validate function @@ -254,8 +172,6 @@ miGlyphs (CARD8 op, pPicture->pDrawable->serialNumber = NEXT_SERIAL_NUMBER; - #endif - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (maskFormat) { diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index d6e2f4c40..0685ef3f6 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -6,9 +6,11 @@ NULL = #if (!(defined(NXAgentServer) && NXAgentServer)) NXAGENT_SKIP_SRCS = \ + miglyph.c \ mitrap.c \ $(NULL) NXAGENT_SKIP_OBJS = \ + miglyph.o \ mitrap.o \ $(NULL) #endif @@ -17,7 +19,6 @@ NXAGENT_SKIP_OBJS = \ filter.c \ glyph.c \ matrix.c \ - miglyph.c \ miindex.c \ mipict.c \ mirect.c \ @@ -32,7 +33,6 @@ NXAGENT_SKIP_OBJS = \ filter.o \ glyph.o \ matrix.o \ - miglyph.o \ miindex.o \ mipict.o \ mirect.o \ diff --git a/nx-X11/programs/Xserver/render/miglyph.c b/nx-X11/programs/Xserver/render/miglyph.c index 8b046bd46..f169c3bb7 100644 --- a/nx-X11/programs/Xserver/render/miglyph.c +++ b/nx-X11/programs/Xserver/render/miglyph.c @@ -89,6 +89,7 @@ miGlyphExtents (int nlist, #define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0) +#ifndef NXAGENT_SERVER void miGlyphs (CARD8 op, PicturePtr pSrc, @@ -241,3 +242,4 @@ miGlyphs (CARD8 op, (*pScreen->DestroyPixmap) (pMaskPixmap); } } +#endif -- cgit v1.2.3 From 0c29f81f1bbd3c507c847ce4460d316478083213 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 9 Apr 2016 00:36:40 +0200 Subject: hw/nxagent/NXpicture.c: Shrink file, drop duplicate code that can identically be found in render/picture.c. --- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 1739 +----------------------- nx-X11/programs/Xserver/render/Imakefile | 4 +- nx-X11/programs/Xserver/render/picture.c | 11 + 3 files changed, 58 insertions(+), 1696 deletions(-) (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 10111adec..ac0eb5016 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -40,23 +40,6 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" #include "NXpicturestr.h" #include "Screen.h" @@ -64,6 +47,23 @@ #include "Drawable.h" #include "Render.h" +/* prototypes */ + +PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp); +PicturePtr AllocatePicture (ScreenPtr pScreen); +PicturePtr CreatePicture (Picture pid, + DrawablePtr pDrawable, + PictFormatPtr pFormat, + Mask vmask, + XID *vlist, + ClientPtr client, + int *error); +static PicturePtr createSourcePicture(void); +int FreePicture (void *value, XID pid); + +#include "../../render/picture.c" + + #define PANIC #define WARNING #undef TEST @@ -73,183 +73,8 @@ void *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual); void *nxagentMatchingFormats(PictFormatPtr pForm); -int PictureScreenPrivateIndex = -1; -int PictureWindowPrivateIndex; -int PictureGeneration; -RESTYPE PictureType; -RESTYPE PictFormatType; -RESTYPE GlyphSetType; -int PictureCmapPolicy = PictureCmapPolicyDefault; - -typedef struct _formatInit { - CARD32 format; - CARD8 depth; -} FormatInitRec, *FormatInitPtr; - void nxagentPictureCreateDefaultFormats(ScreenPtr pScreen, FormatInitRec *formats, int *nformats); -/* Picture Private machinery */ - -static int picturePrivateCount; - -void -ResetPicturePrivateIndex (void) -{ - picturePrivateCount = 0; -} - -int -AllocatePicturePrivateIndex (void) -{ - return picturePrivateCount++; -} - -Bool -AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - unsigned int oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= ps->PicturePrivateLen) - { - unsigned int *nsizes; - - nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes, - (index2 + 1) * sizeof(unsigned int)); - if (!nsizes) - return FALSE; - while (ps->PicturePrivateLen <= index2) - { - nsizes[ps->PicturePrivateLen++] = 0; - ps->totalPictureSize += sizeof(DevUnion); - } - ps->PicturePrivateSizes = nsizes; - } - oldamount = ps->PicturePrivateSizes[index2]; - if (amount > oldamount) - { - ps->PicturePrivateSizes[index2] = amount; - ps->totalPictureSize += (amount - oldamount); - } - - return TRUE; -} - - -Bool -PictureDestroyWindow (WindowPtr pWindow) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - PicturePtr pPicture; - PictureScreenPtr ps = GetPictureScreen(pScreen); - Bool ret; - - while ((pPicture = GetPictureWindow(pWindow))) - { - SetPictureWindow(pWindow, pPicture->pNext); - if (pPicture->id) - FreeResource (pPicture->id, PictureType); - FreePicture ((void *) pPicture, pPicture->id); - } - pScreen->DestroyWindow = ps->DestroyWindow; - ret = (*pScreen->DestroyWindow) (pWindow); - ps->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = PictureDestroyWindow; - return ret; -} - -Bool -PictureCloseScreen (int index, ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - Bool ret; - int n; - - pScreen->CloseScreen = ps->CloseScreen; - ret = (*pScreen->CloseScreen) (index, pScreen); - PictureResetFilters (pScreen); - for (n = 0; n < ps->nformats; n++) - if (ps->formats[n].type == PictTypeIndexed) - (*ps->CloseIndexed) (pScreen, &ps->formats[n]); - SetPictureScreen(pScreen, 0); - if (ps->PicturePrivateSizes) - xfree (ps->PicturePrivateSizes); - xfree (ps->formats); - xfree (ps); - return ret; -} - -void -PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef) -{ - ScreenPtr pScreen = pColormap->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - - pScreen->StoreColors = ps->StoreColors; - (*pScreen->StoreColors) (pColormap, ndef, pdef); - ps->StoreColors = pScreen->StoreColors; - pScreen->StoreColors = PictureStoreColors; - - if (pColormap->class == PseudoColor || pColormap->class == GrayScale) - { - PictFormatPtr format = ps->formats; - int nformats = ps->nformats; - - while (nformats--) - { - if (format->type == PictTypeIndexed && - format->index.pColormap == pColormap) - { - (*ps->UpdateIndexed) (pScreen, format, ndef, pdef); - break; - } - format++; - } - } -} - -static int -visualDepth (ScreenPtr pScreen, VisualPtr pVisual) -{ - int d, v; - DepthPtr pDepth; - - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = &pScreen->allowedDepths[d]; - for (v = 0; v < pDepth->numVids; v++) - if (pDepth->vids[v] == pVisual->vid) - return pDepth->depth; - } - return 0; -} - -static int -addFormat (FormatInitRec formats[256], - int nformat, - CARD32 format, - CARD8 depth) -{ - int n; - - for (n = 0; n < nformat; n++) - if (formats[n].format == format && formats[n].depth == depth) - return nformat; - formats[nformat].format = format; - formats[nformat].depth = depth; - - #ifdef DEBUG - fprintf(stderr, "addFormat: Added format [%lu] depth [%d].\n", format, depth); - #endif - - return ++nformat; -} - -#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1)) - PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) { @@ -258,164 +83,10 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) FormatInitRec formats[1024]; CARD32 format; -#ifndef NXAGENT_SERVER - - CARD8 depth; - VisualPtr pVisual; - int v; - int bpp; - int type; - int r, g, b; - int d; - DepthPtr pDepth; - -#endif - nformats = 0; -#ifdef NXAGENT_SERVER - nxagentPictureCreateDefaultFormats(pScreen, formats, &nformats); -#else - - /* formats required by protocol */ - formats[nformats].format = PICT_a1; - formats[nformats].depth = 1; - nformats++; - formats[nformats].format = PICT_a8; - formats[nformats].depth = 8; - nformats++; - formats[nformats].format = PICT_a4; - formats[nformats].depth = 4; - nformats++; - formats[nformats].format = PICT_a8r8g8b8; - formats[nformats].depth = 32; - nformats++; - formats[nformats].format = PICT_x8r8g8b8; - formats[nformats].depth = 32; - nformats++; - - /* now look through the depths and visuals adding other formats */ - for (v = 0; v < pScreen->numVisuals; v++) - { - pVisual = &pScreen->visuals[v]; - depth = visualDepth (pScreen, pVisual); - if (!depth) - continue; - bpp = BitsPerPixel (depth); - - switch (pVisual->class) { - case DirectColor: - case TrueColor: - r = Ones (pVisual->redMask); - g = Ones (pVisual->greenMask); - b = Ones (pVisual->blueMask); - type = PICT_TYPE_OTHER; - /* - * Current rendering code supports only two direct formats, - * fields must be packed together at the bottom of the pixel - * and must be either RGB or BGR - */ - if (pVisual->offsetBlue == 0 && - pVisual->offsetGreen == b && - pVisual->offsetRed == b + g) - { - type = PICT_TYPE_ARGB; - } - else if (pVisual->offsetRed == 0 && - pVisual->offsetGreen == r && - pVisual->offsetBlue == r + g) - { - type = PICT_TYPE_ABGR; - } - if (type != PICT_TYPE_OTHER) - { - format = PICT_FORMAT(bpp, type, 0, r, g, b); - nformats = addFormat (formats, nformats, format, depth); - } - break; - case StaticColor: - case PseudoColor: - format = PICT_VISFORMAT (bpp, PICT_TYPE_COLOR, v); - nformats = addFormat (formats, nformats, format, depth); - break; - case StaticGray: - case GrayScale: - format = PICT_VISFORMAT (bpp, PICT_TYPE_GRAY, v); - nformats = addFormat (formats, nformats, format, depth); - break; - } - } - - /* - * Walk supported depths and add useful Direct formats - */ - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = &pScreen->allowedDepths[d]; - bpp = BitsPerPixel (pDepth->depth); - format = 0; - - switch (bpp) { - case 16: - /* depth 12 formats */ - if (pDepth->depth >= 12) - { - nformats = addFormat (formats, nformats, - PICT_x4r4g4b4, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_x4b4g4r4, pDepth->depth); - } - - /* depth 15 formats */ - if (pDepth->depth >= 15) - { - nformats = addFormat (formats, nformats, - PICT_x1r5g5b5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_x1b5g5r5, pDepth->depth); - } - /* depth 16 formats */ - if (pDepth->depth >= 16) - { - nformats = addFormat (formats, nformats, - PICT_a1r5g5b5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_a1b5g5r5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_r5g6b5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_b5g6r5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_a4r4g4b4, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_a4b4g4r4, pDepth->depth); - } - break; - case 24: - if (pDepth->depth >= 24) - { - nformats = addFormat (formats, nformats, - PICT_r8g8b8, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_b8g8r8, pDepth->depth); - } - break; - case 32: - if (pDepth->depth >= 24) - { - nformats = addFormat (formats, nformats, - PICT_x8r8g8b8, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_x8b8g8r8, pDepth->depth); - } - break; - } - } - -#endif - pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec)); if (!pFormats) return 0; @@ -483,7 +154,6 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) break; } -#ifdef NXAGENT_SERVER if (nxagentMatchingFormats(&pFormats[f]) != NULL) { #ifdef DEBUG @@ -504,347 +174,11 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) pFormats[f].direct.blueMask, pFormats[f].direct.alpha, pFormats[f].direct.alphaMask); #endif } -#endif } *nformatp = nformats; return pFormats; } -static VisualPtr -PictureFindVisual (ScreenPtr pScreen, VisualID visual) -{ - int i; - VisualPtr pVisual; - for (i = 0, pVisual = pScreen->visuals; - i < pScreen->numVisuals; - i++, pVisual++) - { - if (pVisual->vid == visual) - return pVisual; - } - return 0; -} - -Bool -PictureInitIndexedFormats (ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - PictFormatPtr format; - int nformat; - - if (!ps) - return FALSE; - format = ps->formats; - nformat = ps->nformats; - while (nformat--) - { - if (format->type == PictTypeIndexed && !format->index.pColormap) - { - if (format->index.vid == pScreen->rootVisual) - format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap, - RT_COLORMAP); - else - { - VisualPtr pVisual; - - pVisual = PictureFindVisual (pScreen, format->index.vid); - if (CreateColormap (FakeClientID (0), pScreen, - pVisual, - &format->index.pColormap, AllocNone, - 0) != Success) - { - return FALSE; - } - } - if (!(*ps->InitIndexed) (pScreen, format)) - return FALSE; - } - format++; - } - return TRUE; -} - -Bool -PictureFinishInit (void) -{ - int s; - - for (s = 0; s < screenInfo.numScreens; s++) - { - if (!PictureInitIndexedFormats (screenInfo.screens[s])) - return FALSE; - (void) AnimCurInit (screenInfo.screens[s]); - } - - return TRUE; -} - -Bool -PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - - if (!ps) - return FALSE; - ps->subpixel = subpixel; - return TRUE; - -} - -int -PictureGetSubpixelOrder (ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - - if (!ps) - return SubPixelUnknown; - return ps->subpixel; -} - -PictFormatPtr -PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - PictFormatPtr format; - int nformat; - int type; - - if (!ps) - return 0; - format = ps->formats; - nformat = ps->nformats; - switch (pVisual->class) { - case StaticGray: - case GrayScale: - case StaticColor: - case PseudoColor: - type = PictTypeIndexed; - break; - case TrueColor: - case DirectColor: - type = PictTypeDirect; - break; - default: - return 0; - } - while (nformat--) - { - if (format->depth == depth && format->type == type) - { - if (type == PictTypeIndexed) - { - if (format->index.vid == pVisual->vid) - return format; - } - else - { - if (format->direct.redMask << format->direct.red == - pVisual->redMask && - format->direct.greenMask << format->direct.green == - pVisual->greenMask && - format->direct.blueMask << format->direct.blue == - pVisual->blueMask) - { - return format; - } - } - } - format++; - } - return 0; -} - -PictFormatPtr -PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 f) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - PictFormatPtr format; - int nformat; - - if (!ps) - return 0; - format = ps->formats; - nformat = ps->nformats; - while (nformat--) - { - if (format->depth == depth && format->format == (f & 0xffffff)) - return format; - format++; - } - return 0; -} - -int -PictureParseCmapPolicy (const char *name) -{ - if ( strcmp (name, "default" ) == 0) - return PictureCmapPolicyDefault; - else if ( strcmp (name, "mono" ) == 0) - return PictureCmapPolicyMono; - else if ( strcmp (name, "gray" ) == 0) - return PictureCmapPolicyGray; - else if ( strcmp (name, "color" ) == 0) - return PictureCmapPolicyColor; - else if ( strcmp (name, "all" ) == 0) - return PictureCmapPolicyAll; - else - return PictureCmapPolicyInvalid; -} - -Bool -PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) -{ - PictureScreenPtr ps; - int n; - CARD32 type, a, r, g, b; - - if (PictureGeneration != serverGeneration) - { - PictureType = CreateNewResourceType (FreePicture); - if (!PictureType) - return FALSE; - PictFormatType = CreateNewResourceType (FreePictFormat); - if (!PictFormatType) - return FALSE; - GlyphSetType = CreateNewResourceType (FreeGlyphSet); - if (!GlyphSetType) - return FALSE; - PictureScreenPrivateIndex = AllocateScreenPrivateIndex(); - if (PictureScreenPrivateIndex < 0) - return FALSE; - PictureWindowPrivateIndex = AllocateWindowPrivateIndex(); - PictureGeneration = serverGeneration; -#ifdef XResExtension - RegisterResourceName (PictureType, "PICTURE"); - RegisterResourceName (PictFormatType, "PICTFORMAT"); - RegisterResourceName (GlyphSetType, "GLYPHSET"); -#endif - } - if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0)) - return FALSE; - - if (!formats) - { - formats = PictureCreateDefaultFormats (pScreen, &nformats); - if (!formats) - return FALSE; - } - for (n = 0; n < nformats; n++) - { - if (!AddResource (formats[n].id, PictFormatType, (void *) (formats+n))) - { - xfree (formats); - return FALSE; - } - if (formats[n].type == PictTypeIndexed) - { - VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid); - if ((pVisual->class | DynamicClass) == PseudoColor) - type = PICT_TYPE_COLOR; - else - type = PICT_TYPE_GRAY; - a = r = g = b = 0; - } - else - { - if ((formats[n].direct.redMask| - formats[n].direct.blueMask| - formats[n].direct.greenMask) == 0) - type = PICT_TYPE_A; - else if (formats[n].direct.red > formats[n].direct.blue) - type = PICT_TYPE_ARGB; - else - type = PICT_TYPE_ABGR; - a = Ones (formats[n].direct.alphaMask); - r = Ones (formats[n].direct.redMask); - g = Ones (formats[n].direct.greenMask); - b = Ones (formats[n].direct.blueMask); - } - formats[n].format = PICT_FORMAT(0,type,a,r,g,b); - } - ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec)); - if (!ps) - { - xfree (formats); - return FALSE; - } - SetPictureScreen(pScreen, ps); - if (!GlyphInit (pScreen)) - { - SetPictureScreen(pScreen, 0); - xfree (formats); - xfree (ps); - return FALSE; - } - - ps->totalPictureSize = sizeof (PictureRec); - ps->PicturePrivateSizes = 0; - ps->PicturePrivateLen = 0; - - ps->formats = formats; - ps->fallback = formats; - ps->nformats = nformats; - - ps->filters = 0; - ps->nfilters = 0; - ps->filterAliases = 0; - ps->nfilterAliases = 0; - - ps->subpixel = SubPixelUnknown; - - ps->CloseScreen = pScreen->CloseScreen; - ps->DestroyWindow = pScreen->DestroyWindow; - ps->StoreColors = pScreen->StoreColors; - pScreen->DestroyWindow = PictureDestroyWindow; - pScreen->CloseScreen = PictureCloseScreen; - pScreen->StoreColors = PictureStoreColors; - - if (!PictureSetDefaultFilters (pScreen)) - { - PictureResetFilters (pScreen); - SetPictureScreen(pScreen, 0); - xfree (formats); - xfree (ps); - return FALSE; - } - - return TRUE; -} - -void -SetPictureToDefaults (PicturePtr pPicture) -{ - pPicture->refcnt = 1; - pPicture->repeat = 0; - pPicture->graphicsExposures = FALSE; - pPicture->subWindowMode = ClipByChildren; - pPicture->polyEdge = PolyEdgeSharp; - pPicture->polyMode = PolyModePrecise; - pPicture->freeCompClip = FALSE; - pPicture->clientClipType = CT_NONE; - pPicture->componentAlpha = FALSE; - pPicture->repeatType = RepeatNone; - - pPicture->alphaMap = 0; - pPicture->alphaOrigin.x = 0; - pPicture->alphaOrigin.y = 0; - - pPicture->clipOrigin.x = 0; - pPicture->clipOrigin.y = 0; - pPicture->clientClip = 0; - - pPicture->transform = 0; - - pPicture->dither = None; - pPicture->filter = PictureGetFilterId (FilterNearest, -1, TRUE); - pPicture->filter_params = 0; - pPicture->filter_nparams = 0; - - pPicture->serialNumber = GC_CHANGE_SERIAL_BIT; - pPicture->stateChanges = (1 << (CPLastBit+1)) - 1; - pPicture->pSourcePict = 0; -} - PicturePtr AllocatePicture (ScreenPtr pScreen) { @@ -879,14 +213,6 @@ AllocatePicture (ScreenPtr pScreen) return pPicture; } -/* - * Let picture always point to the virtual pixmap. - * For sure this is not the best way to deal with - * the virtual frame-buffer. - */ - -#define NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL - PicturePtr CreatePicture (Picture pid, DrawablePtr pDrawable, @@ -912,12 +238,13 @@ CreatePicture (Picture pid, pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24); if (pDrawable->type == DRAWABLE_PIXMAP) { - #ifdef NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL - + /* + * Let picture always point to the virtual pixmap. + * For sure this is not the best way to deal with + * the virtual frame-buffer. + */ pPicture->pDrawable = nxagentVirtualDrawable(pDrawable); - #endif - ++((PixmapPtr)pDrawable)->refcnt; pPicture->pNext = 0; } @@ -943,125 +270,30 @@ CreatePicture (Picture pid, return pPicture; } -static CARD32 xRenderColorToCard32(xRenderColor c) -{ - return - (c.alpha >> 8 << 24) | - (c.red >> 8 << 16) | - (c.green & 0xff00) | - (c.blue >> 8); -} - -static unsigned int premultiply(unsigned int x) -{ - unsigned int a = x >> 24; - unsigned int t = (x & 0xff00ff) * a; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; - t &= 0xff00ff; - - x = ((x >> 8) & 0xff) * a; - x = (x + ((x >> 8) & 0xff) + 0x80); - x &= 0xff00; - x |= t | (a << 24); - return x; -} - -static unsigned int INTERPOLATE_PIXEL_256(unsigned int x, unsigned int a, - unsigned int y, unsigned int b) -{ - CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; - t >>= 8; - t &= 0xff00ff; - - x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; - x &= 0xff00ff00; - x |= t; - return x; -} - -static void initGradientColorTable(SourcePictPtr pGradient, int *error) -{ - int begin_pos, end_pos; - xFixed incr, dpos; - int pos, current_stop; - PictGradientStopPtr stops = pGradient->linear.stops; - int nstops = pGradient->linear.nstops; - - /* The position where the gradient begins and ends */ - begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; - end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; - - pos = 0; /* The position in the color table. */ - - /* Up to first point */ - while (pos <= begin_pos) { - pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color); - ++pos; - } - - incr = (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */ - dpos = incr * pos; /* The position in terms of 0-1. */ - - current_stop = 0; /* We always interpolate between current and current + 1. */ - - /* Gradient area */ - while (pos < end_pos) { - unsigned int current_color = xRenderColorToCard32(stops[current_stop].color); - unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color); - - int dist = (int)(256*(dpos - stops[current_stop].x) - / (stops[current_stop+1].x - stops[current_stop].x)); - int idist = 256 - dist; - - pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)); - - ++pos; - dpos += incr; - - if (dpos > stops[current_stop + 1].x) - ++current_stop; - } - - /* After last point */ - while (pos < PICT_GRADIENT_STOPTABLE_SIZE) { - pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color); - ++pos; - } -} - -static void initGradient(SourcePictPtr pGradient, int stopCount, - xFixed *stopPoints, xRenderColor *stopColors, int *error) +PicturePtr +CreateSolidPicture (Picture pid, xRenderColor *color, int *error) { - int i; - xFixed dpos; - - if (stopCount <= 0) { - *error = BadValue; - return; - } - - dpos = -1; - for (i = 0; i < stopCount; ++i) { - if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) { - *error = BadValue; - return; - } - dpos = stopPoints[i]; - } - - pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop)); - if (!pGradient->linear.stops) { + PicturePtr pPicture; + pPicture = createSourcePicture(); + if (!pPicture) { *error = BadAlloc; - return; + return 0; } - pGradient->linear.nstops = stopCount; - - for (i = 0; i < stopCount; ++i) { - pGradient->linear.stops[i].x = stopPoints[i]; - pGradient->linear.stops[i].color = stopColors[i]; + pPicture->id = pid; + pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill)); + if (!pPicture->pSourcePict) { + *error = BadAlloc; + xfree(pPicture); + return 0; } - initGradientColorTable(pGradient, error); + pPicture->pSourcePict->type = SourcePictTypeSolidFill; + pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); + pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha; + pPicture->pSourcePict->solidFill.fullColor.red=color->red; + pPicture->pSourcePict->solidFill.fullColor.green=color->green; + pPicture->pSourcePict->solidFill.fullColor.blue=color->blue; + return pPicture; } static PicturePtr createSourcePicture(void) @@ -1118,638 +350,15 @@ static PicturePtr createSourcePicture(void) return pPicture; } -PicturePtr -CreateSolidPicture (Picture pid, xRenderColor *color, int *error) +int +FreePicture (void * value, + XID pid) { - PicturePtr pPicture; - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - pPicture->pSourcePict->type = SourcePictTypeSolidFill; - pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); - pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha; - pPicture->pSourcePict->solidFill.fullColor.red=color->red; - pPicture->pSourcePict->solidFill.fullColor.green=color->green; - pPicture->pSourcePict->solidFill.fullColor.blue=color->blue; - return pPicture; -} - -PicturePtr -CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, - int nStops, xFixed *stops, xRenderColor *colors, int *error) -{ - PicturePtr pPicture; - - if (nStops < 2) { - *error = BadValue; - return 0; - } - - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - if (p1->x == p2->x && p1->y == p2->y) { - *error = BadValue; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - - pPicture->pSourcePict->linear.type = SourcePictTypeLinear; - pPicture->pSourcePict->linear.p1 = *p1; - pPicture->pSourcePict->linear.p2 = *p2; - - initGradient(pPicture->pSourcePict, nStops, stops, colors, error); - if (*error) { - xfree(pPicture); - return 0; - } - return pPicture; -} - -#define FixedToDouble(x) ((x)/65536.) - -PicturePtr -CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer, - xFixed innerRadius, xFixed outerRadius, - int nStops, xFixed *stops, xRenderColor *colors, int *error) -{ - PicturePtr pPicture; - PictRadialGradient *radial; - - if (nStops < 2) { - *error = BadValue; - return 0; - } - - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - { - double dx = (double)(inner->x - outer->x); - double dy = (double)(inner->y - outer->y); - if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) { - *error = BadValue; - return 0; - } - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - radial = &pPicture->pSourcePict->radial; - - radial->type = SourcePictTypeRadial; - { - double x = (double)innerRadius / (double)outerRadius; - radial->dx = (outer->x - inner->x); - radial->dy = (outer->y - inner->y); - radial->fx = (inner->x) - x*radial->dx; - radial->fy = (inner->y) - x*radial->dy; - radial->m = 1./(1+x); - radial->b = -x*radial->m; - radial->dx /= 65536.; - radial->dy /= 65536.; - radial->fx /= 65536.; - radial->fy /= 65536.; - x = outerRadius/65536.; - radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy; - } - - initGradient(pPicture->pSourcePict, nStops, stops, colors, error); - if (*error) { - xfree(pPicture); - return 0; - } - return pPicture; -} - -PicturePtr -CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle, - int nStops, xFixed *stops, xRenderColor *colors, int *error) -{ - PicturePtr pPicture; - - if (nStops < 2) { - *error = BadValue; - return 0; - } - - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - - pPicture->pSourcePict->conical.type = SourcePictTypeConical; - pPicture->pSourcePict->conical.center = *center; - pPicture->pSourcePict->conical.angle = angle; - - initGradient(pPicture->pSourcePict, nStops, stops, colors, error); - if (*error) { - xfree(pPicture); - return 0; - } - return pPicture; -} - -#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val) - -#define NEXT_PTR(_type) ((_type) ulist++->ptr) - -int -ChangePicture (PicturePtr pPicture, - Mask vmask, - XID *vlist, - DevUnion *ulist, - ClientPtr client) -{ - ScreenPtr pScreen = pPicture->pDrawable ? pPicture->pDrawable->pScreen : 0; - PictureScreenPtr ps = pScreen ? GetPictureScreen(pScreen) : 0; - BITS32 index2; - int error = 0; - BITS32 maskQ; - - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - maskQ = vmask; - while (vmask && !error) - { - index2 = (BITS32) lowbit (vmask); - vmask &= ~index2; - pPicture->stateChanges |= index2; - switch (index2) - { - case CPRepeat: - { - unsigned int newr; - newr = NEXT_VAL(unsigned int); - if (newr <= RepeatReflect) - { - pPicture->repeat = (newr != RepeatNone); - pPicture->repeatType = newr; - } - else - { - client->errorValue = newr; - error = BadValue; - } - } - break; - case CPAlphaMap: - { - PicturePtr pAlpha; - - if (vlist) - { - Picture pid = NEXT_VAL(Picture); - - if (pid == None) - pAlpha = 0; - else - { - pAlpha = (PicturePtr) SecurityLookupIDByType(client, - pid, - PictureType, - SecurityWriteAccess|SecurityReadAccess); - if (!pAlpha) - { - client->errorValue = pid; - error = BadPixmap; - break; - } - if (pAlpha->pDrawable->type != DRAWABLE_PIXMAP) - { - client->errorValue = pid; - error = BadMatch; - break; - } - } - } - else - pAlpha = NEXT_PTR(PicturePtr); - if (!error) - { - if (pAlpha && pAlpha->pDrawable->type == DRAWABLE_PIXMAP) - pAlpha->refcnt++; - if (pPicture->alphaMap) - FreePicture ((void *) pPicture->alphaMap, (XID) 0); - pPicture->alphaMap = pAlpha; - } - } - break; - case CPAlphaXOrigin: - pPicture->alphaOrigin.x = NEXT_VAL(INT16); - break; - case CPAlphaYOrigin: - pPicture->alphaOrigin.y = NEXT_VAL(INT16); - break; - case CPClipXOrigin: - pPicture->clipOrigin.x = NEXT_VAL(INT16); - break; - case CPClipYOrigin: - pPicture->clipOrigin.y = NEXT_VAL(INT16); - break; - case CPClipMask: - { - Pixmap pid; - PixmapPtr pPixmap; - int clipType; - if (!pScreen) - return BadDrawable; - - if (vlist) - { - pid = NEXT_VAL(Pixmap); - if (pid == None) - { - clipType = CT_NONE; - pPixmap = NullPixmap; - } - else - { - clipType = CT_PIXMAP; - pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - pid, - RT_PIXMAP, - SecurityReadAccess); - if (!pPixmap) - { - client->errorValue = pid; - error = BadPixmap; - break; - } - } - } - else - { - pPixmap = NEXT_PTR(PixmapPtr); - if (pPixmap) - clipType = CT_PIXMAP; - else - clipType = CT_NONE; - } - - if (pPixmap) - { - if ((pPixmap->drawable.depth != 1) || - (pPixmap->drawable.pScreen != pScreen)) - { - error = BadMatch; - break; - } - else - { - clipType = CT_PIXMAP; - pPixmap->refcnt++; - } - } - - #ifdef DEBUG - fprintf(stderr, "ChangePicture: Going to call ChangePictureClip with clipType [%d] pPixmap [%p].\n", - clipType, (void *) pPixmap); - #endif - - error = (*ps->ChangePictureClip)(pPicture, clipType, - (void *)pPixmap, 0); - break; - } - case CPGraphicsExposure: - { - unsigned int newe; - newe = NEXT_VAL(unsigned int); - if (newe <= xTrue) - pPicture->graphicsExposures = newe; - else - { - client->errorValue = newe; - error = BadValue; - } - } - break; - case CPSubwindowMode: - { - unsigned int news; - news = NEXT_VAL(unsigned int); - if (news == ClipByChildren || news == IncludeInferiors) - pPicture->subWindowMode = news; - else - { - client->errorValue = news; - error = BadValue; - } - } - break; - case CPPolyEdge: - { - unsigned int newe; - newe = NEXT_VAL(unsigned int); - if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth) - pPicture->polyEdge = newe; - else - { - client->errorValue = newe; - error = BadValue; - } - } - break; - case CPPolyMode: - { - unsigned int newm; - newm = NEXT_VAL(unsigned int); - if (newm == PolyModePrecise || newm == PolyModeImprecise) - pPicture->polyMode = newm; - else - { - client->errorValue = newm; - error = BadValue; - } - } - break; - case CPDither: - pPicture->dither = NEXT_VAL(Atom); - break; - case CPComponentAlpha: - { - unsigned int newca; - - newca = NEXT_VAL (unsigned int); - if (newca <= xTrue) - pPicture->componentAlpha = newca; - else - { - client->errorValue = newca; - error = BadValue; - } - } - break; - default: - client->errorValue = maskQ; - error = BadValue; - break; - } - } - if (ps) - (*ps->ChangePicture) (pPicture, maskQ); - return error; -} - -int -SetPictureClipRects (PicturePtr pPicture, - int xOrigin, - int yOrigin, - int nRect, - xRectangle *rects) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - RegionPtr clientClip; - int result; - - clientClip = RegionFromRects( - nRect, rects, CT_UNSORTED); - if (!clientClip) - return BadAlloc; - result =(*ps->ChangePictureClip) (pPicture, CT_REGION, - (void *) clientClip, 0); - if (result == Success) - { - pPicture->clipOrigin.x = xOrigin; - pPicture->clipOrigin.y = yOrigin; - pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask; - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - } - return result; -} - -int -SetPictureClipRegion (PicturePtr pPicture, - int xOrigin, - int yOrigin, - RegionPtr pRegion) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - RegionPtr clientClip; - int result; - int type; - - if (pRegion) - { - type = CT_REGION; - clientClip = RegionCreate( - RegionExtents(pRegion), - RegionNumRects(pRegion)); - if (!clientClip) - return BadAlloc; - if (!RegionCopy(clientClip, pRegion)) - { - RegionDestroy(clientClip); - return BadAlloc; - } - } - else - { - type = CT_NONE; - clientClip = 0; - } - - result =(*ps->ChangePictureClip) (pPicture, type, - (void *) clientClip, 0); - if (result == Success) - { - pPicture->clipOrigin.x = xOrigin; - pPicture->clipOrigin.y = yOrigin; - pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask; - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - } - return result; -} - - -int -SetPictureTransform (PicturePtr pPicture, - PictTransform *transform) -{ - static const PictTransform identity = { { - { xFixed1, 0x00000, 0x00000 }, - { 0x00000, xFixed1, 0x00000 }, - { 0x00000, 0x00000, xFixed1 }, - } }; - - if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0) - transform = 0; - - if (transform) - { - if (!pPicture->transform) - { - pPicture->transform = (PictTransform *) xalloc (sizeof (PictTransform)); - if (!pPicture->transform) - return BadAlloc; - } - *pPicture->transform = *transform; - } - else - { - if (pPicture->transform) - { - xfree (pPicture->transform); - pPicture->transform = 0; - } - } - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - - return Success; -} - -void -CopyPicture (PicturePtr pSrc, - Mask mask, - PicturePtr pDst) -{ - PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen); - Mask origMask = mask; - - pDst->serialNumber |= GC_CHANGE_SERIAL_BIT; - pDst->stateChanges |= mask; - - while (mask) { - Mask bit = lowbit(mask); - - switch (bit) - { - case CPRepeat: - pDst->repeat = pSrc->repeat; - pDst->repeatType = pSrc->repeatType; - break; - case CPAlphaMap: - if (pSrc->alphaMap && pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP) - pSrc->alphaMap->refcnt++; - if (pDst->alphaMap) - FreePicture ((void *) pDst->alphaMap, (XID) 0); - pDst->alphaMap = pSrc->alphaMap; - break; - case CPAlphaXOrigin: - pDst->alphaOrigin.x = pSrc->alphaOrigin.x; - break; - case CPAlphaYOrigin: - pDst->alphaOrigin.y = pSrc->alphaOrigin.y; - break; - case CPClipXOrigin: - pDst->clipOrigin.x = pSrc->clipOrigin.x; - break; - case CPClipYOrigin: - pDst->clipOrigin.y = pSrc->clipOrigin.y; - break; - case CPClipMask: - switch (pSrc->clientClipType) { - case CT_NONE: - (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0); - break; - case CT_REGION: - if (!pSrc->clientClip) { - (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0); - } else { - RegionPtr clientClip; - RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip; - - clientClip = RegionCreate( - RegionExtents(srcClientClip), - RegionNumRects(srcClientClip)); - (*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0); - } - break; - default: - /* XXX: CT_PIXMAP unimplemented */ - break; - } - break; - case CPGraphicsExposure: - pDst->graphicsExposures = pSrc->graphicsExposures; - break; - case CPPolyEdge: - pDst->polyEdge = pSrc->polyEdge; - break; - case CPPolyMode: - pDst->polyMode = pSrc->polyMode; - break; - case CPDither: - pDst->dither = pSrc->dither; - break; - case CPComponentAlpha: - pDst->componentAlpha = pSrc->componentAlpha; - break; - } - mask &= ~bit; - } - - (*ps->ChangePicture)(pDst, origMask); -} - -static void -ValidateOnePicture (PicturePtr pPicture) -{ - if (pPicture->pDrawable && pPicture->serialNumber != pPicture->pDrawable->serialNumber) - { - PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); - - (*ps->ValidatePicture) (pPicture, pPicture->stateChanges); - pPicture->stateChanges = 0; - pPicture->serialNumber = pPicture->pDrawable->serialNumber; - } -} - -void -ValidatePicture(PicturePtr pPicture) -{ - ValidateOnePicture (pPicture); - if (pPicture->alphaMap) - ValidateOnePicture (pPicture->alphaMap); -} - -int -FreePicture (void * value, - XID pid) -{ - PicturePtr pPicture = (PicturePtr) value; + PicturePtr pPicture = (PicturePtr) value; if (--pPicture->refcnt == 0) { -#ifdef NXAGENT_SERVER nxagentDestroyPicture(pPicture); -#endif if (pPicture->transform) xfree (pPicture->transform); @@ -1793,264 +402,6 @@ FreePicture (void * value, return Success; } -int -FreePictFormat (void * pPictFormat, - XID pid) -{ - return Success; -} - -/** - * ReduceCompositeOp is used to choose simpler ops for cases where alpha - * channels are always one and so math on the alpha channel per pixel becomes - * unnecessary. It may also avoid destination reads sometimes if apps aren't - * being careful to avoid these cases. - */ -static CARD8 -ReduceCompositeOp (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst) -{ - Bool no_src_alpha, no_dst_alpha; - - no_src_alpha = PICT_FORMAT_COLOR(pSrc->format) && - PICT_FORMAT_A(pSrc->format) == 0 && - pSrc->alphaMap == NULL && - pMask == NULL; - no_dst_alpha = PICT_FORMAT_COLOR(pDst->format) && - PICT_FORMAT_A(pDst->format) == 0 && - pDst->alphaMap == NULL; - - /* TODO, maybe: Conjoint and Disjoint op reductions? */ - - /* Deal with simplifications where the source alpha is always 1. */ - if (no_src_alpha) - { - switch (op) { - case PictOpOver: - op = PictOpSrc; - break; - case PictOpInReverse: - op = PictOpDst; - break; - case PictOpOutReverse: - op = PictOpClear; - break; - case PictOpAtop: - op = PictOpIn; - break; - case PictOpAtopReverse: - op = PictOpOverReverse; - break; - case PictOpXor: - op = PictOpOut; - break; - default: - break; - } - } - - /* Deal with simplifications when the destination alpha is always 1 */ - if (no_dst_alpha) - { - switch (op) { - case PictOpOverReverse: - op = PictOpDst; - break; - case PictOpIn: - op = PictOpSrc; - break; - case PictOpOut: - op = PictOpClear; - break; - case PictOpAtop: - op = PictOpOver; - break; - case PictOpXor: - op = PictOpOutReverse; - break; - default: - break; - } - } - - /* Reduce some con/disjoint ops to the basic names. */ - switch (op) { - case PictOpDisjointClear: - case PictOpConjointClear: - op = PictOpClear; - break; - case PictOpDisjointSrc: - case PictOpConjointSrc: - op = PictOpSrc; - break; - case PictOpDisjointDst: - case PictOpConjointDst: - op = PictOpDst; - break; - default: - break; - } - - return op; -} - -void -CompositePicture (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - if (pMask) - ValidatePicture (pMask); - ValidatePicture (pDst); - - op = ReduceCompositeOp (op, pSrc, pMask, pDst); - if (op == PictOpDst) - return; - - (*ps->Composite) (op, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height); -} - -void -CompositeGlyphs (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr lists, - GlyphPtr *glyphs) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - - #ifdef TEST - fprintf(stderr, "CompositeGlyphs: Going to composite glyphs with " - "source at [%p] and destination at [%p].\n", - (void *) pSrc, (void *) pDst); - #endif - - (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs); -} - -void -CompositeRects (CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pDst); - (*ps->CompositeRects) (op, pDst, color, nRect, rects); -} - -void -CompositeTrapezoids (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntrap, - xTrapezoid *traps) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->Trapezoids) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps); -} - -void -CompositeTriangles (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntriangles, - xTriangle *triangles) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntriangles, triangles); -} - -void -CompositeTriStrip (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); -} - -void -CompositeTriFan (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); -} - -void -AddTraps (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntrap, - xTrap *traps) -{ - PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); - - ValidatePicture (pPicture); - (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps); -} - #ifndef True # define True 1 #endif diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index 0685ef3f6..5db244d6d 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -8,10 +8,12 @@ NULL = NXAGENT_SKIP_SRCS = \ miglyph.c \ mitrap.c \ + picture.c \ $(NULL) NXAGENT_SKIP_OBJS = \ miglyph.o \ mitrap.o \ + picture.o \ $(NULL) #endif @@ -23,7 +25,6 @@ NXAGENT_SKIP_OBJS = \ mipict.c \ mirect.c \ mitri.c \ - picture.c \ render.c \ renderedge.c \ $(NXAGENT_SKIP_SRCS) \ @@ -37,7 +38,6 @@ NXAGENT_SKIP_OBJS = \ mipict.o \ mirect.o \ mitri.o \ - picture.o \ render.o \ renderedge.o \ $(NXAGENT_SKIP_OBJS) \ diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c index 3c43abd67..a29a9568c 100644 --- a/nx-X11/programs/Xserver/render/picture.c +++ b/nx-X11/programs/Xserver/render/picture.c @@ -40,7 +40,10 @@ #include "dixstruct.h" #include "gcstruct.h" #include "servermd.h" + +#ifndef NXAGENT_SERVER #include "picturestr.h" +#endif int PictureScreenPrivateIndex = -1; int PictureWindowPrivateIndex; @@ -212,6 +215,7 @@ addFormat (FormatInitRec formats[256], #define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1)) +#ifndef NXAGENT_SERVER PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) { @@ -431,6 +435,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) *nformatp = nformats; return pFormats; } +#endif static VisualPtr PictureFindVisual (ScreenPtr pScreen, VisualID visual) @@ -767,6 +772,7 @@ SetPictureToDefaults (PicturePtr pPicture) pPicture->pSourcePict = 0; } +#ifndef NXAGENT_SERVER PicturePtr AllocatePicture (ScreenPtr pScreen) { @@ -847,6 +853,7 @@ CreatePicture (Picture pid, } return pPicture; } +#endif static CARD32 xRenderColorToCard32(xRenderColor c) { @@ -969,6 +976,7 @@ static void initGradient(SourcePictPtr pGradient, int stopCount, initGradientColorTable(pGradient, error); } +#ifndef NXAGENT_SERVER static PicturePtr createSourcePicture(void) { PicturePtr pPicture; @@ -1002,6 +1010,7 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); return pPicture; } +#endif PicturePtr CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, @@ -1592,6 +1601,7 @@ ValidatePicture(PicturePtr pPicture) ValidateOnePicture (pPicture->alphaMap); } +#ifndef NXAGENT_SERVER int FreePicture (void * value, XID pid) @@ -1641,6 +1651,7 @@ FreePicture (void * value, } return Success; } +#endif int FreePictFormat (void * pPictFormat, -- cgit v1.2.3 From 778e83a3cb717f4033a3bff65134cc5697a528fc Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 13 Apr 2016 15:28:33 +0200 Subject: hw/nxagent/NX{glyphstr,picturestr}.h: Don't ship the complete header files in nxagent's code base. Rather replace structures we need modified only. --- nx-X11/programs/Xserver/fb/Imakefile | 12 +- nx-X11/programs/Xserver/hw/nxagent/NXglyph.c | 6 +- nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h | 174 ----- .../Xserver/hw/nxagent/NXglyphstr_GlyphRef.h | 54 ++ .../Xserver/hw/nxagent/NXglyphstr_GlyphSet.h | 58 ++ nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h | 707 --------------------- .../hw/nxagent/NXpicturestr_PictSolidFill.h | 55 ++ nx-X11/programs/Xserver/hw/nxagent/NXrender.c | 4 +- nx-X11/programs/Xserver/hw/nxagent/Render.c | 4 +- nx-X11/programs/Xserver/hw/nxagent/Render.h | 2 +- nx-X11/programs/Xserver/render/Imakefile | 2 + nx-X11/programs/Xserver/render/glyphstr.h | 8 + nx-X11/programs/Xserver/render/picturestr.h | 4 + 14 files changed, 201 insertions(+), 891 deletions(-) delete mode 100644 nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h create mode 100644 nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h create mode 100644 nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h delete mode 100644 nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h create mode 100644 nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/fb/Imakefile b/nx-X11/programs/Xserver/fb/Imakefile index 662a70717..2d17a856e 100644 --- a/nx-X11/programs/Xserver/fb/Imakefile +++ b/nx-X11/programs/Xserver/fb/Imakefile @@ -34,7 +34,7 @@ SUBDIRS = module #include #ifdef FbNoPixelAddrCode -DEFINES=-DFBNOPIXADDR -DFBNO24BIT +FB_DEFINES=-DFBNOPIXADDR -DFBNO24BIT #endif #if defined(IHaveModules) @@ -47,6 +47,16 @@ RENDERSRC = fbcompose.c RENDEROBJ = fbcompose.o #endif +#if defined(NXAgentServer) && NXAgentServer +NX_DEFINES = -DNXAGENT_SERVER +#endif + +#if defined(NXAgentServer) && NXAgentServer + DEFINES = $(FB_DEFINES) $(NX_DEFINES) +#else + DEFINES = $(FB_DEFINES) +#endif + SRCS = $(XFMODSRC) \ fballpriv.c \ fbbits.c \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 757ffff21..b5f1e8ac0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -60,8 +60,7 @@ #ifdef NXAGENT_SERVER -#include "NXpicturestr.h" -#include "NXglyphstr.h" +#include "picturestr.h" #include "Render.h" #define PANIC @@ -72,10 +71,11 @@ #else #include "picturestr.h" -#include "glyphstr.h" #endif +#include "glyphstr.h" + #include /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h deleted file mode 100644 index 5d7fcf640..000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NXAGENT, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* - * $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $ - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -/* - * This must keep the same symbol as the original glyphstr.h - * or symbols will be redefined. The code here adds a field - * to _GlyphSet. This should be done by defining a new type - * and casting when appropriate. - */ - -#ifndef _GLYPHSTR_H_ -#define _GLYPHSTR_H_ - -#include -#include "../../render/picture.h" -#include "screenint.h" - -#define GlyphFormat1 0 -#define GlyphFormat4 1 -#define GlyphFormat8 2 -#define GlyphFormat16 3 -#define GlyphFormat32 4 -#define GlyphFormatNum 5 - -typedef struct _Glyph { - CARD32 refcnt; - CARD32 size; /* info + bitmap */ - xGlyphInfo info; - /* bits follow */ -} GlyphRec, *GlyphPtr; - -typedef struct _GlyphRef { - CARD32 signature; - GlyphPtr glyph; - CARD16 corruptedGlyph; -} GlyphRefRec, *GlyphRefPtr; - -#define DeletedGlyph ((GlyphPtr) 1) - -typedef struct _GlyphHashSet { - CARD32 entries; - CARD32 size; - CARD32 rehash; -} GlyphHashSetRec, *GlyphHashSetPtr; - -typedef struct _GlyphHash { - GlyphRefPtr table; - GlyphHashSetPtr hashSet; - CARD32 tableEntries; -} GlyphHashRec, *GlyphHashPtr; - -typedef struct _GlyphSet { - CARD32 refcnt; - PictFormatPtr format; - int fdepth; - GlyphHashRec hash; - int maxPrivate; - void **devPrivates; - CARD32 remoteID; -} GlyphSetRec, *GlyphSetPtr; - -#define GlyphSetGetPrivate(pGlyphSet,n) \ - ((n) > (pGlyphSet)->maxPrivate ? \ - (void *) 0 : \ - (pGlyphSet)->devPrivates[n]) - -#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \ - ((n) > (pGlyphSet)->maxPrivate ? \ - _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \ - ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE)) - -typedef struct _GlyphList { - INT16 xOff; - INT16 yOff; - CARD8 len; - PictFormatPtr format; -} GlyphListRec, *GlyphListPtr; - -extern GlyphHashRec globalGlyphs[GlyphFormatNum]; - -GlyphHashSetPtr -FindGlyphHashSet (CARD32 filled); - -int -AllocateGlyphSetPrivateIndex (void); - -void -ResetGlyphSetPrivateIndex (void); - -Bool -_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr); - -Bool -GlyphInit (ScreenPtr pScreen); - -GlyphRefPtr -FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare); - -CARD32 -HashGlyph (GlyphPtr glyph); - -void -FreeGlyph (GlyphPtr glyph, int format); - -void -AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id); - -Bool -DeleteGlyph (GlyphSetPtr glyphSet, Glyph id); - -GlyphPtr -FindGlyph (GlyphSetPtr glyphSet, Glyph id); - -GlyphPtr -AllocateGlyph (xGlyphInfo *gi, int format); - -Bool -AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet); - -Bool -ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global); - -Bool -ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change); - -GlyphSetPtr -AllocateGlyphSet (int fdepth, PictFormatPtr format); - -int -FreeGlyphSet (void *value, - XID gid); - - - -#endif /* _GLYPHSTR_H_ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h new file mode 100644 index 000000000..6239b113e --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h @@ -0,0 +1,54 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NXAGENT, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of Medialogic S.p.A. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* + * $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $ + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +/* this header file gets included into Xserver/render/glyphstr.h */ + +#ifndef NX_GLYPHSTR_GLYPHREF_H +#define NX_GLYPHSTR_GLYPHREF_H 1 + +typedef struct _GlyphRef { + CARD32 signature; + GlyphPtr glyph; + CARD16 corruptedGlyph; +} GlyphRefRec, *GlyphRefPtr; + +#endif /* NX_GLYPHSTR_GLYPHREF_H */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h new file mode 100644 index 000000000..9f6ab45e6 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h @@ -0,0 +1,58 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NXAGENT, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of Medialogic S.p.A. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* + * $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $ + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +/* this header file gets included into Xserver/render/glyphstr.h */ + +#ifndef NX_GLYPHSTR_GLYPHSET_H +#define NX_GLYPHSTR_GLYPHSET_H 1 + +typedef struct _GlyphSet { + CARD32 refcnt; + PictFormatPtr format; + int fdepth; + GlyphHashRec hash; + int maxPrivate; + void **devPrivates; + CARD32 remoteID; +} GlyphSetRec, *GlyphSetPtr; + +#endif /* NX_GLYPHSTR_GLYPHSET_H */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index ac0eb5016..a47e158df 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -40,7 +40,7 @@ * Author: Keith Packard, SuSE, Inc. */ -#include "NXpicturestr.h" +#include "picturestr.h" #include "Screen.h" #include "Pixmaps.h" diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h b/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h deleted file mode 100644 index 30e1005c2..000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h +++ /dev/null @@ -1,707 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NXAGENT, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* - * $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $ - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -/* - * This must keep the same symbol as the original - * picturestr.h or symbols will be redefined. We - * should define a new types and cast when appro- - * priate. - */ - -#ifndef _PICTURESTR_H_ -#define _PICTURESTR_H_ - -#include "NXglyphstr.h" -#include "scrnintstr.h" -#include "resource.h" - -typedef struct _DirectFormat { - CARD16 red, redMask; - CARD16 green, greenMask; - CARD16 blue, blueMask; - CARD16 alpha, alphaMask; -} DirectFormatRec; - -typedef struct _IndexFormat { - VisualID vid; - ColormapPtr pColormap; - int nvalues; - xIndexValue *pValues; - void *devPrivate; -} IndexFormatRec; - -typedef struct _PictFormat { - CARD32 id; - CARD32 format; /* except bpp */ - unsigned char type; - unsigned char depth; - DirectFormatRec direct; - IndexFormatRec index; -} PictFormatRec; - -typedef struct pixman_vector PictVector, *PictVectorPtr; -typedef struct pixman_transform PictTransform, *PictTransformPtr; - -#define pict_f_transform pixman_f_transform - -#define PICT_GRADIENT_STOPTABLE_SIZE 1024 -#define SourcePictTypeSolidFill 0 -#define SourcePictTypeLinear 1 -#define SourcePictTypeRadial 2 -#define SourcePictTypeConical 3 - -typedef struct _PictSolidFill { - unsigned int type; - CARD32 color; - xRenderColor fullColor; -} PictSolidFill, *PictSolidFillPtr; - -typedef struct _PictGradientStop { - xFixed x; - xRenderColor color; -} PictGradientStop, *PictGradientStopPtr; - -typedef struct _PictGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; -} PictGradient, *PictGradientPtr; - -typedef struct _PictLinearGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - xPointFixed p1; - xPointFixed p2; -} PictLinearGradient, *PictLinearGradientPtr; - -typedef struct _PictRadialGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - double fx; - double fy; - double dx; - double dy; - double a; - double m; - double b; -} PictRadialGradient, *PictRadialGradientPtr; - -typedef struct _PictConicalGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - xPointFixed center; - xFixed angle; -} PictConicalGradient, *PictConicalGradientPtr; - -typedef union _SourcePict { - unsigned int type; - PictSolidFill solidFill; - PictGradient gradient; - PictLinearGradient linear; - PictRadialGradient radial; - PictConicalGradient conical; -} SourcePict, *SourcePictPtr; - -typedef struct _Picture { - DrawablePtr pDrawable; - PictFormatPtr pFormat; - CARD32 format; /* PICT_FORMAT */ - int refcnt; - CARD32 id; - PicturePtr pNext; /* chain on same drawable */ - - unsigned int repeat : 1; - unsigned int graphicsExposures : 1; - unsigned int subWindowMode : 1; - unsigned int polyEdge : 1; - unsigned int polyMode : 1; - unsigned int freeCompClip : 1; - unsigned int clientClipType : 2; - unsigned int componentAlpha : 1; - unsigned int repeatType : 2; - unsigned int unused : 21; - - PicturePtr alphaMap; - DDXPointRec alphaOrigin; - - DDXPointRec clipOrigin; - void * clientClip; - - Atom dither; - - unsigned long stateChanges; - unsigned long serialNumber; - - RegionPtr pCompositeClip; - - DevUnion *devPrivates; - - PictTransform *transform; - - int filter; - xFixed *filter_params; - int filter_nparams; - SourcePictPtr pSourcePict; -} PictureRec; - -typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id, - xFixed *params, int nparams, - int *width, int *height); -typedef struct { - char *name; - int id; - PictFilterValidateParamsProcPtr ValidateParams; - int width, height; -} PictFilterRec, *PictFilterPtr; - -#define PictFilterNearest 0 -#define PictFilterBilinear 1 - -#define PictFilterFast 2 -#define PictFilterGood 3 -#define PictFilterBest 4 - -#define PictFilterConvolution 5 - -typedef struct { - char *alias; - int alias_id; - int filter_id; -} PictFilterAliasRec, *PictFilterAliasPtr; - -typedef int (*CreatePictureProcPtr) (PicturePtr pPicture); -typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture); -typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture, - int clipType, - void *value, - int n); -typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture); - -typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture, - PictTransform *transform); - -typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture, - int filter, - xFixed *params, - int nparams); - -typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture); - -typedef void (*ChangePictureProcPtr) (PicturePtr pPicture, - Mask mask); -typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture, - Mask mask); -typedef void (*CompositeProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -typedef void (*GlyphsProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlists, - GlyphListPtr lists, - GlyphPtr *glyphs); - -typedef void (*CompositeRectsProcPtr) (CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects); - -typedef void (*RasterizeTrapezoidProcPtr)(PicturePtr pMask, - xTrapezoid *trap, - int x_off, - int y_off); - -typedef void (*TrapezoidsProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntrap, - xTrapezoid *traps); - -typedef void (*TrianglesProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntri, - xTriangle *tris); - -typedef void (*TriStripProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoint, - xPointFixed *points); - -typedef void (*TriFanProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoint, - xPointFixed *points); - -typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen, - PictFormatPtr pFormat); - -typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen, - PictFormatPtr pFormat); - -typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen, - PictFormatPtr pFormat, - int ndef, - xColorItem *pdef); - -typedef void (*AddTrapsProcPtr) (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntrap, - xTrap *traps); - -typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntri, - xTriangle *tris); - -typedef struct _PictureScreen { - int totalPictureSize; - unsigned int *PicturePrivateSizes; - int PicturePrivateLen; - - PictFormatPtr formats; - PictFormatPtr fallback; - int nformats; - - CreatePictureProcPtr CreatePicture; - DestroyPictureProcPtr DestroyPicture; - ChangePictureClipProcPtr ChangePictureClip; - DestroyPictureClipProcPtr DestroyPictureClip; - - ChangePictureProcPtr ChangePicture; - ValidatePictureProcPtr ValidatePicture; - - CompositeProcPtr Composite; - GlyphsProcPtr Glyphs; - CompositeRectsProcPtr CompositeRects; - - DestroyWindowProcPtr DestroyWindow; - CloseScreenProcPtr CloseScreen; - - StoreColorsProcPtr StoreColors; - - InitIndexedProcPtr InitIndexed; - CloseIndexedProcPtr CloseIndexed; - UpdateIndexedProcPtr UpdateIndexed; - - int subpixel; - - PictFilterPtr filters; - int nfilters; - PictFilterAliasPtr filterAliases; - int nfilterAliases; - - ChangePictureTransformProcPtr ChangePictureTransform; - - /** - * Called immediately after a picture's transform is changed through the - * SetPictureFilter request. Not called for source-only pictures. - */ - ChangePictureFilterProcPtr ChangePictureFilter; - - DestroyPictureFilterProcPtr DestroyPictureFilter; - - TrapezoidsProcPtr Trapezoids; - TrianglesProcPtr Triangles; - TriStripProcPtr TriStrip; - TriFanProcPtr TriFan; - - RasterizeTrapezoidProcPtr RasterizeTrapezoid; - - AddTrianglesProcPtr AddTriangles; - - AddTrapsProcPtr AddTraps; - -} PictureScreenRec, *PictureScreenPtr; - -extern int PictureScreenPrivateIndex; -extern int PictureWindowPrivateIndex; -extern RESTYPE PictureType; -extern RESTYPE PictFormatType; -extern RESTYPE GlyphSetType; - -#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr)) -#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL) -#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (void *) (p)) -#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr)) -#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (void *) (p)) - -#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\ - pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\ - if (!pPicture) { \ - client->errorValue = pid; \ - return err; \ - } \ -} - -#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\ - if (pid == None) \ - pPicture = 0; \ - else { \ - VERIFY_PICTURE(pPicture, pid, client, mode, err); \ - } \ -} \ - -void -ResetPicturePrivateIndex (void); - -int -AllocatePicturePrivateIndex (void); - -Bool -AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount); - -Bool -PictureDestroyWindow (WindowPtr pWindow); - -Bool -PictureCloseScreen (int Index, ScreenPtr pScreen); - -void -PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef); - -Bool -PictureInitIndexedFormats (ScreenPtr pScreen); - -Bool -PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel); - -int -PictureGetSubpixelOrder (ScreenPtr pScreen); - -PictFormatPtr -PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp); - -PictFormatPtr -PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual); - -PictFormatPtr -PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format); - -Bool -PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); - -int -PictureGetFilterId (char *filter, int len, Bool makeit); - -char * -PictureGetFilterName (int id); - -int -PictureAddFilter (ScreenPtr pScreen, - char *filter, - PictFilterValidateParamsProcPtr ValidateParams); - -Bool -PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias); - -Bool -PictureSetDefaultFilters (ScreenPtr pScreen); - -void -PictureResetFilters (ScreenPtr pScreen); - -PictFilterPtr -PictureFindFilter (ScreenPtr pScreen, char *name, int len); - -int -SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter, - xFixed *params, int nparams); - -int -SetPictureFilter (PicturePtr pPicture, char *name, int len, - xFixed *params, int nparams); - -Bool -PictureFinishInit (void); - -void -SetPictureToDefaults (PicturePtr pPicture); - -PicturePtr -AllocatePicture (ScreenPtr pScreen); - -#if 0 -Bool -miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); -#endif - - -PicturePtr -CreatePicture (Picture pid, - DrawablePtr pDrawable, - PictFormatPtr pFormat, - Mask mask, - XID *list, - ClientPtr client, - int *error); - -int -ChangePicture (PicturePtr pPicture, - Mask vmask, - XID *vlist, - DevUnion *ulist, - ClientPtr client); - -int -SetPictureClipRects (PicturePtr pPicture, - int xOrigin, - int yOrigin, - int nRect, - xRectangle *rects); - -int -SetPictureClipRegion (PicturePtr pPicture, - int xOrigin, - int yOrigin, - RegionPtr pRegion); - -int -SetPictureTransform (PicturePtr pPicture, - PictTransform *transform); - -void -CopyPicture (PicturePtr pSrc, - Mask mask, - PicturePtr pDst); - -void -ValidatePicture(PicturePtr pPicture); - -int -FreePicture (void * pPicture, - XID pid); - -int -FreePictFormat (void * pPictFormat, - XID pid); - -void -CompositePicture (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -CompositeGlyphs (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr lists, - GlyphPtr *glyphs); - -void -CompositeRects (CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects); - -void -CompositeTrapezoids (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntrap, - xTrapezoid *traps); - -void -CompositeTriangles (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntriangles, - xTriangle *triangles); - -void -CompositeTriStrip (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points); - -void -CompositeTriFan (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points); - -Bool -PictureTransformPoint (PictTransformPtr transform, - PictVectorPtr vector); - -Bool -PictureTransformPoint3d (PictTransformPtr transform, - PictVectorPtr vector); - -void RenderExtensionInit (void); - -Bool -AnimCurInit (ScreenPtr pScreen); - -int -AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor); - -void -AddTraps (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntraps, - xTrap *traps); - -PicturePtr -CreateSolidPicture (Picture pid, - xRenderColor *color, - int *error); - -PicturePtr -CreateLinearGradientPicture (Picture pid, - xPointFixed *p1, - xPointFixed *p2, - int nStops, - xFixed *stops, - xRenderColor *colors, - int *error); - -PicturePtr -CreateRadialGradientPicture (Picture pid, - xPointFixed *inner, - xPointFixed *outer, - xFixed innerRadius, - xFixed outerRadius, - int nStops, - xFixed *stops, - xRenderColor *colors, - int *error); - -PicturePtr -CreateConicalGradientPicture (Picture pid, - xPointFixed *center, - xFixed angle, - int nStops, - xFixed *stops, - xRenderColor *colors, - int *error); - -#ifdef PANORAMIX -void PanoramiXRenderInit (void); -void PanoramiXRenderReset (void); -#endif - -/* - * matrix.c - */ - -extern _X_EXPORT void -PictTransform_from_xRenderTransform(PictTransformPtr pict, - xRenderTransform * render); - -extern _X_EXPORT void -xRenderTransform_from_PictTransform(xRenderTransform * render, - PictTransformPtr pict); - -extern _X_EXPORT Bool - PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector); - -extern _X_EXPORT Bool - PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector); - -#endif /* _PICTURESTR_H_ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h b/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h new file mode 100644 index 000000000..e54bfafc2 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h @@ -0,0 +1,55 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NXAGENT, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of Medialogic S.p.A. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* + * $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $ + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +/* this header file gets included into Xserver/render/picturestr.h */ + +#ifndef NX_PICTURESTR_PICTSOLIDFILL_H +#define NX_PICTURESTR_PICTSOLIDFILL_H 1 + + +typedef struct _PictSolidFill { + unsigned int type; + CARD32 color; + xRenderColor fullColor; +} PictSolidFill, *PictSolidFillPtr; + +#endif /* NX_PICTURESTR_PICTSOLIDFILL_H */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 238e5a39c..f6e016a77 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -71,8 +71,8 @@ #define UINT32_MAX 0xffffffffU #endif -#include "NXpicturestr.h" -#include "NXglyphstr.h" +#include "picturestr.h" +#include "glyphstr.h" #include "Trap.h" diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index b4bd615e7..72da2df19 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -15,8 +15,8 @@ /* */ /**************************************************************************/ -#include "NXpicturestr.h" -#include "NXglyphstr.h" +#include "picturestr.h" +#include "glyphstr.h" #include "Render.h" diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.h b/nx-X11/programs/Xserver/hw/nxagent/Render.h index 08c719370..54fe5452a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.h @@ -23,7 +23,7 @@ #include "picture.h" #include "renderproto.h" -#include "NXglyphstr.h" +#include "glyphstr.h" #include "Agent.h" diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index 5db244d6d..f39e74830 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -15,6 +15,8 @@ NXAGENT_SKIP_OBJS = \ mitrap.o \ picture.o \ $(NULL) +#else + DEFINES = -DNXAGENT_SERVER #endif SRCS = animcur.c \ diff --git a/nx-X11/programs/Xserver/render/glyphstr.h b/nx-X11/programs/Xserver/render/glyphstr.h index f27a73fbb..d0c14919c 100644 --- a/nx-X11/programs/Xserver/render/glyphstr.h +++ b/nx-X11/programs/Xserver/render/glyphstr.h @@ -44,10 +44,14 @@ typedef struct _Glyph { /* bits follow */ } GlyphRec, *GlyphPtr; +#ifdef NXAGENT_SERVER +#include "../hw/nxagent/NXglyphstr_GlyphRef.h" +#else typedef struct _GlyphRef { CARD32 signature; GlyphPtr glyph; } GlyphRefRec, *GlyphRefPtr; +#endif /* NXAGENT_SERVER */ #define DeletedGlyph ((GlyphPtr) 1) @@ -63,6 +67,9 @@ typedef struct _GlyphHash { CARD32 tableEntries; } GlyphHashRec, *GlyphHashPtr; +#ifdef NXAGENT_SERVER +#include "../hw/nxagent/NXglyphstr_GlyphSet.h" +#else typedef struct _GlyphSet { CARD32 refcnt; PictFormatPtr format; @@ -71,6 +78,7 @@ typedef struct _GlyphSet { int maxPrivate; void **devPrivates; } GlyphSetRec, *GlyphSetPtr; +#endif /* NXAGENT_SERVER */ #define GlyphSetGetPrivate(pGlyphSet,n) \ ((n) > (pGlyphSet)->maxPrivate ? \ diff --git a/nx-X11/programs/Xserver/render/picturestr.h b/nx-X11/programs/Xserver/render/picturestr.h index 4969f6cab..27c36dc9c 100644 --- a/nx-X11/programs/Xserver/render/picturestr.h +++ b/nx-X11/programs/Xserver/render/picturestr.h @@ -65,10 +65,14 @@ typedef struct pixman_transform PictTransform, *PictTransformPtr; #define SourcePictTypeRadial 2 #define SourcePictTypeConical 3 +#ifdef NXAGENT_SERVER +#include "../hw/nxagent/NXpicturestr_PictSolidFill.h" +#else typedef struct _PictSolidFill { unsigned int type; CARD32 color; } PictSolidFill, *PictSolidFillPtr; +#endif /* NXAGENT_SERVER */ typedef struct _PictGradientStop { xFixed x; -- cgit v1.2.3 From a648558796042b0cdb1a373f52bf8a4ca2dbea87 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 13 Apr 2016 15:29:32 +0200 Subject: hw/nxagent/NXrender.c: Shrink file, drop duplicate code that can identically be found in render/render.c. Fixes ArcticaProject/nx-libs#37 --- nx-X11/programs/Xserver/hw/nxagent/NXrender.c | 2300 +------------------------ nx-X11/programs/Xserver/render/Imakefile | 4 +- nx-X11/programs/Xserver/render/render.c | 26 +- 3 files changed, 102 insertions(+), 2228 deletions(-) (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index f6e016a77..93760f482 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -41,38 +41,7 @@ /* */ /**************************************************************************/ -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "resource.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "colormapst.h" -#include "extnsionst.h" -#include "servermd.h" -#include -#include -#include -#include "cursorstr.h" -#ifdef EXTMODULE -#include "xf86_ansic.h" -#endif - -#if !defined(UINT32_MAX) -#define UINT32_MAX 0xffffffffU -#endif - -#include "picturestr.h" -#include "glyphstr.h" +#include "../render/render.c" #include "Trap.h" @@ -99,6 +68,7 @@ * From NXmiglyph.c. */ +extern void miGlyphExtents(int nlist, GlyphListPtr list, GlyphPtr *glyphs, BoxPtr extents); @@ -106,52 +76,48 @@ void miGlyphExtents(int nlist, GlyphListPtr list, * From NXmitrap.c. */ +extern void miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box); /* * Functions from Render.c. */ -int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr); -void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int); -int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); -int nxagentCreatePicture(PicturePtr, Mask); -void nxagentChangePicture(PicturePtr, Mask); -int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int); -void nxagentComposite(CARD8, PicturePtr, PicturePtr, PicturePtr, INT16, INT16, - INT16, INT16, INT16, INT16, CARD16, CARD16); -void nxagentCompositeRects(CARD8, PicturePtr, xRenderColor *, int, xRectangle *); -void nxagentCreateGlyphSet(GlyphSetPtr glyphSet); -void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet); -void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph); -void nxagentFreeGlyphSet(GlyphSetPtr glyphSet); -void nxagentSetPictureTransform(PicturePtr pPicture, void * transform); -void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_size, - void * params, int nparams); -void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps); - -void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color); - -void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, - xPointFixed *p2, int nStops, - xFixed *stops, - xRenderColor *colors); - -void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, - xPointFixed *outer, - xFixed innerRadius, - xFixed outerRadius, - int nStops, - xFixed *stops, - xRenderColor *colors); - -void nxagentRenderCreateConicalGradient(PicturePtr pPicture, - xPointFixed *center, - xFixed angle, int nStops, - xFixed *stops, - xRenderColor *colors); - +extern int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr); +extern void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int); +extern int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); +extern int nxagentCreatePicture(PicturePtr, Mask); +extern void nxagentChangePicture(PicturePtr, Mask); +extern int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int); +extern void nxagentComposite(CARD8, PicturePtr, PicturePtr, PicturePtr, INT16, INT16, + INT16, INT16, INT16, INT16, CARD16, CARD16); +extern void nxagentCompositeRects(CARD8, PicturePtr, xRenderColor *, int, xRectangle *); +extern void nxagentCreateGlyphSet(GlyphSetPtr glyphSet); +extern void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet); +extern void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph); +extern void nxagentFreeGlyphSet(GlyphSetPtr glyphSet); +extern void nxagentSetPictureTransform(PicturePtr pPicture, void * transform); +extern void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_size, + void * params, int nparams); +extern void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps); +extern void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color); +extern void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, + xPointFixed *p2, int nStops, + xFixed *stops, + xRenderColor *colors); +extern void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, + xPointFixed *outer, + xFixed innerRadius, + xFixed outerRadius, + int nStops, + xFixed *stops, + xRenderColor *colors); +extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture, + xPointFixed *center, + xFixed angle, int nStops, + xFixed *stops, + xRenderColor *colors); /* * The void pointer is actually a XGlyphElt8. @@ -160,225 +126,6 @@ void nxagentRenderCreateConicalGradient(PicturePtr pPicture, void nxagentGlyphs(CARD8, PicturePtr, PicturePtr, PictFormatPtr, INT16, INT16, int, void *, int, GlyphPtr *); -static int ProcRenderQueryVersion (ClientPtr pClient); -static int ProcRenderQueryPictFormats (ClientPtr pClient); -static int ProcRenderQueryPictIndexValues (ClientPtr pClient); -static int ProcRenderQueryDithers (ClientPtr pClient); -static int ProcRenderCreatePicture (ClientPtr pClient); -static int ProcRenderChangePicture (ClientPtr pClient); -static int ProcRenderSetPictureClipRectangles (ClientPtr pClient); -static int ProcRenderFreePicture (ClientPtr pClient); -static int ProcRenderComposite (ClientPtr pClient); -static int ProcRenderScale (ClientPtr pClient); -static int ProcRenderTrapezoids (ClientPtr pClient); -static int ProcRenderTriangles (ClientPtr pClient); -static int ProcRenderTriStrip (ClientPtr pClient); -static int ProcRenderTriFan (ClientPtr pClient); -static int ProcRenderColorTrapezoids (ClientPtr pClient); -static int ProcRenderColorTriangles (ClientPtr pClient); -static int ProcRenderTransform (ClientPtr pClient); -static int ProcRenderCreateGlyphSet (ClientPtr pClient); -static int ProcRenderReferenceGlyphSet (ClientPtr pClient); -static int ProcRenderFreeGlyphSet (ClientPtr pClient); -static int ProcRenderAddGlyphs (ClientPtr pClient); -static int ProcRenderAddGlyphsFromPicture (ClientPtr pClient); -static int ProcRenderFreeGlyphs (ClientPtr pClient); -static int ProcRenderCompositeGlyphs (ClientPtr pClient); -static int ProcRenderFillRectangles (ClientPtr pClient); -static int ProcRenderCreateCursor (ClientPtr pClient); -static int ProcRenderSetPictureTransform (ClientPtr pClient); -static int ProcRenderQueryFilters (ClientPtr pClient); -static int ProcRenderSetPictureFilter (ClientPtr pClient); -static int ProcRenderCreateAnimCursor (ClientPtr pClient); -static int ProcRenderAddTraps (ClientPtr pClient); -static int ProcRenderCreateSolidFill (ClientPtr pClient); -static int ProcRenderCreateLinearGradient (ClientPtr pClient); -static int ProcRenderCreateRadialGradient (ClientPtr pClient); -static int ProcRenderCreateConicalGradient (ClientPtr pClient); - -static int ProcRenderDispatch (ClientPtr pClient); - -static int SProcRenderQueryVersion (ClientPtr pClient); -static int SProcRenderQueryPictFormats (ClientPtr pClient); -static int SProcRenderQueryPictIndexValues (ClientPtr pClient); -static int SProcRenderQueryDithers (ClientPtr pClient); -static int SProcRenderCreatePicture (ClientPtr pClient); -static int SProcRenderChangePicture (ClientPtr pClient); -static int SProcRenderSetPictureClipRectangles (ClientPtr pClient); -static int SProcRenderFreePicture (ClientPtr pClient); -static int SProcRenderComposite (ClientPtr pClient); -static int SProcRenderScale (ClientPtr pClient); -static int SProcRenderTrapezoids (ClientPtr pClient); -static int SProcRenderTriangles (ClientPtr pClient); -static int SProcRenderTriStrip (ClientPtr pClient); -static int SProcRenderTriFan (ClientPtr pClient); -static int SProcRenderColorTrapezoids (ClientPtr pClient); -static int SProcRenderColorTriangles (ClientPtr pClient); -static int SProcRenderTransform (ClientPtr pClient); -static int SProcRenderCreateGlyphSet (ClientPtr pClient); -static int SProcRenderReferenceGlyphSet (ClientPtr pClient); -static int SProcRenderFreeGlyphSet (ClientPtr pClient); -static int SProcRenderAddGlyphs (ClientPtr pClient); -static int SProcRenderAddGlyphsFromPicture (ClientPtr pClient); -static int SProcRenderFreeGlyphs (ClientPtr pClient); -static int SProcRenderCompositeGlyphs (ClientPtr pClient); -static int SProcRenderFillRectangles (ClientPtr pClient); -static int SProcRenderCreateCursor (ClientPtr pClient); -static int SProcRenderSetPictureTransform (ClientPtr pClient); -static int SProcRenderQueryFilters (ClientPtr pClient); -static int SProcRenderSetPictureFilter (ClientPtr pClient); -static int SProcRenderCreateAnimCursor (ClientPtr pClient); -static int SProcRenderAddTraps (ClientPtr pClient); -static int SProcRenderCreateSolidFill (ClientPtr pClient); -static int SProcRenderCreateLinearGradient (ClientPtr pClient); -static int SProcRenderCreateRadialGradient (ClientPtr pClient); -static int SProcRenderCreateConicalGradient (ClientPtr pClient); - -static int SProcRenderDispatch (ClientPtr pClient); - -int (*ProcRenderVector[RenderNumberRequests])(ClientPtr) = { - ProcRenderQueryVersion, - ProcRenderQueryPictFormats, - ProcRenderQueryPictIndexValues, - ProcRenderQueryDithers, - ProcRenderCreatePicture, - ProcRenderChangePicture, - ProcRenderSetPictureClipRectangles, - ProcRenderFreePicture, - ProcRenderComposite, - ProcRenderScale, - ProcRenderTrapezoids, - ProcRenderTriangles, - ProcRenderTriStrip, - ProcRenderTriFan, - ProcRenderColorTrapezoids, - ProcRenderColorTriangles, - ProcRenderTransform, - ProcRenderCreateGlyphSet, - ProcRenderReferenceGlyphSet, - ProcRenderFreeGlyphSet, - ProcRenderAddGlyphs, - ProcRenderAddGlyphsFromPicture, - ProcRenderFreeGlyphs, - ProcRenderCompositeGlyphs, - ProcRenderCompositeGlyphs, - ProcRenderCompositeGlyphs, - ProcRenderFillRectangles, - ProcRenderCreateCursor, - ProcRenderSetPictureTransform, - ProcRenderQueryFilters, - ProcRenderSetPictureFilter, - ProcRenderCreateAnimCursor, - ProcRenderAddTraps, - ProcRenderCreateSolidFill, - ProcRenderCreateLinearGradient, - ProcRenderCreateRadialGradient, - ProcRenderCreateConicalGradient -}; - -int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { - SProcRenderQueryVersion, - SProcRenderQueryPictFormats, - SProcRenderQueryPictIndexValues, - SProcRenderQueryDithers, - SProcRenderCreatePicture, - SProcRenderChangePicture, - SProcRenderSetPictureClipRectangles, - SProcRenderFreePicture, - SProcRenderComposite, - SProcRenderScale, - SProcRenderTrapezoids, - SProcRenderTriangles, - SProcRenderTriStrip, - SProcRenderTriFan, - SProcRenderColorTrapezoids, - SProcRenderColorTriangles, - SProcRenderTransform, - SProcRenderCreateGlyphSet, - SProcRenderReferenceGlyphSet, - SProcRenderFreeGlyphSet, - SProcRenderAddGlyphs, - SProcRenderAddGlyphsFromPicture, - SProcRenderFreeGlyphs, - SProcRenderCompositeGlyphs, - SProcRenderCompositeGlyphs, - SProcRenderCompositeGlyphs, - SProcRenderFillRectangles, - SProcRenderCreateCursor, - SProcRenderSetPictureTransform, - SProcRenderQueryFilters, - SProcRenderSetPictureFilter, - SProcRenderCreateAnimCursor, - SProcRenderAddTraps, - SProcRenderCreateSolidFill, - SProcRenderCreateLinearGradient, - SProcRenderCreateRadialGradient, - SProcRenderCreateConicalGradient -}; - -static void -RenderResetProc (ExtensionEntry *extEntry); - -#if 0 -static CARD8 RenderReqCode; -#endif -int RenderErrBase; -int RenderClientPrivateIndex; - -typedef struct _RenderClient { - int major_version; - int minor_version; -} RenderClientRec, *RenderClientPtr; - -#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr) - -static void -RenderClientCallback (CallbackListPtr *list, - void * closure, - void * data) -{ - NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; - ClientPtr pClient = clientinfo->client; - RenderClientPtr pRenderClient = GetRenderClient (pClient); - - pRenderClient->major_version = 0; - pRenderClient->minor_version = 0; -} - -void -RenderExtensionInit (void) -{ - ExtensionEntry *extEntry; - - if (!PictureType) - return; - if (!PictureFinishInit ()) - return; - RenderClientPrivateIndex = AllocateClientPrivateIndex (); - if (!AllocateClientPrivate (RenderClientPrivateIndex, - sizeof (RenderClientRec))) - return; - if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0)) - return; - - extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors, - ProcRenderDispatch, SProcRenderDispatch, - RenderResetProc, StandardMinorOpcode); - if (!extEntry) - return; -#if 0 - RenderReqCode = (CARD8) extEntry->base; -#endif - RenderErrBase = extEntry->errorBase; -} - -static void -RenderResetProc (ExtensionEntry *extEntry) -{ - ResetPicturePrivateIndex(); - ResetGlyphSetPrivateIndex(); -} - static int ProcRenderQueryVersion (ClientPtr client) { @@ -408,43 +155,6 @@ ProcRenderQueryVersion (ClientPtr client) return (client->noClientException); } -#if 0 -static int -VisualDepth (ScreenPtr pScreen, VisualPtr pVisual) -{ - DepthPtr pDepth; - int d, v; - - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = pScreen->allowedDepths + d; - for (v = 0; v < pDepth->numVids; v++) - { - if (pDepth->vids[v] == pVisual->vid) - return pDepth->depth; - } - } - return 0; -} -#endif - -static VisualPtr -findVisual (ScreenPtr pScreen, VisualID vid) -{ - VisualPtr pVisual; - int v; - - for (v = 0; v < pScreen->numVisuals; v++) - { - pVisual = pScreen->visuals + v; - if (pVisual->vid == vid) - return pVisual; - } - return 0; -} - -extern char *ConnectionInfo; - static int ProcRenderQueryPictFormats (ClientPtr client) { @@ -656,76 +366,6 @@ ProcRenderQueryPictFormats (ClientPtr client) return client->noClientException; } -static int -ProcRenderQueryPictIndexValues (ClientPtr client) -{ - PictFormatPtr pFormat; - int num; - int rlength; - int i, n; - REQUEST(xRenderQueryPictIndexValuesReq); - xRenderQueryPictIndexValuesReply *reply; - xIndexValue *values; - - REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); - - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->format, - PictFormatType, - SecurityReadAccess); - - if (!pFormat) - { - client->errorValue = stuff->format; - return RenderErrBase + BadPictFormat; - } - if (pFormat->type != PictTypeIndexed) - { - client->errorValue = stuff->format; - return BadMatch; - } - num = pFormat->index.nvalues; - rlength = (sizeof (xRenderQueryPictIndexValuesReply) + - num * sizeof(xIndexValue)); - reply = (xRenderQueryPictIndexValuesReply *) xalloc (rlength); - if (!reply) - return BadAlloc; - - reply->type = X_Reply; - reply->sequenceNumber = client->sequence; - reply->length = (rlength - sizeof(xGenericReply)) >> 2; - reply->numIndexValues = num; - - values = (xIndexValue *) (reply + 1); - - memcpy (reply + 1, pFormat->index.pValues, num * sizeof (xIndexValue)); - - if (client->swapped) - { - for (i = 0; i < num; i++) - { - swapl (&values[i].pixel, n); - swaps (&values[i].red, n); - swaps (&values[i].green, n); - swaps (&values[i].blue, n); - swaps (&values[i].alpha, n); - } - swaps (&reply->sequenceNumber, n); - swapl (&reply->length, n); - swapl (&reply->numIndexValues, n); - } - - WriteToClient(client, rlength, (char *) reply); - xfree(reply); - return (client->noClientException); -} - -static int -ProcRenderQueryDithers (ClientPtr client) -{ - return BadImplementation; -} - static int ProcRenderCreatePicture (ClientPtr client) { @@ -836,33 +476,6 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) return(result); } -static int -ProcRenderFreePicture (ClientPtr client) -{ - PicturePtr pPicture; - REQUEST(xRenderFreePictureReq); - - REQUEST_SIZE_MATCH(xRenderFreePictureReq); - - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityDestroyAccess, - RenderErrBase + BadPicture); - - FreeResource (stuff->picture, RT_NONE); - return(client->noClientException); -} - -static Bool -PictOpValid (CARD8 op) -{ - if (/*PictOpMinimum <= op && */ op <= PictOpMaximum) - return TRUE; - if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum) - return TRUE; - if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum) - return TRUE; - return FALSE; -} - /* * Check if both pictures have drawables which are * virtual pixmaps. See the corresponding define @@ -948,13 +561,7 @@ ProcRenderComposite (ClientPtr client) RenderErrBase + BadPicture); VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess, RenderErrBase + BadPicture); -/* -FIXME: Imported change from newest version of Xorg. Changed pSrc to pDst. - if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || - (pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen)) - return BadMatch; -*/ if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || (pMask && pMask->pDrawable && pDst->pDrawable->pScreen != pMask->pDrawable->pScreen)) return BadMatch; @@ -1061,12 +668,6 @@ FIXME: Imported change from newest version of Xorg. Changed pSrc to pDst. return Success; } -static int -ProcRenderScale (ClientPtr client) -{ - return BadImplementation; -} - static int ProcRenderTrapezoids (ClientPtr client) { @@ -1138,165 +739,6 @@ ProcRenderTrapezoids (ClientPtr client) return client->noClientException; } -static int -ProcRenderTriangles (ClientPtr client) -{ - int ntris; - PicturePtr pSrc, pDst; - PictFormatPtr pFormat; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - if (!PictOpValid (stuff->op)) - { - client->errorValue = stuff->op; - return BadValue; - } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pDst->pDrawable) - return BadDrawable; - if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) - return BadMatch; - if (stuff->maskFormat) - { - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->maskFormat, - PictFormatType, - SecurityReadAccess); - if (!pFormat) - { - client->errorValue = stuff->maskFormat; - return RenderErrBase + BadPictFormat; - } - } - else - pFormat = 0; - ntris = (client->req_len << 2) - sizeof (xRenderTrianglesReq); - if (ntris % sizeof (xTriangle)) - return BadLength; - ntris /= sizeof (xTriangle); - if (ntris) - CompositeTriangles (stuff->op, pSrc, pDst, pFormat, - stuff->xSrc, stuff->ySrc, - ntris, (xTriangle *) &stuff[1]); - return client->noClientException; -} - -static int -ProcRenderTriStrip (ClientPtr client) -{ - int npoints; - PicturePtr pSrc, pDst; - PictFormatPtr pFormat; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - if (!PictOpValid (stuff->op)) - { - client->errorValue = stuff->op; - return BadValue; - } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pDst->pDrawable) - return BadDrawable; - if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) - return BadMatch; - if (stuff->maskFormat) - { - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->maskFormat, - PictFormatType, - SecurityReadAccess); - if (!pFormat) - { - client->errorValue = stuff->maskFormat; - return RenderErrBase + BadPictFormat; - } - } - else - pFormat = 0; - npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); - if (npoints & 4) - return(BadLength); - npoints >>= 3; - if (npoints >= 3) - CompositeTriStrip (stuff->op, pSrc, pDst, pFormat, - stuff->xSrc, stuff->ySrc, - npoints, (xPointFixed *) &stuff[1]); - return client->noClientException; -} - -static int -ProcRenderTriFan (ClientPtr client) -{ - int npoints; - PicturePtr pSrc, pDst; - PictFormatPtr pFormat; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - if (!PictOpValid (stuff->op)) - { - client->errorValue = stuff->op; - return BadValue; - } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pDst->pDrawable) - return BadDrawable; - if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) - return BadMatch; - if (stuff->maskFormat) - { - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->maskFormat, - PictFormatType, - SecurityReadAccess); - if (!pFormat) - { - client->errorValue = stuff->maskFormat; - return RenderErrBase + BadPictFormat; - } - } - else - pFormat = 0; - npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); - if (npoints & 4) - return(BadLength); - npoints >>= 3; - if (npoints >= 3) - CompositeTriFan (stuff->op, pSrc, pDst, pFormat, - stuff->xSrc, stuff->ySrc, - npoints, (xPointFixed *) &stuff[1]); - return client->noClientException; -} - -static int -ProcRenderColorTrapezoids (ClientPtr client) -{ - return BadImplementation; -} - -static int -ProcRenderColorTriangles (ClientPtr client) -{ - return BadImplementation; -} - -static int -ProcRenderTransform (ClientPtr client) -{ - return BadImplementation; -} - static int ProcRenderCreateGlyphSet (ClientPtr client) { @@ -1377,9 +819,6 @@ ProcRenderReferenceGlyphSet (ClientPtr client) return client->noClientException; } -#define NLOCALDELTA 64 -#define NLOCALGLYPH 256 - static int ProcRenderFreeGlyphSet (ClientPtr client) { @@ -1403,29 +842,16 @@ ProcRenderFreeGlyphSet (ClientPtr client) return client->noClientException; } -typedef struct _GlyphNew { - Glyph id; - GlyphPtr glyph; -} GlyphNewRec, *GlyphNewPtr; - static int -ProcRenderAddGlyphs (ClientPtr client) +ProcRenderFreeGlyphs (ClientPtr client) { + REQUEST(xRenderFreeGlyphsReq); GlyphSetPtr glyphSet; - REQUEST(xRenderAddGlyphsReq); - GlyphNewRec glyphsLocal[NLOCALGLYPH]; - GlyphNewPtr glyphsBase, glyphs; - GlyphPtr glyph = NULL; - int remain, nglyphs; + int nglyph; CARD32 *gids; - xGlyphInfo *gi; - CARD8 *bits; - int size; - int err = BadAlloc; - - int totSizeImages; + CARD32 glyph; - REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); + REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->glyphset, GlyphSetType, @@ -1435,126 +861,18 @@ ProcRenderAddGlyphs (ClientPtr client) client->errorValue = stuff->glyphset; return RenderErrBase + BadGlyphSet; } - - nglyphs = stuff->nglyphs; - if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec)) - return BadAlloc; - - if (nglyphs <= NLOCALGLYPH) - glyphsBase = glyphsLocal; - else - { - glyphsBase = (GlyphNewPtr) Xalloc (nglyphs * sizeof (GlyphNewRec)); - if (!glyphsBase) - return BadAlloc; - } - - remain = (client->req_len << 2) - sizeof (xRenderAddGlyphsReq); - - glyphs = glyphsBase; - - totSizeImages = 0; + nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2; gids = (CARD32 *) (stuff + 1); - gi = (xGlyphInfo *) (gids + nglyphs); - bits = (CARD8 *) (gi + nglyphs); - remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; - while (remain >= 0 && nglyphs) + nxagentFreeGlyphs(glyphSet, gids, nglyph); + + while (nglyph-- > 0) { - glyph = AllocateGlyph (gi, glyphSet->fdepth); - if (!glyph) + glyph = *gids++; + if (!DeleteGlyph (glyphSet, glyph)) { - err = BadAlloc; - goto bail; - } - - glyphs->glyph = glyph; - glyphs->id = *gids; - - size = glyph->size - sizeof (xGlyphInfo); - if (remain < size) - break; - memcpy ((CARD8 *) (glyph + 1), bits, size); - - if (size & 3) - size += 4 - (size & 3); - bits += size; - totSizeImages += size; - remain -= size; - gi++; - gids++; - glyphs++; - nglyphs--; - } - - if (nglyphs || remain) - { - err = BadLength; - goto bail; - } - nglyphs = stuff->nglyphs; - if (!ResizeGlyphSet (glyphSet, nglyphs)) - { - err = BadAlloc; - goto bail; - } - glyphs = glyphsBase; - while (nglyphs--) { - AddGlyph (glyphSet, glyphs->glyph, glyphs->id); - glyphs++; - } - - if (glyphsBase != glyphsLocal) - Xfree (glyphsBase); - return client->noClientException; -bail: - while (glyphs != glyphsBase) - { - --glyphs; - xfree (glyphs->glyph); - } - if (glyphsBase != glyphsLocal) - Xfree (glyphsBase); - return err; -} - -static int -ProcRenderAddGlyphsFromPicture (ClientPtr client) -{ - return BadImplementation; -} - -static int -ProcRenderFreeGlyphs (ClientPtr client) -{ - REQUEST(xRenderFreeGlyphsReq); - GlyphSetPtr glyphSet; - int nglyph; - CARD32 *gids; - CARD32 glyph; - - REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); - glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, - stuff->glyphset, - GlyphSetType, - SecurityWriteAccess); - if (!glyphSet) - { - client->errorValue = stuff->glyphset; - return RenderErrBase + BadGlyphSet; - } - nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2; - gids = (CARD32 *) (stuff + 1); - - nxagentFreeGlyphs(glyphSet, gids, nglyph); - - while (nglyph-- > 0) - { - glyph = *gids++; - if (!DeleteGlyph (glyphSet, glyph)) - { - client->errorValue = glyph; - return RenderErrBase + BadGlyph; + client->errorValue = glyph; + return RenderErrBase + BadGlyph; } } return client->noClientException; @@ -1866,32 +1184,6 @@ ProcRenderFillRectangles (ClientPtr client) return client->noClientException; } -static void -SetBit (unsigned char *line, int x, int bit) -{ - unsigned char mask; - - if (screenInfo.bitmapBitOrder == LSBFirst) - mask = (1 << (x & 7)); - else - mask = (0x80 >> (x & 7)); - /* XXX assumes byte order is host byte order */ - line += (x >> 3); - if (bit) - *line |= mask; - else - *line &= ~mask; -} - -#define DITHER_DIM 2 - -static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = { - { 1, 3, }, - { 4, 2, }, -}; - -#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) - static int ProcRenderCreateCursor (ClientPtr client) { @@ -2145,115 +1437,6 @@ ProcRenderSetPictureTransform (ClientPtr client) return(result); } -static int -ProcRenderQueryFilters (ClientPtr client) -{ - REQUEST (xRenderQueryFiltersReq); - DrawablePtr pDrawable; - xRenderQueryFiltersReply *reply; - int nbytesName; - int nnames; - ScreenPtr pScreen; - PictureScreenPtr ps; - int i, j; - int len; - int total_bytes; - INT16 *aliases; - char *names; - - REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); - SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, SecurityReadAccess); - - pScreen = pDrawable->pScreen; - nbytesName = 0; - nnames = 0; - ps = GetPictureScreenIfSet(pScreen); - if (ps) - { - for (i = 0; i < ps->nfilters; i++) - nbytesName += 1 + strlen (ps->filters[i].name); - for (i = 0; i < ps->nfilterAliases; i++) - nbytesName += 1 + strlen (ps->filterAliases[i].alias); - nnames = ps->nfilters + ps->nfilterAliases; - } - len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2); - total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2); - reply = (xRenderQueryFiltersReply *) xalloc (total_bytes); - if (!reply) - return BadAlloc; - aliases = (INT16 *) (reply + 1); - names = (char *) (aliases + ((nnames + 1) & ~1)); - - reply->type = X_Reply; - reply->sequenceNumber = client->sequence; - reply->length = len; - reply->numAliases = nnames; - reply->numFilters = nnames; - if (ps) - { - - /* fill in alias values */ - for (i = 0; i < ps->nfilters; i++) - aliases[i] = FilterAliasNone; - for (i = 0; i < ps->nfilterAliases; i++) - { - for (j = 0; j < ps->nfilters; j++) - if (ps->filterAliases[i].filter_id == ps->filters[j].id) - break; - if (j == ps->nfilters) - { - for (j = 0; j < ps->nfilterAliases; j++) - if (ps->filterAliases[i].filter_id == - ps->filterAliases[j].alias_id) - { - break; - } - if (j == ps->nfilterAliases) - j = FilterAliasNone; - else - j = j + ps->nfilters; - } - aliases[i + ps->nfilters] = j; - } - - /* fill in filter names */ - for (i = 0; i < ps->nfilters; i++) - { - j = strlen (ps->filters[i].name); - *names++ = j; - strncpy (names, ps->filters[i].name, j); - names += j; - } - - /* fill in filter alias names */ - for (i = 0; i < ps->nfilterAliases; i++) - { - j = strlen (ps->filterAliases[i].alias); - *names++ = j; - strncpy (names, ps->filterAliases[i].alias, j); - names += j; - } - } - - if (client->swapped) - { - register int n; - - for (i = 0; i < (int)reply->numAliases; i++) - { - swaps (&aliases[i], n); - } - swaps(&reply->sequenceNumber, n); - swapl(&reply->length, n); - swapl(&reply->numAliases, n); - swapl(&reply->numFilters, n); - } - WriteToClient(client, total_bytes, (char *) reply); - xfree (reply); - - return(client->noClientException); -} - static int ProcRenderSetPictureFilter (ClientPtr client) { @@ -2329,29 +1512,6 @@ ProcRenderCreateAnimCursor (ClientPtr client) return BadAlloc; } -static int -ProcRenderAddTraps (ClientPtr client) -{ - int ntraps; - PicturePtr pPicture; - REQUEST(xRenderAddTrapsReq); - - REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pPicture->pDrawable) - return BadDrawable; - ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); - if (ntraps % sizeof (xTrap)) - return BadLength; - ntraps /= sizeof (xTrap); - if (ntraps) - AddTraps (pPicture, - stuff->xOff, stuff->yOff, - ntraps, (xTrap *) &stuff[1]); - return client->noClientException; -} - static int ProcRenderCreateSolidFill(ClientPtr client) { PicturePtr pPicture; @@ -2530,1348 +1690,38 @@ ProcRenderDispatch (ClientPtr client) } static int -SProcRenderQueryVersion (ClientPtr client) -{ - register int n; - REQUEST(xRenderQueryVersionReq); - REQUEST_SIZE_MATCH(xRenderQueryVersionReq); - - swaps(&stuff->length, n); - swapl(&stuff->majorVersion, n); - swapl(&stuff->minorVersion, n); - return (*ProcRenderVector[stuff->renderReqType])(client); -} - -static int -SProcRenderQueryPictFormats (ClientPtr client) -{ - register int n; - REQUEST(xRenderQueryPictFormatsReq); - REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); - swaps(&stuff->length, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderQueryPictIndexValues (ClientPtr client) -{ - register int n; - REQUEST(xRenderQueryPictIndexValuesReq); - REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); - swaps(&stuff->length, n); - swapl(&stuff->format, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderQueryDithers (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderCreatePicture (ClientPtr client) -{ - register int n; - REQUEST(xRenderCreatePictureReq); - REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->drawable, n); - swapl(&stuff->format, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderChangePicture (ClientPtr client) -{ - register int n; - REQUEST(xRenderChangePictureReq); - REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderSetPictureClipRectangles (ClientPtr client) -{ - register int n; - REQUEST(xRenderSetPictureClipRectanglesReq); - REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - SwapRestS(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderFreePicture (ClientPtr client) -{ - register int n; - REQUEST(xRenderFreePictureReq); - REQUEST_SIZE_MATCH(xRenderFreePictureReq); - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderComposite (ClientPtr client) -{ - register int n; - REQUEST(xRenderCompositeReq); - REQUEST_SIZE_MATCH(xRenderCompositeReq); - swaps(&stuff->length, n); - swapl(&stuff->src, n); - swapl(&stuff->mask, n); - swapl(&stuff->dst, n); - swaps(&stuff->xSrc, n); - swaps(&stuff->ySrc, n); - swaps(&stuff->xMask, n); - swaps(&stuff->yMask, n); - swaps(&stuff->xDst, n); - swaps(&stuff->yDst, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderScale (ClientPtr client) -{ - register int n; - REQUEST(xRenderScaleReq); - REQUEST_SIZE_MATCH(xRenderScaleReq); - swaps(&stuff->length, n); - swapl(&stuff->src, n); - swapl(&stuff->dst, n); - swapl(&stuff->colorScale, n); - swapl(&stuff->alphaScale, n); - swaps(&stuff->xSrc, n); - swaps(&stuff->ySrc, n); - swaps(&stuff->xDst, n); - swaps(&stuff->yDst, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTrapezoids (ClientPtr client) -{ - register int n; - REQUEST(xRenderTrapezoidsReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTriangles (ClientPtr client) -{ - register int n; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTriStrip (ClientPtr client) -{ - register int n; - REQUEST(xRenderTriStripReq); - - REQUEST_AT_LEAST_SIZE(xRenderTriStripReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTriFan (ClientPtr client) -{ - register int n; - REQUEST(xRenderTriFanReq); - - REQUEST_AT_LEAST_SIZE(xRenderTriFanReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderColorTrapezoids (ClientPtr client) +SProcRenderDispatch (ClientPtr client) { - return BadImplementation; -} + int result; -static int -SProcRenderColorTriangles (ClientPtr client) -{ - return BadImplementation; -} + REQUEST(xReq); + + /* + * Let the client fail if we are + * hiding the RENDER extension. + */ + + if (nxagentRenderTrap) + { + return BadRequest; + } -static int -SProcRenderTransform (ClientPtr client) -{ - return BadImplementation; -} + if (stuff->data < RenderNumberRequests) + { + /* + * Set the nxagentGCTrap flag while + * dispatching a render operation to + * avoid reentrancy in GCOps.c. + */ -static int -SProcRenderCreateGlyphSet (ClientPtr client) -{ - register int n; - REQUEST(xRenderCreateGlyphSetReq); - REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); - swaps(&stuff->length, n); - swapl(&stuff->gsid, n); - swapl(&stuff->format, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} + nxagentGCTrap = 1; -static int -SProcRenderReferenceGlyphSet (ClientPtr client) -{ - register int n; - REQUEST(xRenderReferenceGlyphSetReq); - REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); - swaps(&stuff->length, n); - swapl(&stuff->gsid, n); - swapl(&stuff->existing, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} + result = (*SProcRenderVector[stuff->data]) (client); -static int -SProcRenderFreeGlyphSet (ClientPtr client) -{ - register int n; - REQUEST(xRenderFreeGlyphSetReq); - REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); - swaps(&stuff->length, n); - swapl(&stuff->glyphset, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} + nxagentGCTrap = 0; -static int -SProcRenderAddGlyphs (ClientPtr client) -{ - register int n; - register unsigned int i; - CARD32 *gids; - void *end; - xGlyphInfo *gi; - REQUEST(xRenderAddGlyphsReq); - REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); - swaps(&stuff->length, n); - swapl(&stuff->glyphset, n); - swapl(&stuff->nglyphs, n); - if (stuff->nglyphs & 0xe0000000) - return BadLength; - end = (CARD8 *) stuff + (client->req_len << 2); - gids = (CARD32 *) (stuff + 1); - gi = (xGlyphInfo *) (gids + stuff->nglyphs); - if ((char *) end - (char *) (gids + stuff->nglyphs) < 0) - return BadLength; - if ((char *) end - (char *) (gi + stuff->nglyphs) < 0) - return BadLength; - for (i = 0; i < stuff->nglyphs; i++) - { - swapl (&gids[i], n); - swaps (&gi[i].width, n); - swaps (&gi[i].height, n); - swaps (&gi[i].x, n); - swaps (&gi[i].y, n); - swaps (&gi[i].xOff, n); - swaps (&gi[i].yOff, n); - } - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderAddGlyphsFromPicture (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderFreeGlyphs (ClientPtr client) -{ - register int n; - REQUEST(xRenderFreeGlyphsReq); - REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); - swaps(&stuff->length, n); - swapl(&stuff->glyphset, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCompositeGlyphs (ClientPtr client) -{ - register int n; - xGlyphElt *elt; - CARD8 *buffer; - CARD8 *end; - int space; - int i; - int size; - - REQUEST(xRenderCompositeGlyphsReq); - REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); - - switch (stuff->renderReqType) { - default: size = 1; break; - case X_RenderCompositeGlyphs16: size = 2; break; - case X_RenderCompositeGlyphs32: size = 4; break; - } - - swaps(&stuff->length, n); - swapl(&stuff->src, n); - swapl(&stuff->dst, n); - swapl(&stuff->maskFormat, n); - swapl(&stuff->glyphset, n); - swaps(&stuff->xSrc, n); - swaps(&stuff->ySrc, n); - buffer = (CARD8 *) (stuff + 1); - end = (CARD8 *) stuff + (client->req_len << 2); - while (buffer + sizeof (xGlyphElt) < end) - { - elt = (xGlyphElt *) buffer; - buffer += sizeof (xGlyphElt); - - swaps (&elt->deltax, n); - swaps (&elt->deltay, n); - - i = elt->len; - if (i == 0xff) - { - swapl (buffer, n); - buffer += 4; - } - else - { - space = size * i; - switch (size) { - case 1: - buffer += i; - break; - case 2: - while (i--) - { - swaps (buffer, n); - buffer += 2; - } - break; - case 4: - while (i--) - { - swapl (buffer, n); - buffer += 4; - } - break; - } - if (space & 3) - buffer += 4 - (space & 3); - } - } - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderFillRectangles (ClientPtr client) -{ - register int n; - REQUEST(xRenderFillRectanglesReq); - - REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); - swaps(&stuff->length, n); - swapl(&stuff->dst, n); - swaps(&stuff->color.red, n); - swaps(&stuff->color.green, n); - swaps(&stuff->color.blue, n); - swaps(&stuff->color.alpha, n); - SwapRestS(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateCursor (ClientPtr client) -{ - register int n; - REQUEST(xRenderCreateCursorReq); - REQUEST_SIZE_MATCH (xRenderCreateCursorReq); - - swaps(&stuff->length, n); - swapl(&stuff->cid, n); - swapl(&stuff->src, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderSetPictureTransform (ClientPtr client) -{ - register int n; - REQUEST(xRenderSetPictureTransformReq); - REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); - - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swapl(&stuff->transform.matrix11, n); - swapl(&stuff->transform.matrix12, n); - swapl(&stuff->transform.matrix13, n); - swapl(&stuff->transform.matrix21, n); - swapl(&stuff->transform.matrix22, n); - swapl(&stuff->transform.matrix23, n); - swapl(&stuff->transform.matrix31, n); - swapl(&stuff->transform.matrix32, n); - swapl(&stuff->transform.matrix33, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderQueryFilters (ClientPtr client) -{ - register int n; - REQUEST (xRenderQueryFiltersReq); - REQUEST_SIZE_MATCH (xRenderQueryFiltersReq); - - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderSetPictureFilter (ClientPtr client) -{ - register int n; - REQUEST (xRenderSetPictureFilterReq); - REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq); - - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swaps(&stuff->nbytes, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateAnimCursor (ClientPtr client) -{ - register int n; - REQUEST (xRenderCreateAnimCursorReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateAnimCursorReq); - - swaps(&stuff->length, n); - swapl(&stuff->cid, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderAddTraps (ClientPtr client) -{ - register int n; - REQUEST (xRenderAddTrapsReq); - REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); - - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swaps(&stuff->xOff, n); - swaps(&stuff->yOff, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateSolidFill(ClientPtr client) -{ - register int n; - REQUEST (xRenderCreateSolidFillReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateSolidFillReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swaps(&stuff->color.alpha, n); - swaps(&stuff->color.red, n); - swaps(&stuff->color.green, n); - swaps(&stuff->color.blue, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static void swapStops(void *stuff, int num) -{ - int i, n; - CARD32 *stops; - stops = (CARD32 *)(stuff); - for (i = 0; i < num; ++i) { - swapl(stops, n); - ++stops; - } - for (i = 0; i < 4*num; ++i) { - swaps(stops, n); - ++stops; - } -} - -static int -SProcRenderCreateLinearGradient (ClientPtr client) -{ - register int n; - int len; - REQUEST (xRenderCreateLinearGradientReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateLinearGradientReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->p1.x, n); - swapl(&stuff->p1.y, n); - swapl(&stuff->p2.x, n); - swapl(&stuff->p2.y, n); - swapl(&stuff->nStops, n); - - len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - swapStops(stuff+1, stuff->nStops); - - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateRadialGradient (ClientPtr client) -{ - register int n; - int len; - REQUEST (xRenderCreateRadialGradientReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateRadialGradientReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->inner.x, n); - swapl(&stuff->inner.y, n); - swapl(&stuff->outer.x, n); - swapl(&stuff->outer.y, n); - swapl(&stuff->inner_radius, n); - swapl(&stuff->outer_radius, n); - swapl(&stuff->nStops, n); - - len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - swapStops(stuff+1, stuff->nStops); - - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateConicalGradient (ClientPtr client) -{ - register int n; - int len; - REQUEST (xRenderCreateConicalGradientReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateConicalGradientReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->center.x, n); - swapl(&stuff->center.y, n); - swapl(&stuff->angle, n); - swapl(&stuff->nStops, n); - - len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - swapStops(stuff+1, stuff->nStops); - - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderDispatch (ClientPtr client) -{ - int result; - - REQUEST(xReq); - - /* - * Let the client fail if we are - * hiding the RENDER extension. - */ - - if (nxagentRenderTrap) - { - return BadRequest; - } - - if (stuff->data < RenderNumberRequests) - { - /* - * Set the nxagentGCTrap flag while - * dispatching a render operation to - * avoid reentrancy in GCOps.c. - */ - - nxagentGCTrap = 1; - - result = (*SProcRenderVector[stuff->data]) (client); - - nxagentGCTrap = 0; - - return result; + return result; } else return BadRequest; } - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" - -#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\ - pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\ - if (!pPicture) { \ - client->errorValue = pid; \ - return err; \ - } \ -} - -#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\ - if (pid == None) \ - pPicture = 0; \ - else { \ - VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err); \ - } \ -} \ - -int (*PanoramiXSaveRenderVector[RenderNumberRequests])(ClientPtr); - -unsigned long XRT_PICTURE; - -static int -PanoramiXRenderCreatePicture (ClientPtr client) -{ - REQUEST(xRenderCreatePictureReq); - PanoramiXRes *refDraw, *newPict; - int result = Success, j; - - REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); - if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) - return BadAlloc; - newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; - - if (refDraw->type == XRT_WINDOW && - stuff->drawable == screenInfo.screens[0]->root->drawable.id) - { - newPict->u.pict.root = TRUE; - } - else - newPict->u.pict.root = FALSE; - - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); - - FOR_NSCREENS_BACKWARD(j) { - stuff->pid = newPict->info[j].id; - stuff->drawable = refDraw->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newPict->info[0].id, XRT_PICTURE, newPict); - else - xfree(newPict); - - return (result); -} - -static int -PanoramiXRenderChangePicture (ClientPtr client) -{ - PanoramiXRes *pict; - int result = Success, j; - REQUEST(xRenderChangePictureReq); - - REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderSetPictureClipRectangles (ClientPtr client) -{ - REQUEST(xRenderSetPictureClipRectanglesReq); - int result = Success, j; - PanoramiXRes *pict; - - REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderSetPictureTransform (ClientPtr client) -{ - REQUEST(xRenderSetPictureTransformReq); - int result = Success, j; - PanoramiXRes *pict; - - REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderSetPictureFilter (ClientPtr client) -{ - REQUEST(xRenderSetPictureFilterReq); - int result = Success, j; - PanoramiXRes *pict; - - REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderFreePicture (ClientPtr client) -{ - PanoramiXRes *pict; - int result = Success, j; - REQUEST(xRenderFreePictureReq); - - REQUEST_SIZE_MATCH(xRenderFreePictureReq); - - client->errorValue = stuff->picture; - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityDestroyAccess, - RenderErrBase + BadPicture); - - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client); - if(result != Success) break; - } - - /* Since ProcRenderFreePicture is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - - return (result); -} - -static int -PanoramiXRenderComposite (ClientPtr client) -{ - PanoramiXRes *src, *msk, *dst; - int result = Success, j; - xRenderCompositeReq orig; - REQUEST(xRenderCompositeReq); - - REQUEST_SIZE_MATCH(xRenderCompositeReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_ALPHA (msk, stuff->mask, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - orig = *stuff; - - FOR_NSCREENS_FORWARD(j) { - stuff->src = src->info[j].id; - if (src->u.pict.root) - { - stuff->xSrc = orig.xSrc - panoramiXdataPtr[j].x; - stuff->ySrc = orig.ySrc - panoramiXdataPtr[j].y; - } - stuff->dst = dst->info[j].id; - if (dst->u.pict.root) - { - stuff->xDst = orig.xDst - panoramiXdataPtr[j].x; - stuff->yDst = orig.yDst - panoramiXdataPtr[j].y; - } - if (msk) - { - stuff->mask = msk->info[j].id; - if (msk->u.pict.root) - { - stuff->xMask = orig.xMask - panoramiXdataPtr[j].x; - stuff->yMask = orig.yMask - panoramiXdataPtr[j].y; - } - } - result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client); - if(result != Success) break; - } - - return result; -} - -static int -PanoramiXRenderCompositeGlyphs (ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderCompositeGlyphsReq); - xGlyphElt origElt, *elt; - INT16 xSrc, ySrc; - - REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) + - sizeof (xGlyphElt))) - { - elt = (xGlyphElt *) (stuff + 1); - origElt = *elt; - xSrc = stuff->xSrc; - ySrc = stuff->ySrc; - FOR_NSCREENS_FORWARD(j) { - stuff->src = src->info[j].id; - if (src->u.pict.root) - { - stuff->xSrc = xSrc - panoramiXdataPtr[j].x; - stuff->ySrc = ySrc - panoramiXdataPtr[j].y; - } - stuff->dst = dst->info[j].id; - if (dst->u.pict.root) - { - elt->deltax = origElt.deltax - panoramiXdataPtr[j].x; - elt->deltay = origElt.deltay - panoramiXdataPtr[j].y; - } - result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client); - if(result != Success) break; - } - } - - return result; -} - -static int -PanoramiXRenderFillRectangles (ClientPtr client) -{ - PanoramiXRes *dst; - int result = Success, j; - REQUEST(xRenderFillRectanglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq); - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) - { - memcpy (extra, stuff + 1, extra_len); - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) - { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xRectangle *rects = (xRectangle *) (stuff + 1); - int i = extra_len / sizeof (xRectangle); - - while (i--) - { - rects->x -= x_off; - rects->y -= y_off; - rects++; - } - } - } - stuff->dst = dst->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client); - if(result != Success) break; - } - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTrapezoids(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTrapezoidsReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xTrapezoid *trap = (xTrapezoid *) (stuff + 1); - int i = extra_len / sizeof (xTrapezoid); - - while (i--) { - trap->top -= y_off; - trap->bottom -= y_off; - trap->left.p1.x -= x_off; - trap->left.p1.y -= y_off; - trap->left.p2.x -= x_off; - trap->left.p2.y -= y_off; - trap->right.p1.x -= x_off; - trap->right.p1.y -= y_off; - trap->right.p2.x -= x_off; - trap->right.p2.y -= y_off; - trap++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTriangles(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTrianglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xTriangle *tri = (xTriangle *) (stuff + 1); - int i = extra_len / sizeof (xTriangle); - - while (i--) { - tri->p1.x -= x_off; - tri->p1.y -= y_off; - tri->p2.x -= x_off; - tri->p2.y -= y_off; - tri->p3.x -= x_off; - tri->p3.y -= y_off; - tri++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTriStrip(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTriStripReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTriStripReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xPointFixed *fixed = (xPointFixed *) (stuff + 1); - int i = extra_len / sizeof (xPointFixed); - - while (i--) { - fixed->x -= x_off; - fixed->y -= y_off; - fixed++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTriFan(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTriFanReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTriFanReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xPointFixed *fixed = (xPointFixed *) (stuff + 1); - int i = extra_len / sizeof (xPointFixed); - - while (i--) { - fixed->x -= x_off; - fixed->y -= y_off; - fixed++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -#if 0 /* Not implemented yet */ - -static int -PanoramiXRenderColorTrapezoids(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderColorTrapezoidsReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq); - - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - ....; - } - } - - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderColorTrapezoids]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderColorTriangles(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderColorTrianglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq); - - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - ....; - } - } - - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderColorTriangles]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -#endif - -static int -PanoramiXRenderAddTraps (ClientPtr client) -{ - PanoramiXRes *picture; - int result = Success, j; - REQUEST(xRenderAddTrapsReq); - char *extra; - int extra_len; - INT16 x_off, y_off; - - REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); - VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) - { - memcpy (extra, stuff + 1, extra_len); - x_off = stuff->xOff; - y_off = stuff->yOff; - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - stuff->picture = picture->info[j].id; - - if (picture->u.pict.root) - { - stuff->xOff = x_off + panoramiXdataPtr[j].x; - stuff->yOff = y_off + panoramiXdataPtr[j].y; - } - result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client); - if(result != Success) break; - } - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -void -PanoramiXRenderInit (void) -{ - int i; - - XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource); - for (i = 0; i < RenderNumberRequests; i++) - PanoramiXSaveRenderVector[i] = ProcRenderVector[i]; - /* - * Stuff in Xinerama aware request processing hooks - */ - ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture; - ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture; - ProcRenderVector[X_RenderSetPictureTransform] = PanoramiXRenderSetPictureTransform; - ProcRenderVector[X_RenderSetPictureFilter] = PanoramiXRenderSetPictureFilter; - ProcRenderVector[X_RenderSetPictureClipRectangles] = PanoramiXRenderSetPictureClipRectangles; - ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture; - ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite; - ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs; - ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs; - ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs; - ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles; - - ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids; - ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles; - ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip; - ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan; - ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps; -} - -void -PanoramiXRenderReset (void) -{ - int i; - for (i = 0; i < RenderNumberRequests; i++) - ProcRenderVector[i] = PanoramiXSaveRenderVector[i]; -} - -#endif /* PANORAMIX */ - diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index f39e74830..a8eab5149 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -9,11 +9,13 @@ NXAGENT_SKIP_SRCS = \ miglyph.c \ mitrap.c \ picture.c \ + render.c \ $(NULL) NXAGENT_SKIP_OBJS = \ miglyph.o \ mitrap.o \ picture.o \ + render.o \ $(NULL) #else DEFINES = -DNXAGENT_SERVER @@ -27,7 +29,6 @@ NXAGENT_SKIP_OBJS = \ mipict.c \ mirect.c \ mitri.c \ - render.c \ renderedge.c \ $(NXAGENT_SKIP_SRCS) \ $(NULL) @@ -40,7 +41,6 @@ NXAGENT_SKIP_OBJS = \ mipict.o \ mirect.o \ mitri.o \ - render.o \ renderedge.o \ $(NXAGENT_SKIP_OBJS) \ $(NULL) diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c index b165cf549..3c14ac0e7 100644 --- a/nx-X11/programs/Xserver/render/render.c +++ b/nx-X11/programs/Xserver/render/render.c @@ -275,6 +275,7 @@ RenderResetProc (ExtensionEntry *extEntry) ResetGlyphSetPrivateIndex(); } +#ifndef NXAGENT_SERVER static int ProcRenderQueryVersion (ClientPtr client) { @@ -303,6 +304,7 @@ ProcRenderQueryVersion (ClientPtr client) WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep); return (client->noClientException); } +#endif /* NXAGENT_SERVER */ #if 0 static int @@ -341,6 +343,7 @@ findVisual (ScreenPtr pScreen, VisualID vid) extern char *ConnectionInfo; +#ifndef NXAGENT_SERVER static int ProcRenderQueryPictFormats (ClientPtr client) { @@ -550,6 +553,7 @@ ProcRenderQueryPictFormats (ClientPtr client) xfree (reply); return client->noClientException; } +#endif /* NXAGENT_SERVER */ static int ProcRenderQueryPictIndexValues (ClientPtr client) @@ -621,6 +625,7 @@ ProcRenderQueryDithers (ClientPtr client) return BadImplementation; } +#ifndef NXAGENT_SERVER static int ProcRenderCreatePicture (ClientPtr client) { @@ -710,6 +715,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) else return(result); } +#endif /* NXAGENT_SERVER */ static int ProcRenderFreePicture (ClientPtr client) @@ -737,6 +743,7 @@ PictOpValid (CARD8 op) return FALSE; } +#ifndef NXAGENT_SERVER static int ProcRenderComposite (ClientPtr client) { @@ -774,6 +781,7 @@ ProcRenderComposite (ClientPtr client) stuff->height); return Success; } +#endif /* NXAGENT_SERVER */ static int ProcRenderScale (ClientPtr client) @@ -781,6 +789,7 @@ ProcRenderScale (ClientPtr client) return BadImplementation; } +#ifndef NXAGENT_SERVER static int ProcRenderTrapezoids (ClientPtr client) { @@ -827,6 +836,7 @@ ProcRenderTrapezoids (ClientPtr client) ntraps, (xTrapezoid *) &stuff[1]); return client->noClientException; } +#endif /* NXAGENT_SERVER */ static int ProcRenderTriangles (ClientPtr client) @@ -987,6 +997,7 @@ ProcRenderTransform (ClientPtr client) return BadImplementation; } +#ifndef NXAGENT_SERVER static int ProcRenderCreateGlyphSet (ClientPtr client) { @@ -1060,10 +1071,12 @@ ProcRenderReferenceGlyphSet (ClientPtr client) return BadAlloc; return client->noClientException; } +#endif /* NXAGENT_SERVER */ #define NLOCALDELTA 64 #define NLOCALGLYPH 256 +#ifndef NXAGENT_SERVER static int ProcRenderFreeGlyphSet (ClientPtr client) { @@ -1083,6 +1096,7 @@ ProcRenderFreeGlyphSet (ClientPtr client) FreeResource (stuff->glyphset, RT_NONE); return client->noClientException; } +#endif /* NXAGENT_SERVER */ typedef struct _GlyphNew { Glyph id; @@ -1096,7 +1110,7 @@ ProcRenderAddGlyphs (ClientPtr client) REQUEST(xRenderAddGlyphsReq); GlyphNewRec glyphsLocal[NLOCALGLYPH]; GlyphNewPtr glyphsBase, glyphs; - GlyphPtr glyph; + GlyphPtr glyph = NULL; int remain, nglyphs; CARD32 *gids; xGlyphInfo *gi; @@ -1199,6 +1213,7 @@ ProcRenderAddGlyphsFromPicture (ClientPtr client) return BadImplementation; } +#ifndef NXAGENT_SERVER static int ProcRenderFreeGlyphs (ClientPtr client) { @@ -1454,6 +1469,7 @@ ProcRenderFillRectangles (ClientPtr client) return client->noClientException; } +#endif /* NXAGENT_SERVER */ static void SetBit (unsigned char *line, int x, int bit) @@ -1481,6 +1497,7 @@ static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = { #define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) +#ifndef NXAGENT_SERVER static int ProcRenderCreateCursor (ClientPtr client) { @@ -1694,6 +1711,7 @@ ProcRenderSetPictureTransform (ClientPtr client) else return(result); } +#endif /* NXAGENT_SERVER */ static int ProcRenderQueryFilters (ClientPtr client) @@ -1804,6 +1822,7 @@ ProcRenderQueryFilters (ClientPtr client) return(client->noClientException); } +#ifndef NXAGENT_SERVER static int ProcRenderSetPictureFilter (ClientPtr client) { @@ -1868,6 +1887,7 @@ ProcRenderCreateAnimCursor (ClientPtr client) return client->noClientException; return BadAlloc; } +#endif /* NXAGENT_SERVER */ static int ProcRenderAddTraps (ClientPtr client) @@ -1892,6 +1912,7 @@ ProcRenderAddTraps (ClientPtr client) return client->noClientException; } +#ifndef NXAGENT_SERVER static int ProcRenderCreateSolidFill(ClientPtr client) { PicturePtr pPicture; @@ -2011,6 +2032,7 @@ ProcRenderDispatch (ClientPtr client) else return BadRequest; } +#endif /* NXAGENT_SERVER */ static int SProcRenderQueryVersion (ClientPtr client) @@ -2611,6 +2633,7 @@ SProcRenderCreateConicalGradient (ClientPtr client) return (*ProcRenderVector[stuff->renderReqType]) (client); } +#ifndef NXAGENT_SERVER static int SProcRenderDispatch (ClientPtr client) { @@ -2621,6 +2644,7 @@ SProcRenderDispatch (ClientPtr client) else return BadRequest; } +#endif /* NXAGENT_SERVER */ #ifdef PANORAMIX #include "panoramiX.h" -- cgit v1.2.3 From 0571ece6a4ea66b4d558b3f6d0dc1d81b47c799b Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 18 Apr 2016 08:19:05 +0200 Subject: hw/nxagent/NXglyph.c: Shrink file, drop duplicate code that can identically be found in render/glyph.c. --- nx-X11/programs/Xserver/hw/nxagent/NXglyph.c | 395 +-------------------------- nx-X11/programs/Xserver/render/Imakefile | 2 + nx-X11/programs/Xserver/render/glyph.c | 7 + 3 files changed, 10 insertions(+), 394 deletions(-) (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index b5f1e8ac0..4359a552b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -40,27 +40,10 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" +#include "../../render/glyph.c" #ifdef NXAGENT_SERVER -#include "picturestr.h" #include "Render.h" #define PANIC @@ -68,239 +51,8 @@ #undef DEBUG #undef TEST -#else - -#include "picturestr.h" - -#endif - -#include "glyphstr.h" - -#include - -/* - * From Knuth -- a good choice for hash/rehash values is p, p-2 where - * p and p-2 are both prime. These tables are sized to have an extra 10% - * free to avoid exponential performance degradation as the hash table fills - */ -static GlyphHashSetRec glyphHashSets[] = { - { 32, 43, 41 }, - { 64, 73, 71 }, - { 128, 151, 149 }, - { 256, 283, 281 }, - { 512, 571, 569 }, - { 1024, 1153, 1151 }, - { 2048, 2269, 2267 }, - { 4096, 4519, 4517 }, - { 8192, 9013, 9011 }, - { 16384, 18043, 18041 }, - { 32768, 36109, 36107 }, - { 65536, 72091, 72089 }, - { 131072, 144409, 144407 }, - { 262144, 288361, 288359 }, - { 524288, 576883, 576881 }, - { 1048576, 1153459, 1153457 }, - { 2097152, 2307163, 2307161 }, - { 4194304, 4613893, 4613891 }, - { 8388608, 9227641, 9227639 }, - { 16777216, 18455029, 18455027 }, - { 33554432, 36911011, 36911009 }, - { 67108864, 73819861, 73819859 }, - { 134217728, 147639589, 147639587 }, - { 268435456, 295279081, 295279079 }, - { 536870912, 590559793, 590559791 } -}; - -#define NGLYPHHASHSETS (sizeof(glyphHashSets)/sizeof(glyphHashSets[0])) - -const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 }; - -GlyphHashRec globalGlyphs[GlyphFormatNum]; - -GlyphHashSetPtr -FindGlyphHashSet (CARD32 filled) -{ - int i; - - for (i = 0; i < NGLYPHHASHSETS; i++) - if (glyphHashSets[i].entries >= filled) - return &glyphHashSets[i]; - return 0; -} - -static int _GlyphSetPrivateAllocateIndex = 0; - -int -AllocateGlyphSetPrivateIndex (void) -{ - return _GlyphSetPrivateAllocateIndex++; -} - -void -ResetGlyphSetPrivateIndex (void) -{ - _GlyphSetPrivateAllocateIndex = 0; -} - -Bool -_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr) -{ - void **new; - - if (n > glyphSet->maxPrivate) { - if (glyphSet->devPrivates && - glyphSet->devPrivates != (void *)(&glyphSet[1])) { - new = (void **) xrealloc (glyphSet->devPrivates, - (n + 1) * sizeof (void *)); - if (!new) - return FALSE; - } else { - new = (void **) xalloc ((n + 1) * sizeof (void *)); - if (!new) - return FALSE; - if (glyphSet->devPrivates) - memcpy (new, - glyphSet->devPrivates, - (glyphSet->maxPrivate + 1) * sizeof (void *)); - } - glyphSet->devPrivates = new; - /* Zero out new, uninitialize privates */ - while (++glyphSet->maxPrivate < n) - glyphSet->devPrivates[glyphSet->maxPrivate] = (void *)0; - } - glyphSet->devPrivates[n] = ptr; - return TRUE; -} - -Bool -GlyphInit (ScreenPtr pScreen) -{ - return TRUE; -} - -GlyphRefPtr -FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) -{ - CARD32 elt, step, s; - GlyphPtr glyph; - GlyphRefPtr table, gr, del; - CARD32 tableSize = hash->hashSet->size; - - table = hash->table; - elt = signature % tableSize; - step = 0; - del = 0; - for (;;) - { - gr = &table[elt]; - s = gr->signature; - glyph = gr->glyph; - if (!glyph) - { - if (del) - gr = del; - break; - } - if (glyph == DeletedGlyph) - { - if (!del) - del = gr; - else if (gr == del) - break; - } - else if (s == signature && - (!match || - memcmp (&compare->info, &glyph->info, compare->size) == 0)) - { - break; - } - if (!step) - { - step = signature % hash->hashSet->rehash; - if (!step) - step = 1; - } - elt += step; - if (elt >= tableSize) - elt -= tableSize; - } - return gr; -} - -CARD32 -HashGlyph (GlyphPtr glyph) -{ - CARD32 *bits = (CARD32 *) &(glyph->info); - CARD32 hash; - int n = glyph->size / sizeof (CARD32); - - hash = 0; - while (n--) - hash ^= *bits++; - return hash; -} - -#ifdef CHECK_DUPLICATES -void -DuplicateRef (GlyphPtr glyph, char *where) -{ - ErrorF ("Duplicate Glyph 0x%x from %s\n", glyph, where); -} - -void -CheckDuplicates (GlyphHashPtr hash, char *where) -{ - GlyphPtr g; - int i, j; - - for (i = 0; i < hash->hashSet->size; i++) - { - g = hash->table[i].glyph; - if (!g || g == DeletedGlyph) - continue; - for (j = i + 1; j < hash->hashSet->size; j++) - if (hash->table[j].glyph == g) - DuplicateRef (g, where); - } -} -#else -#define CheckDuplicates(a,b) -#define DuplicateRef(a,b) #endif -void -FreeGlyph (GlyphPtr glyph, int format) -{ - CheckDuplicates (&globalGlyphs[format], "FreeGlyph"); - if (--glyph->refcnt == 0) - { - GlyphRefPtr gr; - int i; - int first; - - first = -1; - for (i = 0; i < globalGlyphs[format].hashSet->size; i++) - if (globalGlyphs[format].table[i].glyph == glyph) - { - if (first != -1) - DuplicateRef (glyph, "FreeGlyph check"); - first = i; - } - - gr = FindGlyphRef (&globalGlyphs[format], - HashGlyph (glyph), TRUE, glyph); - if (gr - globalGlyphs[format].table != first) - DuplicateRef (glyph, "Found wrong one"); - if (gr->glyph && gr->glyph != DeletedGlyph) - { - gr->glyph = DeletedGlyph; - gr->signature = 0; - globalGlyphs[format].tableEntries--; - } - xfree (glyph); - } -} - void AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) { @@ -342,26 +94,6 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom"); } -Bool -DeleteGlyph (GlyphSetPtr glyphSet, Glyph id) -{ - GlyphRefPtr gr; - GlyphPtr glyph; - - gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0); - glyph = gr->glyph; - if (glyph && glyph != DeletedGlyph) - { - gr->glyph = DeletedGlyph; - glyphSet->hash.tableEntries--; - FreeGlyph (glyph, glyphSet->fdepth); - return TRUE; - } - return FALSE; -} - -#ifdef NXAGENT_SERVER - GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id) { GlyphRefPtr gr; @@ -388,53 +120,6 @@ GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id) return glyph; } -#else - -GlyphPtr -FindGlyph (GlyphSetPtr glyphSet, Glyph id) -{ - GlyphPtr glyph; - - glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph; - if (glyph == DeletedGlyph) - glyph = 0; - return glyph; -} - -#endif - -GlyphPtr -AllocateGlyph (xGlyphInfo *gi, int fdepth) -{ - int size; - GlyphPtr glyph; - size_t padded_width; - - padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]); - if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height) - return 0; - size = gi->height * padded_width; - glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec)); - if (!glyph) - return 0; - glyph->refcnt = 0; - glyph->size = size + sizeof (xGlyphInfo); - glyph->info = *gi; - return glyph; -} - -Bool -AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet) -{ - hash->table = (GlyphRefPtr) xalloc (hashSet->size * sizeof (GlyphRefRec)); - if (!hash->table) - return FALSE; - memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec)); - hash->hashSet = hashSet; - hash->tableEntries = 0; - return TRUE; -} - Bool ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) { @@ -497,81 +182,3 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) CheckDuplicates (hash, "ResizeGlyphHash bottom"); return TRUE; } - -Bool -ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change) -{ - return (ResizeGlyphHash (&glyphSet->hash, change, FALSE) && - ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], change, TRUE)); -} - -GlyphSetPtr -AllocateGlyphSet (int fdepth, PictFormatPtr format) -{ - GlyphSetPtr glyphSet; - int size; - - if (!globalGlyphs[fdepth].hashSet) - { - if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0])) - return FALSE; - } - - size = (sizeof (GlyphSetRec) + - (sizeof (void *) * _GlyphSetPrivateAllocateIndex)); - glyphSet = xalloc (size); - if (!glyphSet) - return FALSE; - bzero((char *)glyphSet, size); - glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1; - if (_GlyphSetPrivateAllocateIndex) - glyphSet->devPrivates = (void *)(&glyphSet[1]); - - if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0])) - { - xfree (glyphSet); - return FALSE; - } - glyphSet->refcnt = 1; - glyphSet->fdepth = fdepth; - glyphSet->format = format; - return glyphSet; -} - -int -FreeGlyphSet (void * value, - XID gid) -{ - GlyphSetPtr glyphSet = (GlyphSetPtr) value; - - if (--glyphSet->refcnt == 0) - { - CARD32 i, tableSize = glyphSet->hash.hashSet->size; - GlyphRefPtr table = glyphSet->hash.table; - GlyphPtr glyph; - - for (i = 0; i < tableSize; i++) - { - glyph = table[i].glyph; - if (glyph && glyph != DeletedGlyph) - FreeGlyph (glyph, glyphSet->fdepth); - } - if (!globalGlyphs[glyphSet->fdepth].tableEntries) - { - xfree (globalGlyphs[glyphSet->fdepth].table); - globalGlyphs[glyphSet->fdepth].table = 0; - globalGlyphs[glyphSet->fdepth].hashSet = 0; - } - else - ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE); - xfree (table); - - if (glyphSet->devPrivates && - glyphSet->devPrivates != (void *)(&glyphSet[1])) - xfree(glyphSet->devPrivates); - - xfree (glyphSet); - } - return Success; -} - diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index a8eab5149..2d918458b 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -6,12 +6,14 @@ NULL = #if (!(defined(NXAgentServer) && NXAgentServer)) NXAGENT_SKIP_SRCS = \ + glyph.c \ miglyph.c \ mitrap.c \ picture.c \ render.c \ $(NULL) NXAGENT_SKIP_OBJS = \ + glyph.o \ miglyph.o \ mitrap.o \ picture.o \ diff --git a/nx-X11/programs/Xserver/render/glyph.c b/nx-X11/programs/Xserver/render/glyph.c index f15b199b5..854a9069d 100644 --- a/nx-X11/programs/Xserver/render/glyph.c +++ b/nx-X11/programs/Xserver/render/glyph.c @@ -268,6 +268,7 @@ FreeGlyph (GlyphPtr glyph, int format) } } +#ifndef NXAGENT_SERVER void AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) { @@ -301,6 +302,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) gr->signature = id; CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom"); } +#endif /* NXAGENT_SERVER */ Bool DeleteGlyph (GlyphSetPtr glyphSet, Glyph id) @@ -320,6 +322,7 @@ DeleteGlyph (GlyphSetPtr glyphSet, Glyph id) return FALSE; } +#ifndef NXAGENT_SERVER GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id) { @@ -330,6 +333,7 @@ FindGlyph (GlyphSetPtr glyphSet, Glyph id) glyph = 0; return glyph; } +#endif /* NXAGENT_SERVER */ GlyphPtr AllocateGlyph (xGlyphInfo *gi, int fdepth) @@ -363,6 +367,8 @@ AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet) return TRUE; } + +#ifndef NXAGENT_SERVER Bool ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) { @@ -405,6 +411,7 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) CheckDuplicates (hash, "ResizeGlyphHash bottom"); return TRUE; } +#endif /* NXAGENT_SERVER */ Bool ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change) -- cgit v1.2.3 From 3bdcd172757a10aeaeceff4447a62f7513804893 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 2 May 2016 11:29:53 +0200 Subject: hw/nxagent/NX*.c: Amend re-introduced nxagent warnings by fixing the corresponding code section in files included from "somewhere" in nx-X11/programs/Xserver/. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (1) In file included from NXrender.c:44:0: ../../mi/../render/render.c: In function ‘swapStops’: ../../mi/../render/render.c:2541:13: warning: variable ‘colors’ set but not used [-Wunused-but-set-variable] CARD16 *colors; ^ (2) In file included from NXevents.c:133:0: ../../dix/events.c: In function ‘ReinitializeRootWindow’: ../../dix/events.c:2046:15: warning: unused variable ‘pScreen’ [-Wunused-variable] ScreenPtr pScreen = win->drawable.pScreen; ^ ../../dix/events.c: In function ‘XineramaPointInWindowIsVisible’: ../../dix/events.c:2177:15: warning: variable ‘pScreen’ set but not used [-Wunused-but-set-variable] ScreenPtr pScreen = pWin->drawable.pScreen; ^ In file included from NXevents.c:133:0: ../../dix/events.c: In function ‘XineramaPointInWindowIsVisible’: ../../dix/events.c:2191:2: error: ‘pScreen’ undeclared (first use in this function) pScreen = pWin->drawable.pScreen; ^ (3) In file included from NXdixfonts.c:77:0: ../../dix/dixfonts.c: In function ‘GetFontPath’: ../../dix/dixfonts.c:1890:2: warning: return makes pointer from integer without a cast return BadAlloc; ^ --- nx-X11/programs/Xserver/dix/dixfonts.c | 2 +- nx-X11/programs/Xserver/render/render.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'nx-X11/programs/Xserver/render') diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index c9d64c7b0..58e562411 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -1884,7 +1884,7 @@ GetFontPath(int *count, int *length) if (c == NULL) { free(font_path_string); font_path_string = NULL; - return BadAlloc; + return NULL; } font_path_string = c; diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c index 3c14ac0e7..c73ff8305 100644 --- a/nx-X11/programs/Xserver/render/render.c +++ b/nx-X11/programs/Xserver/render/render.c @@ -2538,13 +2538,11 @@ static void swapStops(void *stuff, int num) { int i, n; CARD32 *stops; - CARD16 *colors; stops = (CARD32 *)(stuff); for (i = 0; i < num; ++i) { swapl(stops, n); ++stops; } - colors = (CARD16 *)(stops); for (i = 0; i < 4*num; ++i) { swaps(stops, n); ++stops; -- cgit v1.2.3