static void FreeLayerList (ScreenPtr pScreen, LayerListPtr pLayList) { REGION_UNINIT (pScreen, &pLayList->clipList); REGION_UNINIT (pScreen, &pLayList->borderClip); xfree (pLayList); }
/** * Vertically invert a region. */ static void InvertRegion(RegionPtr reg, int height) { const BoxPtr b = REGION_RECTS(reg); const int n = REGION_NUM_RECTS(reg); int i; RegionRec newRegion; miRegionInit(&newRegion, NULL, 0); CRASSERT(miValidRegion(reg)); for (i = 0; i < n; i++) { BoxRec invBox; RegionRec invReg; invBox.x1 = b[i].x1; invBox.y1 = height - b[i].y2; invBox.x2 = b[i].x2; invBox.y2 = height - b[i].y1; CRASSERT(invBox.y1 <= invBox.y2); miRegionInit(&invReg, &invBox, 1); REGION_UNION(&newRegion, &newRegion, &invReg); REGION_UNINIT(&invReg); } CRASSERT(miValidRegion(&newRegion)); REGION_COPY(reg, &newRegion); REGION_UNINIT(&newRegion); }
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; }
void xglAddCurrentSurfaceDamage (DrawablePtr pDrawable) { XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); if (BOX_NOTEMPTY (&pPixmapPriv->damageBox)) { RegionRec region; REGION_INIT (pDrawable->pScreen, ®ion, &pPixmapPriv->damageBox, 1); if (pPixmapPriv->pDamage) { RegionPtr pDamageRegion; pDamageRegion = DamageRegion (pPixmapPriv->pDamage); REGION_UNION (pDrawable->pScreen, pDamageRegion, pDamageRegion, ®ion); } REGION_UNION (pDrawable->pScreen, &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion, ®ion); REGION_UNINIT (pDrawable->pScreen, ®ion); pPixmapPriv->damageBox = miEmptyBox; } }
/* * Destroy a layer. The layer must not contain any windows. */ void LayerDestroy (ScreenPtr pScreen, LayerPtr pLay) { layerScrPriv(pScreen); LayerPtr *pPrev; --pLay->refcnt; if (pLay->refcnt > 0) return; /* * Unhook the layer from the list */ for (pPrev = &pLayScr->pLayers; *pPrev; pPrev = &(*pPrev)->pNext) if (*pPrev == pLay) { *pPrev = pLay->pNext; break; } /* * Free associated storage */ LayerDestroyPixmap (pScreen, pLay); REGION_UNINIT (pScreen, &pLay->region); xfree (pLay); }
void fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { RegionRec rgnDst; int dx, dy; WindowPtr pwinRoot; pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); REGION_NULL (pWin->drawable.pScreen, &rgnDst); REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, 0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0); REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); fbValidateDrawable (&pWin->drawable); }
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, ®, &box, 1); REGION_UNION(pScreen, dst, dst, ®); REGION_UNINIT(pScreen, ®); if (pExaScr->SavedSourceValidate) { swap(pExaScr, pScreen, SourceValidate); pScreen->SourceValidate(pDrawable, x, y, width, height); swap(pExaScr, pScreen, SourceValidate); } }
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, ®, &box, 1); pExaScr->prepare_access_reg(pPixmap, index, ®); REGION_UNINIT(pScreen, ®); } else exaPrepareAccess(pDrawable, index); }
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); }
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); }
void fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { RegionRec rgnDst; int dx, dy; PixmapPtr pPixmap = fbGetWindowPixmap (pWin); DrawablePtr pDrawable = &pPixmap->drawable; dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); REGION_NULL (pWin->drawable.pScreen, &rgnDst); 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 (pDrawable, pDrawable, 0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0); REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); fbValidateDrawable (&pWin->drawable); }
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; }
/** * 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, ®ion, &box, 1); REGION_UNION(pScreen, pDamageReg, pDamageReg, ®ion); REGION_UNINIT(pScreen, ®ion); }
/* * Free one of the per-client per-window resources, clearing * redirect and the per-window pointer as appropriate */ void compFreeClientWindow (WindowPtr pWin, XID id) { CompWindowPtr cw = GetCompWindow (pWin); CompClientWindowPtr ccw, *prev; Bool wasMapped = pWin->mapped; if (!cw) return; for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next) { if (ccw->id == id) { *prev = ccw->next; if (ccw->update == CompositeRedirectManual) cw->update = CompositeRedirectAutomatic; xfree (ccw); break; } } if (!cw->clients) { if (wasMapped) { DisableMapUnmapEvents (pWin); UnmapWindow (pWin, FALSE); EnableMapUnmapEvents (pWin); } if (pWin->redirectDraw != RedirectDrawNone) compFreePixmap (pWin); if (cw->damage) DamageDestroy (cw->damage); REGION_UNINIT (pScreen, &cw->borderClip); dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL); xfree (cw); } else if (cw->update == CompositeRedirectAutomatic && !cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone) { DamageRegister (&pWin->drawable, cw->damage); cw->damageRegistered = TRUE; pWin->redirectDraw = RedirectDrawAutomatic; DamageRegionAppend(&pWin->drawable, &pWin->borderSize); } if (wasMapped && !pWin->mapped) { Bool overrideRedirect = pWin->overrideRedirect; pWin->overrideRedirect = TRUE; DisableMapUnmapEvents (pWin); MapWindow (pWin, clients[CLIENT_ID(id)]); EnableMapUnmapEvents (pWin); pWin->overrideRedirect = overrideRedirect; } }
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, ®, pbox, nbox); REGION_TRANSLATE(pScreen, ®, xoff + dx, yoff + dy); pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, ®); REGION_UNINIT(pScreen, ®); } 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, ®, pbox, nbox); REGION_TRANSLATE(pScreen, ®, xoff, yoff); pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, ®); REGION_UNINIT(pScreen, ®); } 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); }
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, ®ion, pBox, 1); xglAddSurfaceDamage (pDrawable, ®ion); REGION_UNINIT (pDrawable->pScreen, ®ion); pBox++; } } else xglAddCurrentBitDamage (pDrawable); }
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, ®ion, &box, 1); REGION_INTERSECT (pDrawable->pScreen, ®ion, pClip, ®ion); xglAddSurfaceDamage (pDrawable, ®ion); REGION_UNINIT (pDrawable->pScreen, ®ion); } }
/** * 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); }
void cfbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { DDXPointPtr pptSrc; DDXPointPtr ppt; RegionRec rgnDst; BoxPtr pbox; int dx, dy; int i, nbox; WindowPtr pwinRoot; pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; REGION_NULL(pWin->drawable.pScreen, &rgnDst); dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); pbox = REGION_RECTS(&rgnDst); nbox = REGION_NUM_RECTS(&rgnDst); if(!nbox || !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) { REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); return; } ppt = pptSrc; for (i = nbox; --i >= 0; ppt++, pbox++) { ppt->x = pbox->x1 + dx; ppt->y = pbox->y1 + dy; } cfbDoBitbltCopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, &rgnDst, pptSrc, ~0L); DEALLOCATE_LOCAL(pptSrc); REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); }
/** * Union the window's accum-dirty and prev-accum-dirty regions with the * incoming region. * Called by crHashtableWalk() via vncspuGetScreenRects(). */ static void WindowDirtyUnionCB(unsigned long key, void *windowData, void *regionData) { WindowInfo *window = (WindowInfo *) windowData; RegionPtr regionUnion = (RegionPtr) regionData; RegionRec accumScrn; /* accumulated region, in screen coords */ Bool overlap; miRegionInit(&accumScrn, NULL, 0); /* init local var */ CRASSERT(miValidRegion(&window->accumDirtyRegion)); CRASSERT(miValidRegion(&window->prevAccumDirtyRegion)); /* crDebug("accum area: %d prev accum: %d", miRegionArea(&window->accumDirtyRegion), miRegionArea(&window->prevAccumDirtyRegion)); */ /* at first, accumScrn region is in window coords */ REGION_UNION(&accumScrn, &window->accumDirtyRegion, &window->prevAccumDirtyRegion); /* intersect with window bounds */ REGION_INTERSECT(&accumScrn, &accumScrn, &window->clipRegion); REGION_VALIDATE(&accumScrn, &overlap); /* change y=0=bottom to y=0=top */ InvertRegion(&accumScrn, window->height ? window->height : 1); if (REGION_NUM_RECTS(&accumScrn) == 1 && accumScrn.extents.x1 == 0 && accumScrn.extents.y1 == 0 && accumScrn.extents.x2 == 1 && accumScrn.extents.y2 == 1) { /* empty / sentinal region */ } else { /* add window offset */ miTranslateRegion(&accumScrn, window->xPos, window->yPos); } /* now, accumScrn region is in screen coords */ REGION_UNION(regionUnion, regionUnion, &accumScrn); REGION_UNINIT(&accumScrn); /* done with local var */ }
/** * Close function (called when client goes away) */ static void cf_client(void) { CL_SLOT *cl = (CL_SLOT *)cur_slot; int i; if (cur_slot->errread_f) { if (cur_slot->io_errno) { log_write(LL_WARN, "Error reading from %s: %s", cur_slot->name, strerror(cur_slot->io_errno)); } else { log_write(LL_WARN, "Error reading from %s", cur_slot->name); } } else if (cur_slot->errwrite_f) { if (cur_slot->io_errno) { log_write(LL_WARN, "Error sending to %s: %s", cur_slot->name, strerror(cur_slot->io_errno)); } else { log_write(LL_WARN, "Error sending to %s", cur_slot->name); } } else if (cur_slot->errio_f) { log_write(LL_WARN, "I/O error, client %s", cur_slot->name); } log_write(LL_MSG, "Closing client connection %s", cur_slot->name); /* Free region structures. */ REGION_UNINIT(&cl->pending_region); REGION_UNINIT(&cl->copy_region); /* Free zlib streams. FIXME: Maybe put cleanup function in encoder. */ for (i = 0; i < 4; i++) { if (cl->zs_active[i]) deflateEnd(&cl->zs_struct[i]); } /* Free dynamically allocated memory. */ if (cl->trans_table != NULL) free(cl->trans_table); }
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; }
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_NULL(pWin->drawable.pScreen, &rgnDst); 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 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; }
/***** * miHandleValidateExposures(pWin) * starting at pWin, draw background in any windows that have exposure * regions, translate the regions, restore any backing store, * and then send any regions still exposed to the client *****/ void miHandleValidateExposures(WindowPtr pWin) { WindowPtr pChild; ValidatePtr val; ScreenPtr pScreen; WindowExposuresProcPtr WindowExposures; pScreen = pWin->drawable.pScreen; pChild = pWin; WindowExposures = pChild->drawable.pScreen->WindowExposures; while (1) { if ( (val = pChild->valdata) ) { if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed)) miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER); REGION_UNINIT(pScreen, &val->after.borderExposed); (*WindowExposures)(pChild, &val->after.exposed, NullRegion); REGION_UNINIT(pScreen, &val->after.exposed); xfree(val); pChild->valdata = NULL; if (pChild->firstChild) { pChild = pChild->firstChild; continue; } } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) break; pChild = pChild->nextSib; } }
static Bool shadowCloseScreen(int i, ScreenPtr pScreen) { shadowBuf(pScreen); unwrap(pBuf, pScreen, GetImage); unwrap(pBuf, pScreen, CloseScreen); shadowRemove(pScreen, pBuf->pPixmap); DamageDestroy(pBuf->pDamage); #ifdef BACKWARDS_COMPATIBILITY REGION_UNINIT(pScreen, &pBuf->damage); /* bc */ #endif if (pBuf->pPixmap) pScreen->DestroyPixmap(pBuf->pPixmap); xfree(pBuf); return pScreen->CloseScreen(i, pScreen); }
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); }
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; }
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); } }
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++; } } } }