mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
LibGfx: Allow requesting vector graphic frames from ImageDecoder
Only supported for plugins that set is_vector() to true. This returns the frames as Gfx::VectorGraphics, which allows painting/rasterizing them with arbitrary transforms and scales.
This commit is contained in:
parent
8784568a36
commit
753cf04be8
3 changed files with 39 additions and 30 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/RefPtr.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibGfx/VectorGraphic.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -25,6 +26,11 @@ struct ImageFrameDescriptor {
|
|||
int duration { 0 };
|
||||
};
|
||||
|
||||
struct VectorImageFrameDescriptor {
|
||||
RefPtr<VectorGraphic> image;
|
||||
int duration { 0 };
|
||||
};
|
||||
|
||||
class ImageDecoderPlugin {
|
||||
public:
|
||||
virtual ~ImageDecoderPlugin() = default;
|
||||
|
@ -34,12 +40,16 @@ public:
|
|||
virtual ErrorOr<void> initialize() { return {}; }
|
||||
|
||||
virtual bool is_animated() = 0;
|
||||
|
||||
virtual size_t loop_count() = 0;
|
||||
virtual size_t frame_count() = 0;
|
||||
virtual size_t first_animated_frame_index() = 0;
|
||||
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) = 0;
|
||||
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() = 0;
|
||||
|
||||
virtual bool is_vector() { return false; }
|
||||
virtual ErrorOr<VectorImageFrameDescriptor> vector_frame(size_t) { VERIFY_NOT_REACHED(); }
|
||||
|
||||
protected:
|
||||
ImageDecoderPlugin() = default;
|
||||
};
|
||||
|
@ -59,6 +69,9 @@ public:
|
|||
ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) const { return m_plugin->frame(index, ideal_size); }
|
||||
ErrorOr<Optional<ReadonlyBytes>> icc_data() const { return m_plugin->icc_data(); }
|
||||
|
||||
bool is_vector() { return m_plugin->is_vector(); }
|
||||
ErrorOr<VectorImageFrameDescriptor> vector_frame(size_t index) { return m_plugin->vector_frame(index); }
|
||||
|
||||
private:
|
||||
explicit ImageDecoder(NonnullOwnPtr<ImageDecoderPlugin>);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue