📄 mibstore.c
字号:
} REGION_SUBTRACT(pScreen, &Border, &pWin->borderSize, &pWin->winSize); REGION_INTERSECT(pScreen, &Border, &Border, &Remaining); if (REGION_NUM_RECTS(&Border) > 0) { REGION_TRANSLATE(pScreen, &Border, -pWin->drawable.x, -pWin->drawable.y); miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Border, xoff, yoff, pWin->borderIsPixel ? (int)BackgroundPixel : (int)BackgroundPixmap, pWin->border, ~0L); } } if (pWin->viewable && pWin->firstChild) pWin = pWin->firstChild; else { while (!pWin->nextSib && pWin != (WindowPtr) pDrawable) pWin = pWin->parent; if (pWin == (WindowPtr) pDrawable) break; pWin = pWin->nextSib; } } REGION_UNINIT(pScreen, &Remaining); if (pPixmap) { REGION_UNINIT(pScreen, &Border); REGION_UNINIT(pScreen, &Inside); (*pScreen->GetImage) ((DrawablePtr) pPixmap, 0, 0, w, h, format, planemask, pdstLine); (*pScreen->DestroyPixmap) (pPixmap); FreeScratchGC (pGC); } else { goto punt; } } else {punt: ; (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine); } SCREEN_EPILOGUE (pScreen, GetImage, miBSGetImage);}static voidmiBSGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) DrawablePtr pDrawable; int wMax; DDXPointPtr ppt; int *pwidth; int nspans; char *pdstStart;{ ScreenPtr pScreen = pDrawable->pScreen; BoxRec bounds; int i; WindowPtr pWin; int dx, dy; SCREEN_PROLOGUE (pScreen, GetSpans); if (pDrawable->type != DRAWABLE_PIXMAP && ((WindowPtr) pDrawable)->backStorage) { PixmapPtr pPixmap; miBSWindowPtr pWindowPriv; GCPtr pGC; pWin = (WindowPtr) pDrawable; pWindowPriv = (miBSWindowPtr) pWin->backStorage; pPixmap = pWindowPriv->pBackingPixmap; bounds.x1 = ppt->x; bounds.y1 = ppt->y; bounds.x2 = bounds.x1 + *pwidth; bounds.y2 = ppt->y; for (i = 0; i < nspans; i++) { if (ppt[i].x < bounds.x1) bounds.x1 = ppt[i].x; if (ppt[i].x + pwidth[i] > bounds.x2) bounds.x2 = ppt[i].x + pwidth[i]; if (ppt[i].y < bounds.y1) bounds.y1 = ppt[i].y; else if (ppt[i].y > bounds.y2) bounds.y2 = ppt[i].y; } switch (RECT_IN_REGION(pScreen, &pWindowPriv->SavedRegion, &bounds)) { case rgnPART: if (!pPixmap) { miCreateBSPixmap (pWin, NullBox); if (!(pPixmap = pWindowPriv->pBackingPixmap)) break; } pWindowPriv->status = StatusNoPixmap; pGC = GetScratchGC(pPixmap->drawable.depth, pPixmap->drawable.pScreen); if (pGC) { ValidateGC ((DrawablePtr) pPixmap, pGC); (*pGC->ops->CopyArea) (pDrawable, (DrawablePtr) pPixmap, pGC, bounds.x1, bounds.y1, bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, bounds.x1 + pPixmap->drawable.x - pWin->drawable.x - pWindowPriv->x, bounds.y1 + pPixmap->drawable.y - pWin->drawable.y - pWindowPriv->y); FreeScratchGC(pGC); } pWindowPriv->status = StatusContents; /* fall through */ case rgnIN: if (!pPixmap) { miCreateBSPixmap (pWin, NullBox); if (!(pPixmap = pWindowPriv->pBackingPixmap)) break; } dx = pPixmap->drawable.x - pWin->drawable.x - pWindowPriv->x; dy = pPixmap->drawable.y - pWin->drawable.y - pWindowPriv->y; for (i = 0; i < nspans; i++) { ppt[i].x += dx; ppt[i].y += dy; } (*pScreen->GetSpans) ((DrawablePtr) pPixmap, wMax, ppt, pwidth, nspans, pdstStart); break; case rgnOUT: (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); break; } } else { (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); } SCREEN_EPILOGUE (pScreen, GetSpans, miBSGetSpans);}static BoolmiBSChangeWindowAttributes (pWin, mask) WindowPtr pWin; unsigned long mask;{ ScreenPtr pScreen; Bool ret; pScreen = pWin->drawable.pScreen; SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes); ret = (*pScreen->ChangeWindowAttributes) (pWin, mask); if (ret && (mask & CWBackingStore)) { if (pWin->backingStore != NotUseful || pWin->DIXsaveUnder) miBSAllocate (pWin); else miBSFree (pWin); } SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, miBSChangeWindowAttributes); return ret;}/* * GC Create wrapper. Set up the cheap GC func wrappers to track * GC validation on BackingStore windows */static BoolmiBSCreateGC (pGC) GCPtr pGC;{ ScreenPtr pScreen = pGC->pScreen; Bool ret; SCREEN_PROLOGUE (pScreen, CreateGC); if ( (ret = (*pScreen->CreateGC) (pGC)) ) { pGC->devPrivates[miBSGCIndex].ptr = (pointer) pGC->funcs; pGC->funcs = &miBSCheapGCFuncs; } SCREEN_EPILOGUE (pScreen, CreateGC, miBSCreateGC); return ret;}static BoolmiBSDestroyWindow (pWin) WindowPtr pWin;{ ScreenPtr pScreen = pWin->drawable.pScreen; Bool ret; SCREEN_PROLOGUE (pScreen, DestroyWindow); ret = (*pScreen->DestroyWindow) (pWin); miBSFree (pWin); SCREEN_EPILOGUE (pScreen, DestroyWindow, miBSDestroyWindow); return ret;}/* * cheap GC func wrappers. Simply track validation on windows * with backing store to enable the real func/op wrappers */static voidmiBSCheapValidateGC (pGC, stateChanges, pDrawable) GCPtr pGC; unsigned long stateChanges; DrawablePtr pDrawable;{ CHEAP_FUNC_PROLOGUE (pGC); if (pDrawable->type != DRAWABLE_PIXMAP && ((WindowPtr) pDrawable)->backStorage != NULL && miBSCreateGCPrivate (pGC)) { (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable); } else { (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable); /* rewrap funcs as Validate may have changed them */ pGC->devPrivates[miBSGCIndex].ptr = (pointer) pGC->funcs; CHEAP_FUNC_EPILOGUE (pGC); }}static voidmiBSCheapChangeGC (pGC, mask) GCPtr pGC; unsigned long mask;{ CHEAP_FUNC_PROLOGUE (pGC); (*pGC->funcs->ChangeGC) (pGC, mask); CHEAP_FUNC_EPILOGUE (pGC);}static voidmiBSCheapCopyGC (pGCSrc, mask, pGCDst) GCPtr pGCSrc, pGCDst; unsigned long mask;{ CHEAP_FUNC_PROLOGUE (pGCDst); (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); CHEAP_FUNC_EPILOGUE (pGCDst);}static voidmiBSCheapDestroyGC (pGC) GCPtr pGC;{ CHEAP_FUNC_PROLOGUE (pGC); (*pGC->funcs->DestroyGC) (pGC); /* leave it unwrapped */}static voidmiBSCheapChangeClip (pGC, type, pvalue, nrects) GCPtr pGC; int type; pointer pvalue; int nrects;{ CHEAP_FUNC_PROLOGUE (pGC); (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); CHEAP_FUNC_EPILOGUE (pGC);}static voidmiBSCheapCopyClip(pgcDst, pgcSrc) GCPtr pgcDst, pgcSrc;{ CHEAP_FUNC_PROLOGUE (pgcDst); (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); CHEAP_FUNC_EPILOGUE (pgcDst);}static voidmiBSCheapDestroyClip(pGC) GCPtr pGC;{ CHEAP_FUNC_PROLOGUE (pGC); (* pGC->funcs->DestroyClip)(pGC); CHEAP_FUNC_EPILOGUE (pGC);}/* * create the full func/op wrappers for a GC */static BoolmiBSCreateGCPrivate (pGC) GCPtr pGC;{ miBSGCRec *pPriv; pPriv = (miBSGCRec *) xalloc (sizeof (miBSGCRec)); if (!pPriv) return FALSE; pPriv->pBackingGC = NULL; pPriv->guarantee = GuaranteeNothing; pPriv->serialNumber = 0; pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1; pPriv->wrapOps = pGC->ops; pPriv->wrapFuncs = pGC->funcs; pGC->funcs = &miBSGCFuncs; pGC->ops = &miBSGCOps; pGC->devPrivates[miBSGCIndex].ptr = (pointer) pPriv; return TRUE;}static voidmiBSDestroyGCPrivate (pGC) GCPtr pGC;{ miBSGCRec *pPriv; pPriv = (miBSGCRec *) pGC->devPrivates[miBSGCIndex].ptr; if (pPriv) { pGC->devPrivates[miBSGCIndex].ptr = (pointer) pPriv->wrapFuncs; pGC->funcs = &miBSCheapGCFuncs; pGC->ops = pPriv->wrapOps; if (pPriv->pBackingGC) FreeGC (pPriv->pBackingGC, (GContext) 0); xfree ((pointer) pPriv); }}/* * GC ops -- wrap each GC operation with our own function *//*- *----------------------------------------------------------------------- * miBSFillSpans -- * Perform a FillSpans, routing output to backing-store as needed. * * Results: * None. * * Side Effects: * *----------------------------------------------------------------------- */static voidmiBSFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ DDXPointPtr pptCopy, pptReset; int *pwidthCopy; SETUP_BACKING (pDrawable, pGC); PROLOGUE(pGC); pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(nInit*sizeof(DDXPointRec)); pwidthCopy=(int *)ALLOCATE_LOCAL(nInit*sizeof(int)); if (pptCopy && pwidthCopy) { copyData(pptInit, pptCopy, nInit, MoreCopy0); memmove((char *)pwidthCopy,(char *)pwidthInit,nInit*sizeof(int)); (* pGC->ops->FillSpans)(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted); if (pGC->miTranslate) { int dx, dy; int nReset; pptReset = pptCopy; dx = pDrawable->x - pBackingDrawable->x; dy = pDrawable->y - pBackingDrawable->y; nReset = nInit; while (nReset--) { pptReset->x -= dx; pptReset->y -= dy; ++pptReset; } } (* pBackingGC->ops->FillSpans)(pBackingDrawable, pBackingGC, nInit, pptCopy, pwidthCopy, fSorted); } if (pwidthCopy) DEALLOCATE_LOCAL(pwidthCopy); if (pptCopy) DEALLOCATE_LOCAL(pptCopy); EPILOGUE (pGC);}/*- *----------------------------------------------------------------------- * miBSSetSpans -- * Perform a SetSpans, routing output to backing-store as needed. * * Results: * None. * * Side Effects: * *----------------------------------------------------------------------- */static voidmiBSSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted) DrawablePtr pDrawable; GCPtr pGC; char *psrc; register DDXPointPtr ppt; int *pwidth; int nspans; int fSorted;{ DDXPointPtr pptCopy, pptReset; int *pwidthCopy; SETUP_BACKING (pDrawable, pGC); PROLOGUE(pGC); pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(nspans*sizeof(DDXPointRec)); pwidthCopy=(int *)ALLOCATE_LOCAL(nspans*sizeof(int)); if (pptCopy && pwidthCopy) { copyData(ppt, pptCopy, nspans, MoreCopy0); memmove((char *)pwidthCopy,(char *)pwidth,nspans*sizeof(int)); (* pGC->ops->SetSpans)(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); if (pGC->miTranslate) { int dx, dy; int nReset; pptReset = pptCopy; dx = pDrawable->x - pBackingDrawable->x; dy = pDrawable->y - pBackingDrawable->y; nReset = nspans; while (nReset--) { pptReset->x -= dx; pptReset->y -= dy; ++pptReset; } } (* pBackingGC->ops->SetSpans)(pBackingDrawable, pBackingGC, psrc, pptCopy, pwidthCopy, nspans, fSorted); } if (pwidthCopy) DEALLOCATE_LOCAL(pwidthCopy); if (pptCopy) DEALLOCATE_LOCAL(pptCopy); EPILOGUE (pGC);}/*- *----------------------------------------------------------------------- * miBSPutImage --
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -