LibGfx: clear previous GIF frame to transparent instead of whole image
This commit is contained in:
parent
f63592f871
commit
c3ee5e3451
Notes:
sideshowbarker
2024-07-19 02:58:10 +09:00
Author: https://github.com/peterdn Commit: https://github.com/SerenityOS/serenity/commit/c3ee5e34514 Pull-request: https://github.com/SerenityOS/serenity/pull/3363
1 changed files with 8 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue