mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:28:12 +00:00
LibWeb: Move bitmap animation from HTMLImageElement to ImageLoader
Since ImageLoader manages the image decoder anyway, let it manage animation as well.
This commit is contained in:
parent
63b1c8e882
commit
c45615128b
4 changed files with 51 additions and 44 deletions
|
@ -27,6 +27,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibWeb/Loader/ImageResource.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -44,6 +45,7 @@ public:
|
|||
|
||||
Function<void()> on_load;
|
||||
Function<void()> on_fail;
|
||||
Function<void()> on_animate;
|
||||
|
||||
private:
|
||||
// ^ImageResourceClient
|
||||
|
@ -52,8 +54,14 @@ private:
|
|||
virtual void resource_did_replace_decoder() override;
|
||||
virtual bool is_visible_in_viewport() const override { return m_visible_in_viewport; }
|
||||
|
||||
void animate();
|
||||
|
||||
RefPtr<Gfx::ImageDecoder> m_decoder;
|
||||
bool m_visible_in_viewport { false };
|
||||
|
||||
size_t m_current_frame_index { 0 };
|
||||
size_t m_loops_completed { 0 };
|
||||
NonnullRefPtr<Core::Timer> m_timer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue