Bo Peng wrote:
> You are right. Since the loading is blocking, this method means double
> loading work when we go to a new unloaded page. So I am thinking of a
> side loader:  (just idea, details might be totally wrong.)
>    1. count the instances of GraphicsLoader (using a static counter)
>    2. if there is no instance (all visible insets have been loaded),
>       try to locate a unloaded formula and load it. So this loader will
>       eventually load all bitmaps, not just next screen.
>    3. do this every second by a timer or trigger it by some event.
>       Hopefully, loading one bitmap a time will not disturb user
>       interaction very much.
> 
>> Sorry if I've misunderstood everything...
> 
> me too. I am also in the process of reading codes. :-) Any other idea is
> welcome.

Looks to me like you both understand the code pretty well. To recap: 

At the moment, each inset::draw routine triggers a call to the 
GraphicsLoader::startLoading routine. This starts off a timer which returns 
2 secs later, checks if the inset is still visible and, if so, initiates 
loading proper with a call to GraphicsCacheItem::startLoading. All very 
convoluted but necessary I'm afraid.

What might be a nice thing to do when loading images is to group the loading 
and displaying of multiple images together. I believe this jumping of the 
screen as multiple formula images are loaded is what originally caused Bo 
to look at the code ;-) Insets are told to redraw themselves when 
PreviewImage::Impl::statusChanged() is called and in turn emits a signal to 
the outside world:
        case Ready:
                lyx::unlink(iloader_.filename());
                ploader_.emitSignal(parent_);
                break;

It should be quite easy to have PreviewImage call an instance of some (new) 
wrapper class that collects all these Ready images together and finally 
tells the outside world when all loading images are loaded. Something like 
that anyway.

Alternatively, throw away this complex mess and use threads ;-)

-- 
Angus

Reply via email to