InvalidateRect() Efficiency
-
Hi I'm working on an application that displays a lot of trend graphs and associated numerical values. These are updated on a regular scan in the OnIdle() function, with the processor running at full load. I started off using InvalidateRect() on the trends and the values individually to minimise the area of each View that was redrawn on each scan, but the code got a bit complicated, so I changed it to group them together. The total area redrawn is now much larger, but the number of InvalidateRect() calls has halved. I expected that the program would run a little slower but to my surprise there is no noticable difference. This gives me the impression that there is a considerable overhead associated with each InvalidateRect() call, and that if you get too fussy about drawing only those regions that have changed you rapidly run into dimishing returns. Does anyone know if this is a correct interpretation? Thanks in advance for your help. Cliff Hatch -- modified at 7:32 Sunday 16th October, 2005
-
Hi I'm working on an application that displays a lot of trend graphs and associated numerical values. These are updated on a regular scan in the OnIdle() function, with the processor running at full load. I started off using InvalidateRect() on the trends and the values individually to minimise the area of each View that was redrawn on each scan, but the code got a bit complicated, so I changed it to group them together. The total area redrawn is now much larger, but the number of InvalidateRect() calls has halved. I expected that the program would run a little slower but to my surprise there is no noticable difference. This gives me the impression that there is a considerable overhead associated with each InvalidateRect() call, and that if you get too fussy about drawing only those regions that have changed you rapidly run into dimishing returns. Does anyone know if this is a correct interpretation? Thanks in advance for your help. Cliff Hatch -- modified at 7:32 Sunday 16th October, 2005
It sounds like a drawing problem not an InvalidateRect() problem. No matter what the size of the invalidated rectangular area is, if you are drawing the whole area instead of just drawing in the invalid area then the drawing speed will be uneffected. Example, if you where designing a bitmap editor and modify the bitmap by adding a 10x10 pixel square, then you just want to redraw that 10x10 area in OnPaint(). If you where to just blit the whole bitmap each time OnPaint() was called, then drawing a simple line (via click and drag) becomes a nightmare. The above also applies to text editors or any othe application that does a lot of drawing. INTP Every thing is relative...
-
It sounds like a drawing problem not an InvalidateRect() problem. No matter what the size of the invalidated rectangular area is, if you are drawing the whole area instead of just drawing in the invalid area then the drawing speed will be uneffected. Example, if you where designing a bitmap editor and modify the bitmap by adding a 10x10 pixel square, then you just want to redraw that 10x10 area in OnPaint(). If you where to just blit the whole bitmap each time OnPaint() was called, then drawing a simple line (via click and drag) becomes a nightmare. The above also applies to text editors or any othe application that does a lot of drawing. INTP Every thing is relative...
Thanks for you comments John