Ejemplo n.º 1
0
static void
fbBresFill(DrawablePtr drawable, GCPtr gc, int dashOffset,
           int sdx, int sdy, int axis,
	   int x1, int y1,
	   int e, int e1, int e3, int len)
{
	while (len--) {
		fbFill(drawable, gc, x1, y1, 1, 1);
		if (axis == X_AXIS) {
			x1 += sdx;
			e += e1;
			if (e >= 0) {
				e += e3;
				y1 += sdy;
			}
		} else {
			y1 += sdy;
			e += e1;
			if (e >= 0) {
				e += e3;
				x1 += sdx;
			}
		}
	}
}
Ejemplo n.º 2
0
static void
fbBresFillDash(DrawablePtr pDrawable,
               GCPtr pGC,
               int dashOffset,
               int signdx,
               int signdy,
               int axis, int x1, int y1, int e, int e1, int e3, int len)
{
    FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);

    FbDashDeclare;
    int dashlen;
    Bool even;
    Bool doOdd;
    Bool doBg;
    Pixel fg, bg;

    fg = pGC->fgPixel;
    bg = pGC->bgPixel;

    /* whether to fill the odd dashes */
    doOdd = pGC->lineStyle == LineDoubleDash;
    /* whether to switch fg to bg when filling odd dashes */
    doBg = doOdd && (pGC->fillStyle == FillSolid ||
                     pGC->fillStyle == FillStippled);

    /* compute current dash position */
    FbDashInit(pGC, pPriv, dashOffset, dashlen, even);

    while (len--) {
        if (even || doOdd) {
            if (doBg) {
                if (even)
                    fbSetFg(pDrawable, pGC, fg);
                else
                    fbSetFg(pDrawable, pGC, bg);
            }
            fbFill(pDrawable, pGC, x1, y1, 1, 1);
        }
        if (axis == X_AXIS) {
            x1 += signdx;
            e += e1;
            if (e >= 0) {
                e += e3;
                y1 += signdy;
            }
        }
        else {
            y1 += signdy;
            e += e1;
            if (e >= 0) {
                e += e3;
                x1 += signdx;
            }
        }
        FbDashStep(dashlen, even);
    }
    if (doBg)
        fbSetFg(pDrawable, pGC, fg);
}
Ejemplo n.º 3
0
static void
fbBresFillDash(DrawablePtr drawable,
               GCPtr gc,
               int dashOffset,
               int sdx,
               int sdy,
               int axis, int x1, int y1, int e, int e1, int e3, int len)
{
	FbGCPrivPtr pgc = fb_gc(gc);

	FbDashDeclare;
	int dashlen;
	bool even;
	bool doOdd;
	bool doBg;
	Pixel fg, bg;

	fg = gc->fgPixel;
	bg = gc->bgPixel;

	/* whether to fill the odd dashes */
	doOdd = gc->lineStyle == LineDoubleDash;
	/* whether to switch fg to bg when filling odd dashes */
	doBg = doOdd && (gc->fillStyle == FillSolid ||
			 gc->fillStyle == FillStippled);

	/* compute current dash position */
	FbDashInit(gc, pgc, dashOffset, dashlen, even);

	while (len--) {
		if (even || doOdd) {
			if (doBg) {
				if (even)
					fbSetFg(drawable, gc, fg);
				else
					fbSetFg(drawable, gc, bg);
			}
			fbFill(drawable, gc, x1, y1, 1, 1);
		}
		if (axis == X_AXIS) {
			x1 += sdx;
			e += e1;
			if (e >= 0) {
				e += e3;
				y1 += sdy;
			}
		} else {
			y1 += sdy;
			e += e1;
			if (e >= 0) {
				e += e3;
				x1 += sdx;
			}
		}
		FbDashStep(dashlen, even);
	}
	if (doBg)
		fbSetFg(drawable, gc, fg);
}
Ejemplo n.º 4
0
static void
fbPushPattern(DrawablePtr pDrawable,
              GCPtr pGC,
              FbStip * src,
              FbStride srcStride, int srcX, int x, int y, int width, int height)
{
    FbStip *s, bitsMask, bitsMask0, bits;
    int xspan;
    int w;
    int lenspan;

    src += srcX >> FB_STIP_SHIFT;
    srcX &= FB_STIP_MASK;

    bitsMask0 = FbStipMask(srcX, 1);

    while (height--) {
        bitsMask = bitsMask0;
        w = width;
        s = src;
        src += srcStride;
        bits = READ(s++);
        xspan = x;
        while (w) {
            if (bits & bitsMask) {
                lenspan = 0;
                do {
                    lenspan++;
                    if (lenspan == w)
                        break;
                    bitsMask = FbStipRight(bitsMask, 1);
                    if (!bitsMask) {
                        bits = READ(s++);
                        bitsMask = FbBitsMask(0, 1);
                    }
                } while (bits & bitsMask);
                fbFill(pDrawable, pGC, xspan, y, lenspan, 1);
                xspan += lenspan;
                w -= lenspan;
            }
            else {
                do {
                    w--;
                    xspan++;
                    if (!w)
                        break;
                    bitsMask = FbStipRight(bitsMask, 1);
                    if (!bitsMask) {
                        bits = READ(s++);
                        bitsMask = FbBitsMask(0, 1);
                    }
                } while (!(bits & bitsMask));
            }
        }
        y++;
    }
}
Ejemplo n.º 5
0
/**
 * Does an fbFill of the rectangle to be drawn.
 */
