📄 mbuf.c
字号:
pDrawable = (DrawablePtr)pWin; else pDrawable = (DrawablePtr)pMultibuffer->pPixmap; ValidateGC(pDrawable, pClearGC); (*pClearGC->ops->PolyFillRect) (pDrawable, pClearGC, 1, &clearRect); FreeScratchGC(pClearGC); } if (stuff->exposures) { RegionRec region; BoxRec box; box.x1 = clearRect.x; box.y1 = clearRect.y; box.x2 = clearRect.x + clearRect.width; box.y2 = clearRect.y + clearRect.height; REGION_INIT(pScreen, ®ion, &box, 1); MultibufferExpose(pMultibuffer, ®ion); REGION_UNINIT(pScreen, ®ion); } return Success;}static intProcMultibufferDispatch (client) register ClientPtr client;{ REQUEST(xReq); switch (stuff->data) { case X_MbufGetBufferVersion: return ProcGetBufferVersion (client); case X_MbufCreateImageBuffers: return ProcCreateImageBuffers (client); case X_MbufDisplayImageBuffers: return ProcDisplayImageBuffers (client); case X_MbufDestroyImageBuffers: return ProcDestroyImageBuffers (client); case X_MbufSetMBufferAttributes: return ProcSetMBufferAttributes (client); case X_MbufGetMBufferAttributes: return ProcGetMBufferAttributes (client); case X_MbufSetBufferAttributes: return ProcSetBufferAttributes (client); case X_MbufGetBufferAttributes: return ProcGetBufferAttributes (client); case X_MbufGetBufferInfo: return ProcGetBufferInfo (client); case X_MbufClearImageBufferArea: return ProcClearImageBufferArea (client); default: return BadRequest; }}static intSProcGetBufferVersion (client) register ClientPtr client;{ register int n; REQUEST (xMbufGetBufferVersionReq); swaps (&stuff->length, n); return ProcGetBufferVersion (client);}static intSProcCreateImageBuffers (client) register ClientPtr client;{ register int n; REQUEST (xMbufCreateImageBuffersReq); swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); swapl (&stuff->window, n); SwapRestL(stuff); return ProcCreateImageBuffers (client);}static intSProcDisplayImageBuffers (client) register ClientPtr client;{ register int n; REQUEST (xMbufDisplayImageBuffersReq); swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq); swaps (&stuff->minDelay, n); swaps (&stuff->maxDelay, n); SwapRestL(stuff); return ProcDisplayImageBuffers (client);}static intSProcDestroyImageBuffers (client) register ClientPtr client;{ register int n; REQUEST (xMbufDestroyImageBuffersReq); swaps (&stuff->length, n); REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq); swapl (&stuff->window, n); return ProcDestroyImageBuffers (client);}static intSProcSetMBufferAttributes (client) register ClientPtr client;{ register int n; REQUEST (xMbufSetMBufferAttributesReq); swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE(xMbufSetMBufferAttributesReq); swapl (&stuff->window, n); swapl (&stuff->valueMask, n); SwapRestL(stuff); return ProcSetMBufferAttributes (client);}static intSProcGetMBufferAttributes (client) register ClientPtr client;{ register int n; REQUEST (xMbufGetMBufferAttributesReq); swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE(xMbufGetMBufferAttributesReq); swapl (&stuff->window, n); return ProcGetMBufferAttributes (client);}static intSProcSetBufferAttributes (client) register ClientPtr client;{ register int n; REQUEST (xMbufSetBufferAttributesReq); swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE(xMbufSetBufferAttributesReq); swapl (&stuff->buffer, n); swapl (&stuff->valueMask, n); SwapRestL(stuff); return ProcSetBufferAttributes (client);}static intSProcGetBufferAttributes (client) register ClientPtr client;{ register int n; REQUEST (xMbufGetBufferAttributesReq); swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE(xMbufGetBufferAttributesReq); swapl (&stuff->buffer, n); return ProcGetBufferAttributes (client);}static intSProcGetBufferInfo (client) register ClientPtr client;{ register int n; REQUEST (xMbufGetBufferInfoReq); swaps (&stuff->length, n); REQUEST_SIZE_MATCH (xMbufGetBufferInfoReq); swapl (&stuff->drawable, n); return ProcGetBufferInfo (client);}static intSProcClearImageBufferArea(client) register ClientPtr client;{ register char n; REQUEST(xMbufClearImageBufferAreaReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq); swapl(&stuff->buffer, n); swaps(&stuff->x, n); swaps(&stuff->y, n); swaps(&stuff->width, n); swaps(&stuff->height, n); return ProcClearImageBufferArea(client);}static intSProcMultibufferDispatch (client) register ClientPtr client;{ REQUEST(xReq); switch (stuff->data) { case X_MbufGetBufferVersion: return SProcGetBufferVersion (client); case X_MbufCreateImageBuffers: return SProcCreateImageBuffers (client); case X_MbufDisplayImageBuffers: return SProcDisplayImageBuffers (client); case X_MbufDestroyImageBuffers: return SProcDestroyImageBuffers (client); case X_MbufSetMBufferAttributes: return SProcSetMBufferAttributes (client); case X_MbufGetMBufferAttributes: return SProcGetMBufferAttributes (client); case X_MbufSetBufferAttributes: return SProcSetBufferAttributes (client); case X_MbufGetBufferAttributes: return SProcGetBufferAttributes (client); case X_MbufGetBufferInfo: return SProcGetBufferInfo (client); case X_MbufClearImageBufferArea: return SProcClearImageBufferArea (client); default: return BadRequest; }}static voidSUpdateNotifyEvent (from, to) xMbufUpdateNotifyEvent *from, *to;{ to->type = from->type; cpswaps (from->sequenceNumber, to->sequenceNumber); cpswapl (from->buffer, to->buffer); cpswapl (from->timeStamp, to->timeStamp);}static voidSClobberNotifyEvent (from, to) xMbufClobberNotifyEvent *from, *to;{ to->type = from->type; cpswaps (from->sequenceNumber, to->sequenceNumber); cpswapl (from->buffer, to->buffer); to->state = from->state;}static voidPerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf) MultibufferPtr *pMultibuffer; MultibuffersPtr *ppMultibuffers; int nbuf;{ GCPtr pGC; PixmapPtr pPrevPixmap, pNewPixmap; xRectangle clearRect; WindowPtr pWin; RegionPtr pExposed; int i; MultibufferPtr pPrevMultibuffer; XID graphicsExpose; UpdateCurrentTime (); for (i = 0; i < nbuf; i++) { pWin = ppMultibuffers[i]->pWindow; pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen); pPrevMultibuffer = &ppMultibuffers[i]->buffers[ppMultibuffers[i]->displayedMultibuffer]; pPrevPixmap = pPrevMultibuffer->pPixmap; pNewPixmap = pMultibuffer[i]->pPixmap; switch (ppMultibuffers[i]->updateAction) { case MultibufferUpdateActionUndefined: break; case MultibufferUpdateActionBackground: SetupBackgroundPainter (pWin, pGC); ValidateGC ((DrawablePtr)pPrevPixmap, pGC); clearRect.x = 0; clearRect.y = 0; clearRect.width = pPrevPixmap->drawable.width; clearRect.height = pPrevPixmap->drawable.height; (*pGC->ops->PolyFillRect) ((DrawablePtr)pPrevPixmap, pGC, 1, &clearRect); break; case MultibufferUpdateActionUntouched: /* copy the window to the pixmap that represents the * currently displayed buffer */ if (pPrevMultibuffer->eventMask & ExposureMask) { graphicsExpose = TRUE; DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE); } ValidateGC ((DrawablePtr)pPrevPixmap, pGC); pExposed = (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pPrevPixmap, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); /* if we couldn't copy the whole window to the buffer, * send expose events (if any client wants them) */ if (pPrevMultibuffer->eventMask & ExposureMask) { /* some client wants expose events */ if (pExposed) { RegionPtr pWinSize; ScreenPtr pScreen = pWin->drawable.pScreen; pWinSize = CreateUnclippedWinSize (pWin); /* pExposed is window-relative, but at this point * pWinSize is screen-relative. Make pWinSize be * window-relative so that region ops involving * pExposed and pWinSize behave sensibly. */ REGION_TRANSLATE(pScreen, pWinSize, -pWin->drawable.x, -pWin->drawable.y); REGION_INTERSECT(pScreen, pExposed, pExposed, pWinSize); REGION_DESTROY(pScreen, pWinSize); MultibufferExpose (pPrevMultibuffer, pExposed); REGION_DESTROY(pScreen, pExposed); } graphicsExpose = FALSE; DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE); } break; /* end case MultibufferUpdateActionUntouched */ case MultibufferUpdateActionCopied: ValidateGC ((DrawablePtr)pPrevPixmap, pGC); (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pPrevPixmap, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); break; } /* end switch on update action */ /* display the new buffer */ ValidateGC ((DrawablePtr)pWin, pGC); (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); ppMultibuffers[i]->lastUpdate = currentTime; MultibufferUpdate (pMultibuffer[i], ppMultibuffers[i]->lastUpdate.milliseconds); AliasMultibuffer (ppMultibuffers[i], pMultibuffer[i] - ppMultibuffers[i]->buffers); FreeScratchGC (pGC); }}DrawablePtrGetBufferPointer (pWin, i) WindowPtr pWin; int i;{ MultibuffersPtr pMultibuffers; if (!(pMultibuffers = (MultibuffersPtr) pWin->devPrivates[MultibufferWindowIndex].ptr)) return NULL; return (DrawablePtr) pMultibuffers->buffers[i].pPixmap;}intDisplayImageBuffers (ids, nbuf) XID *ids; int nbuf;{ MultibufferPtr *pMultibuffer; MultibuffersPtr *pMultibuffers; int i, j; pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL (nbuf * sizeof *pMultibuffer + nbuf * sizeof *pMultibuffers); if (!pMultibuffer) return BadAlloc; pMultibuffers = (MultibuffersPtr *) (pMultibuffer + nbuf); for (i = 0; i < nbuf; i++) { pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i], MultibufferResType); if (!pMultibuffer[i]) { DEALLOCATE_LOCAL (pMultibuffer); return MultibufferErrorBase + MultibufferBadBuffer; } pMultibuffers[i] = pMultibuffer[i]->pMultibuffers; for (j = 0; j < i; j++) if (pMultibuffers[i] == pMultibuffers[j]) { DEALLOCATE_LOCAL (pMultibuffer); return BadMatch; } } PerformDisplayRequest (pMultibuffers, pMultibuffer, nbuf); DEALLOCATE_LOCAL (pMultibuffer); return Success;}static BoolQueueDisplayRequest (client, activateTime) ClientPtr client; TimeStamp activateTime;{ /* see xtest.c:ProcXTestFakeInput for code similar to this */ if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) { return FALSE; } /* swap the request back so we can simply re-execute it */ if (client->swapped) { register int n; REQUEST (xMbufDisplayImageBuffersReq); SwapRestL(stuff); swaps (&stuff->length, n); swaps (&stuff->minDelay, n); swaps (&stuff->maxDelay, n); } ResetCurrentRequest (client); client->sequence--; return TRUE;}/* * Deliver events to a buffer */static intDeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter) MultibufferPtr pMultibuffer; xEvent *pEvents; int count; Mask filter;{ int deliveries = 0, nondeliveries = 0; int attempt; OtherClients *other; /* if nobody wants the event, we're done */ if (!((pMultibuffer->otherEventMask|pMultibuffer->eventMask) & filter)) return 0; /* maybe send event to owner */ if ((attempt = TryClientEvents(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -