示例#1
0
	ScreenEncoder::ScreenEncoder(ScreenBuffer& buffer) :
		screenBuffer(buffer), tightEncoder(0), flashClient(false),sendCount(0), maxSize(DDSS_MAX_SUB_PKT_SIZE),overflowCount(0), underflowCount(0)
	{
	
		tightEncoder = new TightEncoder(*this);
		CL_SLOT *cl = (CL_SLOT *)&slot;
		memset(cl, 0, sizeof(CL_SLOT));
		cl->fb_width = screenBuffer.getWidth();
		cl->fb_height = screenBuffer.getHeight();
		screenBuffer.screenInfo.populate(cl->format);
	
		cl->trans_table = 0;
		cl->enc_enable[RFB_ENCODING_RAW] = 1;
		cl->enc_enable[RFB_ENCODING_TIGHT] = 1;
		//cl->enc_enable[RFB_ENCODING_LASTRECT] = 1;
		cl->enc_prefer = RFB_ENCODING_TIGHT;
		cl->bgr233_f = (screenBuffer.screenInfo.getBitsPerPixel() == 8)?1:0;
		cl->compress_level = 9; /* default compression level */
		cl->jpeg_quality = -1; /* disable JPEG by default */
	
		/* The client did not requested framebuffer updates yet */
		cl->update_requested = 0;
		cl->update_in_progress = 0;
		REGION_INIT(&cl->pending_region, NullBox, 16);
		REGION_INIT(&cl->copy_region, NullBox, 8);
		cl->newfbsize_pending = 0;
		/* We are connected. */
		cl->connected = 1;
		cl->enable_lastrect = 1;
		
		u32 wFull = screenBuffer.getWidth();
		u32 hFull = screenBuffer.getHeight();
		u32 wChunk = wFull / 16;
		u32 hChunk = hFull / 16;
		u32 wLast = wFull - wChunk * 15;
		u32 hLast = hFull - hChunk * 15;
		for(int y = 0; y < 16; y++)
		{

			for(int x = 0; x < 16; x++)
			{
				ScreenRectangle r;
				r.w = (u16)(x == 15? wLast:wChunk);
				r.h = (u16)(y == 15? hLast:hChunk);
				r.x = (u16)(x * wChunk);
				r.y = (u16)(y * hChunk);
				r.enc = RFB_ENCODING_TIGHT;
				this->pendingRectList.push_back(r);
			}
		}
		DDSS_VERBOSE("ScreenEncoder")<<"Pixel format translation tables not needed"<<std::endl;
		//String id = "ddd";
		//IDGenerator::generateClientId(id);
		//id+="-rect.log";
		//dumpFile.open(id.c_str());
	
		screenBuffer.screenInfo.fill(&cl->format);
}
示例#2
0
void
xglAddCurrentBitDamage (DrawablePtr pDrawable)
{
    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);

    if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
    {
	BoxPtr pBitExt;

	pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);

	if (pPixmapPriv->damageBox.x1 < pBitExt->x2 &&
	    pPixmapPriv->damageBox.y1 < pBitExt->y2 &&
	    pPixmapPriv->damageBox.x2 > pBitExt->x1 &&
	    pPixmapPriv->damageBox.y2 > pBitExt->y1)
	{
	    REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
	    REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
			 NullBox, 0);
	    pPixmapPriv->allBits = FALSE;
	}
    }

    pPixmapPriv->damageBox = miEmptyBox;
}
示例#3
0
/**
 * exaPixmapDirty() marks a pixmap as dirty, allowing for
 * optimizations in pixmap migration when no changes have occurred.
 */
void
exaPixmapDirty (PixmapPtr pPix, int x1, int y1, int x2, int y2)
{
    ExaPixmapPriv(pPix);
    BoxRec box;
    RegionPtr pDamageReg;
    RegionRec region;

    if (!pExaPixmap)
	return;
	
    box.x1 = max(x1, 0);
    box.y1 = max(y1, 0);
    box.x2 = min(x2, pPix->drawable.width);
    box.y2 = min(y2, pPix->drawable.height);

    if (box.x1 >= box.x2 || box.y1 >= box.y2)
	return;

    pDamageReg = DamageRegion(pExaPixmap->pDamage);

    REGION_INIT(pScreen, &region, &box, 1);
    REGION_UNION(pScreen, pDamageReg, pDamageReg, &region);
    REGION_UNINIT(pScreen, &region);
}
示例#4
0
文件: xf86fbman.c 项目: aosm/X11
static void
localFreeOffscreenArea(FBAreaPtr area)
{
   FBManagerPtr offman;
   FBLinkPtr pLink, pLinkPrev = NULL;
   RegionRec FreedRegion;
   ScreenPtr pScreen;

   pScreen = area->pScreen;
   offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
       
   pLink = offman->UsedAreas;
   if(!pLink) return;  
 
   while(&(pLink->area) != area) {
	pLinkPrev = pLink;
	pLink = pLink->next;
	if(!pLink) return;
   }

   /* put the area back into the pool */
   REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1); 
   REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
   REGION_UNINIT(pScreen, &FreedRegion); 

   if(pLinkPrev)
	pLinkPrev->next = pLink->next;
   else offman->UsedAreas = pLink->next;

   xfree(pLink); 
   offman->NumUsedAreas--;

   SendCallFreeBoxCallbacks(offman);
}
示例#5
0
void
xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
{
    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);

    if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
    {
	RegionRec region;

	REGION_INIT (pDrawable->pScreen, &region, &pPixmapPriv->damageBox, 1);

	if (pPixmapPriv->pDamage)
	{
	    RegionPtr pDamageRegion;

	    pDamageRegion = DamageRegion (pPixmapPriv->pDamage);

	    REGION_UNION (pDrawable->pScreen,
			  pDamageRegion, pDamageRegion,
			  &region);
	}

	REGION_UNION (pDrawable->pScreen,
		      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
		      &region);

	REGION_UNINIT (pDrawable->pScreen, &region);

	pPixmapPriv->damageBox = miEmptyBox;
    }
}
示例#6
0
static void
kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
    RegionRec	rgnDst;
    int		dx, dy;
    PixmapPtr	pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);

    dx = ptOldOrg.x - pWin->drawable.x;
    dy = ptOldOrg.y - pWin->drawable.y;
    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);

    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
    
    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
#ifdef COMPOSITE
    if (pPixmap->screen_x || pPixmap->screen_y)
	REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, 
			  -pPixmap->screen_x, -pPixmap->screen_y);
#endif

    fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
		  0,
		  &rgnDst, dx, dy, kaaCopyNtoN, 0, 0);
    
    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
}
示例#7
0
static void
ExaSrcValidate(DrawablePtr pDrawable,
	       int x,
	       int y,
	       int width,
	       int height)
{
    ScreenPtr pScreen = pDrawable->pScreen;
    ExaScreenPriv(pScreen);
    PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
    BoxRec box;
    RegionRec reg;
    RegionPtr dst;
    int xoff, yoff;

    exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);

    box.x1 = x + xoff;
    box.y1 = y + yoff;
    box.x2 = box.x1 + width;
    box.y2 = box.y1 + height;

    dst = (pExaScr->srcPix == pPix) ? &pExaScr->srcReg :
	&pExaScr->maskReg;

    REGION_INIT(pScreen, &reg, &box, 1);
    REGION_UNION(pScreen, dst, dst, &reg);
    REGION_UNINIT(pScreen, &reg);

    if (pExaScr->SavedSourceValidate) {
        swap(pExaScr, pScreen, SourceValidate);
        pScreen->SourceValidate(pDrawable, x, y, width, height);
        swap(pExaScr, pScreen, SourceValidate);
    }
}
示例#8
0
static void
ExaFallbackPrepareReg(DrawablePtr pDrawable,
		      GCPtr pGC,
		      int x, int y, int width, int height,
		      int index, Bool checkReads)
{
    ScreenPtr pScreen = pDrawable->pScreen;
    ExaScreenPriv(pScreen);

    if (pExaScr->prepare_access_reg &&
	!(checkReads && exaGCReadsDestination(pDrawable,
					      pGC->planemask,
					      pGC->fillStyle,
					      pGC->alu,
					      pGC->clientClipType))) {
	BoxRec box;
	RegionRec reg;
	int xoff, yoff;
	PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);

	exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
	box.x1 = pDrawable->x + x + xoff;
	box.y1 = pDrawable->y + y + yoff;
	box.x2 = box.x1 + width;
	box.y2 = box.y1 + height;

	REGION_INIT(pScreen, &reg, &box, 1);
	pExaScr->prepare_access_reg(pPixmap, index, &reg);
	REGION_UNINIT(pScreen, &reg);
    } else
	exaPrepareAccess(pDrawable, index);
}
示例#9
0
static void
update_screen(struct omap_screen_info *omaps)
{
    BoxPtr tmp;
    int i;

    if (region_is_null(omaps))
        return;

    if (!omaps->block_updates) {
        /* Remove the video region from our active area. */
        if (omaps->video_region &&
            REGION_NOTEMPTY(omaps->screen->pScreen, omaps->video_region) &&
            RECT_IN_REGION(omaps->screen->pScreen, omaps->video_region,
                           &omaps->dirty_area)) {
            REGION_INIT(omaps->screen->pScreen, omaps->tmp_region,
                        &omaps->dirty_area, 1);
            REGION_SUBTRACT(omaps->screen->pScreen, omaps->tmp_region,
                            omaps->tmp_region, omaps->video_region);
            tmp = REGION_RECTS(omaps->tmp_region);
            for (i = 0; i < REGION_NUM_RECTS(omaps->tmp_region); i++, tmp++)
                push_box(omaps, tmp);
            REGION_EMPTY(omaps->screen->pScreen, omaps->tmp_region);
        }
        else {
            push_box(omaps, &omaps->dirty_area);
        }

    }

    reset_damage(omaps);
}
示例#10
0
static void
xf86CrtcDamageShadow (xf86CrtcPtr crtc)
{
    ScrnInfoPtr	pScrn = crtc->scrn;
    BoxRec	damage_box;
    RegionRec   damage_region;
    ScreenPtr	pScreen = pScrn->pScreen;

    damage_box.x1 = 0;
    damage_box.x2 = crtc->mode.HDisplay;
    damage_box.y1 = 0;
    damage_box.y2 = crtc->mode.VDisplay;
    if (!pixman_transform_bounds (&crtc->crtc_to_framebuffer, &damage_box))
    {
	damage_box.x1 = 0;
	damage_box.y1 = 0;
	damage_box.x2 = pScreen->width;
	damage_box.y2 = pScreen->height;
    }
    if (damage_box.x1 < 0) damage_box.x1 = 0;
    if (damage_box.y1 < 0) damage_box.y1 = 0;
    if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
    if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
    REGION_INIT (pScreen, &damage_region, &damage_box, 1);
    DamageRegionAppend (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
			&damage_region);
    REGION_UNINIT (pScreen, &damage_region);
    crtc->shadowClear = TRUE;
}
示例#11
0
void
ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst,  GCPtr pGC,
	     BoxPtr	pbox, int nbox, int dx, int dy, Bool	reverse, 
	     Bool upsidedown, Pixel bitplane, void *closure)
{
    RegionRec reg;
    int xoff, yoff;
    EXA_PRE_FALLBACK_GC(pGC);
    EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
		  exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));

    if (pExaScr->prepare_access_reg) {
	PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);

	exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
	REGION_INIT(pScreen, &reg, pbox, nbox);
	REGION_TRANSLATE(pScreen, &reg, xoff + dx, yoff + dy);
	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, &reg);
	REGION_UNINIT(pScreen, &reg);
    } else
	exaPrepareAccess (pSrc, EXA_PREPARE_SRC);

    if (pExaScr->prepare_access_reg &&
	!exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
			       pGC->alu, pGC->clientClipType)) {
	PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);

	exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
	REGION_INIT(pScreen, &reg, pbox, nbox);
	REGION_TRANSLATE(pScreen, &reg, xoff, yoff);
	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, &reg);
	REGION_UNINIT(pScreen, &reg);
    } else
	exaPrepareAccess (pDst, EXA_PREPARE_DEST);

    /* This will eventually call fbCopyNtoN, with some calculation overhead. */
    while (nbox--) {
	pGC->ops->CopyArea (pSrc, pDst, pGC, pbox->x1 - pSrc->x + dx, pbox->y1 - pSrc->y + dy, 
			pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, pbox->x1 - pDst->x, pbox->y1 - pDst->y);
	pbox++;
    }
    exaFinishAccess (pSrc, EXA_PREPARE_SRC);
    exaFinishAccess (pDst, EXA_PREPARE_DEST);
    EXA_POST_FALLBACK_GC(pGC);
}
示例#12
0
static XF86VideoAdaptorPtr 
CHIPSSetupImageVideo(ScreenPtr pScreen)
{
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    CHIPSPtr cPtr = CHIPSPTR(pScrn);
    XF86VideoAdaptorPtr adapt;
    CHIPSPortPrivPtr pPriv;

    if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
			    sizeof(CHIPSPortPrivRec) +
			    sizeof(DevUnion))))
	return NULL;

    adapt->type = XvWindowMask | XvInputMask | XvImageMask;
    adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
    adapt->name = "Chips and Technologies Backend Scaler";
    adapt->nEncodings = 1;
    adapt->pEncodings = DummyEncoding;
    adapt->nFormats = NUM_FORMATS;
    adapt->pFormats = Formats;
    adapt->nPorts = 1;
    adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
    pPriv = (CHIPSPortPrivPtr)(&adapt->pPortPrivates[1]);
    adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
    adapt->pAttributes = Attributes;
    adapt->nImages = NUM_IMAGES;
    adapt->nAttributes = NUM_ATTRIBUTES;
    adapt->pImages = Images;
    adapt->PutVideo = NULL;
    adapt->PutStill = NULL;
    adapt->GetVideo = NULL;
    adapt->GetStill = NULL;
    adapt->StopVideo = CHIPSStopVideo;
    adapt->SetPortAttribute = CHIPSSetPortAttribute;
    adapt->GetPortAttribute = CHIPSGetPortAttribute;
    adapt->QueryBestSize = CHIPSQueryBestSize;
    adapt->PutImage = CHIPSPutImage;
    adapt->QueryImageAttributes = CHIPSQueryImageAttributes;

    pPriv->colorKey = cPtr->videoKey;
    pPriv->videoStatus = 0;
    pPriv->doubleBuffer = TRUE;
    pPriv->manualDoubleBuffer = FALSE;
    pPriv->currentBuffer	= 0;

    /* gotta uninit this someplace */
    REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); 

    cPtr->adaptor = adapt;

    xvColorKey   = MAKE_ATOM("XV_COLORKEY");

    CHIPSResetVideo(pScrn);

    return adapt;
}
示例#13
0
static void rf_client_initmsg(void)
{
  CL_SLOT *cl = (CL_SLOT *)cur_slot;
  unsigned char msg_server_init[24];

  if (cur_slot->readbuf[0] == 0) {
    log_write(LL_WARN, "Non-shared session requested by %s", cur_slot->name);
    aio_close(0);
  }

  /* Save initial desktop geometry for this client */
  cl->fb_width = g_screen_info.width;
  cl->fb_height = g_screen_info.height;
  cl->enable_newfbsize = 0;
  cl->enable_cliprects_enc = 0;

  /* Send ServerInitialisation message */
  buf_put_CARD16(msg_server_init, cl->fb_width);
  buf_put_CARD16(msg_server_init + 2, cl->fb_height);
  buf_put_pixfmt(msg_server_init + 4, &g_screen_info.pixformat);
  buf_put_CARD32(msg_server_init + 20, g_screen_info.name_length);
  aio_write(NULL, msg_server_init, 24);
  aio_write(NULL, g_screen_info.name, g_screen_info.name_length);
  aio_setread(rf_client_msg, NULL, 1);

  /* Set up initial pixel format and encoders' parameters */
  memcpy(&cl->format, &g_screen_info.pixformat, sizeof(RFB_PIXEL_FORMAT));
  cl->trans_func = transfunc_null;
  cl->bgr233_f = 0;
  cl->compress_level = 6;       /* default compression level */
  cl->jpeg_quality = -1;        /* disable JPEG by default */

  /* The client did not request framebuffer updates yet */
  cl->update_requested = 0;
  cl->update_in_progress = 0;
  REGION_INIT(&cl->pending_region, NullBox, 16);
  REGION_INIT(&cl->copy_region, NullBox, 8);
  cl->newfbsize_pending = 0;
  cl->new_cliprects = 0;

  /* We are connected. */
  cl->connected = 1;
}
示例#14
0
void
xglPutImage (DrawablePtr pDrawable,
	     GCPtr	 pGC,
	     int	 depth,
	     int	 x,
	     int	 y,
	     int	 w,
	     int	 h,
	     int	 leftPad,
	     int	 format,
	     char	 *bits)
{
    XGL_GC_PRIV (pGC);

    if (pGC->alu != GXcopy || (pGCPriv->flags & xglGCPlaneMaskFlag))
    {
	XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
	(*pGC->ops->PutImage) (pDrawable, pGC, depth,
			       x, y, w, h, leftPad, format, bits);
	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
    }
    else
    {
	RegionPtr pClip = pGC->pCompositeClip;
	RegionRec region;
	BoxRec	  box;

	XGL_DRAWABLE_PIXMAP (pDrawable);

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

	XGL_GC_UNWRAP (funcs);
	XGL_GC_UNWRAP (ops);

	(*pGC->ops->PutImage) (pDrawable, pGC, depth,
			       x, y, w, h, leftPad, format, bits);

	XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
	XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);

	box.x1 = pDrawable->x + x;
	box.y1 = pDrawable->y + y;
	box.x2 = box.x1 + w;
	box.y2 = box.y1 + h;

	REGION_INIT (pDrawable->pScreen, &region, &box, 1);
	REGION_INTERSECT (pDrawable->pScreen, &region, pClip, &region);

	xglAddSurfaceDamage (pDrawable, &region);

	REGION_UNINIT (pDrawable->pScreen, &region);
    }
}
示例#15
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);
}
示例#16
0
static void
nouveau_dri2_finish_swap(DrawablePtr draw, unsigned int frame,
			 unsigned int tv_sec, unsigned int tv_usec,
			 struct nouveau_dri2_vblank_state *s)
{
	ScrnInfoPtr scrn = xf86ScreenToScrn(draw->pScreen);
	NVPtr pNv = NVPTR(scrn);
	PixmapPtr dst_pix;
	PixmapPtr src_pix = nouveau_dri2_buffer(s->src)->ppix;
	struct nouveau_bo *dst_bo;
	struct nouveau_bo *src_bo = nouveau_pixmap_bo(src_pix);
	struct nouveau_pushbuf *push = pNv->pushbuf;
	RegionRec reg;
	int type, ret;
	Bool front_updated, will_exchange;
	xf86CrtcPtr ref_crtc;

	REGION_INIT(0, &reg, (&(BoxRec){ 0, 0, draw->width, draw->height }), 0);
	REGION_TRANSLATE(0, &reg, draw->x, draw->y);

	/* Main crtc for this drawable shall finally deliver pageflip event. */
	ref_crtc = nouveau_pick_best_crtc(scrn, FALSE, draw->x, draw->y,
                                      draw->width, draw->height);

	/* Update frontbuffer pixmap and name: Could have changed due to
	 * window (un)redirection as part of compositing.
	 */
	front_updated = update_front(draw, s->dst);

	/* Assign frontbuffer pixmap, after update in update_front() */
	dst_pix = nouveau_dri2_buffer(s->dst)->ppix;
	dst_bo = nouveau_pixmap_bo(dst_pix);

	/* Throttle on the previous frame before swapping */
	nouveau_bo_wait(dst_bo, NOUVEAU_BO_RD, push->client);

	/* Swap by buffer exchange possible? */
	will_exchange = front_updated && can_exchange(draw, dst_pix, src_pix);

	/* Only emit a wait for vblank pushbuf here if this is a copy-swap, or
	 * if it is a kms pageflip-swap on an old kernel. Pure exchange swaps
	 * don't need sync to vblank. kms pageflip-swaps on Linux 3.13+ are
	 * synced to vblank in the kms driver, so we must not sync here, or
	 * framerate will be cut in half!
	 */
	if (can_sync_to_vblank(draw) &&
		(!will_exchange ||
		(!pNv->has_async_pageflip && nouveau_exa_pixmap_is_onscreen(dst_pix)))) {
		/* Reference the back buffer to sync it to vblank */
		nouveau_pushbuf_refn(push, &(struct nouveau_pushbuf_refn) {
					   src_bo,
					   NOUVEAU_BO_VRAM | NOUVEAU_BO_RD
				     }, 1);
示例#17
0
/**
 * Append given rectangle to the client's list of dirty regions.
 */
void fn_client_add_rect(AIO_SLOT *slot, FB_RECT *rect)
{
  CL_SLOT *cl = (CL_SLOT *)slot;
  RegionRec add_region;
  BoxRec add_rect;
  int stored;
  int dx, dy;

  if (!cl->connected || cl->newfbsize_pending)
    return;

  /* If the framebuffer geometry has been changed, then we don't care
     about pending pixel updates any more, because all clients will
     want to update the whole framebuffer. */

  if (g_screen_info.width != cl->fb_width ||
      g_screen_info.height != cl->fb_height) {
    cl->newfbsize_pending = 1;
    REGION_EMPTY(&cl->pending_region);
    REGION_EMPTY(&cl->copy_region);
    return;
  }

  add_rect.x1 = rect->x;
  add_rect.y1 = rect->y;
  add_rect.x2 = add_rect.x1 + rect->w;
  add_rect.y2 = add_rect.y1 + rect->h;
  REGION_INIT(&add_region, &add_rect, 4);

  /* FIXME: Currently, CopyRect is stored in copy_region only if there
     were no other non-CopyRect updates pending for this client.
     Normally, that's ok, because VNC servers send CopyRect rectangles
     before non-CopyRect ones, but of course more elegant and
     efficient handling could be possible to implement here. */
  stored = 0;
  if (rect->enc == RFB_ENCODING_COPYRECT &&
      cl->enc_enable[RFB_ENCODING_COPYRECT] &&
      !REGION_NOTEMPTY(&cl->pending_region)) {
    dx = rect->x - rect->src_x;
    dy = rect->y - rect->src_y;
    if (!REGION_NOTEMPTY(&cl->copy_region) ||
        (dx == cl->copy_dx && dy == cl->copy_dy)) {
      REGION_UNION(&cl->copy_region, &cl->copy_region, &add_region);
      cl->copy_dx = dx;
      cl->copy_dy = dy;
      stored = 1;
    }
  }
  if (!stored)
    REGION_UNION(&cl->pending_region, &cl->pending_region, &add_region);

  REGION_UNINIT(&add_region);
}
示例#18
0
/*
 * At any point after LayerStartInit, a new layer can be created.
 */
LayerPtr
LayerCreate (ScreenPtr		pScreen, 
	     int		kind, 
	     int		depth,
	     PixmapPtr		pPixmap,
	     ShadowUpdateProc	update,
	     ShadowWindowProc	window,
	     int		rotate,
	     void		*closure)
{
    layerScrPriv(pScreen);
    LayerPtr	    pLay, *pPrev;
    LayerKindPtr    pLayKind;

    if (kind < 0 || pLayScr->nkinds <= kind)
	return 0;
    pLayKind = &pLayScr->kinds[kind];
    pLay = (LayerPtr) xalloc (sizeof (LayerRec));
    if (!pLay)
	return 0;
    /*
     * Initialize the layer
     */
    pLay->pNext = 0;
    pLay->pKind = pLayKind;
    pLay->refcnt = 1;
    pLay->windows = 0;
    pLay->depth = depth;
    pLay->pPixmap = pPixmap;
    pLay->update = update;
    pLay->window = window;
    pLay->rotate = rotate;
    pLay->closure = closure;
    if (pPixmap == LAYER_SCREEN_PIXMAP)
	pLay->freePixmap = FALSE;
    else
    {
	pLay->freePixmap = TRUE;
	if (pPixmap)
	    pPixmap->refcnt++;
    }
    REGION_INIT (pScreen, &pLay->region, NullBox, 0);
    /*
     * Hook the layer at the end of the list
     */
    for (pPrev = &pLayScr->pLayers; *pPrev; pPrev = &(*pPrev)->pNext)
	;
    *pPrev = pLay;
    return pLay;
}
示例#19
0
static Bool
xf86RotateRedisplay(ScreenPtr pScreen)
{
    ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    DamagePtr		damage = xf86_config->rotation_damage;
    RegionPtr		region;

    if (!damage)
	return FALSE;
    xf86RotatePrepare (pScreen);
    region = DamageRegion(damage);
    if (REGION_NOTEMPTY(pScreen, region)) 
    {
	int			c;
	SourceValidateProcPtr	SourceValidate;

	/*
	 * SourceValidate is used by the software cursor code
	 * to pull the cursor off of the screen when reading
	 * bits from the frame buffer. Bypassing this function
	 * leaves the software cursor in place
	 */
	SourceValidate = pScreen->SourceValidate;
	pScreen->SourceValidate = NULL;

	for (c = 0; c < xf86_config->num_crtc; c++)
	{
	    xf86CrtcPtr	    crtc = xf86_config->crtc[c];

	    if (crtc->rotation != RR_Rotate_0 && crtc->enabled)
	    {
		RegionRec   crtc_damage;

		/* compute portion of damage that overlaps crtc */
		REGION_INIT(pScreen, &crtc_damage, &crtc->bounds, 1);
		REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region);
		
		/* update damaged region */
		if (REGION_NOTEMPTY(pScreen, &crtc_damage))
    		    xf86RotateCrtcRedisplay (crtc, &crtc_damage);
		
		REGION_UNINIT (pScreen, &crtc_damage);
	    }
	}
	pScreen->SourceValidate = SourceValidate;
	DamageEmpty(damage);
    }
    return TRUE;
}
示例#20
0
文件: xf86fbman.c 项目: aosm/X11
Bool
xf86InitFBManager(
    ScreenPtr pScreen,  
    BoxPtr FullBox
){
   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
   RegionRec ScreenRegion;
   RegionRec FullRegion;
   BoxRec ScreenBox;
   Bool ret;

   ScreenBox.x1 = 0;
   ScreenBox.y1 = 0;
   ScreenBox.x2 = pScrn->virtualX;
   ScreenBox.y2 = pScrn->virtualY;

   if((FullBox->x1 >  ScreenBox.x1) || (FullBox->y1 >  ScreenBox.y1) ||
      (FullBox->x2 <  ScreenBox.x2) || (FullBox->y2 <  ScreenBox.y2)) {
	return FALSE;   
   }

   if (FullBox->y2 < FullBox->y1) return FALSE;
   if (FullBox->x2 < FullBox->x2) return FALSE;

   REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1); 
   REGION_INIT(pScreen, &FullRegion, FullBox, 1); 

   REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);

   ret = xf86InitFBManagerRegion(pScreen, &FullRegion);

   REGION_UNINIT(pScreen, &ScreenRegion);
   REGION_UNINIT(pScreen, &FullRegion);
    
   return ret;
}
示例#21
0
static void
xf86CrtcDamageShadow (xf86CrtcPtr crtc)
{
    ScrnInfoPtr	pScrn = crtc->scrn;
    BoxRec	damage_box;
    RegionRec   damage_region;
    ScreenPtr	pScreen = pScrn->pScreen;

    damage_box.x1 = crtc->x;
    damage_box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation);
    damage_box.y1 = crtc->y;
    damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
    REGION_INIT (pScreen, &damage_region, &damage_box, 1);
    DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
			&damage_region);
    REGION_UNINIT (pScreen, &damage_region);
}
示例#22
0
static XF86VideoAdaptorPtr
MGASetupImageVideoOverlay(ScreenPtr pScreen)
{
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    MGAPtr pMga = MGAPTR(pScrn);
    XF86VideoAdaptorPtr adapt;

    adapt = MGAAllocAdaptor(pScrn, TRUE);

    adapt->type = XvWindowMask | XvInputMask | XvImageMask;
    adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
    adapt->name = "Matrox G-Series Backend Scaler";
    adapt->nEncodings = 1;
    adapt->pEncodings = &DummyEncoding[0];
    adapt->nFormats = NUM_FORMATS;
    adapt->pFormats = Formats;
    adapt->nPorts = 1;
    adapt->pAttributes = Attributes;
    if (pMga->Chipset == PCI_CHIP_MGAG400 ||
            pMga->Chipset == PCI_CHIP_MGAG550) {
        adapt->nImages = 4;
        adapt->nAttributes = 4;
    } else {
        adapt->nImages = 3;
        adapt->nAttributes = 1;
    }
    adapt->pImages = Images;
    adapt->PutVideo = NULL;
    adapt->PutStill = NULL;
    adapt->GetVideo = NULL;
    adapt->GetStill = NULL;
    adapt->StopVideo = MGAStopVideo;
    adapt->SetPortAttribute = MGASetPortAttributeOverlay;
    adapt->GetPortAttribute = MGAGetPortAttributeOverlay;
    adapt->QueryBestSize = MGAQueryBestSize;
    adapt->PutImage = MGAPutImage;
    adapt->QueryImageAttributes = MGAQueryImageAttributes;

    /* gotta uninit this someplace */
    REGION_INIT(pScreen, &(pMga->portPrivate->clip), NullBox, 0);

    MGAResetVideoOverlay(pScrn);

    return adapt;
}
示例#23
0
文件: xf86fbman.c 项目: aosm/X11
static Bool
localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
{
   FBManagerPtr offman;
   FBLinkPtr pLink, tmp, pPrev = NULL;
   RegionRec FreedRegion;
   Bool anyUsed = FALSE;

   offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
       
   pLink = offman->UsedAreas;
   if(!pLink) return TRUE;  
 
   while(pLink) {
	if(pLink->area.RemoveAreaCallback) {
	    (*pLink->area.RemoveAreaCallback)(&pLink->area);

	    REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1); 
	    REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion);
	    REGION_UNINIT(pScreen, &FreedRegion); 

	    if(pPrev)
	      pPrev->next = pLink->next;
	    else offman->UsedAreas = pLink->next;

	    tmp = pLink;
	    pLink = pLink->next;
  	    xfree(tmp); 
	    offman->NumUsedAreas--;
	    anyUsed = TRUE;
	} else {
	    pPrev = pLink;
	    pLink = pLink->next;
	}
   }

   if(anyUsed) {
	REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed);
	SendCallFreeBoxCallbacks(offman);
   }

   return TRUE;
}
示例#24
0
static void
xf86RotateRedisplay(ScreenPtr pScreen)
{
    ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    DamagePtr		damage = xf86_config->rotation_damage;
    RegionPtr		region;

    if (!damage)
	return;
    xf86RotatePrepare (pScreen);
    region = DamageRegion(damage);
    if (REGION_NOTEMPTY(pScreen, region)) 
    {
	int		    c;
	
	for (c = 0; c < xf86_config->num_crtc; c++)
	{
	    xf86CrtcPtr	    crtc = xf86_config->crtc[c];

	    if (crtc->rotation != RR_Rotate_0)
	    {
		BoxRec	    box;
		RegionRec   crtc_damage;

		/* compute portion of damage that overlaps crtc */
		box.x1 = crtc->x;
		box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation);
		box.y1 = crtc->y;
		box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
		REGION_INIT(pScreen, &crtc_damage, &box, 1);
		REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region);
		
		/* update damaged region */
		if (REGION_NOTEMPTY(pScreen, &crtc_damage))
    		    xf86RotateCrtcRedisplay (crtc, &crtc_damage);
		
		REGION_UNINIT (pScreen, &crtc_damage);
	    }
	}
	DamageEmpty(damage);
    }
}
示例#25
0
void
xglAddBitDamage (DrawablePtr pDrawable,
		 RegionPtr   pRegion)
{
    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);

    if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
    {
	BoxPtr pBox;
	BoxPtr pExt, pBitExt;
	int    nBox;

	pBox = REGION_RECTS (pRegion);
	pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
	nBox = REGION_NUM_RECTS (pRegion);

	pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);

	if (pExt->x1 < pBitExt->x2 &&
	    pExt->y1 < pBitExt->y2 &&
	    pExt->x2 > pBitExt->x1 &&
	    pExt->y2 > pBitExt->y1)
	{
	    while (nBox--)
	    {
		if (pBox->x1 < pBitExt->x2 &&
		    pBox->y1 < pBitExt->y2 &&
		    pBox->x2 > pBitExt->x1 &&
		    pBox->y2 > pBitExt->y1)
		{
		    REGION_UNINIT (pDrawable->pScreen,
				   &pPixmapPriv->bitRegion);
		    REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
				 NullBox, 0);
		    pPixmapPriv->allBits = FALSE;
		    return;
		}

		pBox++;
	    }
	}
    }
}
示例#26
0
int
ProcXFixesExpandRegion (ClientPtr client)
{
    RegionPtr	pSource, pDestination;
    int		ret = Success;
    REQUEST (xXFixesExpandRegionReq);
    BoxPtr	pTmp;
    BoxPtr	pSrc;
    int		nBoxes;
    int		i;

    REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
    VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
    VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
    
    nBoxes = REGION_NUM_RECTS(pSource);
    pSrc = REGION_RECTS(pSource);
    if (nBoxes)
    {
	pTmp = xalloc (nBoxes * sizeof (BoxRec));
	if (!pTmp)
	    return BadAlloc;
	for (i = 0; i < nBoxes; i++)
	{
	    pTmp[i].x1 = pSrc[i].x1 - stuff->left;
	    pTmp[i].x2 = pSrc[i].x2 + stuff->right;
	    pTmp[i].y1 = pSrc[i].y1 - stuff->top;
	    pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
	}
	REGION_EMPTY (pScreen, pDestination);
	for (i = 0; i < nBoxes; i++)
	{
	    RegionRec	r;
	    REGION_INIT (pScreen, &r, &pTmp[i], 0);
	    REGION_UNION (pScreen, pDestination, pDestination, &r);
	}
	xfree(pTmp);
    }
    if (ret == Success) 
	ret = client->noClientException;
    return ret;
}
示例#27
0
文件: exa_accel.c 项目: L3oV1nc3/VMGL
void
exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
    RegionRec	rgnDst;
    int		dx, dy;
    PixmapPtr	pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
    ExaScreenPriv(pWin->drawable.pScreen);

    dx = ptOldOrg.x - pWin->drawable.x;
    dy = ptOldOrg.y - pWin->drawable.y;
    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);

    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);

    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
#ifdef COMPOSITE
    if (pPixmap->screen_x || pPixmap->screen_y)
	REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
			  -pPixmap->screen_x, -pPixmap->screen_y);
#endif

    if (pExaScr->fallback_counter) {
	pExaScr->fallback_flags |= EXA_FALLBACK_COPYWINDOW;
	goto fallback;
    }

    pExaScr->fallback_flags |= EXA_ACCEL_COPYWINDOW;
    miCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
		  NULL,
		  &rgnDst, dx, dy, exaCopyNtoN, 0, NULL);
    pExaScr->fallback_flags &= ~EXA_ACCEL_COPYWINDOW;

fallback:
    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);

    if (pExaScr->fallback_flags & EXA_FALLBACK_COPYWINDOW) {
	pExaScr->fallback_flags &= ~EXA_FALLBACK_COPYWINDOW;
	REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, dx, dy);
	ExaCheckCopyWindow(pWin, ptOldOrg, prgnSrc);
    }
}
示例#28
0
/**
 * uxa_prepare_access() is UXA's wrapper for the driver's PrepareAccess() handler.
 *
 * It deals with waiting for synchronization with the card, determining if
 * PrepareAccess() is necessary, and working around PrepareAccess() failure.
 */
Bool uxa_prepare_access(DrawablePtr pDrawable, RegionPtr region, uxa_access_t access)
{
	ScreenPtr pScreen = pDrawable->pScreen;
	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
	int xoff, yoff;
	PixmapPtr pPixmap = uxa_get_offscreen_pixmap(pDrawable, &xoff, &yoff);
	BoxRec box;
	RegionRec region_rec;
	Bool result;

	if (!pPixmap)
	    return TRUE;

	if (!region)
	{
	    box.x1 = 0;
	    box.y1 = 0;
	    box.x2 = pDrawable->width;
	    box.y2 = pDrawable->height;

	    REGION_INIT (pScreen, &region_rec, &box, 1);
	    region = &region_rec;
	}
	else
	{
	    /* The driver expects a region in drawable coordinates */
	    REGION_TRANSLATE (pScreen, region, xoff, yoff);
	}
	
	result = TRUE;

	if (uxa_screen->info->prepare_access)
	    result = (*uxa_screen->info->prepare_access) (pPixmap, region, access);

	if (region == &region_rec)
	    REGION_UNINIT (pScreen, &region_rec);
	
	return result;
}
示例#29
0
static void 
ShadowCopyWindow(
   WindowPtr pWin,
   DDXPointRec ptOldOrg,
   RegionPtr prgn 
){
    ScreenPtr pScreen = pWin->drawable.pScreen;
    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
    int num = 0;
    RegionRec rgnDst;

    if (pPriv->vtSema) {
        REGION_INIT(pWin->drawable.pScreen, &rgnDst, NullBox, 0);
	REGION_COPY(pWin->drawable.pScreen, &rgnDst, prgn);
        
        REGION_TRANSLATE(pWin->drawable.pScreen, &rgnDst,
                         pWin->drawable.x - ptOldOrg.x,
                         pWin->drawable.y - ptOldOrg.y);
        REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, &rgnDst);
        if ((num = REGION_NUM_RECTS(&rgnDst))) {
            if(pPriv->preRefresh)
                (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
        } else {
            REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
        }
    }
    
    pScreen->CopyWindow = pPriv->CopyWindow;
    (*pScreen->CopyWindow) (pWin, ptOldOrg, prgn);
    pScreen->CopyWindow = ShadowCopyWindow;
    
    if (num) {
        if (pPriv->postRefresh)
            (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
        REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
    }
}
Bool
saa_pad_read_box(DrawablePtr draw, int x, int y, int w, int h)
{
    ScreenPtr pScreen = draw->pScreen;
    PixmapPtr pix;
    int xp;
    int yp;
    BoxRec box;
    RegionRec entire;
    Bool ret;

    (void)pScreen;
    pix = saa_get_pixmap(draw, &xp, &yp);

    box.x1 = x + xp;
    box.y1 = y + yp;
    box.x2 = box.x1 + w;
    box.y2 = box.y1 + h;

    REGION_INIT(pScreen, &entire, &box, 1);
    ret = saa_prepare_access_pixmap(pix, SAA_ACCESS_R, &entire);
    REGION_UNINIT(pScreen, &entire);
    return ret;
}