dix: write out X_AllocNamedColor reply directly
No need for using a complex callback machinery, if we just move the little pieces of byte-swapping directly into the request handler. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									f062333422
								
							
						
					
					
						commit
						df44f063a0
					
				|  | @ -2672,38 +2672,48 @@ ProcAllocNamedColor(ClientPtr client) | ||||||
|     REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); |     REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); | ||||||
|     rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP, |     rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP, | ||||||
|                                  client, DixAddAccess); |                                  client, DixAddAccess); | ||||||
|     if (rc == Success) { |     if (rc != Success) { | ||||||
|         xAllocNamedColorReply ancr = { |  | ||||||
|             .type = X_Reply, |  | ||||||
|             .sequenceNumber = client->sequence, |  | ||||||
|             .length = 0 |  | ||||||
|         }; |  | ||||||
|         if (dixLookupBuiltinColor |  | ||||||
|             (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, |  | ||||||
|              &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) { |  | ||||||
|             ancr.screenRed = ancr.exactRed; |  | ||||||
|             ancr.screenGreen = ancr.exactGreen; |  | ||||||
|             ancr.screenBlue = ancr.exactBlue; |  | ||||||
|             ancr.pixel = 0; |  | ||||||
|             if ((rc = AllocColor(pcmp, |  | ||||||
|                                  &ancr.screenRed, &ancr.screenGreen, |  | ||||||
|                                  &ancr.screenBlue, &ancr.pixel, client->index))) |  | ||||||
|                 return rc; |  | ||||||
| #ifdef XINERAMA |  | ||||||
|             if (noPanoramiXExtension || !pcmp->pScreen->myNum) |  | ||||||
| #endif /* XINERAMA */ |  | ||||||
|                 WriteReplyToClient(client, sizeof(xAllocNamedColorReply), |  | ||||||
|                                    &ancr); |  | ||||||
|             return Success; |  | ||||||
|         } |  | ||||||
|         else |  | ||||||
|             return BadName; |  | ||||||
| 
 |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|         client->errorValue = stuff->cmap; |         client->errorValue = stuff->cmap; | ||||||
|         return rc; |         return rc; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     xAllocNamedColorReply rep = { | ||||||
|  |         .type = X_Reply, | ||||||
|  |         .sequenceNumber = client->sequence, | ||||||
|  |         .length = 0 | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     if (!dixLookupBuiltinColor | ||||||
|  |             (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, | ||||||
|  |              &rep.exactRed, &rep.exactGreen, &rep.exactBlue)) | ||||||
|  |         return BadName; | ||||||
|  | 
 | ||||||
|  |     rep.screenRed = rep.exactRed; | ||||||
|  |     rep.screenGreen = rep.exactGreen; | ||||||
|  |     rep.screenBlue = rep.exactBlue; | ||||||
|  |     rep.pixel = 0; | ||||||
|  | 
 | ||||||
|  |     if ((rc = AllocColor(pcmp, | ||||||
|  |                          &rep.screenRed, &rep.screenGreen, | ||||||
|  |                          &rep.screenBlue, &rep.pixel, client->index))) | ||||||
|  |         return rc; | ||||||
|  | 
 | ||||||
|  |     if (client->swapped) { | ||||||
|  |         swaps(&rep.sequenceNumber); | ||||||
|  |         swapl(&rep.pixel); | ||||||
|  |         swaps(&rep.exactRed); | ||||||
|  |         swaps(&rep.exactGreen); | ||||||
|  |         swaps(&rep.exactBlue); | ||||||
|  |         swaps(&rep.screenRed); | ||||||
|  |         swaps(&rep.screenGreen); | ||||||
|  |         swaps(&rep.screenBlue); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | #ifdef XINERAMA | ||||||
|  |     if (noPanoramiXExtension || !pcmp->pScreen->myNum) | ||||||
|  | #endif /* XINERAMA */ | ||||||
|  |         WriteToClient(client, sizeof(rep), &rep); | ||||||
|  |     return Success; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int | int | ||||||
|  |  | ||||||
|  | @ -310,20 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep) | ||||||
|     WriteToClient(pClient, size, pRep); |     WriteToClient(pClient, size, pRep); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void _X_COLD |  | ||||||
| SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep) |  | ||||||
| { |  | ||||||
|     swaps(&pRep->sequenceNumber); |  | ||||||
|     swapl(&pRep->pixel); |  | ||||||
|     swaps(&pRep->exactRed); |  | ||||||
|     swaps(&pRep->exactGreen); |  | ||||||
|     swaps(&pRep->exactBlue); |  | ||||||
|     swaps(&pRep->screenRed); |  | ||||||
|     swaps(&pRep->screenGreen); |  | ||||||
|     swaps(&pRep->screenBlue); |  | ||||||
|     WriteToClient(pClient, size, pRep); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void _X_COLD | void _X_COLD | ||||||
| SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply * pRep) | SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply * pRep) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -800,7 +800,7 @@ ReplySwapPtr ReplySwapVector[256] = { | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     (ReplySwapPtr) SAllocNamedColorReply,       /* 85 */ |     ReplyNotSwappd,                             /* 85 */ | ||||||
|     (ReplySwapPtr) SAllocColorCellsReply, |     (ReplySwapPtr) SAllocColorCellsReply, | ||||||
|     (ReplySwapPtr) SAllocColorPlanesReply, |     (ReplySwapPtr) SAllocColorPlanesReply, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|  |  | ||||||
|  | @ -68,11 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ , | ||||||
|                               int /* size */ , |                               int /* size */ , | ||||||
|                               xGetFontPathReply * /* pRep */ ); |                               xGetFontPathReply * /* pRep */ ); | ||||||
| 
 | 
 | ||||||
| extern void SAllocNamedColorReply(ClientPtr /* pClient */ , |  | ||||||
|                                   int /* size */ , |  | ||||||
|                                   xAllocNamedColorReply *       /* pRep */ |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
| extern void SAllocColorCellsReply(ClientPtr /* pClient */ , | extern void SAllocColorCellsReply(ClientPtr /* pClient */ , | ||||||
|                                   int /* size */ , |                                   int /* size */ , | ||||||
|                                   xAllocColorCellsReply *       /* pRep */ |                                   xAllocColorCellsReply *       /* pRep */ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue