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:
- Patches Qt, so that
QPaintEvent
forQOpenGLWidget
contains a proper dirty rect instead of full area of the widget. - Makes
KisOpenGLCanvas2
handle these partial updates properly:- The rendering of image tiles is limited to dirty rect only
- Rendering of other components of the canvas, like background and checkers, is limited with
glScissor
test. - Rendering of decorations is limited with QPainter's clip rect functionality
- Fixes vector tools to issue partial updates properly. That was a problem for years, but it was visible only in
KisQPainterCanvas
, becauseKisOpenGLCanvas
always updated the entire canvas. - 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
- Windows: https://yadi.sk/d/rbkk_844s0PK9g
- Linux: https://yadi.sk/d/p29WG9yBAcFfJQ
- OSX: https://drive.google.com/file/d/1P5CqXCI_ISDqIf6RDswlukuo7lnp50c8/view?usp=sharing
Test Plan
- Test speed:
- Activate both, brush outline and hardware cursor in Krita settings.
- Compare the lag between hardware cursor and brush outline when hovering the stylus over the canvas without painting with Krita 4.3.0.
- Compare the same lag when painting. Preferably using some brush with complex outline and "drawing angle" sensor active.
- Shape Selection Tool
- Manipulating shapes on the canvas should not leave any traces of handles and decorations on the canvas
- Don't forget about extra actions available via Tool Options docker!
- Undo/Redo of actions should update decorations correctly and should not generate any artifacts
- Test snapping (use Shift+S to activate it)
- Bezier Path Tool
- Creating a path in any mode (dragging, Alt and Shift modifier) should not generate any artifacts
- It should be possible to start/end(?) a path on an existing path.
- Test snapping (use Shift+S to activate it)
- Path Editing Tool
- Manipulating shapes on the canvas should not leave any traces of handles and decorations on the canvas
- Don't forget about extra actions available via Tool Options docker!
- Undo/Redo of actions should update decorations correctly and should not generate any artifacts
- Test snapping (use Shift+S to activate it)
- Test manipulating reference images
- [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