W dniu 30 sierpnia 2011 21:51 użytkownik Johan Engelen <jbc.engelen@...2592...> napisał:
To me it sounds pretty straightforward to cache the bbox value for items. Perhaps we could make a struct of cached values for items that are invalidated upon (relevant) changes? I have no experience with this, perhaps someone knows how this can be implemented in a straightforward and easily usable way? For LPE, it is also be desirable to cache intermediate results, so something like this would be awesome: SPItem::addItemToCache(string key, any value) optional value SPItem::retrieveFromCache(string key)
1. There is a complication that the bbox depends on the transformation supplied to the bounds() method. We could cache document and desktop bounds though. 2. I don't think the caching mechanism should be explicit. 3. The SPItem should contain an OptRect for document bounds. It should not be a list external to the SP tree. I assume that even after we allow any desktop transforms, they will be limited to zooming (e.g. only translation & uniform scale, no rotations), so storing a separate rect for desktop coords is unnecessary.
So we would modify documentVisualBounds to something like that: if (bbox_valid) return bbox; bbox = call virtual bbox method; bbox_valid = true; return bbox;
The update() method of SPItem would set bbox_valid to false when appropriate.
Sorry for a lot of talking and little coding but I have reinstalled both my systems recently after a disk upgrade and not everything is working yet.
Regards, Krzysztof