Skip to content

Optimize OpenGL canvas with partial updates

The patchset allows Krita's openGL canvas to be updated in patches when on a portion of a canvas changes. It should increase rendering speed, especially on 4K displays. The main effect of the patch is reducing the lag between the brush outline and hardware cursor when hovering over the canvas.

See this bug for details: https://bugs.kde.org/show_bug.cgi?id=413504

The patch does several changes:

  1. Patches Qt, so that QPaintEvent for QOpenGLWidget contains a proper dirty rect instead of full area of the widget.
  2. Makes KisOpenGLCanvas2 handle these partial updates properly:
    1. The rendering of image tiles is limited to dirty rect only
    2. Rendering of other components of the canvas, like background and checkers, is limited with glScissor test.
    3. Rendering of decorations is limited with QPainter's clip rect functionality
  3. Fixes vector tools to issue partial updates properly. That was a problem for years, but it was visible only in KisQPainterCanvas, because KisOpenGLCanvas always updated the entire canvas.
  4. Fixes reference images to handle partial updates as well.

The patch is rather dangerous, though it would be good to pull it into krita/4.3.

Testing Packages

Test Plan

  1. Test speed:
    1. Activate both, brush outline and hardware cursor in Krita settings.
    2. Compare the lag between hardware cursor and brush outline when hovering the stylus over the canvas without painting with Krita 4.3.0.
    3. Compare the same lag when painting. Preferably using some brush with complex outline and "drawing angle" sensor active.
  2. Shape Selection Tool
    1. Manipulating shapes on the canvas should not leave any traces of handles and decorations on the canvas
    2. Don't forget about extra actions available via Tool Options docker!
    3. Undo/Redo of actions should update decorations correctly and should not generate any artifacts
    4. Test snapping (use Shift+S to activate it)
  3. Bezier Path Tool
    1. Creating a path in any mode (dragging, Alt and Shift modifier) should not generate any artifacts
    2. It should be possible to start/end(?) a path on an existing path.
    3. Test snapping (use Shift+S to activate it)
  4. Path Editing Tool
    1. Manipulating shapes on the canvas should not leave any traces of handles and decorations on the canvas
    2. Don't forget about extra actions available via Tool Options docker!
    3. Undo/Redo of actions should update decorations correctly and should not generate any artifacts
    4. Test snapping (use Shift+S to activate it)
  5. Test manipulating reference images
  6. [on OSX] Test if "bended lines" problem still visible when painting with a tablet

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Dmitry Kazakov

Merge request reports