예제 #1
0
_X_EXPORT Bool
AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
{
    unsigned oldamount;

    /* Round up sizes for proper alignment */
    amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);

    if (index2 >= pScreen->PixmapPrivateLen) {
        unsigned *nsizes;

        nsizes = (unsigned *) realloc(pScreen->PixmapPrivateSizes,
                                       (index2 + 1) * sizeof(unsigned));
        if (!nsizes)
            return FALSE;
        while (pScreen->PixmapPrivateLen <= index2) {
            nsizes[pScreen->PixmapPrivateLen++] = 0;
            pScreen->totalPixmapSize += sizeof(DevUnion);
        }
        pScreen->PixmapPrivateSizes = nsizes;
    }
    oldamount = pScreen->PixmapPrivateSizes[index2];
    if (amount > oldamount) {
        pScreen->PixmapPrivateSizes[index2] = amount;
        pScreen->totalPixmapSize += (amount - oldamount);
    }
    pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8);
    return TRUE;
}
예제 #2
0
void *
shadowAlloc (int width, int height, int bpp)
{
    int	    stride;
    void    *fb;

    /* Cant use PixmapBytePad -- the structure is probably not initialized yet */
    stride = BitmapBytePad (width * bpp);
    fb = xalloc (stride * height);
    return fb;
}
예제 #3
0
static Bool
EmptyMask(CursorBitsPtr bits)
{
    unsigned char *mask = bits->mask;
    int n = BitmapBytePad(bits->width) * bits->height;

    while (n--)
        if (*mask++ != 0) return FALSE;
#ifdef ARGB_CURSOR
    if (bits->argb) {
        CARD32 *argb = bits->argb;
        n = bits->width * bits->height;
        while (n--)
            if (*argb++ & 0xff000000) return FALSE;
    }
#endif
    return TRUE;
}
예제 #4
0
static Bool
afbCreateScreenResources(ScreenPtr pScreen)
{
	Bool retval;

	pointer oldDevPrivate = pScreen->devPrivate;

	pScreen->devPrivate = pScreen->devPrivates[afbScreenPrivateIndex].ptr;
	retval = miCreateScreenResources(pScreen);

	/* Modify screen's pixmap devKind value stored off devPrivate to
	 * be the width of a single plane in longs rather than the width
	 * of a chunky screen in longs as incorrectly setup by the mi routine.
	 */
	((PixmapPtr)pScreen->devPrivate)->devKind = BitmapBytePad(pScreen->width);
	pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
	pScreen->devPrivate = oldDevPrivate;
	return(retval);
}
예제 #5
0
파일: cursor.c 프로젝트: 4eremuxa/xserver
/*
 * We check for empty cursors so that we won't have to display them
 */
static void
CheckForEmptyMask(CursorBitsPtr bits)
{
    unsigned char *msk = bits->mask;
    int n = BitmapBytePad(bits->width) * bits->height;

    bits->emptyMask = FALSE;
    while(n--) 
	if(*(msk++) != 0) return;
#ifdef ARGB_CURSOR
    if (bits->argb)
    {
	CARD32 *argb = bits->argb;
	int n = bits->width * bits->height;
	while (n--)
	    if (*argb++ & 0xff000000) return;
    }
#endif
    bits->emptyMask = TRUE;
}
예제 #6
0
파일: cfbscrinit.c 프로젝트: aosm/X11
static Bool
cfb24_32CreateScreenResources(ScreenPtr pScreen)
{
    miScreenInitParmsPtr pScrInitParms;
    int pitch;
    Bool retval;

    /* get the pitch before mi destroys it */
    pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
    pitch = BitmapBytePad(pScrInitParms->width * 24);

    if((retval = miCreateScreenResources(pScreen))) {
	/* fix the screen pixmap */
	PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate;
	pPix->drawable.bitsPerPixel = 24;
	pPix->devKind = pitch;
    }

    return retval;
}
예제 #7
0
Bool
AllocateGlyphPrivate (ScreenPtr pScreen,
		      int	index2,
		      unsigned	amount)
{
    PictureScreenPtr ps;
    unsigned	     oldamount;

    ps = GetPictureScreenIfSet (pScreen);
    if (!ps)
	return FALSE;

    /* Round up sizes for proper alignment */
    amount = ((amount + (sizeof (DevUnion) - 1)) / sizeof (DevUnion)) *
	sizeof (DevUnion);

    if (index2 >= ps->glyphPrivateLen)
    {
	unsigned *nsizes;
	nsizes = (unsigned *) xrealloc (ps->glyphPrivateSizes,
					(index2 + 1) * sizeof (unsigned));
	if (!nsizes)
	    return FALSE;
	
	while (ps->glyphPrivateLen <= index2)
	{
	    nsizes[ps->glyphPrivateLen++] = 0;
	    ps->totalGlyphPrivateSize += sizeof (DevUnion);
	}
	ps->glyphPrivateSizes = nsizes;
    }
    oldamount = ps->glyphPrivateSizes[index2];
    if (amount > oldamount)
    {
	ps->glyphPrivateSizes[index2] = amount;
	ps->totalGlyphPrivateSize += (amount - oldamount);
    }
    ps->totalGlyphPrivateSize = BitmapBytePad (ps->totalGlyphPrivateSize * 8);
    
    return TRUE;
}
예제 #8
0
/*
 * Convert X cursor to Windows cursor
 * FIXME: Perhaps there are more smart code
 */
HCURSOR
winXCursorToHCURSOR(WMUTIL_CURSOR *pCursor)
{
    HCURSOR hCursor = NULL;
    unsigned char *pAnd;
    unsigned char *pXor;
    int nCX, nCY;
    int nBytes;
    double dForeY, dBackY;
    BOOL fReverse;
    HBITMAP hAnd, hXor;
    ICONINFO ii;
    unsigned char *pCur;
    unsigned char bit;
    HDC hDC;
    BITMAPV4HEADER bi;
    BITMAPINFO *pbmi;
    uint32_t *lpBits;

    int sm_cx = GetSystemMetrics(SM_CXCURSOR);
    int sm_cy = GetSystemMetrics(SM_CYCURSOR);

    WIN_DEBUG_MSG("winXCursorToHCURSOR: Win32 size: %dx%d X11 size: %dx%d hotspot: %d,%d\n",
                  sm_cx, sm_cy,
                  pCursor->width, pCursor->height,
                  pCursor->xhot, pCursor->yhot);

    /* We can use only White and Black, so calc brightness of color
     * Also check if the cursor is inverted */
    dForeY = BRIGHTNESS(pCursor->fore);
    dBackY = BRIGHTNESS(pCursor->back);
    fReverse = dForeY < dBackY;

    /* Check whether the X11 cursor is bigger than the win32 cursor */
    if (sm_cx < pCursor->width ||
        sm_cy < pCursor->height) {
        winError("winXCursorToHCURSOR - Windows requires %dx%d cursor but X requires %dx%d\n",
                 sm_cx, sm_cy,
                 pCursor->width, pCursor->height);
    }

    /* Get the number of bytes required to store the whole cursor image
     * This is roughly (sm_cx * sm_cy) / 8
     * round up to 8 pixel boundary so we can convert whole bytes */
    nBytes =
        bits_to_bytes(sm_cx) * sm_cy;

    /* Get the effective width and height */
    nCX = min(sm_cx, pCursor->width);
    nCY = min(sm_cy, pCursor->height);

    /* Allocate memory for the bitmaps */
    pAnd = malloc(nBytes);
    memset(pAnd, 0xFF, nBytes);
    pXor = calloc(1, nBytes);
    memset(pXor, 0x00, nBytes);

    /* prepare the pointers */
    hCursor = NULL;
    lpBits = NULL;

    /* We have a truecolor alpha-blended cursor and can use it! */
    if (pCursor->argb) {
        WIN_DEBUG_MSG("winXCursorToHCURSOR: Trying truecolor alphablended cursor\n");
        memset(&bi, 0, sizeof(BITMAPV4HEADER));
        bi.bV4Size = sizeof(BITMAPV4HEADER);
        bi.bV4Width = sm_cx;
        bi.bV4Height = -(sm_cy);    /* right-side up */
        bi.bV4Planes = 1;
        bi.bV4BitCount = 32;
        bi.bV4V4Compression = BI_BITFIELDS;
        bi.bV4RedMask = 0x00FF0000;
        bi.bV4GreenMask = 0x0000FF00;
        bi.bV4BlueMask = 0x000000FF;
        bi.bV4AlphaMask = 0xFF000000;

        lpBits =
            (uint32_t *) calloc(sm_cx *
                                sm_cy,
                                sizeof(uint32_t));

        if (lpBits) {
            int y;
            for (y = 0; y < nCY; y++) {
                void *src, *dst;
                src = &(pCursor->argb[y * pCursor->width]);
                dst = &(lpBits[y * sm_cx]);
                memcpy(dst, src, 4 * nCX);
            }
        }
    }                           /* End if-truecolor-icon */
    else
    {
        /* Convert the X11 bitmap to a win32 bitmap
         * The first is for an empty mask */
        if (pCursor->emptyMask) {
          int x, y, xmax = bits_to_bytes(nCX);

          for (y = 0; y < nCY; ++y)
            for (x = 0; x < xmax; ++x) {
              int nWinPix = bits_to_bytes(sm_cx) * y + x;
              int nXPix = BitmapBytePad(pCursor->width) * y + x;

              pAnd[nWinPix] = 0;
              if (fReverse)
                pXor[nWinPix] = reverse(~pCursor->source[nXPix]);
              else
                pXor[nWinPix] = reverse(pCursor->source[nXPix]);
            }
        }
        else {
          int x, y, xmax = bits_to_bytes(nCX);

          for (y = 0; y < nCY; ++y)
            for (x = 0; x < xmax; ++x) {
              int nWinPix = bits_to_bytes(sm_cx) * y + x;
              int nXPix = BitmapBytePad(pCursor->width) * y + x;

              unsigned char mask = pCursor->mask[nXPix];

              pAnd[nWinPix] = reverse(~mask);
              if (fReverse)
                pXor[nWinPix] =
                  reverse(~pCursor->source[nXPix] & mask);
              else
                pXor[nWinPix] =
                  reverse(pCursor->source[nXPix] & mask);
            }
        }
    }

    if (!lpBits) {
        RGBQUAD *pbmiColors;
        /* Bicolor, use a palettized DIB */
        WIN_DEBUG_MSG("winXCursorToHCURSOR: Trying two color cursor\n");
        pbmi = (BITMAPINFO *) &bi;
        pbmiColors = &(pbmi->bmiColors[0]);

        memset(pbmi, 0, sizeof(BITMAPINFOHEADER));
        pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        pbmi->bmiHeader.biWidth = sm_cx;
        pbmi->bmiHeader.biHeight = -abs(sm_cy);     /* right-side up */
        pbmi->bmiHeader.biPlanes = 1;
        pbmi->bmiHeader.biBitCount = 8;
        pbmi->bmiHeader.biCompression = BI_RGB;
        pbmi->bmiHeader.biSizeImage = 0;
        pbmi->bmiHeader.biClrUsed = 3;
        pbmi->bmiHeader.biClrImportant = 3;

        pbmiColors[0].rgbRed = 0;  /* Empty */
        pbmiColors[0].rgbGreen = 0;
        pbmiColors[0].rgbBlue = 0;
        pbmiColors[0].rgbReserved = 0;
        pbmiColors[1].rgbRed = pCursor->backRed >> 8;      /* Background */
        pbmiColors[1].rgbGreen = pCursor->backGreen >> 8;
        pbmiColors[1].rgbBlue = pCursor->backBlue >> 8;
        pbmiColors[1].rgbReserved = 0;
        pbmiColors[2].rgbRed = pCursor->foreRed >> 8;      /* Foreground */
        pbmiColors[2].rgbGreen = pCursor->foreGreen >> 8;
        pbmiColors[2].rgbBlue = pCursor->foreBlue >> 8;
        pbmiColors[2].rgbReserved = 0;

        lpBits =
            (uint32_t *) calloc(sm_cx * sm_cy, sizeof(char));

        pCur = (unsigned char *) lpBits;
        if (lpBits) {
	    int x, y;
            for (y = 0; y < sm_cy; y++) {
                for (x = 0; x < sm_cx; x++) {
                    if (x >= nCX || y >= nCY)   /* Outside of X11 icon bounds */
                        (*pCur++) = 0;
                    else {      /* Within X11 icon bounds */

                        int nWinPix =
                            bits_to_bytes(sm_cx) * y +
                            (x / 8);

                        bit = pAnd[nWinPix];
                        bit = bit & (1 << (7 - (x & 7)));
                        if (!bit) {     /* Within the cursor mask? */
                            int nXPix =
                                BitmapBytePad(pCursor->width) * y +
                                (x / 8);
                            bit =
                                ~reverse(~pCursor->
                                         source[nXPix] & pCursor->
                                         mask[nXPix]);
                            bit = bit & (1 << (7 - (x & 7)));
                            if (bit)    /* Draw foreground */
                                (*pCur++) = 2;
                            else        /* Draw background */
                                (*pCur++) = 1;
                        }
                        else    /* Outside the cursor mask */
                            (*pCur++) = 0;
                    }
                }               /* end for (x) */
            }                   /* end for (y) */
        }                       /* end if (lpbits) */
    }
예제 #9
0
void
miPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
	       unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)
{
    int width, height;
    PixmapPtr pPixmap;
    int nbyLine;			/* bytes per line of padded pixmap */
    FontPtr pfont;
    GCPtr pGCtmp;
    int i;
    int j;
    unsigned char *pbits;		/* buffer for PutImage */
    unsigned char *pb;		/* temp pointer into buffer */
    CharInfoPtr pci;		/* currect char info */
    unsigned char *pglyph;	/* pointer bits in glyph */
    int gWidth, gHeight;		/* width and height of glyph */
    int nbyGlyphWidth;		/* bytes per scanline of glyph */
    int nbyPadGlyph;			/* server padded line of glyph */

    XID gcvals[3];

    if (pGC->miTranslate)
    {
	x += pDrawable->x;
	y += pDrawable->y;
    }

    pfont = pGC->font;
    width = FONTMAXBOUNDS(pfont,rightSideBearing) - 
	    FONTMINBOUNDS(pfont,leftSideBearing);
    height = FONTMAXBOUNDS(pfont,ascent) +
	     FONTMAXBOUNDS(pfont,descent);

    pPixmap = (*pDrawable->pScreen->CreatePixmap)(pDrawable->pScreen,
						  width, height, 1);
    if (!pPixmap)
	return;

    pGCtmp = GetScratchGC(1, pDrawable->pScreen);
    if (!pGCtmp)
    {
	(*pDrawable->pScreen->DestroyPixmap)(pPixmap);
	return;
    }

    gcvals[0] = GXcopy;
    gcvals[1] = 1;
    gcvals[2] = 0;

    DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0);

    nbyLine = BitmapBytePad(width);
    pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
    if (!pbits)
    {
	(*pDrawable->pScreen->DestroyPixmap)(pPixmap);
	FreeScratchGC(pGCtmp);
        return;
    }
    while(nglyph--)
    {
	pci = *ppci++;
	pglyph = FONTGLYPHBITS(pglyphBase, pci);
	gWidth = GLYPHWIDTHPIXELS(pci);
	gHeight = GLYPHHEIGHTPIXELS(pci);
	if (gWidth && gHeight)
	{
	    nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
	    nbyPadGlyph = BitmapBytePad(gWidth);

	    if (nbyGlyphWidth == nbyPadGlyph
#if GLYPHPADBYTES != 4
	        && (((int) pglyph) & 3) == 0
#endif
		)
	    {
		pb = pglyph;
	    }
	    else
	    {
		for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
		    for (j = 0; j < nbyGlyphWidth; j++)
			*pb++ = *pglyph++;
		pb = pbits;
	    }

	    if ((pGCtmp->serialNumber) != (pPixmap->drawable.serialNumber))
		ValidateGC((DrawablePtr)pPixmap, pGCtmp);
	    (*pGCtmp->ops->PutImage)((DrawablePtr)pPixmap, pGCtmp,
				pPixmap->drawable.depth,
				0, 0, gWidth, gHeight, 
				0, XYBitmap, (char *)pb);

	    if ((pGC->serialNumber) != (pDrawable->serialNumber))
		ValidateGC(pDrawable, pGC);
	    (*pGC->ops->PushPixels)(pGC, pPixmap, pDrawable,
			       gWidth, gHeight,
			       x + pci->metrics.leftSideBearing,
			       y - pci->metrics.ascent);
	}
	x += pci->metrics.characterWidth;
    }
    (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
    DEALLOCATE_LOCAL(pbits);
    FreeScratchGC(pGCtmp);
}
예제 #10
0
파일: dmxgcops.c 프로젝트: 4eremuxa/xserver
/** Transfer \a pBits image to back-end server associated with \a
 *  pDrawable's screen.  If primitive subdivision optimization is
 *  enabled, then only transfer the sections of \a pBits that are
 *  visible (i.e., not-clipped) to the back-end server. */
void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
		 int depth, int x, int y, int w, int h,
		 int leftPad, int format, char *pBits)
{
    DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
    dmxGCPrivPtr   pGCPriv = DMX_GET_GC_PRIV(pGC);
    XImage        *img;

    if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;

    img = XCreateImage(dmxScreen->beDisplay,
		       dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
		       depth, format, leftPad, pBits, w, h,
		       BitmapPad(dmxScreen->beDisplay),
		       (format == ZPixmap) ?
		       PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));

    if (img) {
	Drawable draw;

	DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);

	if (dmxSubdividePrimitives && pGC->pCompositeClip) {
	    RegionPtr  pSubImages;
	    RegionPtr  pClip;
	    BoxRec     box;
	    BoxPtr     pBox;
	    int        nBox;

	    box.x1 = x;
	    box.y1 = y;
	    box.x2 = x + w;
	    box.y2 = y + h;
	    pSubImages = RegionCreate(&box, 1);

	    pClip = RegionCreate(NullBox, 1);
	    RegionCopy(pClip, pGC->pCompositeClip);
	    RegionTranslate(pClip,
			     -pDrawable->x, -pDrawable->y);
	    RegionIntersect(pSubImages, pSubImages, pClip);

	    nBox = RegionNumRects(pSubImages);
	    pBox = RegionRects(pSubImages);

	    while (nBox--) {
		XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img,
			  pBox->x1 - box.x1,
			  pBox->y1 - box.y1,
			  pBox->x1,
			  pBox->y1,
			  pBox->x2 - pBox->x1,
			  pBox->y2 - pBox->y1);
		pBox++;
	    }
            RegionDestroy(pClip);
            RegionDestroy(pSubImages);
	} else {
	    XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc,
		      img, 0, 0, x, y, w, h);
	}
	XFree(img);             /* Use XFree instead of XDestroyImage
                                 * because pBits is passed in from the
                                 * caller. */

	dmxSync(dmxScreen, FALSE);
    } else {
	/* Error -- this should not happen! */
    }
}
예제 #11
0
파일: fbimage.c 프로젝트: narenas/nx-libs
void
fbPutImage (DrawablePtr	pDrawable,
	    GCPtr	pGC,
	    int		depth,
	    int		x,
	    int		y,
	    int		w,
	    int		h,
	    int		leftPad,
	    int		format,
	    char	*pImage)
{
    FbGCPrivPtr	    pPriv = fbGetGCPrivate(pGC);
    unsigned long   i;
    FbStride	    srcStride;
    FbStip	    *src = (FbStip *) pImage;
    
    x += pDrawable->x;
    y += pDrawable->y;
    
    switch (format)
    {
    case XYBitmap:
	srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
	fbPutXYImage (pDrawable,
		      fbGetCompositeClip(pGC),
		      pPriv->fg,
		      pPriv->bg,
		      pPriv->pm,
		      pGC->alu,
		      TRUE,
		      x, y, w, h,
		      src,
		      srcStride,
		      leftPad);
	break;
    case XYPixmap:
	srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
	for (i = 1 << (pDrawable->depth - 1); i; i >>= 1)
	{
	    if (i & pGC->planemask)
	    {
		fbPutXYImage (pDrawable,
			      fbGetCompositeClip(pGC),
			      FB_ALLONES,
			      0,
			      fbReplicatePixel (i, pDrawable->bitsPerPixel),
			      pGC->alu,
			      TRUE,
			      x, y, w, h,
			      src,
			      srcStride,
			      leftPad);
		src += srcStride * h;
	    }
	}
	break;
    case ZPixmap:
#ifdef FB_24_32BIT
	if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
	{
	    srcStride = PixmapBytePad(w, pDrawable->depth);
	    fb24_32PutZImage (pDrawable,
			      fbGetCompositeClip(pGC),
			      pGC->alu,
			      (FbBits) pGC->planemask,
			      x, y, w, h,
			      (CARD8 *) pImage,
			      srcStride);
	}
	else
#endif
	{
	    srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
	    fbPutZImage (pDrawable,
			 fbGetCompositeClip(pGC),
			 pGC->alu,
			 pPriv->pm,
			 x, y, w, h, 
			 src, srcStride);
	}
    }
}
예제 #12
0
파일: fbimage.c 프로젝트: narenas/nx-libs
void
fbGetImage (DrawablePtr	    pDrawable,
	    int		    x,
	    int		    y,
	    int		    w,
	    int		    h,
	    unsigned int    format,
	    unsigned long   planeMask,
	    char	    *d)
{
    FbBits	    *src;
    FbStride	    srcStride;
    int		    srcBpp;
    int		    srcXoff, srcYoff;
    FbStip	    *dst;
    FbStride	    dstStride;
    
    /*
     * XFree86 DDX empties the root borderClip when the VT is
     * switched away; this checks for that case
     */
    if (!fbDrawableEnabled(pDrawable))
	return;
    
#ifdef FB_24_32BIT
    if (format == ZPixmap &&
	pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
    {
	fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
	return;
    }
#endif
    
    fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
    
    x += pDrawable->x;
    y += pDrawable->y;
    
    dst = (FbStip *) d;
    if (format == ZPixmap || srcBpp == 1)
    {
	FbBits	pm;

	pm = fbReplicatePixel (planeMask, srcBpp);
	dstStride = PixmapBytePad(w, pDrawable->depth);
	if (pm != FB_ALLONES)
	    memset (d, 0, dstStride * h);
	dstStride /= sizeof (FbStip);
	fbBltStip ((FbStip *) (src + (y + srcYoff) * srcStride), 
		   FbBitsStrideToStipStride(srcStride),
		   (x + srcXoff) * srcBpp,
		   
		   dst,
		   dstStride,
		   0,
		   
		   w * srcBpp, h,

		   GXcopy,
		   pm,
		   srcBpp);
    }
    else
    {
	dstStride = BitmapBytePad(w) / sizeof (FbStip);
	fbBltPlane (src + (y + srcYoff) * srcStride,
		    srcStride, 
		    (x + srcXoff) * srcBpp,
		    srcBpp,

		    dst,
		    dstStride,
		    0,
		    
		    w * srcBpp, h,

		    fbAndStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
		    fbXorStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
		    fbAndStip(GXcopy,0,FB_STIP_ALLONES),
		    fbXorStip(GXcopy,0,FB_STIP_ALLONES),
		    planeMask);
    }
}
예제 #13
0
파일: cursor.c 프로젝트: 4eremuxa/xserver
int
AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
                unsigned foreRed, unsigned foreGreen, unsigned foreBlue, 
                unsigned backRed, unsigned backGreen, unsigned backBlue,
		CursorPtr *ppCurs, ClientPtr client, XID cid)
{
    FontPtr  sourcefont, maskfont;
    unsigned char   *srcbits;
    unsigned char   *mskbits;
    CursorMetricRec cm;
    int rc;
    CursorBitsPtr  bits;
    CursorPtr 	pCurs;
    GlyphSharePtr pShare;

    rc = dixLookupResourceByType((pointer *)&sourcefont, source, RT_FONT, client,
				 DixUseAccess);
    if (rc != Success)
    {
	client->errorValue = source;
	return rc;
    }
    rc = dixLookupResourceByType((pointer *)&maskfont, mask, RT_FONT, client,
				 DixUseAccess);
    if (rc != Success && mask != None)
    {
	client->errorValue = mask;
	return rc;
    }
    if (sourcefont != maskfont)
	pShare = (GlyphSharePtr)NULL;
    else
    {
	for (pShare = sharedGlyphs;
	     pShare &&
	     ((pShare->font != sourcefont) ||
	      (pShare->sourceChar != sourceChar) ||
	      (pShare->maskChar != maskChar));
	     pShare = pShare->next)
	    ;
    }
    if (pShare)
    {
	pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
	if (!pCurs)
	    return BadAlloc;
	dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
	bits = pShare->bits;
	bits->refcnt++;
    }
    else
    {
	if (!CursorMetricsFromGlyph(sourcefont, sourceChar, &cm))
	{
	    client->errorValue = sourceChar;
	    return BadValue;
	}
	if (!maskfont)
	{
	    long n;
	    unsigned char *mskptr;

	    n = BitmapBytePad(cm.width)*(long)cm.height;
	    mskptr = mskbits = malloc(n);
	    if (!mskptr)
		return BadAlloc;
	    while (--n >= 0)
		*mskptr++ = ~0;
	}
	else
	{
	    if (!CursorMetricsFromGlyph(maskfont, maskChar, &cm))
	    {
		client->errorValue = maskChar;
		return BadValue;
	    }
	    if ((rc = ServerBitsFromGlyph(maskfont, maskChar, &cm, &mskbits)))
		return rc;
	}
	if ((rc = ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)))
	{
	    free(mskbits);
	    return rc;
	}
	if (sourcefont != maskfont)
	{
	    pCurs = 
                (CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
	    if (pCurs)
		bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
	    else
		bits = (CursorBitsPtr)NULL;
	}
	else
	{
	    pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
	    if (pCurs)
		bits = (CursorBitsPtr)calloc(CURSOR_BITS_SIZE, 1);
	    else
		bits = (CursorBitsPtr)NULL;
	}
	if (!bits)
	{
	    free(pCurs);
	    free(mskbits);
	    free(srcbits);
	    return BadAlloc;
	}
	dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
	dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS);
	bits->source = srcbits;
	bits->mask = mskbits;
#ifdef ARGB_CURSOR
	bits->argb = 0;
#endif
	bits->width = cm.width;
	bits->height = cm.height;
	bits->xhot = cm.xhot;
	bits->yhot = cm.yhot;
	if (sourcefont != maskfont)
	    bits->refcnt = -1;
	else
	{
	    bits->refcnt = 1;
	    pShare = malloc(sizeof(GlyphShare));
	    if (!pShare)
	    {
		FreeCursorBits(bits);
		return BadAlloc;
	    }
	    pShare->font = sourcefont;
	    sourcefont->refcnt++;
	    pShare->sourceChar = sourceChar;
	    pShare->maskChar = maskChar;
	    pShare->bits = bits;
	    pShare->next = sharedGlyphs;
	    sharedGlyphs = pShare;
	}
    }

    CheckForEmptyMask(bits);
    pCurs->bits = bits;
    pCurs->refcnt = 1;
#ifdef XFIXES
    pCurs->serialNumber = ++cursorSerial;
    pCurs->name = None;
#endif

    pCurs->foreRed = foreRed;
    pCurs->foreGreen = foreGreen;
    pCurs->foreBlue = foreBlue;

    pCurs->backRed = backRed;
    pCurs->backGreen = backGreen;
    pCurs->backBlue = backBlue;

    pCurs->id = cid;

    /* security creation/labeling check */
    rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
		  pCurs, RT_NONE, NULL, DixCreateAccess);
    if (rc != Success)
        goto error;

    rc = RealizeCursorAllScreens(pCurs);
    if (rc != Success)
        goto error;

    *ppCurs = pCurs;
    return Success;

error:
    FreeCursorBits(bits);
    dixFiniPrivates(pCurs, PRIVATE_CURSOR);
    free(pCurs);

    return rc;
}