]> git.lizzy.rs Git - minetest.git/blobdiff - src/guiscalingfilter.cpp
Add clouds API
[minetest.git] / src / guiscalingfilter.cpp
index 872d222d85759a3f8872afa8942db2cbca5d461e..41cc7283659ce2fa74058bb6bdc8c5dc4f80b273 100644 (file)
@@ -19,7 +19,6 @@ 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 <stdio.h>
 
@@ -52,13 +51,13 @@ void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *v
 void guiScalingCacheClear(video::IVideoDriver *driver)
 {
        for (std::map<io::path, video::IImage *>::iterator it = g_imgCache.begin();
-                       it != g_imgCache.end(); it++) {
+                       it != g_imgCache.end(); ++it) {
                if (it->second != NULL)
                        it->second->drop();
        }
        g_imgCache.clear();
        for (std::map<io::path, video::ITexture *>::iterator it = g_txrCache.begin();
-                       it != g_txrCache.end(); it++) {
+                       it != g_txrCache.end(); ++it) {
                if (it->second != NULL)
                        driver->removeTexture(it->second);
        }
@@ -73,7 +72,8 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver,
                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;
 
@@ -140,6 +140,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<s32>(0, 0, src->getSize().Width, src->getSize().Height),
                core::rect<s32>(0, 0, width, height));
@@ -155,6 +157,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<s32> mysrcrect = (scaled != txr)