mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibWeb: Make DecodedImageData an abstract class
The existing implementation moves down into a new subclass called AnimatedBitmapDecodedImageData. The purpose of this change is to create an extension point where we can plug in an SVG renderer. :^)
This commit is contained in:
parent
f7185dfa91
commit
4ee1e5b224
6 changed files with 108 additions and 61 deletions
|
@ -13,32 +13,22 @@
|
|||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#img-req-data
|
||||
class DecodedImageData final : public RefCounted<DecodedImageData> {
|
||||
class DecodedImageData : public RefCounted<DecodedImageData> {
|
||||
public:
|
||||
struct Frame {
|
||||
RefPtr<Gfx::Bitmap const> bitmap;
|
||||
int duration { 0 };
|
||||
};
|
||||
virtual ~DecodedImageData();
|
||||
|
||||
static ErrorOr<NonnullRefPtr<DecodedImageData>> create(Vector<Frame>&&, size_t loop_count, bool animated);
|
||||
~DecodedImageData();
|
||||
virtual RefPtr<Gfx::Bitmap const> bitmap(size_t frame_index) const = 0;
|
||||
virtual int frame_duration(size_t frame_index) const = 0;
|
||||
|
||||
RefPtr<Gfx::Bitmap const> bitmap(size_t frame_index) const;
|
||||
int frame_duration(size_t frame_index) const;
|
||||
virtual size_t frame_count() const = 0;
|
||||
virtual size_t loop_count() const = 0;
|
||||
virtual bool is_animated() const = 0;
|
||||
|
||||
size_t frame_count() const { return m_frames.size(); }
|
||||
size_t loop_count() const { return m_loop_count; }
|
||||
bool is_animated() const { return m_animated; }
|
||||
virtual Optional<int> natural_width() const = 0;
|
||||
virtual Optional<int> natural_height() const = 0;
|
||||
|
||||
Optional<int> natural_width() const;
|
||||
Optional<int> natural_height() const;
|
||||
|
||||
private:
|
||||
DecodedImageData(Vector<Frame>&&, size_t loop_count, bool animated);
|
||||
|
||||
Vector<Frame> m_frames;
|
||||
size_t m_loop_count { 0 };
|
||||
bool m_animated { false };
|
||||
protected:
|
||||
DecodedImageData();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue