Example #1
0
void
fbImageGlyphBlt (DrawablePtr	pDrawable,
                 GCPtr		pGC,
                 int		x,
                 int		y,
                 unsigned int	nglyph,
                 CharInfoPtr	*ppciInit,
                 pointer	pglyphBase)
{
    FbGCPrivPtr	    pPriv = fbGetGCPrivate(pGC);
    CharInfoPtr	    *ppci;
    CharInfoPtr	    pci;
    unsigned char   *pglyph;		/* pointer bits in glyph */
    int		    gWidth, gHeight;	/* width and height of glyph */
    FbStride	    gStride;		/* stride of glyph */
    Bool	    opaque;
    int		    n;
    int		    gx, gy;
#ifndef FBNOPIXADDR
    void	    (*glyph) (FbBits *,
                          FbStride,
                          int,
                          FbStip *,
                          FbBits,
                          int,
                          int);
    FbBits	    *dst = 0;
    FbStride	    dstStride = 0;
    int		    dstBpp = 0;
    int		    dstXoff = 0, dstYoff = 0;

    glyph = 0;
    if (pPriv->and == 0)
    {
        fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
        switch (dstBpp) {
        case 8:
            glyph = fbGlyph8;
            break;
        case 16:
            glyph = fbGlyph16;
            break;
#ifdef FB_24BIT
        case 24:
            glyph = fbGlyph24;
            break;
#endif
        case 32:
            glyph = fbGlyph32;
            break;
        }
    }
#endif

    x += pDrawable->x;
    y += pDrawable->y;

    if (TERMINALFONT (pGC->font)
#ifndef FBNOPIXADDR
            && !glyph
#endif
       )
    {
        opaque = TRUE;
    }
    else
    {
        int		xBack, widthBack;
        int		yBack, heightBack;

        ppci = ppciInit;
        n = nglyph;
        widthBack = 0;
        while (n--)
            widthBack += (*ppci++)->metrics.characterWidth;

        xBack = x;
        if (widthBack < 0)
        {
            xBack += widthBack;
            widthBack = -widthBack;
        }
        yBack = y - FONTASCENT(pGC->font);
        heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
        fbSolidBoxClipped (pDrawable,
                           fbGetCompositeClip(pGC),
                           xBack,
                           yBack,
                           xBack + widthBack,
                           yBack + heightBack,
                           fbAnd(GXcopy,pPriv->bg,pPriv->pm),
                           fbXor(GXcopy,pPriv->bg,pPriv->pm));
        opaque = FALSE;
    }

    ppci = ppciInit;
    while (nglyph--)
    {
        pci = *ppci++;
        pglyph = FONTGLYPHBITS(pglyphBase, pci);
        gWidth = GLYPHWIDTHPIXELS(pci);
        gHeight = GLYPHHEIGHTPIXELS(pci);
        if (gWidth && gHeight)
        {
            gx = x + pci->metrics.leftSideBearing;
            gy = y - pci->metrics.ascent;
#ifndef FBNOPIXADDR
            if (glyph && gWidth <= sizeof (FbStip) * 8 &&
                    fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
            {
                (*glyph) (dst + (gy + dstYoff) * dstStride,
                          dstStride,
                          dstBpp,
                          (FbStip *) pglyph,
                          pPriv->fg,
                          gx + dstXoff,
                          gHeight);
            }
            else
#endif
            {
                gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
                fbPutXYImage (pDrawable,
                              fbGetCompositeClip(pGC),
                              pPriv->fg,
                              pPriv->bg,
                              pPriv->pm,
                              GXcopy,
                              opaque,

                              gx,
                              gy,
                              gWidth, gHeight,

                              (FbStip *) pglyph,
                              gStride,
                              0);
            }
        }
        x += pci->metrics.characterWidth;
    }
}
Example #2
0
void
fbPolyGlyphBlt (DrawablePtr	pDrawable,
                GCPtr		pGC,
                int		x,
                int		y,
                unsigned int	nglyph,
                CharInfoPtr	*ppci,
                pointer		pglyphBase)
{
    FbGCPrivPtr	    pPriv = fbGetGCPrivate (pGC);
    CharInfoPtr	    pci;
    unsigned char   *pglyph;		/* pointer bits in glyph */
    int		    gx, gy;
    int		    gWidth, gHeight;	/* width and height of glyph */
    FbStride	    gStride;		/* stride of glyph */
#ifndef FBNOPIXADDR
    void	    (*glyph) (FbBits *,
                          FbStride,
                          int,
                          FbStip *,
                          FbBits,
                          int,
                          int);
    FbBits	    *dst = 0;
    FbStride	    dstStride = 0;
    int		    dstBpp = 0;
    int		    dstXoff = 0, dstYoff = 0;

    glyph = 0;
    if (pGC->fillStyle == FillSolid && pPriv->and == 0)
    {
        fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
        switch (dstBpp) {
        case 8:
            glyph = fbGlyph8;
            break;
        case 16:
            glyph = fbGlyph16;
            break;
#ifdef FB_24BIT
        case 24:
            glyph = fbGlyph24;
            break;
#endif
        case 32:
            glyph = fbGlyph32;
            break;
        }
    }
#endif
    x += pDrawable->x;
    y += pDrawable->y;

    while (nglyph--)
    {
        pci = *ppci++;
        pglyph = FONTGLYPHBITS(pglyphBase, pci);
        gWidth = GLYPHWIDTHPIXELS(pci);
        gHeight = GLYPHHEIGHTPIXELS(pci);
        if (gWidth && gHeight)
        {
            gx = x + pci->metrics.leftSideBearing;
            gy = y - pci->metrics.ascent;
#ifndef FBNOPIXADDR
            if (glyph && gWidth <= sizeof (FbStip) * 8 &&
                    fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
            {
                (*glyph) (dst + (gy + dstYoff) * dstStride,
                          dstStride,
                          dstBpp,
                          (FbStip *) pglyph,
                          pPriv->xor,
                          gx + dstXoff,
                          gHeight);
            }
            else
#endif
            {
                gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
                fbPushImage (pDrawable,
                             pGC,

                             (FbStip *) pglyph,
                             gStride,
                             0,

                             gx,
                             gy,
                             gWidth, gHeight);
            }
        }
        x += pci->metrics.characterWidth;
    }
}
Example #3
0
void
fbImageGlyphBlt(DrawablePtr drawable, GCPtr gc,
                int x, int y,
                unsigned int nglyph, CharInfoPtr * ppciInit, pointer glyphs)
{
	FbGCPrivPtr pgc = fb_gc(gc);
	CharInfoPtr *ppci;
	CharInfoPtr pci;
	unsigned char *pglyph;      /* pointer bits in glyph */
	int gWidth, gHeight;        /* width and height of glyph */
	FbStride gStride;           /* stride of glyph */
	bool opaque;
	int n;
	int gx, gy;
	void (*raster)(FbBits *, FbStride, int, FbStip *, FbBits, int, int);
	FbBits *dst = 0;
	FbStride dstStride = 0;
	int dstBpp = 0;
	int dstXoff = 0, dstYoff = 0;

	DBG(("%s x %d\n", __FUNCTION__, nglyph));

	raster = 0;
	if (pgc->and == 0) {
		dstBpp = drawable->bitsPerPixel;
		switch (dstBpp) {
		case 8:
			raster = fbGlyph8;
			break;
		case 16:
			raster = fbGlyph16;
			break;
		case 32:
			raster = fbGlyph32;
			break;
		}
	}

	x += drawable->x;
	y += drawable->y;

	if (TERMINALFONT(gc->font) && !raster) {
		opaque = TRUE;
	} else {
		int xBack, widthBack;
		int yBack, heightBack;

		ppci = ppciInit;
		n = nglyph;
		widthBack = 0;
		while (n--)
			widthBack += (*ppci++)->metrics.characterWidth;

		xBack = x;
		if (widthBack < 0) {
			xBack += widthBack;
			widthBack = -widthBack;
		}
		yBack = y - FONTASCENT(gc->font);
		heightBack = FONTASCENT(gc->font) + FONTDESCENT(gc->font);
		fbSolidBoxClipped(drawable, gc,
				  xBack, yBack,
				  xBack + widthBack,
				  yBack + heightBack);
		opaque = FALSE;
	}

	ppci = ppciInit;
	while (nglyph--) {
		pci = *ppci++;
		pglyph = FONTGLYPHBITS(glyphs, pci);
		gWidth = GLYPHWIDTHPIXELS(pci);
		gHeight = GLYPHHEIGHTPIXELS(pci);
		if (gWidth && gHeight) {
			gx = x + pci->metrics.leftSideBearing;
			gy = y - pci->metrics.ascent;
			if (raster && gWidth <= sizeof(FbStip) * 8 &&
			    fbGlyphIn(gc, gx, gy, gWidth, gHeight)) {
				fbGetDrawable(drawable, dst, dstStride, dstBpp, dstXoff,
					      dstYoff);
				raster(dst + (gy + dstYoff) * dstStride, dstStride, dstBpp,
				       (FbStip *) pglyph, pgc->fg, gx + dstXoff, gHeight);
			} else {
				gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof(FbStip);
				fbPutXYImage(drawable, gc,
					     pgc->fg, pgc->bg, pgc->pm,
					     GXcopy, opaque,
					     gx, gy, gWidth, gHeight,
					     (FbStip *) pglyph, gStride, 0);
			}
		}
		x += pci->metrics.characterWidth;
	}
}
Example #4
0
void
miPolyGlyphBlt(DrawablePtr pDrawable, GC * pGC, int x, int y, unsigned int nglyph, CharInfoPtr * ppci,  /* array of character info */
               void *pglyphBase       /* start of array of glyphs */
    )
{
    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 */

    ChangeGCVal 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,
                                                   CREATE_PIXMAP_USAGE_SCRATCH);
    if (!pPixmap)
        return;

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

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

    ChangeGC(NullClient, pGCtmp, GCFunction | GCForeground | GCBackground,
             gcvals);

    nbyLine = BitmapBytePad(width);
    pbits = xallocarray(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);

            (*pGC->ops->PushPixels) (pGC, pPixmap, pDrawable,
                                     gWidth, gHeight,
                                     x + pci->metrics.leftSideBearing,
                                     y - pci->metrics.ascent);
        }
        x += pci->metrics.characterWidth;
    }
    (*pDrawable->pScreen->DestroyPixmap) (pPixmap);
    free(pbits);
    FreeScratchGC(pGCtmp);
}
Example #5
0
void
fbPolyGlyphBlt(DrawablePtr drawable, GCPtr gc,
               int x, int y,
               unsigned int nglyph, CharInfoPtr * ppci, pointer glyphs)
{
	FbGCPrivPtr pgc = fb_gc(gc);
	CharInfoPtr pci;
	unsigned char *pglyph;      /* pointer bits in glyph */
	int gx, gy;
	int gWidth, gHeight;        /* width and height of glyph */
	FbStride gStride;           /* stride of glyph */
	void (*raster) (FbBits *, FbStride, int, FbStip *, FbBits, int, int);
	FbBits *dst = 0;
	FbStride dstStride = 0;
	int dstBpp = 0;
	int dstXoff = 0, dstYoff = 0;

	DBG(("%s x %d\n", __FUNCTION__, nglyph));

	raster = 0;
	if (gc->fillStyle == FillSolid && pgc->and == 0) {
		dstBpp = drawable->bitsPerPixel;
		switch (dstBpp) {
		case 8:
			raster = fbGlyph8;
			break;
		case 16:
			raster = fbGlyph16;
			break;
		case 32:
			raster = fbGlyph32;
			break;
		}
	}
	x += drawable->x;
	y += drawable->y;

	while (nglyph--) {
		pci = *ppci++;
		pglyph = FONTGLYPHBITS(glyphs, pci);
		gWidth = GLYPHWIDTHPIXELS(pci);
		gHeight = GLYPHHEIGHTPIXELS(pci);
		if (gWidth && gHeight) {
			gx = x + pci->metrics.leftSideBearing;
			gy = y - pci->metrics.ascent;
			if (raster && gWidth <= sizeof(FbStip) * 8 &&
			    fbGlyphIn(gc, gx, gy, gWidth, gHeight)) {
				fbGetDrawable(drawable, dst, dstStride, dstBpp, dstXoff,
					      dstYoff);
				raster(dst + (gy + dstYoff) * dstStride, dstStride, dstBpp,
					  (FbStip *) pglyph, pgc->xor, gx + dstXoff, gHeight);
			} else {
				gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof(FbStip);
				fbPushImage(drawable, gc,
					    (FbStip *)pglyph,
					    gStride, 0, gx, gy, gWidth, gHeight);
			}
		}
		x += pci->metrics.characterWidth;
	}
}