mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
ImageDecoder+LibImageDecoder+LibWeb: Support animations in ImageDecoder
The ImageDecoder service now returns a list of image frames, each with a duration value. The code for in-process image decoding is removed from LibWeb, an all image decode requests are sent out-of-process to ImageDecoder. :^) This won't scale super well to very long and/or large animations, but we can work on improving that separately. The main goal here is simply to stop doing any image decoding inside LibWeb. Fixes #5165.
This commit is contained in:
parent
449d56ef74
commit
7449c1b27f
10 changed files with 143 additions and 73 deletions
|
@ -35,17 +35,40 @@ class ImageResource final : public Resource {
|
|||
|
||||
public:
|
||||
virtual ~ImageResource() override;
|
||||
Gfx::ImageDecoder& ensure_decoder();
|
||||
const Gfx::Bitmap* bitmap(size_t frame_index = 0) const;
|
||||
|
||||
bool should_decode_in_process() const;
|
||||
struct Frame {
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
size_t duration { 0 };
|
||||
};
|
||||
|
||||
const Gfx::Bitmap* bitmap(size_t frame_index = 0) const;
|
||||
int frame_duration(size_t frame_index) const;
|
||||
size_t frame_count() const
|
||||
{
|
||||
decode_if_needed();
|
||||
return m_decoded_frames.size();
|
||||
}
|
||||
bool is_animated() const
|
||||
{
|
||||
decode_if_needed();
|
||||
return m_animated;
|
||||
}
|
||||
size_t loop_count() const
|
||||
{
|
||||
decode_if_needed();
|
||||
return m_loop_count;
|
||||
}
|
||||
|
||||
void update_volatility();
|
||||
|
||||
private:
|
||||
explicit ImageResource(const LoadRequest&);
|
||||
RefPtr<Gfx::ImageDecoder> m_decoder;
|
||||
mutable RefPtr<Gfx::Bitmap> m_decoded_image;
|
||||
|
||||
void decode_if_needed() const;
|
||||
|
||||
mutable bool m_animated { false };
|
||||
mutable int m_loop_count { 0 };
|
||||
mutable Vector<Frame> m_decoded_frames;
|
||||
mutable bool m_has_attempted_decode { false };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue