2021-11-20 10:46:27 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
2022-04-30 11:21:21 +02:00
|
|
|
* Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
|
2021-11-20 10:46:27 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-04-30 11:21:21 +02:00
|
|
|
#include <AK/RefPtr.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
#include <LibGfx/Bitmap.h>
|
2021-11-20 10:46:27 +01:00
|
|
|
|
2022-04-30 11:21:21 +02:00
|
|
|
namespace Web::ImageDecoding {
|
2021-11-20 10:46:27 +01:00
|
|
|
|
2022-04-30 11:21:21 +02:00
|
|
|
struct Frame {
|
|
|
|
RefPtr<Gfx::Bitmap> bitmap;
|
|
|
|
size_t duration { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DecodedImage {
|
|
|
|
bool is_animated { false };
|
|
|
|
u32 loop_count { 0 };
|
|
|
|
Vector<Frame> frames;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Decoder : public RefCounted<Decoder> {
|
|
|
|
public:
|
|
|
|
virtual ~Decoder();
|
|
|
|
|
|
|
|
static void initialize(RefPtr<Decoder>&&);
|
|
|
|
static Decoder& the();
|
|
|
|
|
|
|
|
virtual Optional<DecodedImage> decode_image(ReadonlyBytes) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit Decoder();
|
|
|
|
};
|
2021-11-20 10:46:27 +01:00
|
|
|
|
|
|
|
}
|