Пример #1
0
void
miImageGlyphBlt(
    DrawablePtr pDrawable,
    GC		*pGC,
    int		 x,
    int		 y,
    unsigned int nglyph,
    CharInfoPtr *ppci,		/* array of character info */
    pointer      pglyphBase	/* start of array of glyphs */
    )
{
    ExtentInfoRec info;		/* used by QueryGlyphExtents() */
    ChangeGCVal gcvals[3];
    int oldAlu, oldFS;
    unsigned long	oldFG;
    xRectangle backrect;

    QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);

    if (info.overallWidth >= 0)
    {
    	backrect.x = x;
    	backrect.width = info.overallWidth;
    }
    else
    {
	backrect.x = x + info.overallWidth;
	backrect.width = -info.overallWidth;
    }
    backrect.y = y - FONTASCENT(pGC->font);
    backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);

    oldAlu = pGC->alu;
    oldFG = pGC->fgPixel;
    oldFS = pGC->fillStyle;

    /* fill in the background */
    gcvals[0].val = GXcopy;
    gcvals[1].val = pGC->bgPixel;
    gcvals[2].val = FillSolid;
    ChangeGC(NullClient, pGC, GCFunction|GCForeground|GCFillStyle, gcvals);
    ValidateGC(pDrawable, pGC);
    (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &backrect);

    /* put down the glyphs */
    gcvals[0].val = oldFG;
    ChangeGC(NullClient, pGC, GCForeground, gcvals);
    ValidateGC(pDrawable, pGC);
    (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci,
			      pglyphBase);

    /* put all the toys away when done playing */
    gcvals[0].val = oldAlu;
    gcvals[1].val = oldFG;
    gcvals[2].val = oldFS;
    ChangeGC(NullClient, pGC, GCFunction|GCForeground|GCFillStyle, gcvals);
    ValidateGC(pDrawable, pGC);

}
Пример #2
0
static void
miDCPutBits (
    DrawablePtr	    pDrawable,
    miDCCursorPtr   pPriv,
    GCPtr	    sourceGC,
    GCPtr	    maskGC,
    int             x_org,
    int             y_org,
    unsigned        w,
    unsigned        h,
    unsigned long   source,
    unsigned long   mask)
{
    ChangeGCVal gcval;
    int     x, y;

    if (sourceGC->fgPixel != source)
    {
	gcval.val = source;
	ChangeGC (NullClient, sourceGC, GCForeground, &gcval);
    }
    if (sourceGC->serialNumber != pDrawable->serialNumber)
	ValidateGC (pDrawable, sourceGC);

    if(sourceGC->miTranslate) 
    {
        x = pDrawable->x + x_org;
        y = pDrawable->y + y_org;
    } 
    else
    {
        x = x_org;
        y = y_org;
    }

    (*sourceGC->ops->PushPixels) (sourceGC, pPriv->sourceBits, pDrawable, w, h, x, y);
    if (maskGC->fgPixel != mask)
    {
	gcval.val = mask;
	ChangeGC (NullClient, maskGC, GCForeground, &gcval);
    }
    if (maskGC->serialNumber != pDrawable->serialNumber)
	ValidateGC (pDrawable, maskGC);

    if(maskGC->miTranslate) 
    {
        x = pDrawable->x + x_org;
        y = pDrawable->y + y_org;
    } 
    else
    {
        x = x_org;
        y = y_org;
    }

    (*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y);
}
Пример #3
0
/**
 * Sets up a scratch GC for fbFill, and saves other parameters for the
 * ephyrSolid implementation.
 */
