diff options
author | Peter Nelson <peter@peterdn.com> | 2020-04-25 14:40:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-25 16:49:09 +0200 |
commit | 76cbfe1c3841b88b714dae1432e47c49c2c83116 (patch) | |
tree | c00782a02dfbcf517372ce17e5f381c0d782c1ac /Libraries | |
parent | e159370ccb7ebe0ddea927cfd8864b76204bbc4c (diff) | |
download | serenity-76cbfe1c3841b88b714dae1432e47c49c2c83116.zip |
LibGfx: Minor changes to adhere to code style guidelines
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGfx/GIFLoader.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Libraries/LibGfx/GIFLoader.cpp b/Libraries/LibGfx/GIFLoader.cpp index eec95768cd..81e73c9e89 100644 --- a/Libraries/LibGfx/GIFLoader.cpp +++ b/Libraries/LibGfx/GIFLoader.cpp @@ -161,8 +161,8 @@ public: return {}; } - // Read code bits using a 32-bit mask. If current code size > 9 bits - // then it's possible the code spans 3 bytes. + // Extract the code bits using a 32-bit mask to cover the possibility that if + // the current code size > 9 bits then the code can span 3 bytes. u8 current_bit_offset = m_current_bit_index % 8; u32 mask = (u32)(pow(2, m_code_size) - 1) << current_bit_offset; @@ -410,12 +410,12 @@ bool load_gif_impl(GIFLoadingContext& context) LZWDecoder decoder(image.lzw_encoded_bytes, image.lzw_min_code_size); // Add GIF-specific control codes - const int CLEAR_CODE = decoder.add_control_code(); - const int END_OF_INFORMATION_CODE = decoder.add_control_code(); + const int clear_code = decoder.add_control_code(); + const int end_of_information_code = decoder.add_control_code(); auto bitmap = Bitmap::create_purgeable(BitmapFormat::RGBA32, { image.width, image.height }); - int pixel_idx = 0; + int pixel_index = 0; while (true) { Optional<u16> code = decoder.next_code(); if (!code.has_value()) { @@ -423,24 +423,24 @@ bool load_gif_impl(GIFLoadingContext& context) return false; } - if (code.value() == CLEAR_CODE) { + if (code.value() == clear_code) { decoder.reset(); continue; - } else if (code.value() == END_OF_INFORMATION_CODE) { + } else if (code.value() == end_of_information_code) { break; } auto colors = decoder.get_output(); - for (size_t i = 0; i < colors.size(); ++i, ++pixel_idx) { - auto color = colors.at(i); + for (const auto& color : colors) { auto rgb = logical_screen.color_map[color]; - int x = pixel_idx % image.width; - int y = pixel_idx / image.width; + int x = pixel_index % image.width; + int y = pixel_index / image.width; Color c = Color(rgb.r, rgb.g, rgb.b); bitmap->set_pixel(x, y, c); + ++pixel_index; } } |