aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/Xext/xres.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/Xext/xres.c')
-rw-r--r--nx-X11/programs/Xserver/Xext/xres.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/nx-X11/programs/Xserver/Xext/xres.c b/nx-X11/programs/Xserver/Xext/xres.c
index 03597ad95..977ea4ce6 100644
--- a/nx-X11/programs/Xserver/Xext/xres.c
+++ b/nx-X11/programs/Xserver/Xext/xres.c
@@ -17,6 +17,9 @@
#include "swaprep.h"
#include <nx-X11/extensions/XResproto.h>
#include "pixmapstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+
#include "protocol-versions.h"
static int
@@ -171,13 +174,54 @@ ProcXResQueryClientResources (ClientPtr client)
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 (void * value, XID id, void * cdata)
{
unsigned long *bytes = (unsigned long *)cdata;
PixmapPtr pix = (PixmapPtr)value;
- *bytes += (pix->devKind * pix->drawable.height);
+ *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);
}
static int
@@ -204,6 +248,24 @@ ProcXResQueryClientPixmapBytes (ClientPtr client)
FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps,
(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 COMPOSITE
+ /* FIXME: include composite pixmaps too */
+#endif
+
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;