| 52 | } |
| 53 | |
| 54 | QPixmap TexturePack::image(QSize size, Qt::AspectRatioMode mode) const |
| 55 | { |
| 56 | QPixmap cached_image; |
| 57 | if (PixmapCache::find(m_pack_image_cache_key.key, &cached_image)) { |
| 58 | if (size.isNull()) |
| 59 | return cached_image; |
| 60 | return cached_image.scaled(size, mode, Qt::SmoothTransformation); |
| 61 | } |
| 62 | |
| 63 | // No valid image we can get |
| 64 | if (!m_pack_image_cache_key.was_ever_used) { |
| 65 | return {}; |
| 66 | } else { |
| 67 | qDebug() << "Texture Pack" << name() << "Had it's image evicted from the cache. reloading..."; |
| 68 | PixmapCache::markCacheMissByEviciton(); |
| 69 | } |
| 70 | |
| 71 | // Imaged got evicted from the cache. Re-process it and retry. |
| 72 | TexturePackUtils::processPackPNG(*this); |
| 73 | return image(size); |
| 74 | } |
| 75 | |
| 76 | bool TexturePack::valid() const |
| 77 | { |
no test coverage detected