2020-06-22 19:35:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-22 19:35:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <ImageDecoder/ImageDecoderClientEndpoint.h>
|
|
|
|
#include <ImageDecoder/ImageDecoderServerEndpoint.h>
|
2022-02-25 10:27:37 +00:00
|
|
|
#include <LibIPC/ConnectionToServer.h>
|
2020-06-22 19:35:22 +00:00
|
|
|
|
|
|
|
namespace ImageDecoderClient {
|
|
|
|
|
2021-01-29 21:30:48 +00:00
|
|
|
struct Frame {
|
2023-10-01 18:56:19 +00:00
|
|
|
NonnullRefPtr<Gfx::Bitmap> bitmap;
|
2021-01-29 21:30:48 +00:00
|
|
|
u32 duration { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DecodedImage {
|
|
|
|
bool is_animated { false };
|
|
|
|
u32 loop_count { 0 };
|
|
|
|
Vector<Frame> frames;
|
|
|
|
};
|
|
|
|
|
2021-02-20 10:35:00 +00:00
|
|
|
class Client final
|
2022-02-25 10:27:37 +00:00
|
|
|
: public IPC::ConnectionToServer<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>
|
2020-06-22 19:35:22 +00:00
|
|
|
, public ImageDecoderClientEndpoint {
|
2022-09-06 06:04:06 +00:00
|
|
|
IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/image"sv);
|
2020-06-22 19:35:22 +00:00
|
|
|
|
|
|
|
public:
|
2023-09-08 10:30:50 +00:00
|
|
|
Client(NonnullOwnPtr<Core::LocalSocket>);
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
Optional<DecodedImage> decode_image(ReadonlyBytes, Optional<ByteString> mime_type = {});
|
2020-06-22 19:35:22 +00:00
|
|
|
|
2021-02-20 10:35:00 +00:00
|
|
|
Function<void()> on_death;
|
|
|
|
|
2020-06-22 19:35:22 +00:00
|
|
|
private:
|
2021-02-20 10:35:00 +00:00
|
|
|
virtual void die() override;
|
2020-06-22 19:35:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|