static void
ephyrSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2)
{
    ScreenPtr pScreen = pPix->drawable.pScreen;
    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;
    EphyrScrPriv *scrpriv = screen->driver;
    EphyrFakexaPriv *fakexa = scrpriv->fakexa;

    fbFill(&fakexa->pDst->drawable, fakexa->pGC, x1, y1, x2 - x1, y2 - y1);
}
Ejemplo n.º 6
0
static void
xglFillBox (DrawablePtr pDrawable,
	    GCPtr	pGC,
	    int		x,
	    int		y,
	    int		width,
	    int		height,
	    BoxPtr	pBox,
	    int		nBox)
{
    if (!nBox)
	return;

    if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
    {
	RegionRec region;

	XGL_DRAWABLE_PIXMAP (pDrawable);
	XGL_PIXMAP_PRIV (pPixmap);

	if (!xglMapPixmapBits (pPixmap))
	    FatalError (XGL_SW_FAILURE_STRING);

	switch (pGC->fillStyle) {
	case FillSolid:
	    break;
	case FillStippled:
	case FillOpaqueStippled:
	    if (!xglSyncBits (&pGC->stipple->drawable, NullBox))
		FatalError (XGL_SW_FAILURE_STRING);
	    break;
	case FillTiled:
	    if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox))
		FatalError (XGL_SW_FAILURE_STRING);
	    break;
	}

	pPixmapPriv->damageBox = miEmptyBox;

	while (nBox--)
	{
	    fbFill (pDrawable, pGC,
		    pBox->x1, pBox->y1,
		    pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);

	    REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
	    xglAddSurfaceDamage (pDrawable, &region);
	    REGION_UNINIT (pDrawable->pScreen, &region);

	    pBox++;
	}
    } else
	xglAddCurrentBitDamage (pDrawable);
}
Ejemplo n.º 7
0
void
fbFillSpans (DrawablePtr    pDrawable,
	     GCPtr	    pGC,
	     int	    n,
	     DDXPointPtr    ppt,
	     int	    *pwidth,
	     int	    fSorted)
{
    RegionPtr	    pClip = fbGetCompositeClip(pGC);
    BoxPtr	    pextent, pbox;
    int		    nbox;
    int		    extentX1, extentX2, extentY1, extentY2;
    int		    fullX1, fullX2, fullY1;
    int		    partX1, partX2;
    
    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
    extentX1 = pextent->x1;
    extentY1 = pextent->y1;
    extentX2 = pextent->x2;
    extentY2 = pextent->y2;
    while (n--)
    {
	fullX1 = ppt->x;
	fullY1 = ppt->y;
	fullX2 = fullX1 + (int) *pwidth;
	ppt++;
	pwidth++;
	
	if (fullY1 < extentY1 || extentY2 <= fullY1)
	    continue;
	
	if (fullX1 < extentX1)
	    fullX1 = extentX1;

	if (fullX2 > extentX2)
	    fullX2 = extentX2;
	
	if (fullX1 >= fullX2)
	    continue;
	
	nbox = REGION_NUM_RECTS (pClip);
	if (nbox == 1)
	{
	    fbFill (pDrawable,
		    pGC,
		    fullX1, fullY1, fullX2-fullX1, 1);
	}
	else
	{
	    pbox = REGION_RECTS(pClip);
	    while(nbox--)
	    {
		if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
		{
		    partX1 = pbox->x1;
		    if (partX1 < fullX1)
			partX1 = fullX1;
		    partX2 = pbox->x2;
		    if (partX2 > fullX2)
			partX2 = fullX2;
		    if (partX2 > partX1)
		    {
			fbFill (pDrawable, pGC,
				partX1, fullY1,
				partX2 - partX1, 1);
		    }
		}
		pbox++;
	    }
	}
    }
}
Ejemplo n.º 8
0
/** @file glamor_fillspans.c
 *
 * GC fill implementation, based loosely on fb_fill.c
 */
