[PATCH 3/4] render: Report pixmap usage of pictures to resource extension.

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


Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
---
 Xext/xres.c      |   14 ++++++++++++++
 render/picture.c |   22 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/Xext/xres.c b/Xext/xres.c
index e2fd8a7..ae9735a 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -216,6 +216,13 @@ ResFindGCPixmaps (pointer value, XID id, pointer cdata)
     ResFindResourcePixmaps(value, id, RT_GC, cdata);
 }
 
+static RESTYPE RT_PICTURE = RT_NONE;
+static void
+ResFindPicturePixmaps (pointer value, XID id, pointer cdata)
+{
+    ResFindResourcePixmaps(value, id, RT_PICTURE, cdata);
+}
+
 static int
 ProcXResQueryClientPixmapBytes (ClientPtr client)
 {
@@ -252,6 +259,13 @@ ProcXResQueryClientPixmapBytes (ClientPtr client)
 			      ResFindGCPixmaps, 
                               (pointer)(&bytes));
 
+    /* Render extension picture pixmaps. */
+    RT_PICTURE = LookupResourceType("PICTURE");
+    if (RT_PICTURE != RT_NONE)
+        FindClientResourcesByType(clients[clientID], RT_PICTURE,
+                                  ResFindPicturePixmaps,
+                                  (pointer)(&bytes));
+
 #ifdef COMPOSITE
     /* FIXME: include composite pixmaps too */
 #endif
diff --git a/render/picture.c b/render/picture.c
index 7fda6b9..64d9b72 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -606,6 +606,27 @@ PictureParseCmapPolicy (const char *name)
 	return PictureCmapPolicyInvalid;
 }
 
+/** @see GetDefaultBytes */
+static void
+GetPictureBytes(pointer value, XID id, ResourceSizePtr size)
+{
+    PicturePtr picture = value;
+
+    /* Currently only pixmap bytes are reported to clients. */
+    size->resourceSize = 0;
+
+    /* Calculate pixmap reference sizes. */
+    size->pixmapRefSize = 0;
+    if (picture->pDrawable && (picture->pDrawable->type == DRAWABLE_PIXMAP))
+    {
+        SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+        ResourceSizeRec pixmapSize = { 0, 0 };
+        PixmapPtr pixmap = (PixmapPtr)picture->pDrawable;
+        pixmapSizeFunc(pixmap, pixmap->drawable.id, &pixmapSize);
+        size->pixmapRefSize += pixmapSize.pixmapRefSize;
+    }
+}
+
 Bool
 PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
 {
@@ -618,6 +639,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
 	PictureType = CreateNewResourceType (FreePicture, "PICTURE");
 	if (!PictureType)
 	    return FALSE;
+	SetResourceTypeSizeFunc(PictureType, GetPictureBytes);
 	PictFormatType = CreateNewResourceType (FreePictFormat, "PICTFORMAT");
 	if (!PictFormatType)
 	    return FALSE;
-- 
1.6.3.3



More information about the xorg-devel mailing list