Bug 199354 - Over-active repaint behaviour causes slowness
Summary: Over-active repaint behaviour causes slowness
Alias: None
Product: KSquares
Classification: Applications
Component: general (show other bugs)
Version: 0.4
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Matt Williams
Depends on:
Reported: 2009-07-08 00:16 UTC by Casper van Donderen
Modified: 2009-08-16 17:00 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Casper van Donderen 2009-07-08 00:16:34 UTC
Version:           0.4 (using Devel)
Compiler:          GCC 4.3.2 
OS:                Linux
Installed from:    Compiled sources

Running a large grid size with computer players in KSquares is not feasible because of a large amount of repaints being done which should not happen.

If you enable the 'Show Paint' Desktop effect it becomes clear that all repaints do a full repaint from the bottom upwards (when putting a line one the bottom row only a small part, when placing a line on the top row almost the whole view gets repainted).

I tried to fix it by myself but I cannot find the cause, since in gameboardscene.cpp only update(line->boundingRect()); is called. Lowering the spacing to for example 10 already has an advantageous effect I think because the amount of scaling that needs to be done by the graphicsview is greatly decreased/upscaling is easier than downscaling.

To me it looks like the cause can be in the fact that a new QGraphicsLineItem is added and that this might trigger a global update in the QGraphicsView?.

Also the highlight effect decreases speed a lot. It takes up to 2 seconds before I can do a new move after a computer player on a 50x30 grid. When disabling this effect in the source code the application runs a lot smoother.
Comment 1 Albert Astals Cid 2009-07-12 16:41:43 UTC
Can you try if setting QGraphicsScene::NoIndex to the scene fixes the problem too?
Comment 2 Casper van Donderen 2009-07-12 21:41:00 UTC
In both SVN and 4.3 setting this->setItemIndexMethod(QGraphicsScene::NoIndex) in the constructor of gameboardscene.cpp does not work, the reapints still all happen. the index is set nowhere else.
Comment 3 Albert Astals Cid 2009-08-13 20:23:47 UTC
I think i know the problem, there are two combined problems:
 * Qt sucks at rendering long dashed lines
 * KSquares uses lots of long dashed lines

Can you check that disabling dashes, by chaning
 QPen feintPen(Qt::DotLine);
 QPen feintPen;
in gameboardscene.cpp give you a noticeable gain? It did for me

If that's the case and you have time, you should try converting the long dashed lines to short ones, that is doing one per square side instead one per each "row"
Comment 4 Casper van Donderen 2009-08-13 20:27:04 UTC
I checked alot when I was trying to fix it and it is already using short dashed lines, that was something i thought that was the problem. When you click a line it overlays a non-dashed line at the position of a dashed line. it does a line->getindex -> draw new line at that position type scheme to add a move.

Comment 5 Albert Astals Cid 2009-08-16 16:38:33 UTC
SVN commit 1011981 by aacid:

backport r1011979 | aacid | 2009-08-16 16:30:25 +0200 (Sun, 16 Aug 2009) | 3 lines

QGraphicsScene does not like items being deleted without being removed and that cuases lots of redraws
BUGS: 199354

 M  +9 -1      highlightanimation.cpp  
 M  +1 -0      highlightanimation.h  

WebSVN link: http://websvn.kde.org/?view=rev&revision=1011981
Comment 6 Casper van Donderen 2009-08-16 16:49:23 UTC
Forgot to add comment:
When starting with quickstart with 4 computer players the filling of squares is still slow
Comment 7 Albert Astals Cid 2009-08-16 17:00:08 UTC
Closing, there's no huge repainting anymore, just that the AI blocks (bug 204061)