Revamp the cache

Simplify the caching code by using a simpler has+locks structure for the cache instead of the previous custom code. After that revamp the mipmap cache:

  * Serialize to disk image by image and with jpg compression, allowing the in-memory cache to spill-over to disk
  * Put all the thumbnail levels (DT_MIPMAP_#) into a single cache so that the space gets used by whichever thumbnails are most needed
  * Add two more thumbnail levels (4 and 5) and set all the levels to fixed size values, removing thumbnail_width and thumbnail_height in the process

This allows seamless transition between 720p/1080p/4K screens with no settings changes and good efficiency in terms of memory usage. It also makes it much easier to browse large collections as we now have thumbnails pre-calculated on disk.