📄 mbuf.c
字号:
pMultibuffers->displayedMultibuffer = -1; if (i > 0) AliasMultibuffer (pMultibuffers, 0); pMultibuffers->updateAction = action; pMultibuffers->updateHint = hint; pMultibuffers->windowMode = MultibufferModeMono; pMultibuffers->lastUpdate.months = 0; pMultibuffers->lastUpdate.milliseconds = 0; pMultibuffers->width = width; pMultibuffers->height = height; pWin->devPrivates[MultibufferWindowIndex].ptr = (pointer) pMultibuffers; if (pClearGC) FreeScratchGC(pClearGC); return Success;}static intProcCreateImageBuffers (client) register ClientPtr client;{ REQUEST(xMbufCreateImageBuffersReq); xMbufCreateImageBuffersReply rep; register int n; WindowPtr pWin; XID *ids; int len, nbuf; int i; int err; REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2); if (len == 0) return BadLength; if (!(pWin = LookupWindow (stuff->window, client))) return BadWindow; if (pWin->drawable.class == InputOnly) return BadMatch; switch (stuff->updateAction) { case MultibufferUpdateActionUndefined: case MultibufferUpdateActionBackground: case MultibufferUpdateActionUntouched: case MultibufferUpdateActionCopied: break; default: client->errorValue = stuff->updateAction; return BadValue; } switch (stuff->updateHint) { case MultibufferUpdateHintFrequent: case MultibufferUpdateHintIntermittent: case MultibufferUpdateHintStatic: break; default: client->errorValue = stuff->updateHint; return BadValue; } nbuf = len; ids = (XID *) &stuff[1]; for (i = 0; i < nbuf; i++) { LEGAL_NEW_RESOURCE(ids[i], client); } err = CreateImageBuffers (pWin, nbuf, ids, stuff->updateAction, stuff->updateHint); if (err != Success) return err; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.numberBuffer = ((MultibuffersPtr) (pWin->devPrivates[MultibufferWindowIndex].ptr))->numMultibuffer; if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swaps(&rep.numberBuffer, n); } WriteToClient(client, sizeof (xMbufCreateImageBuffersReply), (char *)&rep); return (client->noClientException);}static intProcDisplayImageBuffers (client) register ClientPtr client;{ REQUEST(xMbufDisplayImageBuffersReq); MultibufferPtr *pMultibuffer; MultibuffersPtr *ppMultibuffers; int nbuf; XID *ids; int i, j; CARD32 minDelay; TimeStamp activateTime, bufferTime; REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq); nbuf = stuff->length - (sizeof (xMbufDisplayImageBuffersReq) >> 2); if (!nbuf) return Success; minDelay = stuff->minDelay; ids = (XID *) &stuff[1]; ppMultibuffers = (MultibuffersPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibuffersPtr)); pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibufferPtr)); if (!ppMultibuffers || !pMultibuffer) { if (ppMultibuffers) DEALLOCATE_LOCAL(ppMultibuffers); if (pMultibuffer) DEALLOCATE_LOCAL(pMultibuffer); client->errorValue = 0; return BadAlloc; } activateTime.months = 0; activateTime.milliseconds = 0; for (i = 0; i < nbuf; i++) { pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i], MultibufferResType); if (!pMultibuffer[i]) { DEALLOCATE_LOCAL(ppMultibuffers); DEALLOCATE_LOCAL(pMultibuffer); client->errorValue = ids[i]; return MultibufferErrorBase + MultibufferBadBuffer; } ppMultibuffers[i] = pMultibuffer[i]->pMultibuffers; for (j = 0; j < i; j++) { if (ppMultibuffers[i] == ppMultibuffers[j]) { DEALLOCATE_LOCAL(ppMultibuffers); DEALLOCATE_LOCAL(pMultibuffer); client->errorValue = ids[i]; return BadMatch; } } bufferTime = ppMultibuffers[i]->lastUpdate; BumpTimeStamp (&bufferTime, minDelay); if (CompareTimeStamps (bufferTime, activateTime) == LATER) activateTime = bufferTime; } UpdateCurrentTime (); if (CompareTimeStamps (activateTime, currentTime) == LATER && QueueDisplayRequest (client, activateTime)) { ; } else PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf); DEALLOCATE_LOCAL(ppMultibuffers); DEALLOCATE_LOCAL(pMultibuffer); return Success;}static intProcDestroyImageBuffers (client) register ClientPtr client;{ REQUEST (xMbufDestroyImageBuffersReq); WindowPtr pWin; REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq); if (!(pWin = LookupWindow (stuff->window, client))) return BadWindow; DestroyImageBuffers (pWin); return Success;}static intProcSetMBufferAttributes (client) register ClientPtr client;{ REQUEST (xMbufSetMBufferAttributesReq); WindowPtr pWin; MultibuffersPtr pMultibuffers; int len; Mask vmask; Mask index2; CARD32 updateHint; XID *vlist; REQUEST_AT_LEAST_SIZE (xMbufSetMBufferAttributesReq); pWin = LookupWindow (stuff->window, client); if (!pWin) return BadWindow; pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadMatch; len = stuff->length - (sizeof (xMbufSetMBufferAttributesReq) >> 2); vmask = stuff->valueMask; if (len != Ones (vmask)) return BadLength; vlist = (XID *) &stuff[1]; while (vmask) { index2 = (Mask) lowbit (vmask); vmask &= ~index2; switch (index2) { case MultibufferWindowUpdateHint: updateHint = (CARD32) *vlist; switch (updateHint) { case MultibufferUpdateHintFrequent: case MultibufferUpdateHintIntermittent: case MultibufferUpdateHintStatic: pMultibuffers->updateHint = updateHint; break; default: client->errorValue = updateHint; return BadValue; } vlist++; break; default: client->errorValue = stuff->valueMask; return BadValue; } } return Success;}static intProcGetMBufferAttributes (client) ClientPtr client;{ REQUEST (xMbufGetMBufferAttributesReq); WindowPtr pWin; MultibuffersPtr pMultibuffers; XID *ids; xMbufGetMBufferAttributesReply rep; int i, n; REQUEST_SIZE_MATCH (xMbufGetMBufferAttributesReq); pWin = LookupWindow (stuff->window, client); if (!pWin) return BadWindow; pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadAccess; ids = (XID *) ALLOCATE_LOCAL (pMultibuffers->numMultibuffer * sizeof (XID)); if (!ids) return BadAlloc; for (i = 0; i < pMultibuffers->numMultibuffer; i++) ids[i] = pMultibuffers->buffers[i].pPixmap->drawable.id; rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = pMultibuffers->numMultibuffer; rep.displayedBuffer = pMultibuffers->displayedMultibuffer; rep.updateAction = pMultibuffers->updateAction; rep.updateHint = pMultibuffers->updateHint; rep.windowMode = pMultibuffers->windowMode; if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swaps(&rep.displayedBuffer, n); SwapLongs (ids, pMultibuffers->numMultibuffer); } WriteToClient (client, sizeof(xMbufGetMBufferAttributesReply), (char *)&rep); WriteToClient (client, (int)(pMultibuffers->numMultibuffer * sizeof (XID)), (char *)ids); DEALLOCATE_LOCAL((pointer) ids); return client->noClientException;}static intProcSetBufferAttributes (client) register ClientPtr client;{ REQUEST(xMbufSetBufferAttributesReq); MultibufferPtr pMultibuffer; int len; Mask vmask, index2; XID *vlist; Mask eventMask; int result; REQUEST_AT_LEAST_SIZE (xMbufSetBufferAttributesReq); pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType); if (!pMultibuffer) return MultibufferErrorBase + MultibufferBadBuffer; len = stuff->length - (sizeof (xMbufSetBufferAttributesReq) >> 2); vmask = stuff->valueMask; if (len != Ones (vmask)) return BadLength; vlist = (XID *) &stuff[1]; while (vmask) { index2 = (Mask) lowbit (vmask); vmask &= ~index2; switch (index2) { case MultibufferBufferEventMask: eventMask = (Mask) *vlist; vlist++; result = EventSelectForMultibuffer (pMultibuffer, client, eventMask); if (result != Success) return result; break; default: client->errorValue = stuff->valueMask; return BadValue; } } return Success;}intProcGetBufferAttributes (client) register ClientPtr client;{ REQUEST(xMbufGetBufferAttributesReq); MultibufferPtr pMultibuffer; xMbufGetBufferAttributesReply rep; OtherClientsPtr other; int n; REQUEST_SIZE_MATCH (xMbufGetBufferAttributesReq); pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType); if (!pMultibuffer) return MultibufferErrorBase + MultibufferBadBuffer; rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0; rep.window = pMultibuffer->pMultibuffers->pWindow->drawable.id; if (bClient (pMultibuffer) == client) rep.eventMask = pMultibuffer->eventMask; else { rep.eventMask = (Mask) 0L; for (other = pMultibuffer->otherClients; other; other = other->next) if (SameClient (other, client)) { rep.eventMask = other->mask; break; } } rep.bufferIndex = pMultibuffer->number; rep.side = pMultibuffer->side; if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swapl(&rep.window, n); swapl(&rep.eventMask, n); swaps(&rep.bufferIndex, n); } WriteToClient(client, sizeof (xMbufGetBufferAttributesReply), (char *)&rep); return (client->noClientException);}static intProcGetBufferInfo (client) register ClientPtr client;{ REQUEST (xMbufGetBufferInfoReq); DrawablePtr pDrawable; xMbufGetBufferInfoReply rep; ScreenPtr pScreen; int i, j, k; int n; xMbufBufferInfo *pInfo; int nInfo; DepthPtr pDepth; pDrawable = (DrawablePtr) LookupDrawable (stuff->drawable, client); if (!pDrawable) return BadDrawable; pScreen = pDrawable->pScreen; nInfo = 0; for (i = 0; i < pScreen->numDepths; i++) { pDepth = &pScreen->allowedDepths[i]; nInfo += pDepth->numVids; } pInfo = (xMbufBufferInfo *) ALLOCATE_LOCAL (nInfo * sizeof (xMbufBufferInfo)); if (!pInfo) return BadAlloc; rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = nInfo * (sizeof (xMbufBufferInfo) >> 2); rep.normalInfo = nInfo; rep.stereoInfo = 0; if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swaps(&rep.normalInfo, n); swaps(&rep.stereoInfo, n); } k = 0; for (i = 0; i < pScreen->numDepths; i++) { pDepth = &pScreen->allowedDepths[i]; for (j = 0; j < pDepth->numVids; j++) { pInfo[k].visualID = pDepth->vids[j]; pInfo[k].maxBuffers = 0; pInfo[k].depth = pDepth->depth; if (client->swapped) { swapl (&pInfo[k].visualID, n); swaps (&pInfo[k].maxBuffers, n); } k++; } } WriteToClient (client, sizeof (xMbufGetBufferInfoReply), (pointer) &rep); WriteToClient (client, (int) nInfo * sizeof (xMbufBufferInfo), (pointer) pInfo); DEALLOCATE_LOCAL ((pointer) pInfo); return client->noClientException;}static intProcClearImageBufferArea (client) register ClientPtr client;{ REQUEST (xMbufClearImageBufferAreaReq); MultibufferPtr pMultibuffer; WindowPtr pWin; xRectangle clearRect; int width, height; DrawablePtr pDrawable; ScreenPtr pScreen; REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq); pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType); if (!pMultibuffer) return MultibufferErrorBase + MultibufferBadBuffer; if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) { client->errorValue = stuff->exposures; return(BadValue); } pWin = pMultibuffer->pMultibuffers->pWindow; width = pWin->drawable.width; height = pWin->drawable.height; pScreen = pWin->drawable.pScreen; clearRect.x = stuff->x; clearRect.y = stuff->y; clearRect.width = stuff->width ? stuff->width : width; clearRect.height = stuff->height ? stuff->height : height; if (pWin->backgroundState != None) { GCPtr pClearGC; pClearGC = GetScratchGC (pWin->drawable.depth, pScreen); SetupBackgroundPainter (pWin, pClearGC); if (pMultibuffer->number == pMultibuffer->pMultibuffers->displayedMultibuffer)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -