In this post, I want to show you what I did during my first two weeks of the Google Summer of Code.

Okular before adding support for HiDPI

Okular before adding support for HiDPI

As you can see in the screenshot, Okular unfortunately is one of the applications that still has rendering problems on HiDPI screens. That’s bad for me, because I use Okular regularely for reading scientific papers. To be fair, there is a workaround to create a wrapper script which unsets QT_SCREEN_SCALE_FACTORS, but this also means everything is displayed unscaled.

So I decided to focus on the applications in the kdegraphics module - beginning with okular in the first phase of the GSoC program.

And - drum roll please! - this is the result of two to three weeks coding:

Okular after adding support for HiDPI

Okular after adding support for HiDPI

As you can see, the rendering does now work (if you don’t see the difference, open the images in fullscreen). :-)

This took more time then I hoped it would, due to two reasons:
Most of the code that is responsible for the rendering dates back to 2005 - a time, where Qt still belonged to Trolltech and Qt 3.3 was just released. Of course it was ported over to Qt5 and still works, but sometimes I thought there would be a more efficient/simpler solution today. Unfortunately this was out of scope for this project, so there are still many places where the pixels of QImages are modified directly.

The painting of the individual pages also turned out be be difficult to understand. It basicially happens in one, big, complicated, 1000 line long function. This function contains many if statements to handle special cases - e.g. there are many blocks that are only executed if there is a tile manager, or if the image needs to be back-buffered (if it contains highlighting or annotations), or if the page is not yet loaded and a loading icon is drawn (with, again, a fallback if this fails too).

That means testing will also not be that straightforward - in the coming days, I will make sure that all the features still work as expected: all the different document types, with annotations, while zoomed in…

If you want to try this out, the patch is already up on phabricator. Please also leave feedback after testing, this would help me tremendously.

Okular in kdevelop

I'm sure there are still a few bugs in here - the first person to spot one will get a beer at Akademy

At this point I wanted to tell you about gwenview - the next application I’m tackling in the kdegraphics module. But unfortunately, my patch isn’t ready yet and has to wait for the next blog post…