summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-23 18:06:25 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-23 18:06:25 +0100
commit491a5f5e34238fc35383cc1bb6179deee8688d78 (patch)
tree3d09d92e62544620fa2d1fe9926d4f81c4743a2c
parent068615fe5e25ff763d84262c615ab4c1f178a708 (diff)
downloadserenity-491a5f5e34238fc35383cc1bb6179deee8688d78.zip
LibGfx: Avoid a ByteBuffer heap allocation in PNG filtering
-rw-r--r--Libraries/LibGfx/PNGLoader.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/Libraries/LibGfx/PNGLoader.cpp b/Libraries/LibGfx/PNGLoader.cpp
index a03fafb1d6..11cfaa4353 100644
--- a/Libraries/LibGfx/PNGLoader.cpp
+++ b/Libraries/LibGfx/PNGLoader.cpp
@@ -24,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <AK/ByteBuffer.h>
#include <AK/Endian.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
@@ -465,43 +464,43 @@ NEVER_INLINE FLATTEN static void unfilter(PNGLoadingContext& context)
break;
}
- auto dummy_scanline = ByteBuffer::create_zeroed(context.width * sizeof(RGBA32));
+ u8 dummy_scanline[context.width * sizeof(RGBA32)];
for (int y = 0; y < context.height; ++y) {
auto filter = context.scanlines[y].filter;
if (filter == 0) {
if (context.has_alpha())
- unfilter_impl<true, 0>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<true, 0>(*context.bitmap, y, dummy_scanline);
else
- unfilter_impl<false, 0>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<false, 0>(*context.bitmap, y, dummy_scanline);
continue;
}
if (filter == 1) {
if (context.has_alpha())
- unfilter_impl<true, 1>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<true, 1>(*context.bitmap, y, dummy_scanline);
else
- unfilter_impl<false, 1>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<false, 1>(*context.bitmap, y, dummy_scanline);
continue;
}
if (filter == 2) {
if (context.has_alpha())
- unfilter_impl<true, 2>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<true, 2>(*context.bitmap, y, dummy_scanline);
else
- unfilter_impl<false, 2>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<false, 2>(*context.bitmap, y, dummy_scanline);
continue;
}
if (filter == 3) {
if (context.has_alpha())
- unfilter_impl<true, 3>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<true, 3>(*context.bitmap, y, dummy_scanline);
else
- unfilter_impl<false, 3>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<false, 3>(*context.bitmap, y, dummy_scanline);
continue;
}
if (filter == 4) {
if (context.has_alpha())
- unfilter_impl<true, 4>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<true, 4>(*context.bitmap, y, dummy_scanline);
else
- unfilter_impl<false, 4>(*context.bitmap, y, dummy_scanline.data());
+ unfilter_impl<false, 4>(*context.bitmap, y, dummy_scanline);
continue;
}
}