Bool
glamor_fill(DrawablePtr drawable,
            GCPtr gc, int x, int y, int width, int height, Bool fallback)
{
    PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
    int off_x, off_y;
    PixmapPtr sub_pixmap = NULL;
    glamor_access_t sub_pixmap_access;
    DrawablePtr saved_drawable = NULL;
    int saved_x = x, saved_y = y;

    glamor_get_drawable_deltas(drawable, dst_pixmap, &off_x, &off_y);

    switch (gc->fillStyle) {
    case FillSolid:
        if (!glamor_solid(dst_pixmap,
                          x + off_x,
                          y + off_y,
                          width, height, gc->alu, gc->planemask, gc->fgPixel))
            goto fail;
        break;
    case FillStippled:
    case FillOpaqueStippled:
        if (!glamor_stipple(dst_pixmap,
                            gc->stipple,
                            x + off_x,
                            y + off_y,
                            width,
                            height,
                            gc->alu,
                            gc->planemask,
                            gc->fgPixel,
                            gc->bgPixel, gc->patOrg.x, gc->patOrg.y))
            goto fail;
        break;
    case FillTiled:
        if (!glamor_tile(dst_pixmap,
                         gc->tile.pixmap,
                         x + off_x,
                         y + off_y,
                         width,
                         height,
                         gc->alu,
                         gc->planemask,
                         x - drawable->x - gc->patOrg.x,
                         y - drawable->y - gc->patOrg.y))
            goto fail;
        break;
    }
    return TRUE;

 fail:
    if (!fallback) {
        if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
            && glamor_ddx_fallback_check_gc(gc))
            return FALSE;
    }
    /* Is it possible to set the access as WO? */

    sub_pixmap_access = GLAMOR_ACCESS_RW;

    sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x,
                                       y + off_y, width, height,
                                       sub_pixmap_access);

    if (sub_pixmap != NULL) {
        if (gc->fillStyle != FillSolid) {
            gc->patOrg.x += (drawable->x - x);
            gc->patOrg.y += (drawable->y - y);
        }
        saved_drawable = drawable;
        drawable = &sub_pixmap->drawable;
        saved_x = x;
        saved_y = y;
        x = 0;
        y = 0;
    }
    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
        if (glamor_prepare_access_gc(gc)) {
            fbFill(drawable, gc, x, y, width, height);
            glamor_finish_access_gc(gc);
        }
        glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
    }

    if (sub_pixmap != NULL) {
        if (gc->fillStyle != FillSolid) {
            gc->patOrg.x -= (saved_drawable->x - saved_x);
            gc->patOrg.y -= (saved_drawable->y - saved_y);
        }

        x = saved_x;
        y = saved_y;

        glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
                              x + off_x, y + off_y,
                              width, height, sub_pixmap_access);
    }

    return TRUE;
}
Ejemplo n.º 9
0
void
fbPolyFillRect(DrawablePtr  pDrawable, 
	       GCPtr	    pGC, 
	       int	    nrect,
	       xRectangle   *prect)
{
    RegionPtr	    pClip = fbGetCompositeClip(pGC);
    register BoxPtr pbox;
    BoxPtr	    pextent;
    int		    extentX1, extentX2, extentY1, extentY2;
    int		    fullX1, fullX2, fullY1, fullY2;
    int		    partX1, partX2, partY1, partY2;
    int		    xorg, yorg;
    int		    n;

    xorg = pDrawable->x;
    yorg = pDrawable->y;
    
    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
    extentX1 = pextent->x1;
    extentY1 = pextent->y1;
    extentX2 = pextent->x2;
    extentY2 = pextent->y2;
    while (nrect--)
    {
	fullX1 = prect->x + xorg;
	fullY1 = prect->y + yorg;
	fullX2 = fullX1 + (int) prect->width;
	fullY2 = fullY1 + (int) prect->height;
	prect++;
	
	if (fullX1 < extentX1)
	    fullX1 = extentX1;

	if (fullY1 < extentY1)
	    fullY1 = extentY1;

	if (fullX2 > extentX2)
	    fullX2 = extentX2;
	
	if (fullY2 > extentY2)
	    fullY2 = extentY2;

	if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
	    continue;
	n = REGION_NUM_RECTS (pClip);
	if (n == 1)
	{
	    fbFill (pDrawable,
		    pGC,
		    fullX1, fullY1, fullX2-fullX1, fullY2-fullY1);
	}
	else
	{
	    pbox = REGION_RECTS(pClip);
	    /* 
	     * clip the rectangle to each box in the clip region
	     * this is logically equivalent to calling Intersect()
	     */
	    while(n--)
	    {
		partX1 = pbox->x1;
		if (partX1 < fullX1)
		    partX1 = fullX1;
		partY1 = pbox->y1;
		if (partY1 < fullY1)
		    partY1 = fullY1;
		partX2 = pbox->x2;
		if (partX2 > fullX2)
		    partX2 = fullX2;
		partY2 = pbox->y2;
		if (partY2 > fullY2)
		    partY2 = fullY2;
    
		pbox++;
		
		if (partX1 < partX2 && partY1 < partY2)
		    fbFill (pDrawable, pGC,
			    partX1, partY1,
			    partX2 - partX1, partY2 - partY1);
	    }
	}
    }
}