- Correct some comments so they reflect what the code is now doing.
- Make return None explicit in a few places.
- Wrap render_cover() in an if to check that cover_tuple is valid. This doesn't change behavior because the thrown exception would do the same thing, but being explicit is nice.
1) Set device pixel ratio on generated QPixmap
2) Avoid copying image data when loading cover from library
3) Convert thumbnail to RGBA in cover thread so as to do less work in
GUI thread
I can't use ReadOnlyFileBuffer because PIL requires that the buffer have the lstrip() function. I did eliminate a copy operation when writing the image to the thumbnail cache.
I couldn't make the PIL ImageQt stuff work. It seems to use a common butter somewhere. Generating and adding a second image to the CoverCache corrupted previously added images. This implementation avoids this problem by passing a byte string of the PIL thumbnail to re_render(), which creates the QPixmap on the GUI thread. As a side effect, all the CoverCache operations are now on the GUI thread.
This implementation is visibly faster than the last one.
- All Qt operations are now done on the GUI thread. File operations are done on a separate thread.
- QPixmap is used instead of QImage.
- The ThumbnailCache is now versioned.
The rendering operations are done using a FunctionDispatcher instead of a Qt signal to avoid a long queue of render operations causing the UI to be sluggish.
Emblems etc aren't rendered if the cover cache hasn't been set for the book. This reduces some subtle flashing as the cover is repainted. However, covers are seen as empty regions until the cover is actually rendered.
I also fixed a bug where the wrong cache would be used after a switch library. The UUID used for the cache was set at thread creation time instead of set_database time.