X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fguiscalingfilter.cpp;h=dc6219b60ba9b611f80d60786424283942a116b1;hb=5e61f64ce259fe0b23cbb377b44e90a0fbc820d7;hp=872d222d85759a3f8872afa8942db2cbca5d461e;hpb=ddf96c7a17e45cdfb4a8060c3b0f74f17f7156df;p=oweals%2Fminetest.git diff --git a/src/guiscalingfilter.cpp b/src/guiscalingfilter.cpp index 872d222d8..dc6219b60 100644 --- a/src/guiscalingfilter.cpp +++ b/src/guiscalingfilter.cpp @@ -19,9 +19,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "guiscalingfilter.h" #include "imagefilters.h" #include "settings.h" -#include "main.h" // for g_settings #include "util/numeric.h" -#include +#include +#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 @@ -49,18 +49,16 @@ void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *v } // Manually clear the cache, e.g. when switching to different worlds. -void guiScalingCacheClear(video::IVideoDriver *driver) +void guiScalingCacheClear() { - for (std::map::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::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(); } @@ -73,7 +71,8 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver, video::ITexture *src, const core::rect &srcrect, const core::rect &destrect) { - + if (src == NULL) + return src; if (!g_settings->getBool("gui_scaling_filter")) return src; @@ -140,6 +139,8 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver, video::ITexture *guiScalingImageButton(video::IVideoDriver *driver, video::ITexture *src, s32 width, s32 height) { + if (src == NULL) + return src; return guiScalingResizeCached(driver, src, core::rect(0, 0, src->getSize().Width, src->getSize().Height), core::rect(0, 0, width, height)); @@ -155,6 +156,8 @@ void draw2DImageFilterScaled(video::IVideoDriver *driver, video::ITexture *txr, { // 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 mysrcrect = (scaled != txr)