[PATCH 4/4] composite: Report pixmap usage of client windows to resource extension.

Rami Ylimäki rami.ylimaki at vincit.fi
Thu Oct 28 03:23:44 PDT 2010


Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
---
 Xext/xres.c         |   16 +++++++++++++---
 composite/compext.c |   24 ++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/Xext/xres.c b/Xext/xres.c
index ae9735a..0d626e6 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -223,6 +223,13 @@ ResFindPicturePixmaps (pointer value, XID id, pointer cdata)
     ResFindResourcePixmaps(value, id, RT_PICTURE, cdata);
 }
 
+static RESTYPE RT_COMPOSITE_CLIENT_WINDOW = RT_NONE;
+static void
+ResFindCompositeClientWindowPixmaps (pointer value, XID id, pointer cdata)
+{
+    ResFindResourcePixmaps(value, id, RT_COMPOSITE_CLIENT_WINDOW, cdata);
+}
+
 static int
 ProcXResQueryClientPixmapBytes (ClientPtr client)
 {
@@ -266,9 +273,12 @@ ProcXResQueryClientPixmapBytes (ClientPtr client)
                                   ResFindPicturePixmaps,
                                   (pointer)(&bytes));
 
-#ifdef COMPOSITE
-    /* FIXME: include composite pixmaps too */
-#endif
+    /* Composite extension client window pixmaps. */
+    RT_COMPOSITE_CLIENT_WINDOW = LookupResourceType("CompositeClientWindow");
+    if (RT_COMPOSITE_CLIENT_WINDOW != RT_NONE)
+        FindClientResourcesByType(clients[clientID], RT_COMPOSITE_CLIENT_WINDOW,
+                                  ResFindCompositeClientWindowPixmaps,
+                                  (pointer)(&bytes));
 
     rep.type = X_Reply;
     rep.sequenceNumber = client->sequence;
diff --git a/composite/compext.c b/composite/compext.c
index 30d9dc2..676b9a5 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -508,6 +508,28 @@ SProcCompositeDispatch (ClientPtr client)
 	return BadRequest;
 }
 
+/** @see GetDefaultBytes */
+static void
+GetCompositeClientWindowBytes(pointer value, XID id, ResourceSizePtr size)
+{
+    WindowPtr window = value;
+
+    /* Currently only pixmap bytes are reported to clients. */
+    size->resourceSize = 0;
+
+    /* Calculate pixmap reference sizes. */
+    size->pixmapRefSize = 0;
+    if (window->redirectDraw != RedirectDrawNone)
+    {
+        SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+        ResourceSizeRec pixmapSize = { 0, 0 };
+        ScreenPtr screen = window->drawable.pScreen;
+        PixmapPtr pixmap = screen->GetWindowPixmap(window);
+        pixmapSizeFunc(pixmap, pixmap->drawable.id, &pixmapSize);
+        size->pixmapRefSize += pixmapSize.pixmapRefSize;
+    }
+}
+
 void
 CompositeExtensionInit (void)
 {
@@ -547,6 +569,8 @@ CompositeExtensionInit (void)
 	(FreeCompositeClientWindow, "CompositeClientWindow");
     if (!CompositeClientWindowType)
 	return;
+    SetResourceTypeSizeFunc(CompositeClientWindowType,
+                            GetCompositeClientWindowBytes);
 
     CompositeClientSubwindowsType = CreateNewResourceType
 	(FreeCompositeClientSubwindows, "CompositeClientSubwindows");
-- 
1.6.3.3



More information about the xorg-devel mailing list