diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-23 22:03:17 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-23 22:03:17 +0100 |
commit | 60d25f0f4a7bfeab18366e66b9ef0b648b5c8ace (patch) | |
tree | c0c815ffe60934791175b3087550d0a5f6add93f /SharedGraphics | |
parent | b0de6aa8d82f117da3d5617a2df6d52742f6809c (diff) | |
download | serenity-60d25f0f4a7bfeab18366e66b9ef0b648b5c8ace.zip |
Kernel: Introduce threads, and refactor everything in support of it.
The scheduler now operates on threads, rather than on processes.
Each process has a main thread, and can have any number of additional
threads. The process exits when the main thread exits.
This patch doesn't actually spawn any additional threads, it merely
does all the plumbing needed to make it possible. :^)
Diffstat (limited to 'SharedGraphics')
-rw-r--r-- | SharedGraphics/PNGLoader.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/SharedGraphics/PNGLoader.cpp b/SharedGraphics/PNGLoader.cpp index f248571cfb..97d2c62983 100644 --- a/SharedGraphics/PNGLoader.cpp +++ b/SharedGraphics/PNGLoader.cpp @@ -9,6 +9,8 @@ #include <SharedGraphics/puff.c> #include <serenity.h> +//#define PNG_STOPWATCH_DEBUG + struct PNG_IHDR { NetworkOrdered<dword> width; NetworkOrdered<dword> height; @@ -246,7 +248,9 @@ template<bool has_alpha, byte filter_type> [[gnu::noinline]] static void unfilter(PNGLoadingContext& context) { { +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: unfilter: unpack"); +#endif // First unpack the scanlines to RGBA: switch (context.color_type) { case 2: @@ -275,7 +279,9 @@ template<bool has_alpha, byte filter_type> auto dummy_scanline = ByteBuffer::create_zeroed(context.width * sizeof(RGBA32)); +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: unfilter: process"); +#endif for (int y = 0; y < context.height; ++y) { auto filter = context.scanlines[y].filter; if (filter == 0) { @@ -318,7 +324,9 @@ template<bool has_alpha, byte filter_type> static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) { +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: total"); +#endif const byte* data_ptr = data; int data_remaining = data_size; @@ -336,7 +344,9 @@ static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) data_remaining -= sizeof(png_header); { +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: read chunks"); +#endif Streamer streamer(data_ptr, data_remaining); while (!streamer.at_end()) { if (!process_chunk(streamer, context)) { @@ -346,7 +356,9 @@ static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) } { +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: uncompress"); +#endif unsigned long srclen = context.compressed_data.size() - 6; unsigned long destlen = context.decompression_buffer_size; int ret = puff(context.decompression_buffer, &destlen, context.compressed_data.data() + 2, &srclen); @@ -356,7 +368,9 @@ static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) } { +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: extract scanlines"); +#endif context.scanlines.ensure_capacity(context.height); Streamer streamer(context.decompression_buffer, context.decompression_buffer_size); for (int y = 0; y < context.height; ++y) { @@ -372,7 +386,9 @@ static RetainPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size) } { +#ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: create bitmap"); +#endif context.bitmap = GraphicsBitmap::create(context.has_alpha() ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32, { context.width, context.height }); } |