Created attachment 85383 [details]
If a pixmap has depth=1, ie. is a bitmap, then it doesn't count towards QueryResourceBytes in the X_Resource extension, whereas I thought that it would.
The attached program foo.c when run under recent debian i386 xvfb test server 1.12.4 prints
where I hoped it would print "bytes 8192" or thereabouts.
If you change the program to depth=8 in the XCreatePixmap() then it prints "bytes 65536" as expected.
In Xext/xres.c ResGetApproxPixmapBytes() I suspect that the line
bytesPerPixel = pix->drawable.bitsPerPixel >> 3;
causes any bits-per-pixel less than 8 to be treated as 0, and thus not counted towards the client's pixmap bytes in use, no matter how big the width*height might be.
I suppose calculating the size in bits and then dividing would be easy, but maybe care has to be taken against overflowing 32-bits in such a size. Perhaps if bitsPerPixel < 8 then divide nPixels/pixelsPerByte instead of the multiply nPixels*bytesPerPixel.
Are rows always padded to a byte boundary? If so then a widthInBytes*height could be more accurate.
Author: Adam Jackson <email@example.com>
Date: Thu Apr 10 11:45:37 2014 -0400
xres: Fix size estimation for <8bpp pixmaps (#69057)