Introduce dixLookupFontable for "FONT or GC" parameters.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Jamey Sharp 2010-05-06 11:00:37 -07:00 committed by Keith Packard
parent 2eab697adb
commit 35761d5f81
5 changed files with 33 additions and 48 deletions

View File

@ -427,18 +427,8 @@ ProcXF86BigfontQueryFont(
return BadLength; return BadLength;
} }
#endif #endif
client->errorValue = stuff->id; /* EITHER font or gc */ if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success)
dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, return BadFont; /* procotol spec says only error is BadFont */
client, DixGetAttrAccess);
if (!pFont) {
GC *pGC;
dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC,
client, DixGetAttrAccess);
if (!pGC)
return BadFont; /* procotol spec says only error is BadFont */
pFont = pGC->font;
}
pmax = FONTINKMAX(pFont); pmax = FONTINKMAX(pFont);
pmin = FONTINKMIN(pFont); pmin = FONTINKMIN(pFont);

View File

@ -1283,22 +1283,13 @@ ProcQueryFont(ClientPtr client)
{ {
xQueryFontReply *reply; xQueryFontReply *reply;
FontPtr pFont; FontPtr pFont;
GC *pGC;
int rc; int rc;
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id; /* EITHER font or gc */ rc = dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess);
rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, client,
DixGetAttrAccess);
if (rc == BadValue) {
rc = dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC, client,
DixGetAttrAccess);
if (rc == Success)
pFont = pGC->font;
}
if (rc != Success) if (rc != Success)
return (rc == BadValue) ? BadFont: rc; return rc;
{ {
xCharInfo *pmax = FONTINKMAX(pFont); xCharInfo *pmax = FONTINKMAX(pFont);
@ -1339,24 +1330,15 @@ ProcQueryTextExtents(ClientPtr client)
{ {
xQueryTextExtentsReply reply; xQueryTextExtentsReply reply;
FontPtr pFont; FontPtr pFont;
GC *pGC;
ExtentInfoRec info; ExtentInfoRec info;
unsigned long length; unsigned long length;
int rc; int rc;
REQUEST(xQueryTextExtentsReq); REQUEST(xQueryTextExtentsReq);
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
client->errorValue = stuff->fid; /* EITHER font or gc */ rc = dixLookupFontable(&pFont, stuff->fid, client, DixGetAttrAccess);
rc = dixLookupResourceByType((pointer *)&pFont, stuff->fid, RT_FONT, client,
DixGetAttrAccess);
if (rc == BadValue) {
rc = dixLookupResourceByType((pointer *)&pGC, stuff->fid, RT_GC, client,
DixGetAttrAccess);
if (rc == Success)
pFont = pGC->font;
}
if (rc != Success) if (rc != Success)
return (rc == BadValue) ? BadFont: rc; return rc;
length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq)); length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq));
length = length << 1; length = length << 1;

View File

@ -92,6 +92,7 @@ Author: Adobe Systems Incorporated
#include "windowstr.h" #include "windowstr.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "pixmapstr.h" #include "pixmapstr.h"
#include "gcstruct.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#define XK_LATIN1 #define XK_LATIN1
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
@ -235,6 +236,23 @@ dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
return (rc == BadValue) ? BadGC : rc; return (rc == BadValue) ? BadGC : rc;
} }
int
dixLookupFontable(FontPtr *pFont, XID id, ClientPtr client, Mask access)
{
int rc;
GC *pGC;
client->errorValue = id; /* EITHER font or gc */
rc = dixLookupResourceByType((pointer *) pFont, id, RT_FONT, client, access);
if (rc != BadValue)
return rc;
rc = dixLookupResourceByType((pointer *) &pGC, id, RT_GC, client, access);
if (rc == BadValue)
return BadFont;
if (rc == Success)
*pFont = pGC->font;
return rc;
}
int int
dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
{ {

View File

@ -155,7 +155,6 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc)
ClientPtr client = cl->client; ClientPtr client = cl->client;
xGLXUseXFontReq *req; xGLXUseXFontReq *req;
FontPtr pFont; FontPtr pFont;
GC *pGC;
GLuint currentListIndex; GLuint currentListIndex;
__GLXcontext *cx; __GLXcontext *cx;
int error; int error;
@ -181,19 +180,9 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc)
** containing a font. ** containing a font.
*/ */
error = dixLookupResourceByType((pointer *)&pFont, error = dixLookupFontable(&pFont, req->font, client, DixReadAccess);
req->font, RT_FONT, if (error != Success)
client, DixReadAccess); return error;
if (error != Success) {
error = dixLookupResourceByType((pointer *)&pGC,
req->font, RT_GC,
client, DixReadAccess);
if (error != Success) {
client->errorValue = req->font;
return error == BadGC ? BadFont : error;
}
pFont = pGC->font;
}
return MakeBitmapsFromFont(pFont, req->first, req->count, return MakeBitmapsFromFont(pFont, req->first, req->count,
req->listBase); req->listBase);

View File

@ -199,6 +199,12 @@ extern _X_EXPORT int dixLookupGC(
ClientPtr client, ClientPtr client,
Mask access_mode); Mask access_mode);
extern _X_EXPORT int dixLookupFontable(
FontPtr *result,
XID id,
ClientPtr client,
Mask access_mode);
extern _X_EXPORT int dixLookupClient( extern _X_EXPORT int dixLookupClient(
ClientPtr *result, ClientPtr *result,
XID id, XID id,