Hi Johannes, I'm glad that someone is dealing with this problem. I'll write more about it, here just some first remarks, after only taking a glance at this and other patches. On Fri, Nov 09, Johannes Hofmann wrote:
Hi,
this patch adds set(), isEmpty(), and merge() methods to core::Rectangle. These methods are then used to maintain a rectangle that contains all screen areas for which a redraw was requested. When fltk really draws to the screen, the drawing is limited to this area. The most obvious improvement is visible on pages with very large images that take some time to load. While the image is loaded the rest of the page is no longer flickering - at least if there is no other stuff that requests complete redraws.
You may take a look at the old implementation (gtk-based, somewhere in dw_viewport.c), combining the areas of different redraw requests is already implemented there. Perhaps it is better to adopt the old code, which has been working for a while. Some notes on the general problem. There are several cases when areas are to be redrawn, I hope this list is complete: 1. to react on expose events, 2. if a widget redraws itself, and 3. when scrolling. Regarding the problem, how to restrict drawing to a minimum, case 1 is probably neglectable, since the number of expose events is mostly rather small (only when moving windows, changing there order etc.). It seems that the following code:
+ ::fltk::Rectangle rect (x(), y(), w(), h()); + if (d == DAMAGE_VALUE) {
may be used to distinguish it from the critical cases 2 and 3. For case 1, still the whole viewport is drawn, optimization should be secondary. Sebastian