2021-11-20 10:46:27 +01:00
|
|
|
/*
|
2022-09-16 15:01:47 +02:00
|
|
|
* Copyright (c) 2020-2022, 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>
|
2024-04-19 15:02:12 -06:00
|
|
|
#include <LibCore/Promise.h>
|
2022-09-16 15:01:47 +02:00
|
|
|
#include <LibGfx/Forward.h>
|
2021-11-20 10:46:27 +01:00
|
|
|
|
2022-09-16 15:01:47 +02:00
|
|
|
namespace Web::Platform {
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-16 15:01:47 +02:00
|
|
|
class ImageCodecPlugin {
|
2022-04-30 11:21:21 +02:00
|
|
|
public:
|
2022-09-16 15:01:47 +02:00
|
|
|
static ImageCodecPlugin& the();
|
|
|
|
|
static void install(ImageCodecPlugin&);
|
2022-04-30 11:21:21 +02:00
|
|
|
|
2022-09-16 15:01:47 +02:00
|
|
|
virtual ~ImageCodecPlugin();
|
2022-04-30 11:21:21 +02:00
|
|
|
|
2024-05-17 17:14:06 -07: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 11:21:21 +02:00
|
|
|
};
|
2021-11-20 10:46:27 +01:00
|
|
|
|
|
|
|
|
}
|