From b8d0d19a6d410776b53a41e7cae90f68d4b22bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= Date: Wed, 27 Oct 2010 17:25:50 +0300 Subject: [PATCH] composite: Report pixmap usage of client windows to resource extension. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Erkki Seppälä Signed-off-by: Rami Ylimäki Reviewed-by: Mikhail Gusarov Reviewed-by: Tiago Vignatti --- Xext/xres.c | 14 +++++++++++++- composite/compext.c | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Xext/xres.c b/Xext/xres.c index a0734098c..b7933f251 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -28,6 +28,7 @@ #include "misc.h" #include #include "picturestr.h" +#include "compint.h" /** @brief Holds fragments of responses for ConstructClientIds. * @@ -342,6 +343,14 @@ ResFindPicturePixmaps(pointer value, XID id, pointer cdata) #endif } +static void +ResFindCompositeClientWindowPixmaps (pointer value, XID id, pointer cdata) +{ +#ifdef COMPOSITE + ResFindResourcePixmaps(value, id, CompositeClientWindowType, cdata); +#endif +} + static int ProcXResQueryClientPixmapBytes(ClientPtr client) { @@ -384,7 +393,10 @@ ProcXResQueryClientPixmapBytes(ClientPtr client) #endif #ifdef COMPOSITE - /* FIXME: include composite pixmaps too */ + /* Composite extension client window pixmaps. */ + FindClientResourcesByType(clients[clientID], CompositeClientWindowType, + ResFindCompositeClientWindowPixmaps, + (pointer)(&bytes)); #endif rep.type = X_Reply; diff --git a/composite/compext.c b/composite/compext.c index 940eed1fc..1d4d8bf97 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -497,6 +497,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) { @@ -529,6 +551,9 @@ CompositeExtensionInit(void) if (!CompositeClientWindowType) return; + SetResourceTypeSizeFunc(CompositeClientWindowType, + GetCompositeClientWindowBytes); + CompositeClientSubwindowsType = CreateNewResourceType (FreeCompositeClientSubwindows, "CompositeClientSubwindows"); if (!CompositeClientSubwindowsType)