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>
|
|
|
|
#include <LibIPC/ServerConnection.h>
|
|
|
|
|
|
|
|
namespace ImageDecoderClient {
|
|
|
|
|
2021-01-29 21:30:48 +00:00
|
|
|
struct Frame {
|
|
|
|
RefPtr<Gfx::Bitmap> bitmap;
|
|
|
|
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
|
2020-06-22 19:35:22 +00:00
|
|
|
: public IPC::ServerConnection<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>
|
|
|
|
, public ImageDecoderClientEndpoint {
|
2022-01-14 13:12:49 +00:00
|
|
|
IPC_CLIENT_CONNECTION(Client, "/tmp/portal/image");
|
2020-06-22 19:35:22 +00:00
|
|
|
|
|
|
|
public:
|
2021-11-11 00:06:34 +00:00
|
|
|
Optional<DecodedImage> decode_image(ReadonlyBytes);
|
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:
|
2022-01-14 13:12:49 +00:00
|
|
|
Client(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
2020-06-22 19:35:22 +00:00
|
|
|
|
2021-02-20 10:35:00 +00:00
|
|
|
virtual void die() override;
|
2020-06-22 19:35:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|