diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-21 14:08:14 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-21 14:08:14 +0100 |
commit | fe25f957e55a8355729c6db0443c00b39d9b534c (patch) | |
tree | f39dbabe9d46ea6309e5a444794a6e60842ef04a | |
parent | 332b5a96f61a9200d91b84b6fc267c3a998dbfe7 (diff) | |
download | serenity-fe25f957e55a8355729c6db0443c00b39d9b534c.zip |
PNGLoader: Allocate enough space for the compressed data buffer up front.
This is a 2x speedup on wallpaper loading.
-rw-r--r-- | SharedGraphics/PNGLoader.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/SharedGraphics/PNGLoader.cpp b/SharedGraphics/PNGLoader.cpp index 429135caff..3361861933 100644 --- a/SharedGraphics/PNGLoader.cpp +++ b/SharedGraphics/PNGLoader.cpp @@ -99,7 +99,6 @@ static bool process_chunk(Streamer&, PNGLoadingContext& context); RetainPtr<GraphicsBitmap> load_png(const String& path) { - Stopwatch sw("load_png"); int fd = open(path.characters(), O_RDONLY); if (fd < 0) { perror("open"); @@ -153,7 +152,7 @@ static byte paeth_predictor(int a, int b, int c) static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) { - Stopwatch sw("load_png_impl"); + Stopwatch sw("load_png_impl: total"); const byte* data_ptr = data; int data_remaining = data_size; @@ -165,6 +164,8 @@ static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) PNGLoadingContext context; + context.compressed_data.ensure_capacity(data_size); + data_ptr += sizeof(png_header); data_remaining -= sizeof(png_header); @@ -205,7 +206,7 @@ static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) } { - Stopwatch sw("create bitmap"); + Stopwatch sw("load_png_impl: create bitmap"); context.bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::RGBA32, { context.width, context.height }); } |