Bug 69057 - X_Resource QueryResourceBytes on depth=1 pixmap
Summary: X_Resource QueryResourceBytes on depth=1 pixmap
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Adam Jackson
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-06 23:00 UTC by Kevin Ryde
Modified: 2014-04-22 15:43 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
failing program (551 bytes, text/plain)
2013-09-06 23:00 UTC, Kevin Ryde
no flags Details

Description Kevin Ryde 2013-09-06 23:00:43 UTC
Created attachment 85383 [details]
failing program

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

    xvfb-run ./foo
    =>
    pixmap 200001
    bytes 0

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.
Comment 1 Adam Jackson 2014-04-22 15:43:08 UTC
commit f466fb2432292d74123d701764c432d3aa75ef1d
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Apr 10 11:45:37 2014 -0400

    xres: Fix size estimation for <8bpp pixmaps (#69057)


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.