Implemented https://phabricator.kde.org/T203. When scaled past 400%, 1x1 grid is displayed.
Details
- Reviewers
dkazakov - Group Reviewers
Krita - Commits
- R37:37d839889950: Option to automatically display a 1x1 grid when zoomed past a certain point
Couldn't test shader loading and work in openGL version < 3.0
Also need checking if clause where info passed to openGL via lineBuffer.
Diff Detail
- Repository
- R37 Krita
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Hi!
Thanks for the patch. I've got a couple of questions, that I put inline, and a third question: shouldn't this patch be split in two, one that allows setting the cursor color, and one for the grid? Also, it's probably a good idea to also add setting the cursor color to the display page in the settings dialog.
Hm... Updated to add: I don't see the grid when I zoom in? Should I configure something manually?
libs/ui/opengl/kis_opengl_canvas2.cpp | ||
---|---|---|
507 | I wonder -- is there a reason this patch doesn't re-use the existing grid drawing code? |
Hi, @lieroz!
I have tested your patch! It works almost perfectly. There is only one small problem. The spacing between the grid lines is not the same and, which is worse, this spacing jumps to and fro when you do the panning. Please check the code in KisGridDecoration::drawDecoration() for the example.
To solve the issue one needs to have a bit finer control over the rounding happening during the painting. Try using rounding/ceil/floor in different combinations. It might work...
krita/data/shaders/shaders.qrc | ||
---|---|---|
14 | I would rename it into solid_color.frag so it would be a bit more self-descriptive :) | |
libs/ui/opengl/kis_opengl_canvas2.cpp | ||
75 | I guess this can be removed now, can't it? | |
76 | solidColorShader is probably a bit better name | |
557 | I'm not sure that allocation of the buffer during each run is a good idea. Probably, you could allocate something on resize/pan/zoom event and then just reuse it? |
libs/ui/opengl/kis_opengl_canvas2.cpp | ||
---|---|---|
507 | We thought that it would be more efficient to draw such a dense grid straight in openGL. And there might be troubles with activation/deactivation of the decoration when zooming, like I had long ago with infinity manager decoration. The question is good and very disputable of course. |
Hello, thanks for review!
In my case, works code without linebuffer where it checks KisOpenGL::hasOpenGL3(), I couldn't test it on my machine, i guess there have to be openGL > 3.0.2 but mine is pure 3.0, could you tell me your version so i will know where to dig in.
About reusage of already existing code. Uhm... I just didn't know about it :)
Update: If you want to test it immediately, you will have to comment blocks with KisOpenGL::hasOpenGL3()
Mine is 3.0.0 too at the moment:
OpenGL Info
Vendor: nouveau Renderer: "Gallium 0.4 on NV117" Version: 3.0 Mesa 11.2.2 Shading language: 1.30 Requested format: QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile 2) Current format: QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 0, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile 0) Version: 3 . 0 Supports deprecated functions true
krita has opengl true
It works pretty good overall and seems to line up with the pixels. I have a few suggestions to make it better...
- individual pixel stuff is more important with pixel art. With that people usually work much smaller like 32 x 32. When I make an image at 32 x 32 (72 dpi), the grid turns on at 200% zoom. I would not expect it to turn on at only 200% zoom. 800% would be better like it does at higher pixel densities
- It doesn't appear there is an option to turn this off and on. It would probably be a good idea to have that in either the "View" menu or the settings area area. Saving it to the kritarc would probably be a good idea
I played around with this a bit more and there are some odd artifacts appearing on the canvas when I draw. Turning OpenGL off seems to fix the issue. I am testing on a windows 10 machine.
Not sure if anyone else is getting these artifacts.
screenshot
Thanks, i will try to refactor those changes you suggested. However, your issue is realy strange, right know i don't know where the problem is. Could you please paste here your version of openGL and it would be cool if you could qDebug() if/else branch with KisOpenGL::hasOpenGL3() for me to know whether it is trouble in sending info to openGL via buffers.
Here is my graphics card info...
OpenGL Info
Vendor: ATI Technologies Inc. Renderer: AMD FirePro M4000 Mobility Pro Graphics Version: 3.0.13411 Compatibility Profile Context FireGL 15.201.2701.0 Shading language: 4.40 Version: 3.0 Supports deprecated functions: true
I wonder if anyone else is having this issue? I generally don't have any OpenGL problems on this computer and Krita. Maybe it is just specific to my graphics card? Maybe dmitry or boud can also test.
After I updated to the binary nvidia drivers for Linux, the grid started to work:
OpenGL Info
Vendor: NVIDIA Corporation Renderer: "Quadro K620/PCIe/SSE2" Version: 4.5.0 NVIDIA 375.66 Shading language: 4.50 NVIDIA Requested format: QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile 2) Current format: QSurfaceFormat(version 4.5, options QFlags(0x4), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 0, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile 2) Version: 4 . 5 Supports deprecated functions true
krita has opengl true
Hi, @lieroz and @scottpetrovic!
I have just tested the patch on Windows 10 + AMD GPU and everything seems to work fine.
[5240] No "breeze" available. [5240] Set style "fusion" [5240] OpenGL Info [5240] Vendor: ATI Technologies Inc. [5240] Renderer: "AMD Radeon(TM) R7 Graphics" [5240] Version: 3.0.13474 Compatibility Profile Context 22.19.162.4 [5240] Shading language: 4.50 [5240] Requested format: QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile 2) [5240] Current format: QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior 2, swapInterval 1, profile 0) [5240] Version: 3 . 0 [5240] Supports deprecated functions true [5240] krita has opengl true
@scottpetrovic, could you please test it once again and check if you have the same issue without the patch applied?
Btw, @scottpetrovic, do you see these artifacts right after the start of Krita or only after some special actions/time?
I think this patch is ok.
I re-tested the patch and I am not getting those artifacts any longer. I applied the patch to the tip of master.
I am not sure how I got in the state I did last time. The problem I had before is probably a problem with some situation. It probably isn't related to this patch though. I also am a bit behind in my graphics card updates.
The only comment I would have left is that it would be nice to be able to toggle this functionality off (it can be on by default). I would probably call it something like "Show Pixel Grid" so it won't be confused with the normal grid. It could be in the view main menu.
If it is easier, that could be added as a separate patch...just to get this in the code base