#include "guiscalingfilter.h"
#include "imagefilters.h"
#include "settings.h"
-#include "main.h" // for g_settings
#include "util/numeric.h"
-#include <stdio.h>
+#include <cstdio>
+#include "client/renderingengine.h"
/* Maintain a static cache to store the images that correspond to textures
* in a format that's manipulable by code. Some platforms exhibit issues
}
// Manually clear the cache, e.g. when switching to different worlds.
-void guiScalingCacheClear(video::IVideoDriver *driver)
+void guiScalingCacheClear()
{
- for (std::map<io::path, video::IImage *>::iterator it = g_imgCache.begin();
- it != g_imgCache.end(); it++) {
- if (it->second != NULL)
- it->second->drop();
+ for (auto &it : g_imgCache) {
+ if (it.second)
+ it.second->drop();
}
g_imgCache.clear();
- for (std::map<io::path, video::ITexture *>::iterator it = g_txrCache.begin();
- it != g_txrCache.end(); it++) {
- if (it->second != NULL)
- driver->removeTexture(it->second);
+ for (auto &it : g_txrCache) {
+ if (it.second)
+ RenderingEngine::get_video_driver()->removeTexture(it.second);
}
g_txrCache.clear();
}
video::ITexture *src, const core::rect<s32> &srcrect,
const core::rect<s32> &destrect)
{
-
+ if (src == NULL)
+ return src;
if (!g_settings->getBool("gui_scaling_filter"))
return src;
video::ITexture *guiScalingImageButton(video::IVideoDriver *driver,
video::ITexture *src, s32 width, s32 height)
{
+ if (src == NULL)
+ return src;
return guiScalingResizeCached(driver, src,
core::rect<s32>(0, 0, src->getSize().Width, src->getSize().Height),
core::rect<s32>(0, 0, width, height));
{
// Attempt to pre-scale image in software in high quality.
video::ITexture *scaled = guiScalingResizeCached(driver, txr, srcrect, destrect);
+ if (scaled == NULL)
+ return;
// Correct source rect based on scaled image.
const core::rect<s32> mysrcrect = (scaled != txr)