Following on from yesterday’s post, I have renamed the two types of clipping rect to “foreground” and “background”. It should be possible to optimise it further, and have the cache selectively invalidate either set of regions depending on what exactly has invalidated the cache.

The Gadget::clipRectToHierarchy() function, which clips drawing regions to a gadget’s ancestors, is now non-recursive, which should give a minor speed boost.

A feature that Jeff asked for nearly 18 months ago was a ScrollRect() function in the graphics port that would shift a region of the framebuffer by n pixels. I’ve now got part of this implemented - the GraphicsPort has a “copy()” method that will copy a rectangular region of the framebuffer from one location to another. It uses all of the scrolling tricks I worked out when writing the ScrollingPanel class, such as an off-screen buffer for horizontal copies (wherein the destination overlaps the source), and copying top-to-bottom or bottom-to-top depending on the vertical difference between source and destination. I still need to add in clipping methods to enable this to be used as a scrolling function.

The existing copy() method has allowed me to trim the Screen::drag() method. That was previously recalculating its foreground visible rects (for some inexplicable reason, as they’ve been cached for ages now) and had implemented its own copying routine that worked directly with the framebuffer. I’m trying to eliminate that from Woopsi to make it more portable. Anyway, the upshot of all this is that screen dragging is now faster, and the code is tidier. Hurrah!