Wednesday, June 19, 2013

Qt Line Rendering Differences...

For about a year now, I've been somewhat baffled about a some annoying differences between the way sub-pixel line strokes with < 100% alpha assigned and drawn using QPainter differed between Windows and Linux (i.e. "cross platform" software in my books :P)

A few minutes ago, I finally stumbled across the answer ([1], [2]), while checking out a solution to another problem (namely, how to replace the scrollbars - or better still, access their internals to figure out the position of the trough and thumb in a cross-platform way, and use that info to figure out how to map a indicators/target locations to that - in QAbstractScrollAreas/QScrollAreas and their subclasses such as all the Item-View classes). Apparently on Windows, they use a custom rasterer on Windows, while directly using X11 on Linux. No wonder just changing flags had little to no overall effect on fixing the problems I was having!

Links
[1] http://www.zestymeta.com/2013/03/qt-and-peril-of-multi-platform.html   <- the post which alerted me to this problem in the first place
[2] http://blog.qt.digia.com/blog/2009/12/16/qt-graphics-and-performance-an-overview/   <- confirmation from the source...



The problem in my case was that lines which were perfectly visible on Windows were completely invisible in Linux. That wouldn't be a problem in many cases (if those lines were purely decorative). But in my case, these lines WERE the interface - they were an important part of the whole interactive visualisation technique/widget I was building!

Furthermore, on Windows, I had been struggling for weeks to reign in the "full bodied" drawing of the lines, where they would often end up accumulating and aggregating too vividly, to the point of obscuring and hiding the primary targets. However, on Linux, these same lines would be nowhere to be seen at all - apart from applying a platform-check hack where I had to boost the colours up several notches on Linux to get them even midly visible.

At first, I thought it might have just been a monitor-related difference, since my laptop's screen is starting to get a bit old and faded (but perfect for reading from for long periods without the "glare"/"eyeburn" problems people often complain about when reading from screens) while the monitors I'd been testing with Linux had been Viewsonic ones (for the record, IMO, Viewsonic monitors mostly suck - too much backlight and grainy pixels). However, after managing to test on a few other machines, and a combination of both Windows and Linux boxes (including different version of Fedora), I was finally able to rule that possibility out (though I did find that the brightness of the monitors themselves was contributing a bit to the visibility/contrast problems).

Anyways, now that I know the real problem, and having seen their recommendations, I think I'll definitely need to try out that QApplication::setGraphicsSystem() stuff when I next get back into the office.

No comments:

Post a Comment