aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-08-15 14:46:45 +0200
committersfan5 <sfan5@live.de>2021-08-16 17:56:11 +0200
commit4419e311a96821d12e64073f342877327c655dca (patch)
treefe36876287275acbc07b720c85508cdb3d634a3d
parent963fbd1572e805ae5205381ba6cb372699d6bd30 (diff)
downloadminetest-4419e311a96821d12e64073f342877327c655dca.tar.gz
minetest-4419e311a96821d12e64073f342877327c655dca.tar.bz2
minetest-4419e311a96821d12e64073f342877327c655dca.zip
Cap iterations of imageCleanTransparent sanely
fixes #11513 performance regression with 256x textures
-rw-r--r--src/client/imagefilters.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/imagefilters.cpp b/src/client/imagefilters.cpp
index 7b2ef9822..9c7d0035e 100644
--- a/src/client/imagefilters.cpp
+++ b/src/client/imagefilters.cpp
@@ -95,9 +95,14 @@ void imageCleanTransparent(video::IImage *src, u32 threshold)
Bitmap newmap = bitmap;
+ // Cap iterations to keep runtime reasonable, for higher-res textures we can
+ // get away with filling less pixels.
+ int iter_max = 11 - std::max(dim.Width, dim.Height) / 16;
+ iter_max = std::max(iter_max, 2);
+
// Then repeatedly look for transparent pixels, filling them in until
- // we're finished (capped at 50 iterations).
- for (u32 iter = 0; iter < 50; iter++) {
+ // we're finished.
+ for (u32 iter = 0; iter < iter_max; iter++) {
for (u32 ctry = 0; ctry < dim.Height; ctry++)
for (u32 ctrx = 0; ctrx < dim.Width; ctrx++) {