Friday 13 May 2016

The Call To Adventure

So.. Looks like I will be participating in Google Summer of Code this year. Officially it starts on the 23rd of May, but my thesis is in the way, so I will be starting about two weeks later.

What will I be doing you ask? Well, as some people know Krita on Mac OS X is not quite there yet. Some of the new cool functionality added to Krita 3.0 is forcefully omitted from the OS X release. Deep down in the depths of Krita painting we paint decorations using Qt's kindly provided QPainter class. This class allows us to make pretty lines and shapes very easily, and is perfectly suited to drawing all of the overlay functionality (such as grids, cursors, guides, etc.). What could possibly go wrong there? Well, even though we are grateful to have such easy rendering functionality, the backend of those functions haven't exactly kept up with the times.

In 2008 a new version of OpenGL came out (version 3.0) that threw out much of the old functionality and told programmers to do all of it themselves. You should upload your own data to the graphics card! You should define your own shading algorithms! And you should keep track of your own transformation matrix stack! Sounds like a lot of hassle, but the advantage is that we are not stuck in the rigidity of what OpenGL allows us to do. The problem is that OpenGL doesn't have a clue about what kind of application we are making, so it provides some general functions to us which may or may not suit our needs. And when these functions do not suit our needs, we are going to feel it in the performance.
Want to render a complicated model with many thousands of vertices? Well sorry, I only know how to redundantly upload all these vertices to the graphics card on every frame.

So now we have reached the year 2016 and the new functionality of Krita makes thankful use of this new OpenGL version that allows us to cleverly upload data to the graphics card. But here comes the showstopper, because we still use that old and slow OpenGL version to draw our decorations. D'oh!
Luckily this isn't too much of a problem, the old version is still fast enough to draw a couple of decorations without breaking a sweat. Indeed, mixing both versions works quite a charm... at least... on Windows and Linux..

With the advent of OpenGL version 3.0 the notion of deprecation was introduced. Many of the features that were in use before 3.0 were now replaced with newer better ways to accomplish the same and were marked as deprecated. In order to stay compatible with both ways of doing things, generally OpenGL doesn't really care if you use deprecated functionality together with the new functionality. A program that uses this type of mix is therefore said to use the 'Compatibility Profile'. The compatibility profile allows the programmer to use older and newer versions interchangeably. On the other hand we find something called 'Core Profile (with forward compatibility)'. This core profile removes all deprecated functionality and prevents the programmer from using those functions.

As it happens, the Windows and Linux platforms support programs that were written using core profile or compatibility profile. In contrast, the Mac OS X platform currently only supports using OpenGL versions lower than 3.0 or using versions higher than 3.0 but only in core profile. This forms a problem for Krita, because if we pick a version lower than 3.0, then OS X users don't have access to our new performance features (which use the new OpenGL version). However, if we pick a version higher than 3.0  (as we currently do) then we are disallowed from using the QPainter class (which uses deprecated functionality) to draw our decorations. It appears we are at an impasse...

Well, here is where I come in. It will be my responsibility in this Google Summer of Code to modernise this QPainter class and make it play nicely with the rest of Krita. I will need to make sure that all deprecated functionality is purged from its implementation and that it makes efficient use of the new functionality OpenGL has provided us with.

If all goes to plan it means that OS X users will get to enjoy the new performance enhancements brought to Krita 3.0 whilst at the same time not losing all of their decorations.

No comments:

Post a Comment