? xres-win-pixmap-2.patch ? xres-win-pixmap.patch Index: xres.c =================================================================== RCS file: /cvs/xserver/xserver/Xext/xres.c,v retrieving revision 1.9 diff -u -r1.9 xres.c --- xres.c 2 Nov 2003 19:56:10 -0000 1.9 +++ xres.c 8 Dec 2004 23:26:44 -0000 @@ -17,6 +17,7 @@ #include "swaprep.h" #include #include "pixmapstr.h" +#include "windowstr.h" #include "xext.h" extern RESTYPE lastResourceType; @@ -183,13 +184,38 @@ return (client->noClientException); } +static unsigned long +ResGetApproxPixmapBytes (PixmapPtr pix) +{ + unsigned long nPixels; + int bytesPerPixel; + + bytesPerPixel = pix->drawable.bitsPerPixel>>3; + 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 ResFindPixmaps (pointer value, XID id, pointer cdata) { unsigned long *bytes = (unsigned long *)cdata; PixmapPtr pix = (PixmapPtr)value; - *bytes += (pix->devKind * pix->drawable.height); + *bytes += ResGetApproxPixmapBytes(pix); +} + +static void +ResFindWindowPixmaps (pointer value, XID id, pointer cdata) +{ + unsigned long *bytes = (unsigned long *)cdata; + WindowPtr pWin = (WindowPtr)value; + + if (pWin->backgroundState == BackgroundPixmap) + *bytes += ResGetApproxPixmapBytes(pWin->background.pixmap); } static int @@ -216,6 +242,13 @@ FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps, (pointer)(&bytes)); + /* + * Make sure win background pixmaps also held to account. + */ + FindClientResourcesByType(clients[clientID], RT_WINDOW, + ResFindWindowPixmaps, + (pointer)(&bytes)); + rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0;