{
if (!g_settings->getBool("gui_scaling_filter"))
return;
+
+ if (g_imgCache.find(key) != g_imgCache.end())
+ return; // Already cached.
+
video::IImage *copied = driver->createImage(value->getColorFormat(),
value->getDimension());
value->copyTo(copied);
io::path scalename = origname + "@guiScalingFilter:" + rectstr;
// Search for existing scaled texture.
- video::ITexture *scaled = g_txrCache[scalename];
+ auto it_txr = g_txrCache.find(scalename);
+ video::ITexture *scaled = (it_txr != g_txrCache.end()) ? it_txr->second : nullptr;
if (scaled)
return scaled;
// Try to find the texture converted to an image in the cache.
// If the image was not found, try to extract it from the texture.
- video::IImage* srcimg = g_imgCache[origname];
- if (srcimg == NULL) {
+ auto it_img = g_imgCache.find(origname);
+ video::IImage *srcimg = (it_img != g_imgCache.end()) ? it_img->second : nullptr;
+ if (!srcimg) {
if (!g_settings->getBool("gui_scaling_filter_txr2img"))
return src;
srcimg = driver->createImageFromData(src->getColorFormat(),