2021-11-20 09:46:27 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <andreas@ladybird.org>
|
2022-04-30 09:21:21 +00:00
|
|
|
* Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
|
2021-11-20 09:46:27 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-04-30 09:21:21 +00:00
|
|
|
#include <AK/RefPtr.h>
|
|
|
|
#include <AK/Vector.h>
|
2024-04-19 21:02:12 +00:00
|
|
|
#include <LibCore/Promise.h>
|
2022-09-16 13:01:47 +00:00
|
|
|
#include <LibGfx/Forward.h>
|
2021-11-20 09:46:27 +00:00
|
|
|
|
2022-09-16 13:01:47 +00:00
|
|
|
namespace Web::Platform {
|
2021-11-20 09:46:27 +00:00
|
|
|
|
2022-04-30 09:21:21 +00:00
|
|
|
struct Frame {
|
|
|
|
RefPtr<Gfx::Bitmap> bitmap;
|
|
|
|
size_t duration { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DecodedImage {
|
|
|
|
bool is_animated { false };
|
|
|
|
u32 loop_count { 0 };
|
|
|
|
Vector<Frame> frames;
|
|
|
|
};
|
|
|
|
|
2022-09-16 13:01:47 +00:00
|
|
|
class ImageCodecPlugin {
|
2022-04-30 09:21:21 +00:00
|
|
|
public:
|
2022-09-16 13:01:47 +00:00
|
|
|
static ImageCodecPlugin& the();
|
|
|
|
static void install(ImageCodecPlugin&);
|
2022-04-30 09:21:21 +00:00
|
|
|
|
2022-09-16 13:01:47 +00:00
|
|
|
virtual ~ImageCodecPlugin();
|
2022-04-30 09:21:21 +00:00
|
|
|
|
2024-05-18 00:14:06 +00:00
|
|
|
virtual NonnullRefPtr<Core::Promise<DecodedImage>> decode_image(ReadonlyBytes, ESCAPING Function<ErrorOr<void>(DecodedImage&)> on_resolved, ESCAPING Function<void(Error&)> on_rejected) = 0;
|
2022-04-30 09:21:21 +00:00
|
|
|
};
|
2021-11-20 09:46:27 +00:00
|
|
|
|
|
|
|
}
|