static Bool
ephyrPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
{
    ScreenPtr pScreen = pPix->drawable.pScreen;
    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;
    EphyrScrPriv *scrpriv = screen->driver;
    EphyrFakexaPriv *fakexa = scrpriv->fakexa;
    CARD32 tmpval[3];

    ephyrPreparePipelinedAccess(pPix, EXA_PREPARE_DEST);

    fakexa->pDst = pPix;
    fakexa->pGC = GetScratchGC(pPix->drawable.depth, pScreen);

    tmpval[0] = alu;
    tmpval[1] = pm;
    tmpval[2] = fg;
    ChangeGC(fakexa->pGC, GCFunction | GCPlaneMask | GCForeground, 
	     tmpval);

    ValidateGC(&pPix->drawable, fakexa->pGC);

    TRACE_DRAW();

    return TRUE;
}
Пример #4
0
static void
cwFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, unsigned long pixel)
{
    ScreenPtr pScreen = pDrawable->pScreen;
    GCPtr     pGC;
    BoxPtr    pBox;
    int       nbox, i;
    ChangeGCVal v[3];

    pGC = GetScratchGC(pDrawable->depth, pScreen);
    v[0].val = GXcopy;
    v[1].val = pixel;
    v[2].val = FillSolid;
    dixChangeGC(NullClient, pGC, (GCFunction | GCForeground | GCFillStyle),
		NULL, v);
    ValidateGC(pDrawable, pGC);

    pBox = REGION_RECTS(pRegion);
    nbox = REGION_NUM_RECTS(pRegion);

    for (i = 0; i < nbox; i++, pBox++) {
	xRectangle rect;
	rect.x      = pBox->x1;
	rect.y      = pBox->y1;
	rect.width  = pBox->x2 - pBox->x1;
	rect.height = pBox->y2 - pBox->y1;
	(*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
    }

   FreeScratchGC(pGC);
}
Пример #5
0
/**
 * Sets up a scratch GC for fbCopyArea, and saves other parameters for the
 * ephyrCopy implementation.
 */
static Bool
ephyrPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu,
		 Pixel pm)
{
    ScreenPtr pScreen = pDst->drawable.pScreen;
    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;
    EphyrScrPriv *scrpriv = screen->driver;
    EphyrFakexaPriv *fakexa = scrpriv->fakexa;
    CARD32 tmpval[2];

    ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST);
    ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC);

    fakexa->pSrc = pSrc;
    fakexa->pDst = pDst;
    fakexa->pGC = GetScratchGC(pDst->drawable.depth, pScreen);

    tmpval[0] = alu;
    tmpval[1] = pm;
    ChangeGC (fakexa->pGC, GCFunction | GCPlaneMask, tmpval);

    ValidateGC(&pDst->drawable, fakexa->pGC);

    TRACE_DRAW();

    return TRUE;
}
static void
vivante_dri2_CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
	DRI2BufferPtr dstBuf, DRI2BufferPtr srcBuf)
{
	ScreenPtr screen = drawable->pScreen;
	DrawablePtr src = vivante_dri2_get_drawable(srcBuf, drawable);
	DrawablePtr dst = vivante_dri2_get_drawable(dstBuf, drawable);
	RegionPtr clip;
	GCPtr gc;

	gc = GetScratchGC(dst->depth, screen);
	if (!gc)
		return;

	clip = REGION_CREATE(screen, NULL, 0);
	REGION_COPY(screen, clip, pRegion);
	gc->funcs->ChangeClip(gc, CT_REGION, clip, 0);
	ValidateGC(dst, gc);

	/*
	 * FIXME: wait for scanline to be outside the region to be copied...
	 * that is an interesting problem for Dove/GAL stuff because they're
	 * independent, and there's no way for the GPU to know where the
	 * scan position is.  For now, just do the copy anyway.
	 */
	gc->ops->CopyArea(src, dst, gc, 0, 0,
			  drawable->width, drawable->height, 0, 0);

	FreeScratchGC(gc);
}
Пример #7
0
static void
cwFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
		  int x_off, int y_off)
{
    ScreenPtr pScreen = pDrawable->pScreen;
    GCPtr     pGC;
    BoxPtr    pBox;
    int       nbox, i;
    ChangeGCVal v[5];

    pGC = GetScratchGC(pDrawable->depth, pScreen);
    v[0].val = GXcopy;
    v[1].val = FillTiled;
    v[2].ptr = (pointer) pTile;
    v[3].val = x_off;
    v[4].val = y_off;
    dixChangeGC(NullClient, pGC, (GCFunction | GCFillStyle | GCTile |
		GCTileStipXOrigin | GCTileStipYOrigin), NULL, v);

    ValidateGC(pDrawable, pGC);

    pBox = REGION_RECTS(pRegion);
    nbox = REGION_NUM_RECTS(pRegion);

    for (i = 0; i < nbox; i++, pBox++) {
	xRectangle rect;
	rect.x      = pBox->x1;
	rect.y      = pBox->y1;
	rect.width  = pBox->x2 - pBox->x1;
	rect.height = pBox->y2 - pBox->y1;
	(*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
    }

   FreeScratchGC(pGC);
}
Пример #8
0
Bool
miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
                     int x, int y, int w, int h)
{
    miDCBufferPtr   pBuffer;
    PixmapPtr	    pSave;
    WindowPtr	    pWin;
    GCPtr	    pGC;

    pBuffer = miGetDCDevice(pDev, pScreen);

    pSave = pBuffer->pSave;
    pWin = pScreen->root;
    if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
    {
	if (pSave)
	    (*pScreen->DestroyPixmap) (pSave);
	pBuffer->pSave = pSave =
		(*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth, 0);
	if (!pSave)
	    return FALSE;
    }

    pGC = pBuffer->pSaveGC;
    if (pSave->drawable.serialNumber != pGC->serialNumber)
	ValidateGC ((DrawablePtr) pSave, pGC);
    (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
			    x, y, w, h, 0, 0);
    return TRUE;
}
Пример #9
0
static void
miColorRects (PicturePtr    pDst,
	      PicturePtr    pClipPict,
	      xRenderColor  *color,
	      int	    nRect,
	      xRectangle    *rects,
	      int	    xoff,
	      int	    yoff)
{
    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
    CARD32		pixel;
    GCPtr		pGC;
    CARD32		tmpval[5];
    RegionPtr		pClip;
    unsigned long	mask;

    miRenderColorToPixel (pDst->pFormat, color, &pixel);

    pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
    if (!pGC)
	return;
    tmpval[0] = GXcopy;
    tmpval[1] = pixel;
    tmpval[2] = pDst->subWindowMode;
    mask = GCFunction | GCForeground | GCSubwindowMode;
    if (pClipPict->clientClipType == CT_REGION)
    {
	tmpval[3] = pDst->clipOrigin.x - xoff;
	tmpval[4] = pDst->clipOrigin.y - yoff;
	mask |= GCClipXOrigin|GCClipYOrigin;
	
	pClip = REGION_CREATE (pScreen, NULL, 1);
	REGION_COPY (pScreen, pClip,
		     (RegionPtr) pClipPict->clientClip);
	(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
    }

    ChangeGC (pGC, mask, tmpval);
    ValidateGC (pDst->pDrawable, pGC);
    if (xoff || yoff)
    {
	int	i;
	for (i = 0; i < nRect; i++)
	{
	    rects[i].x -= xoff;
	    rects[i].y -= yoff;
	}
    }
    (*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects);
    if (xoff || yoff)
    {
	int	i;
	for (i = 0; i < nRect; i++)
	{
	    rects[i].x += xoff;
	    rects[i].y += yoff;
	}
    }
    FreeScratchGC (pGC);
}
Пример #10
0
void
glamor_solid_boxes(PixmapPtr pixmap,
                   BoxPtr box, int nbox, unsigned long fg_pixel)
{
    DrawablePtr drawable = &pixmap->drawable;
    GCPtr gc;
    xRectangle *rect;
    int n;

    rect = xallocarray(nbox, sizeof(xRectangle));
    if (!rect)
        return;
    for (n = 0; n < nbox; n++) {
        rect[n].x = box[n].x1;
        rect[n].y = box[n].y1;
        rect[n].width = box[n].x2 - box[n].x1;
        rect[n].height = box[n].y2 - box[n].y1;
    }

    gc = GetScratchGC(drawable->depth, drawable->pScreen);
    if (gc) {
        ChangeGCVal vals[1];

        vals[0].val = fg_pixel;
        ChangeGC(NullClient, gc, GCForeground, vals);
        ValidateGC(drawable, gc);
        gc->ops->PolyFillRect(drawable, gc, nbox, rect);
        FreeScratchGC(gc);
    }
    free(rect);
}
Пример #11
0
void
compRestoreWindow(WindowPtr pWin, PixmapPtr pPixmap)
{
    ScreenPtr pScreen = pWin->drawable.pScreen;
    WindowPtr pParent = pWin->parent;

    if (pParent->drawable.depth == pWin->drawable.depth) {
        GCPtr pGC = GetScratchGC(pWin->drawable.depth, pScreen);
        int bw = (int) pWin->borderWidth;
        int x = bw;
        int y = bw;
        int w = pWin->drawable.width;
        int h = pWin->drawable.height;

        if (pGC) {
            ChangeGCVal val;

            val.val = IncludeInferiors;
            ChangeGC(NullClient, pGC, GCSubwindowMode, &val);
            ValidateGC(&pWin->drawable, pGC);
            (*pGC->ops->CopyArea) (&pPixmap->drawable,
                                   &pWin->drawable, pGC, x, y, w, h, 0, 0);
            FreeScratchGC(pGC);
        }
    }
}
Пример #12
0
/* MICLEARDRAWABLE -- sets the entire drawable to the background color of
 * the GC.  Useful when we have a scratch drawable and need to initialize
 * it. */
void
miClearDrawable(DrawablePtr pDraw, GCPtr pGC)
{
    ChangeGCVal fg, bg;
    xRectangle rect;

    fg.val = pGC->fgPixel;
    bg.val = pGC->bgPixel;
    rect.x = 0;
    rect.y = 0;
    rect.width = pDraw->width;
    rect.height = pDraw->height;
    ChangeGC(NullClient, pGC, GCForeground, &bg);
    ValidateGC(pDraw, pGC);
    (*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &rect);
    ChangeGC(NullClient, pGC, GCForeground, &fg);
    ValidateGC(pDraw, pGC);
}
static PixmapPtr
glamor_get_stipple_pixmap(GCPtr gc)
{
    glamor_gc_private *gc_priv = glamor_get_gc_private(gc);
    ScreenPtr   screen = gc->pScreen;
    PixmapPtr   bitmap;
    PixmapPtr   pixmap;
    GCPtr       scratch_gc;
    ChangeGCVal changes[2];

    if (gc_priv->stipple)
        return gc_priv->stipple;

    bitmap = gc->stipple;
    if (!bitmap)
        goto bail;

    pixmap = glamor_create_pixmap(screen,
                                  bitmap->drawable.width,
                                  bitmap->drawable.height,
                                  8, GLAMOR_CREATE_NO_LARGE);
    if (!pixmap)
        goto bail;

    scratch_gc = GetScratchGC(8, screen);
    if (!scratch_gc)
        goto bail_pixmap;

    changes[0].val = 0xff;
    changes[1].val = 0x00;
    if (ChangeGC(NullClient, scratch_gc,
                 GCForeground|GCBackground, changes) != Success)
        goto bail_gc;
    ValidateGC(&pixmap->drawable, scratch_gc);

    (*scratch_gc->ops->CopyPlane)(&bitmap->drawable,
                                  &pixmap->drawable,
                                  scratch_gc,
                                  0, 0,
                                  bitmap->drawable.width,
                                  bitmap->drawable.height,
                                  0, 0, 0x1);

    FreeScratchGC(scratch_gc);
    gc_priv->stipple = pixmap;

    glamor_track_stipple(gc);

    return pixmap;

bail_gc:
    FreeScratchGC(scratch_gc);
bail_pixmap:
    glamor_destroy_pixmap(pixmap);
bail:
    return NULL;
}
Пример #14
0
/* XXX LARGE pixmap? */
Bool
glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
{
    glamor_pixmap_fbo *old_fbo;
    glamor_pixmap_fbo *new_fbo = NULL;
    PixmapPtr scratch = NULL;
    glamor_pixmap_private *scratch_priv;
    DrawablePtr drawable;
    GCPtr gc = NULL;
    int ret = FALSE;

    drawable = &pixmap_priv->base.pixmap->drawable;

    if (!GLAMOR_PIXMAP_FBO_NOT_EXACT_SIZE(pixmap_priv))
        return TRUE;

    old_fbo = pixmap_priv->base.fbo;

    if (!old_fbo)
        return FALSE;

    gc = GetScratchGC(drawable->depth, screen);
    if (!gc)
        goto fail;

    scratch = glamor_create_pixmap(screen, drawable->width, drawable->height,
                                   drawable->depth, GLAMOR_CREATE_PIXMAP_FIXUP);

    scratch_priv = glamor_get_pixmap_private(scratch);

    if (!scratch_priv->base.fbo)
        goto fail;

    ValidateGC(&scratch->drawable, gc);
    glamor_copy_area(drawable,
                     &scratch->drawable,
                     gc, 0, 0, drawable->width, drawable->height, 0, 0);
    old_fbo = glamor_pixmap_detach_fbo(pixmap_priv);
    new_fbo = glamor_pixmap_detach_fbo(scratch_priv);
    glamor_pixmap_attach_fbo(pixmap_priv->base.pixmap, new_fbo);
    glamor_pixmap_attach_fbo(scratch, old_fbo);

    DEBUGF("old %dx%d type %d\n",
           drawable->width, drawable->height, pixmap_priv->type);
    DEBUGF("copy tex %d  %dx%d to tex %d %dx%d \n",
           old_fbo->tex, old_fbo->width, old_fbo->height, new_fbo->tex,
           new_fbo->width, new_fbo->height);
    ret = TRUE;
 fail:
    if (gc)
        FreeScratchGC(gc);
    if (scratch)
        glamor_destroy_pixmap(scratch);

    return ret;
}
Пример #15
0
static PixmapPtr
glamor_get_dash_pixmap(GCPtr gc)
{
    glamor_gc_private *gc_priv = glamor_get_gc_private(gc);
    ScreenPtr   screen = gc->pScreen;
    PixmapPtr   pixmap;
    int         offset;
    int         d;
    uint32_t    pixel;
    GCPtr       scratch_gc;

    if (gc_priv->dash)
        return gc_priv->dash;

    offset = 0;
    for (d = 0; d < gc->numInDashList; d++)
        offset += gc->dash[d];

    pixmap = glamor_create_pixmap(screen, offset, 1, 8, 0);
    if (!pixmap)
        goto bail;

    scratch_gc = GetScratchGC(8, screen);
    if (!scratch_gc)
        goto bail_pixmap;

    pixel = 0xffffffff;
    offset = 0;
    for (d = 0; d < gc->numInDashList; d++) {
        xRectangle      rect;
        ChangeGCVal     changes;

        changes.val = pixel;
        (void) ChangeGC(NullClient, scratch_gc,
                        GCForeground, &changes);
        ValidateGC(&pixmap->drawable, scratch_gc);
        rect.x = offset;
        rect.y = 0;
        rect.width = gc->dash[d];
        rect.height = 1;
        scratch_gc->ops->PolyFillRect (&pixmap->drawable, scratch_gc, 1, &rect);
        offset += gc->dash[d];
        pixel = ~pixel;
    }
    FreeScratchGC(scratch_gc);

    gc_priv->dash = pixmap;
    return pixmap;

bail_pixmap:
    glamor_destroy_pixmap(pixmap);
bail:
    return NULL;
}
Пример #16
0
static void
fbSetFg(DrawablePtr pDrawable, GCPtr pGC, Pixel fg)
{
    if (fg != pGC->fgPixel) {
        ChangeGCVal val;

        val.val = fg;
        ChangeGC(NullClient, pGC, GCForeground, &val);
        ValidateGC(pDrawable, pGC);
    }
}
Пример #17
0
static void
xf86_dga_blit_rect(ScrnInfoPtr scrn, int srcx, int srcy, int w, int h, int dstx, int dsty)
{
    DrawablePtr	pDrawable;
    GCPtr	pGC;

    if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC))
        return;
    ValidateGC (pDrawable, pGC);
    pGC->ops->CopyArea (pDrawable, pDrawable, pGC, srcx, srcy, w, h, dstx, dsty);
    xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC);
}
Пример #18
0
static void
MSMDRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
		DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
{
	ScreenPtr pScreen = pDraw->pScreen;
	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
	DrawablePtr pSrcDraw = dri2draw(pDraw, pSrcBuffer);
	DrawablePtr pDstDraw = dri2draw(pDraw, pDstBuffer);
	RegionPtr pCopyClip;
	GCPtr pGC;

	DEBUG_MSG("pDraw=%p, pDstBuffer=%p (%p), pSrcBuffer=%p (%p)",
			pDraw, pDstBuffer, pSrcDraw, pSrcBuffer, pDstDraw);

	/* hack.. since we don't have proper fencing / kernel synchronization
	 * we can get in a scenario where we get many frames ahead of the gpu,
	 * with queued up cmd sequence like: render -> blit -> render -> blit ..
	 * This hack makes sure the previous blit has completed.
	 */
	{
	MSMPtr pMsm = MSMPTR(pScrn);
	MSMDRI2BufferPtr buf = MSMBUF(pDstBuffer);
	pMsm->pExa->PrepareAccess(buf->pPixmap, 0);
	pMsm->pExa->FinishAccess(buf->pPixmap, 0);
	}

	pGC = GetScratchGC(pDstDraw->depth, pScreen);
	if (!pGC) {
		return;
	}

	pCopyClip = REGION_CREATE(pScreen, NULL, 0);
	RegionCopy(pCopyClip, pRegion);
	(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pCopyClip, 0);
	ValidateGC(pDstDraw, pGC);

	/* If the dst is the framebuffer, and we had a way to
	 * schedule a deferred blit synchronized w/ vsync, that
	 * would be a nice thing to do utilize here to avoid
	 * tearing..  when we have sync object support for GEM
	 * buffers, I think we could do something more clever
	 * here.
	 */

	pGC->ops->CopyArea(pSrcDraw, pDstDraw, pGC,
			0, 0, pDraw->width, pDraw->height, 0, 0);

	FreeScratchGC(pGC);

	MSMFlushAccel(pScreen);
}
Пример #19
0
/* Do ordinary copy */
static void MaliDRI2CopyRegion_copy(DrawablePtr pDraw,
                                    RegionPtr pRegion,
                                    DRI2BufferPtr pDstBuffer,
                                    DRI2BufferPtr pSrcBuffer)
{
    GCPtr pGC;
    RegionPtr copyRegion;
    ScreenPtr pScreen = pDraw->pScreen;
    MaliDRI2BufferPrivatePtr privates;
    PixmapPtr pScratchPixmap;
    privates = (MaliDRI2BufferPrivatePtr)pSrcBuffer->driverPrivate;

//    DebugMsg("Enter MaliDRI2CopyRegion    buf_name:%d\n",pSrcBuffer->name);
/*
#ifdef HAVE_LIBUMP_CACHE_CONTROL
    if (privates->handle != UMP_INVALID_MEMORY_HANDLE) {
//        That's a normal UMP allocation, not a wrapped framebuffer
        ump_cache_operations_control(UMP_CACHE_OP_START);
        ump_switch_hw_usage_secure_id(pSrcBuffer->name, UMP_USED_BY_CPU);
        ump_cache_operations_control(UMP_CACHE_OP_FINISH);
    }
#endif
*/
    pGC = GetScratchGC(pDraw->depth, pScreen);
    pScratchPixmap = GetScratchPixmapHeader(pScreen,
                                            privates->width, privates->height,
                                            privates->depth, pSrcBuffer->cpp * 8,
                                            pSrcBuffer->pitch,
                                            privates->addr + pSrcBuffer->flags);
    copyRegion = REGION_CREATE(pScreen, NULL, 0);
    REGION_COPY(pScreen, copyRegion, pRegion);
    (*pGC->funcs->ChangeClip)(pGC, CT_REGION, copyRegion, 0);
    ValidateGC(pDraw, pGC);
    (*pGC->ops->CopyArea)((DrawablePtr)pScratchPixmap, pDraw, pGC, 0, 0,
                          pDraw->width, pDraw->height, 0, 0);
    FreeScratchPixmapHeader(pScratchPixmap);
    FreeScratchGC(pGC);
/*
#ifdef HAVE_LIBUMP_CACHE_CONTROL
    if (privates->handle != UMP_INVALID_MEMORY_HANDLE) {
//        That's a normal UMP allocation, not a wrapped framebuffer
        ump_cache_operations_control(UMP_CACHE_OP_START);
        ump_switch_hw_usage_secure_id(pSrcBuffer->name, UMP_USED_BY_MALI);
        ump_cache_operations_control(UMP_CACHE_OP_FINISH);
    }
#endif
*/
}
Пример #20
0
PicturePtr
miCreateAlphaPicture (ScreenPtr	    pScreen, 
		      PicturePtr    pDst,
		      PictFormatPtr pPictFormat,
		      CARD16	    width,
		      CARD16	    height)
{
    PixmapPtr	    pPixmap;
    PicturePtr	    pPicture;
    GCPtr	    pGC;
    int		    error;
    xRectangle	    rect;

    if (width > 32767 || height > 32767)
	return 0;

    if (!pPictFormat)
    {
	if (pDst->polyEdge == PolyEdgeSharp)
	    pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
	else
	    pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
	if (!pPictFormat)
	    return 0;
    }

    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 
					pPictFormat->depth);
    if (!pPixmap)
	return 0;
    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
    if (!pGC)
    {
	(*pScreen->DestroyPixmap) (pPixmap);
	return 0;
    }
    ValidateGC (&pPixmap->drawable, pGC);
    rect.x = 0;
    rect.y = 0;
    rect.width = width;
    rect.height = height;
    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
    FreeScratchGC (pGC);
    pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
			      0, 0, serverClient, &error);
    (*pScreen->DestroyPixmap) (pPixmap);
    return pPicture;
}
Пример #21
0
void XMesaPutImageHelper(ScreenPtr display,
			 DrawablePtr d, GCPtr gc,
			 XMesaImage *image,
			 int src_x, int src_y,
			 int dest_x, int dest_y,
			 unsigned int width, unsigned int height)
{
    /* NOT_DONE: Verify that the following works for all depths */
    char *src = (image->data +
		 src_y * image->bytes_per_line +
		 ((src_x * image->bits_per_pixel) >> 3));

    ValidateGC(d, gc);
    (*gc->ops->PutImage)(d, gc, d->depth, dest_x, dest_y, width, height,
			 0, ZPixmap, src);
}
void sgx_exa_copy_region(DrawablePtr draw, RegionPtr reg, DrawablePtr src_draw,
			DrawablePtr dst_draw)
{
        ScreenPtr screen = dst_draw->pScreen;
	RegionPtr copy_clip = RegionCreate(NULL, 0);
        GCPtr gc;

        gc = GetScratchGC(dst_draw->depth, screen);
	RegionCopy(copy_clip, reg);
        (*gc->funcs->ChangeClip)(gc, CT_REGION, copy_clip, 0);
        ValidateGC(dst_draw, gc);

        (*gc->ops->CopyArea)(src_draw, dst_draw, gc, 0, 0, draw->width,
                                draw->height, 0, 0);

        FreeScratchGC(gc);
}
Пример #23
0
/*
 * If the given request doesn't exactly match PutImage's constraints,
 * wrap the image in a scratch pixmap header and let CopyArea sort it out.
 */
static void
doShmPutImage(DrawablePtr dst, GCPtr pGC,
              int depth, unsigned int format,
              int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
              char *data)
{
    PixmapPtr pPixmap;

    if (format == ZPixmap || (format == XYPixmap && depth == 1)) {
        pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth,
                                         BitsPerPixel(depth),
                                         PixmapBytePad(w, depth), data);
        if (!pPixmap)
            return;
        pGC->ops->CopyArea((DrawablePtr) pPixmap, dst, pGC, sx, sy, sw, sh, dx,
                           dy);
        FreeScratchPixmapHeader(pPixmap);
    }
    else {
        GCPtr putGC = GetScratchGC(depth, dst->pScreen);

        if (!putGC)
            return;

        pPixmap = (*dst->pScreen->CreatePixmap) (dst->pScreen, sw, sh, depth,
                                                 CREATE_PIXMAP_USAGE_SCRATCH);
        if (!pPixmap) {
            FreeScratchGC(putGC);
            return;
        }
        ValidateGC(&pPixmap->drawable, putGC);
        (*putGC->ops->PutImage) (&pPixmap->drawable, putGC, depth, -sx, -sy, w,
                                 h, 0,
                                 (format == XYPixmap) ? XYPixmap : ZPixmap,
                                 data);
        FreeScratchGC(putGC);
        if (format == XYBitmap)
            (void) (*pGC->ops->CopyPlane) (&pPixmap->drawable, dst, pGC, 0, 0,
                                           sw, sh, dx, dy, 1L);
        else
            (void) (*pGC->ops->CopyArea) (&pPixmap->drawable, dst, pGC, 0, 0,
                                          sw, sh, dx, dy);
        (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
    }
}
Пример #24
0
static Bool
CreateDefaultTile (GCPtr pGC)
{
    XID		tmpval[3];
    PixmapPtr 	pTile;
    GCPtr	pgcScratch;
    xRectangle	rect;
    CARD16	w, h;

    w = 1;
    h = 1;
    (*pGC->pScreen->QueryBestSize)(TileShape, &w, &h, pGC->pScreen);
    pTile = (PixmapPtr)
	    (*pGC->pScreen->CreatePixmap)(pGC->pScreen,
					  w, h, pGC->depth);
    pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen);
    if (!pTile || !pgcScratch)
    {
	if (pTile)
	    (*pTile->drawable.pScreen->DestroyPixmap)(pTile);
	if (pgcScratch)
	    FreeScratchGC(pgcScratch);
	return FALSE;
    }
    tmpval[0] = GXcopy;
    tmpval[1] = pGC->tile.pixel;
    tmpval[2] = FillSolid;
    (void)ChangeGC(pgcScratch, GCFunction | GCForeground | GCFillStyle, 
		   tmpval);
    ValidateGC((DrawablePtr)pTile, pgcScratch);
    rect.x = 0;
    rect.y = 0;
    rect.width = w;
    rect.height = h;
    (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pTile, pgcScratch, 1, &rect);
    /* Always remember to free the scratch graphics context after use. */
    FreeScratchGC(pgcScratch);

    pGC->tileIsPixel = FALSE;
    pGC->tile.pixmap = pTile;
    return TRUE;
}
Пример #25
0
static void
ARMSOCDRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
		DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
{
	ScreenPtr pScreen = pDraw->pScreen;
	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
	RegionPtr pCopyClip;
	GCPtr pGC;
        PixmapPtr pScratchPixmap;
        struct ARMSOCDRI2BufferRec *src = ARMSOCBUF(pSrcBuffer);

	DEBUG_MSG("pDraw=%p, pDstBuffer=%p pSrcBuffer=%p",
			pDraw, pDstBuffer, pSrcBuffer);

	pGC = GetScratchGC(pDraw->depth, pScreen);
	if (!pGC)
		return;

	pCopyClip = REGION_CREATE(pScreen, NULL, 0);
	RegionCopy(pCopyClip, pRegion);
	(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pCopyClip, 0);
	ValidateGC(pDraw, pGC);

	/* If the dst is the framebuffer, and we had a way to
	 * schedule a deferred blit synchronized w/ vsync, that
	 * would be a nice thing to do utilize here to avoid
	 * tearing..  when we have sync object support for GEM
	 * buffers, I think we could do something more clever
	 * here.
	 */

        pScratchPixmap = GetScratchPixmapHeader(pScreen,
		armsoc_bo_width(src->bo), armsoc_bo_height(src->bo),
		armsoc_bo_depth(src->bo), armsoc_bo_bpp(src->bo),
		armsoc_bo_pitch(src->bo), armsoc_bo_map(src->bo));
		

	pGC->ops->CopyArea((DrawablePtr) pScratchPixmap, pDraw, pGC,
			0, 0, pDraw->width, pDraw->height, 0, 0);
	FreeScratchPixmapHeader(pScratchPixmap);
	FreeScratchGC(pGC);
}
Пример #26
0
static void
xf86_dga_fill_rect(ScrnInfoPtr scrn, int x, int y, int w, int h, unsigned long color)
{
    GCPtr		pGC;
    DrawablePtr		pDrawable;
    XID			vals[1];
    xRectangle		r;

    if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC))
        return;
    vals[0] = color;
    ChangeGC (pGC, GCForeground, vals);
    ValidateGC (pDrawable, pGC);
    r.x = x;
    r.y = y;
    r.width = w;
    r.height = h;
    pGC->ops->PolyFillRect (pDrawable, pGC, 1, &r);
    xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC);
}
Пример #27
0
static void MaliDRI2CopyRegion(DrawablePtr   pDraw,
                               RegionPtr     pRegion,
                               DRI2BufferPtr pDstBuffer,
                               DRI2BufferPtr pSrcBuffer)
{
    GCPtr pGC;
    RegionPtr copyRegion;
    ScreenPtr pScreen = pDraw->pScreen;
    MaliDRI2BufferPrivatePtr privates;
    PixmapPtr pScratchPixmap;
    privates = (MaliDRI2BufferPrivatePtr)pSrcBuffer->driverPrivate;

    if (privates->depth != pDraw->depth) {
        ErrorF("MaliDRI2CopyRegion: privates->depth != pDraw->depth (%d vs. %d)\n",
               privates->depth, pDraw->depth);
        return;
    }

    //ErrorF("MaliDRI2CopyRegion dstbuf=%p srcbuf=%p, depth=%d\n", pDstBuffer, pSrcBuffer, privates->depth);

    ump_cache_operations_control(UMP_CACHE_OP_START);
    ump_switch_hw_usage_secure_id(pSrcBuffer->name, UMP_USED_BY_CPU);
    ump_cache_operations_control(UMP_CACHE_OP_FINISH);

    pGC = GetScratchGC(pDraw->depth, pScreen);
    pScratchPixmap = GetScratchPixmapHeader(pScreen, privates->width, privates->height,
                                            privates->depth, pSrcBuffer->cpp * 8,
                                            pSrcBuffer->pitch, privates->addr);
    copyRegion = REGION_CREATE(pScreen, NULL, 0);
    REGION_COPY(pScreen, copyRegion, pRegion);
    (*pGC->funcs->ChangeClip)(pGC, CT_REGION, copyRegion, 0);
    ValidateGC(pDraw, pGC);
    (*pGC->ops->CopyArea)(pScratchPixmap, pDraw, pGC, 0, 0,
                          pDraw->width, pDraw->height, 0, 0);
    FreeScratchPixmapHeader(pScratchPixmap);
    FreeScratchGC(pGC);

    ump_cache_operations_control(UMP_CACHE_OP_START);
    ump_switch_hw_usage_secure_id(pSrcBuffer->name, UMP_USED_BY_MALI);
    ump_cache_operations_control(UMP_CACHE_OP_FINISH);
}
static void
uxa_clear_pixmap(ScreenPtr screen,
		 uxa_screen_t *uxa_screen,
		 PixmapPtr pixmap)
{
	if (uxa_screen->info->check_solid &&
	    !uxa_screen->info->check_solid(&pixmap->drawable, GXcopy, FB_ALLONES))
		goto fallback;

	if (!uxa_screen->info->prepare_solid(pixmap, GXcopy, FB_ALLONES, 0))
		goto fallback;

	uxa_screen->info->solid(pixmap,
				0, 0,
				pixmap->drawable.width,
				pixmap->drawable.height);

	uxa_screen->info->done_solid(pixmap);
	return;

fallback:
	{
		GCPtr gc;

		gc = GetScratchGC(pixmap->drawable.depth, screen);
		if (gc) {
			xRectangle rect;

			ValidateGC(&pixmap->drawable, gc);

			rect.x = 0;
			rect.y = 0;
			rect.width  = pixmap->drawable.width;
			rect.height = pixmap->drawable.height;
			gc->ops->PolyFillRect(&pixmap->drawable, gc, 1, &rect);

			FreeScratchGC(gc);
		}
	}
}
Пример #29
0
void
glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
             unsigned long fg_pixel)
{
    DrawablePtr drawable = &pixmap->drawable;
    GCPtr gc;
    ChangeGCVal vals[1];
    xRectangle rect;

    vals[0].val = fg_pixel;
    gc = GetScratchGC(drawable->depth, drawable->pScreen);
    if (!gc)
        return;
    ChangeGC(NullClient, gc, GCForeground, vals);
    ValidateGC(drawable, gc);
    rect.x = x;
    rect.y = y;
    rect.width = width;
    rect.height = height;
    gc->ops->PolyFillRect(drawable, gc, 1, &rect);
    FreeScratchGC(gc);
}
Пример #30
0
Bool
miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
                        int x, int y, int w, int h)
{
    miDCBufferPtr   pBuffer;
    PixmapPtr	    pSave;
    WindowPtr	    pWin;
    GCPtr	    pGC;

    pBuffer = miGetDCDevice(pDev, pScreen);
    pSave = pBuffer->pSave;

    pWin = pScreen->root;
    if (!pSave)
	return FALSE;

    pGC = pBuffer->pRestoreGC;
    if (pWin->drawable.serialNumber != pGC->serialNumber)
	ValidateGC ((DrawablePtr) pWin, pGC);
    (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
			    0, 0, w, h, x, y);
    return TRUE;
}