[xserver,3/3] res: Account for GLXPixmap references too

Submitted by Adam Jackson on Feb. 2, 2016, 7:30 p.m.

Details

Message ID 1454441452-3445-4-git-send-email-ajax@redhat.com
State Accepted
Commit ce82ae1964b2115a780786676c614546297a79c9
Headers show
Series "Accounting fixes for ResQueryClientPixmapBytes" ( rev: 1 ) in X.org (DEPRECATED - USE GITLAB)

Not browsing as part of any series.

Commit Message

Adam Jackson Feb. 2, 2016, 7:30 p.m.
GLX_EXT_tetxure_from_pixmap operates on a GLXPixmap, which takes a
reference on the backing pixmap; that GLXPixmap might be long-lived, so
we should account for it in ResQueryClientPixmapBytes.

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 glx/glxext.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch hide | download patch | download mbox

diff --git a/glx/glxext.c b/glx/glxext.c
index e41b881..9fcd9f5 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -337,6 +337,23 @@  checkScreenVisuals(void)
     return False;
 }
 
+static void
+GetGLXDrawableBytes(void *value, XID id, ResourceSizePtr size)
+{
+    __GLXdrawable *draw = value;
+
+    size->resourceSize = 0;
+    size->pixmapRefSize = 0;
+    size->refCnt = 1;
+
+    if (draw->type == GLX_DRAWABLE_PIXMAP) {
+        SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+        ResourceSizeRec pixmapSize = { 0, };
+        pixmapSizeFunc((PixmapPtr)draw->pDraw, draw->pDraw->id, &pixmapSize);
+        size->pixmapRefSize += pixmapSize.pixmapRefSize;
+    }
+}
+
 /*
 ** Initialize the GLX extension.
 */
@@ -366,6 +383,8 @@  GlxExtensionInit(void)
     if (!__glXContextRes || !__glXDrawableRes)
         return;
 
+    SetResourceTypeSizeFunc(__glXDrawableRes, GetGLXDrawableBytes);
+
     if (!dixRegisterPrivateKey
         (&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(__GLXclientState)))
         return;