res: Simplify QueryClientPixmapBytes
I suspect this code predates the common resource hooks for computing sizes. It's ugly in any case since the Resource extension shouldn't need to know which extensions can take a reference on pixmaps. Instead, let's just walk every resource for the client and sum up all the pixmap bytes that way. This might be slightly slower since we're calling the size func once for every resource. On the other hand, it might be slightly faster since we only walk the resource table once instead of 3-5 times. Probably a wash, and not really a performance path in any case. Acked-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
263c5333a5
commit
4f8a72034c
96
Xext/xres.c
96
Xext/xres.c
|
@ -349,21 +349,6 @@ ProcXResQueryClientResources(ClientPtr client)
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long
|
|
||||||
ResGetApproxPixmapBytes(PixmapPtr pix)
|
|
||||||
{
|
|
||||||
unsigned long nPixels;
|
|
||||||
float bytesPerPixel;
|
|
||||||
|
|
||||||
bytesPerPixel = (float)pix->drawable.bitsPerPixel / 8.0;
|
|
||||||
nPixels = pix->drawable.width * pix->drawable.height;
|
|
||||||
|
|
||||||
/* Divide by refcnt as pixmap could be shared between clients,
|
|
||||||
* so total pixmap mem is shared between these.
|
|
||||||
*/
|
|
||||||
return (nPixels * bytesPerPixel) / pix->refcnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
|
ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
|
||||||
{
|
{
|
||||||
|
@ -375,57 +360,6 @@ ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
|
||||||
*bytes += size.pixmapRefSize;
|
*bytes += size.pixmapRefSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
ResFindPixmaps(void *value, XID id, void *cdata)
|
|
||||||
{
|
|
||||||
unsigned long *bytes = (unsigned long *) cdata;
|
|
||||||
PixmapPtr pix = (PixmapPtr) value;
|
|
||||||
|
|
||||||
*bytes += ResGetApproxPixmapBytes(pix);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ResFindWindowPixmaps(void *value, XID id, void *cdata)
|
|
||||||
{
|
|
||||||
unsigned long *bytes = (unsigned long *) cdata;
|
|
||||||
WindowPtr pWin = (WindowPtr) value;
|
|
||||||
|
|
||||||
if (pWin->backgroundState == BackgroundPixmap)
|
|
||||||
*bytes += ResGetApproxPixmapBytes(pWin->background.pixmap);
|
|
||||||
|
|
||||||
if (pWin->border.pixmap != NULL && !pWin->borderIsPixel)
|
|
||||||
*bytes += ResGetApproxPixmapBytes(pWin->border.pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ResFindGCPixmaps(void *value, XID id, void *cdata)
|
|
||||||
{
|
|
||||||
unsigned long *bytes = (unsigned long *) cdata;
|
|
||||||
GCPtr pGC = (GCPtr) value;
|
|
||||||
|
|
||||||
if (pGC->stipple != NULL)
|
|
||||||
*bytes += ResGetApproxPixmapBytes(pGC->stipple);
|
|
||||||
|
|
||||||
if (pGC->tile.pixmap != NULL && !pGC->tileIsPixel)
|
|
||||||
*bytes += ResGetApproxPixmapBytes(pGC->tile.pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef RENDER
|
|
||||||
static void
|
|
||||||
ResFindPicturePixmaps(void *value, XID id, void *cdata)
|
|
||||||
{
|
|
||||||
ResFindResourcePixmaps(value, id, PictureType, cdata);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
|
||||||
static void
|
|
||||||
ResFindCompositeClientWindowPixmaps (void *value, XID id, void *cdata)
|
|
||||||
{
|
|
||||||
ResFindResourcePixmaps(value, id, CompositeClientWindowType, cdata);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcXResQueryClientPixmapBytes(ClientPtr client)
|
ProcXResQueryClientPixmapBytes(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
@ -445,34 +379,8 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
|
||||||
|
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
|
|
||||||
FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps,
|
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
|
||||||
(void *) (&bytes));
|
(void *) (&bytes));
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure win background pixmaps also held to account.
|
|
||||||
*/
|
|
||||||
FindClientResourcesByType(clients[clientID], RT_WINDOW,
|
|
||||||
ResFindWindowPixmaps, (void *) (&bytes));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* GC Tile & Stipple pixmaps too.
|
|
||||||
*/
|
|
||||||
FindClientResourcesByType(clients[clientID], RT_GC,
|
|
||||||
ResFindGCPixmaps, (void *) (&bytes));
|
|
||||||
|
|
||||||
#ifdef RENDER
|
|
||||||
/* Render extension picture pixmaps. */
|
|
||||||
FindClientResourcesByType(clients[clientID], PictureType,
|
|
||||||
ResFindPicturePixmaps,
|
|
||||||
(void *)(&bytes));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
|
||||||
/* Composite extension client window pixmaps. */
|
|
||||||
FindClientResourcesByType(clients[clientID], CompositeClientWindowType,
|
|
||||||
ResFindCompositeClientWindowPixmaps,
|
|
||||||
(void *)(&bytes));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rep = (xXResQueryClientPixmapBytesReply) {
|
rep = (xXResQueryClientPixmapBytesReply) {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
|
|
Loading…
Reference in New Issue