summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorPeter Nelson <peter@peterdn.com>2020-08-30 16:49:59 +0100
committerAndreas Kling <kling@serenityos.org>2020-08-31 18:54:44 +0200
commitc3ee5e34514574878e36aaf036fac5554e9fd367 (patch)
tree5401889c97bf7d5e57002722489fda20b2d09798 /Libraries
parentf63592f8711f0391db7d9376a81e9a2c038dab57 (diff)
downloadserenity-c3ee5e34514574878e36aaf036fac5554e9fd367.zip
LibGfx: clear previous GIF frame to transparent instead of whole image
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGfx/GIFLoader.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Libraries/LibGfx/GIFLoader.cpp b/Libraries/LibGfx/GIFLoader.cpp
index 15edb35c59..12f0d376a1 100644
--- a/Libraries/LibGfx/GIFLoader.cpp
+++ b/Libraries/LibGfx/GIFLoader.cpp
@@ -30,6 +30,7 @@
#include <AK/MappedFile.h>
#include <AK/NonnullOwnPtrVector.h>
#include <LibGfx/GIFLoader.h>
+#include <LibGfx/Painter.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -63,6 +64,11 @@ struct ImageDescriptor {
u16 duration { 0 };
bool transparent { false };
bool user_input { false };
+
+ const IntRect rect() const
+ {
+ return { this->x, this->y, this->width, this->height };
+ }
};
struct LogicalScreen {
@@ -299,7 +305,8 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index)
const auto previous_image_disposal_method = i > 0 ? context.images.at(i - 1).disposal_method : ImageDescriptor::DisposalMethod::None;
if (previous_image_disposal_method == ImageDescriptor::DisposalMethod::RestoreBackground) {
- context.frame_buffer->fill(Color(Color::NamedColor::Transparent));
+ Painter painter(*context.frame_buffer);
+ painter.clear_rect(context.images.at(i - 1).rect(), Color::Transparent);
} else if (i > 1 && previous_image_disposal_method == ImageDescriptor::DisposalMethod::RestorePrevious) {
// TODO: tricky as it potentially requires remembering _all_ previous frames.
// Luckily it seems GIFs with this mode are rare in the wild.